Author: centic
Date: Sun Dec 15 11:40:02 2024
New Revision: 1922506

URL: http://svn.apache.org/viewvc?rev=1922506&view=rev
Log:
Adjust for removed locale provider in JDK 23 and newer

JDK 23 removes the COMPAT/JRE locale provider
which causes some changes to string formatting

Default German data format changed and thus we
need to introduce a custom format.

Also the US format uses some non-breaking spaces now
which we need to handle properly in tests.

Modified:
    
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java
    
poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java

Modified: 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java?rev=1922506&r1=1922505&r2=1922506&view=diff
==============================================================================
--- 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java
 (original)
+++ 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java
 Sun Dec 15 11:40:02 2024
@@ -59,6 +59,7 @@ public final class LocaleDateFormat {
         VI_VN(LocaleID.VI_VN, 0, 1, 2, 3, 5, 6, 10, 11, 12, 13, 14, 15, 16),
         HI_IN(LocaleID.HI_IN, 1, 2, 3, 5, 7, 11, 13, 0, 1, 5, 10, 11, 14),
         SYR_SY(LocaleID.SYR_SY, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
+        DE_DE(LocaleID.DE_DE, "dd.MM.yyyy", 1, 3, 2, 5, 9, 10, 11, 12, 15, 16, 
13, 14, 4, 6, 7, 8),
         NO_MAP(LocaleID.INVALID_O, 0, 1, 3, 2, 5, 9, 10, 11, 12, 15, 16, 13, 
14, 4, 6, 7, 8)
         ;
 

Modified: 
poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java?rev=1922506&r1=1922505&r2=1922506&view=diff
==============================================================================
--- 
poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
 (original)
+++ 
poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
 Sun Dec 15 11:40:02 2024
@@ -21,6 +21,7 @@ import static org.apache.poi.hslf.HSLFTe
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -471,7 +472,7 @@ public final class TestTextRun {
             // as getShapes()
             List<HSLFShape> sh = slide.getShapes();
             assertEquals(2, sh.size());
-            assertTrue(sh.get(0) instanceof HSLFTextBox);
+            assertInstanceOf(HSLFTextBox.class, sh.get(0));
             HSLFTextBox box1 = (HSLFTextBox) sh.get(0);
             assertSame(run1, box1.getTextParagraphs());
             HSLFTextBox box2 = (HSLFTextBox) sh.get(1);
@@ -613,8 +614,13 @@ public final class TestTextRun {
                 // refresh internal members
                 phs.forEach(PlaceholderDetails::getPlaceholder);
 
-                String[] actDate = 
phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new);
-                assertArrayEquals(me.getValue(), actDate,
+                String[] actDate = 
phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).
+                        // JDK 23 removes the COMPAT/JRE locale provider and 
this changes blanks to some non-breaking space
+                        map(s -> s.replace(" ", " ")).
+                        toArray(String[]::new);
+                String[] values = me.getValue();
+
+                assertArrayEquals(values, actDate,
                         "While handling local " + me.getKey());
             }
         } finally {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to