From: Andreas Beeker Date: Sun, 18 Nov 2018 00:49:54 +0000 (+0000) Subject: #62921 - Provide OOXMLLite alternative for Java 12+ X-Git-Tag: REL_4_0_1~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7239d7c5257dc7d8256f63234806615bdade0b78;p=poi.git #62921 - Provide OOXMLLite alternative for Java 12+ git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1846811 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java index f055d4174b..b7fd43e367 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java +++ b/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java @@ -75,7 +75,7 @@ public class TestExcelStyleDateFormatter { String msg = "Failed testDates for locale " + locale + ", provider: " + provider + " and date " + d + ", having: " + result; - int actIdx = (Locale.CHINESE.equals(locale) && jreVersion >= 12) ? 1 : 0; + int actIdx = localeIndex(locale); assertNotNull(msg, result); assertTrue(msg, result.length() > actIdx); @@ -85,6 +85,18 @@ public class TestExcelStyleDateFormatter { } } + /** + * Depending on the JRE version, the provider setting and the locale, a different result + * is expected and selected via an index + */ + private int localeIndex(Locale locale) { + final String provider = System.getProperty("java.locale.providers"); + return jreVersion < 12 || + !locale.equals (Locale.CHINESE) || + (provider != null && provider.startsWith("JRE")) + ? 0 : 1; + } + private Date parseDate(String dateStr) { try { return DATE_FORMAT.parse(dateStr); @@ -110,9 +122,10 @@ public class TestExcelStyleDateFormatter { testMap.put(new Locale("ru", "RU"), "\u044f\u0444\u043c\u0430\u043c\u0438\u0438\u0430\u0441\u043e\u043d\u0434"); - testMap.put(Locale.CHINESE, jreVersion < 12 - ? "\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341\u5341\u5341" - : "123456789111"); + testMap.put(Locale.CHINESE, new String[]{ + "\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341\u5341\u5341", + "123456789111" + }[localeIndex(Locale.CHINESE)]); testMap.put(new Locale("tr", "TR"), "\u004f\u015e\u004d\u004e\u004d\u0048\u0054\u0041\u0045\u0045\u004b\u0041");