diff options
author | Dominik Stadler <centic@apache.org> | 2020-10-25 07:21:34 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2020-10-25 07:21:34 +0000 |
commit | b6960fbe549cf8078fa8c166ab475c07dc32fce3 (patch) | |
tree | 4bcfa2849b5de5abbc47f9842c8a8becfa4911a8 /src/testcases | |
parent | 90bfac52d607c6a8499bfefe17d12d74253e5b7a (diff) | |
download | poi-b6960fbe549cf8078fa8c166ab475c07dc32fce3.tar.gz poi-b6960fbe549cf8078fa8c166ab475c07dc32fce3.zip |
Prevent some unit-tests from failing when non-English local is used in Maven run
Also improve the error message when parsing the date fails.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1882825 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java | 15 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java | 57 |
2 files changed, 43 insertions, 29 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 129a74fd96..66657a0fd9 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2902,7 +2902,12 @@ public final class TestBugs extends BaseTestBugzillaIssues { } @Test public void test63819() throws IOException { - simpleTest("63819.xls"); + LocaleUtil.setUserLocale(Locale.UK); + try { + simpleTest("63819.xls"); + } finally { + LocaleUtil.resetUserLocale(); + } } /** @@ -2961,8 +2966,12 @@ public final class TestBugs extends BaseTestBugzillaIssues { evals.add(wb.getCreationHelper().createFormulaEvaluator()); evals.addAll(SIMPLE_REFS.values()); - HSSFFormulaEvaluator.setupEnvironment( files.toArray(new String[0]), evals.toArray(new HSSFFormulaEvaluator[0]) ); - evals.get(0).evaluateAll(); + try { + HSSFFormulaEvaluator.setupEnvironment(files.toArray(new String[0]), evals.toArray(new HSSFFormulaEvaluator[0])); + evals.get(0).evaluateAll(); + } catch (RuntimeException e) { + throw new RuntimeException("While handling files " + files + " and evals " + evals, e); + } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java b/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java index edaa5da042..a25fa270d1 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java @@ -50,31 +50,36 @@ public final class TestDateValue { @Test public void testDateValue() { - confirmDateValue(new StringEval("2020-02-01"), 43862); - confirmDateValue(new StringEval("01-02-2020"), 43862); - confirmDateValue(new StringEval("2020-FEB-01"), 43862); - confirmDateValue(new StringEval("2020-Feb-01"), 43862); - confirmDateValue(new StringEval("2020-FEBRUARY-01"), 43862); - confirmDateValue(new StringEval("FEB-01"), 43862); - confirmDateValue(new StringEval("2/1/2020"), 43862); - confirmDateValue(new StringEval("2/1"), 43862); - confirmDateValue(new StringEval("2020/2/1"), 43862); - confirmDateValue(new StringEval("2020/FEB/1"), 43862); - confirmDateValue(new StringEval("FEB/1/2020"), 43862); - confirmDateValue(new StringEval("2020/02/01"), 43862); - - confirmDateValue(new StringEval("")); - confirmDateValue(BlankEval.instance); - - confirmDateValueError(new StringEval("non-date text")); - - // // EXCEL - confirmDateValue(new StringEval("8/22/2011"), 40777); // Serial number of a date entered as text. - confirmDateValue(new StringEval("22-MAY-2011"), 40685); // Serial number of a date entered as text. - confirmDateValue(new StringEval("2011/02/23"), 40597); // Serial number of a date entered as text. - - // LibreOffice compatibility - confirmDateValue(new StringEval("1954-07-20"), 19925); + LocaleUtil.setUserLocale(Locale.ENGLISH); + try { + confirmDateValue(new StringEval("2020-02-01"), 43862); + confirmDateValue(new StringEval("01-02-2020"), 43862); + confirmDateValue(new StringEval("2020-FEB-01"), 43862); + confirmDateValue(new StringEval("2020-Feb-01"), 43862); + confirmDateValue(new StringEval("2020-FEBRUARY-01"), 43862); + confirmDateValue(new StringEval("FEB-01"), 43862); + confirmDateValue(new StringEval("2/1/2020"), 43862); + confirmDateValue(new StringEval("2/1"), 43862); + confirmDateValue(new StringEval("2020/2/1"), 43862); + confirmDateValue(new StringEval("2020/FEB/1"), 43862); + confirmDateValue(new StringEval("FEB/1/2020"), 43862); + confirmDateValue(new StringEval("2020/02/01"), 43862); + + confirmDateValue(new StringEval("")); + confirmDateValue(BlankEval.instance); + + confirmDateValueError(new StringEval("non-date text")); + + // // EXCEL + confirmDateValue(new StringEval("8/22/2011"), 40777); // Serial number of a date entered as text. + confirmDateValue(new StringEval("22-MAY-2011"), 40685); // Serial number of a date entered as text. + confirmDateValue(new StringEval("2011/02/23"), 40597); // Serial number of a date entered as text. + + // LibreOffice compatibility + confirmDateValue(new StringEval("1954-07-20"), 19925); + } finally { + LocaleUtil.setUserLocale(null); + } } private ValueEval invokeDateValue(ValueEval text) { @@ -97,4 +102,4 @@ public final class TestDateValue { assertEquals(ErrorEval.class, result.getClass()); assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), ((ErrorEval) result).getErrorCode()); } -}
\ No newline at end of file +} |