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
This commit is contained in:
Dominik Stadler 2024-12-15 11:40:02 +00:00
parent ba6b755107
commit be83ccf2ef
2 changed files with 10 additions and 3 deletions

View File

@ -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), 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), 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), 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) NO_MAP(LocaleID.INVALID_O, 0, 1, 3, 2, 5, 9, 10, 11, 12, 15, 16, 13, 14, 4, 6, 7, 8)
; ;

View File

@ -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.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; 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.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
@ -471,7 +472,7 @@ public final class TestTextRun {
// as getShapes() // as getShapes()
List<HSLFShape> sh = slide.getShapes(); List<HSLFShape> sh = slide.getShapes();
assertEquals(2, sh.size()); assertEquals(2, sh.size());
assertTrue(sh.get(0) instanceof HSLFTextBox); assertInstanceOf(HSLFTextBox.class, sh.get(0));
HSLFTextBox box1 = (HSLFTextBox) sh.get(0); HSLFTextBox box1 = (HSLFTextBox) sh.get(0);
assertSame(run1, box1.getTextParagraphs()); assertSame(run1, box1.getTextParagraphs());
HSLFTextBox box2 = (HSLFTextBox) sh.get(1); HSLFTextBox box2 = (HSLFTextBox) sh.get(1);
@ -613,8 +614,13 @@ public final class TestTextRun {
// refresh internal members // refresh internal members
phs.forEach(PlaceholderDetails::getPlaceholder); phs.forEach(PlaceholderDetails::getPlaceholder);
String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new); String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).
assertArrayEquals(me.getValue(), actDate, // 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()); "While handling local " + me.getKey());
} }
} finally { } finally {