You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2018/11/18 00:49:54 UTC

svn commit: r1846811 - /poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java

Author: kiwiwings
Date: Sun Nov 18 00:49:54 2018
New Revision: 1846811

URL: http://svn.apache.org/viewvc?rev=1846811&view=rev
Log:
#62921 - Provide OOXMLLite alternative for Java 12+

Modified:
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java?rev=1846811&r1=1846810&r2=1846811&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java Sun Nov 18 00:49:54 2018
@@ -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");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org