Changeset 12217 in josm for trunk/test


Ignore:
Timestamp:
2017-05-20T17:11:37+02:00 (2 years ago)
Author:
Don-vip
Message:

see #14821 - workaround for JDK-8180379/JDK-8179014 : prevent JVM crash when opening a file chooser on Windows 10 Creators Update with Windows look & feel + add information about OS build number for Windows & macOS + add utilities to get Java update/build version numbers

File:
1 edited

Legend:

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

    r12130 r12217  
    219219
    220220    /**
     221     * Test {@link Utils#getJavaUpdate}
     222     */
     223    @Test
     224    public void testGetJavaUpdate() {
     225        String javaVersion = System.getProperty("java.version");
     226        try {
     227            System.setProperty("java.version", "1.8.0_131");
     228            assertEquals(131, Utils.getJavaUpdate());
     229
     230            System.setProperty("java.version", "1.8.0_152-ea");
     231            assertEquals(152, Utils.getJavaUpdate());
     232
     233            System.setProperty("java.version", "9-ea");
     234            assertEquals(0, Utils.getJavaUpdate());
     235
     236            System.setProperty("java.version", "9");
     237            assertEquals(0, Utils.getJavaUpdate());
     238
     239            System.setProperty("java.version", "9.1.2");
     240            assertEquals(1, Utils.getJavaUpdate());
     241        } finally {
     242            System.setProperty("java.version", javaVersion);
     243        }
     244    }
     245
     246    /**
     247     * Test {@link Utils#getJavaBuild}
     248     */
     249    @Test
     250    public void testGetJavaBuild() {
     251        String javaVersion = System.getProperty("java.runtime.version");
     252        try {
     253            System.setProperty("java.runtime.version", "1.8.0_131-b11");
     254            assertEquals(11, Utils.getJavaBuild());
     255
     256            System.setProperty("java.runtime.version", "1.8.0_152-ea-b04");
     257            assertEquals(4, Utils.getJavaBuild());
     258
     259            System.setProperty("java.runtime.version", "9-ea+170");
     260            assertEquals(170, Utils.getJavaBuild());
     261
     262            System.setProperty("java.runtime.version", "9+200");
     263            assertEquals(200, Utils.getJavaBuild());
     264
     265            System.setProperty("java.runtime.version", "9.1.2+62");
     266            assertEquals(62, Utils.getJavaBuild());
     267        } finally {
     268            System.setProperty("java.runtime.version", javaVersion);
     269        }
     270    }
     271
     272    /**
    221273     * Tests if readBytesFromStream handles null streams (might happen when there is no data on error stream)
    222274     * @throws IOException in case of I/O error
Note: See TracChangeset for help on using the changeset viewer.