aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2024-12-15 11:40:02 +0000
committerDominik Stadler <centic@apache.org>2024-12-15 11:40:02 +0000
commitbe83ccf2ef8d6805ed2a5f3b95ae7ce2e68e12ef (patch)
tree90fc8396f48422075907a163816bd3f5f9b3b361
parentba6b7551074858575dce15129006ec435df60605 (diff)
downloadpoi-be83ccf2ef8d6805ed2a5f3b95ae7ce2e68e12ef.tar.gz
poi-be83ccf2ef8d6805ed2a5f3b95ae7ce2e68e12ef.zip
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. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1922506 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java1
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java12
2 files changed, 10 insertions, 3 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java
index 3542fbf264..f46c145f15 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/util/LocaleDateFormat.java
@@ -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)
;
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
index a361ad650b..bff3775218 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
@@ -21,6 +21,7 @@ import static org.apache.poi.hslf.HSLFTestDataSamples.getSlideShow;
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 {