]> source.dussan.org Git - poi.git/commitdiff
Print out information that current locale might be wrong if a specific test fails
authorDominik Stadler <centic@apache.org>
Wed, 7 Jul 2021 10:04:16 +0000 (10:04 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 7 Jul 2021 10:04:16 +0000 (10:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891345 13f79535-47bb-0310-9956-ffa450edef68

poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java
poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java

index 65283593a1f4ae7273d2c466048eeee00070cdab..8df9ab69a99a52615e5082301090920a726a8ef3 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.poi.ss.formula.eval;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -81,7 +82,14 @@ final class TestOperandResolver {
         values.put("18-Jan-2019", 43483.);
 
         for (String str : values.keySet()) {
-            assertEquals(OperandResolver.coerceValueToDouble(new StringEval(str)), values.get(str), 0.00001);
+               try {
+                               assertEquals(OperandResolver.coerceValueToDouble(new StringEval(str)), values.get(str), 0.00001);
+                       } catch (EvaluationException e) {
+                       fail("While handling: " + str + ". "
+                                               + "This failure can indicate that the wrong locale is used during test-execution, "
+                                               + "ensure you run with english/US via -Duser.language=en -Duser.country=US. "
+                                               + "Having: " + System.getProperty("user.language") + "/" + System.getProperty("user.country"), e);
+                       }
         }
     }
 
index da68a86b2022ac921bad53da1978a70116f976db..6a4d1135eb5c02663d8351508400d2526878e10d 100644 (file)
@@ -69,7 +69,7 @@ class TestDataFormatter {
         assertTrue(Locale.ROOT.equals(ul) || Locale.getDefault().equals(ul));
         final String textValue = NumberToTextConverter.toText(1234.56);
         assertEquals(-1, textValue.indexOf('E'));
-        Object cellValueO = Double.valueOf(1234.56);
+        Object cellValueO = 1234.56;
 
         /*CellFormat cellFormat = new CellFormat("_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-");
         CellFormatResult result = cellFormat.apply(cellValueO);
@@ -78,7 +78,9 @@ class TestDataFormatter {
         CellFormat cfmt = CellFormat.getInstance("_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-");
         CellFormatResult result = cfmt.apply(cellValueO);
         assertEquals("    1,234.56 ", result.text,
-            "This failure can indicate that the wrong locale is used during test-execution, ensure you run with english/US via -Duser.language=en -Duser.country=US");
+            "This failure can indicate that the wrong locale is used during test-execution, "
+                                       + "ensure you run with english/US via -Duser.language=en -Duser.country=US. "
+                                       + "Having: " + System.getProperty("user.language") + "/" + System.getProperty("user.country"));
     }
 
     /**
@@ -975,7 +977,7 @@ class TestDataFormatter {
      * A numeric format string like 0E+0 should be E+
      */
     @Test
-    void testWithEinFormat() throws Exception {
+    void testWithEinFormat() {
         DataFormatter formatter = new DataFormatter();
 
         // Format string literals with an E in them shouldn't be