From: Dominik Stadler Date: Wed, 7 Jul 2021 10:04:16 +0000 (+0000) Subject: Print out information that current locale might be wrong if a specific test fails X-Git-Tag: REL_5_1_0~162 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=454baca538f9f10c09deefae7196a3f547d85add;p=poi.git Print out information that current locale might be wrong if a specific test fails git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891345 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java b/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java index 65283593a1..8df9ab69a9 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/eval/TestOperandResolver.java @@ -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); + } } } diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java b/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java index da68a86b20..6a4d1135eb 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java @@ -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