Ignore:
Timestamp:
2021-07-09T01:09:04+02:00 (3 years ago)
Author:
Don-vip
Message:

see #19888 - make sure java.locale.providers is set early to SPI,JRE,CLDR for unit tests with Java >= 9 (before JUnit itself initializes Java locales)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/JosmDecimalFormatSymbolsProviderTest.java

    r17677 r17967  
    66import static org.junit.jupiter.api.Assumptions.assumeTrue;
    77
     8import java.io.IOException;
     9import java.io.InputStream;
     10import java.nio.charset.StandardCharsets;
    811import java.text.DecimalFormat;
    912import java.util.Locale;
    1013import java.util.stream.Stream;
    1114
     15import org.junit.jupiter.api.BeforeAll;
    1216import org.junit.jupiter.api.Test;
    1317import org.junit.jupiter.api.extension.RegisterExtension;
     
    2731    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2832    public JOSMTestRules test = new JOSMTestRules();
     33
     34    @BeforeAll
     35    static void beforeAll() throws IOException {
     36        if (Utils.getJavaVersion() >= 9) {
     37            assertEquals("SPI,JRE,CLDR", System.getProperty("java.locale.providers"), "This test must be launched with -Djava.locale.providers=SPI,JRE,CLDR");
     38            try (InputStream in = I18n.class.getResourceAsStream("/META-INF/services/java.text.spi.DecimalFormatSymbolsProvider")) {
     39                assertEquals("org.openstreetmap.josm.tools.JosmDecimalFormatSymbolsProvider", new String(Utils.readBytesFromStream(in), StandardCharsets.UTF_8).trim());
     40            }
     41        }
     42    }
    2943
    3044    @Test
Note: See TracChangeset for help on using the changeset viewer.