Changeset 17967 in josm


Ignore:
Timestamp:
2021-07-09T01:09:04+02:00 (5 months 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)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.xml

    r17966 r17967  
    402402                            <jvmarg value="${jacocoagent@{testfamily}@{testITsuffix}}" if:set="jacocoagent@{testfamily}@{testITsuffix}" />
    403403                            <jvmarg value="-Dfile.encoding=UTF-8"/>
     404                            <jvmarg value="-Djava.locale.providers=SPI,JRE,CLDR" if:set="isJava9" />
    404405                            <jvmarg value="-javaagent:${test.dir}/lib/jmockit.jar"/>
    405406                            <jvmarg value="-Djunit.jupiter.extensions.autodetection.enabled=true"/>
  • 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.