Changeset 12130 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-05-13T00:56:58+02:00 (7 years ago)
Author:
Don-vip
Message:

see #11924 - do not try old workaround with java 9 (pollutes console with stacktrace)

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r12045 r12130  
    154154
    155155    /**
    156      * Returns the Java version as an int value.
    157      * @return the Java version as an int value (8, 9, etc.)
    158      */
    159     public static int getJavaVersion() {
    160         String version = System.getProperty("java.version");
    161         if (version.startsWith("1.")) {
    162             version = version.substring(2);
    163         }
    164         // Allow these formats:
    165         // 1.8.0_72-ea
    166         // 9-ea
    167         // 9
    168         // 9.0.1
    169         int dotPos = version.indexOf('.');
    170         int dashPos = version.indexOf('-');
    171         return Integer.parseInt(version.substring(0,
    172                 dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1));
    173     }
    174 
    175     /**
    176156     * Returns a private field value.
    177157     * @param obj object
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r12022 r12130  
    2525import org.junit.Test;
    2626import org.openstreetmap.josm.JOSMFixture;
    27 import org.openstreetmap.josm.TestUtils;
    2827import org.openstreetmap.josm.data.Bounds;
    2928import org.openstreetmap.josm.data.coor.EastNorth;
    3029import org.openstreetmap.josm.data.coor.LatLon;
    3130import org.openstreetmap.josm.tools.Pair;
     31import org.openstreetmap.josm.tools.Utils;
    3232
    3333/**
     
    180180        }
    181181
    182         final boolean java9 = TestUtils.getJavaVersion() >= 9;
     182        final boolean java9 = Utils.getJavaVersion() >= 9;
    183183        for (TestData data : allData) {
    184184            Projection proj = Projections.getProjectionByCode(data.code);
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r11921 r12130  
    196196
    197197    /**
     198     * Test {@link Utils#getJavaVersion}
     199     */
     200    @Test
     201    public void testGetJavaVersion() {
     202        String javaVersion = System.getProperty("java.version");
     203        try {
     204            System.setProperty("java.version", "1.8.0_72-ea");
     205            assertEquals(8, Utils.getJavaVersion());
     206
     207            System.setProperty("java.version", "9-ea");
     208            assertEquals(9, Utils.getJavaVersion());
     209
     210            System.setProperty("java.version", "9");
     211            assertEquals(9, Utils.getJavaVersion());
     212
     213            System.setProperty("java.version", "9.0.1");
     214            assertEquals(9, Utils.getJavaVersion());
     215        } finally {
     216            System.setProperty("java.version", javaVersion);
     217        }
     218    }
     219
     220    /**
    198221     * Tests if readBytesFromStream handles null streams (might happen when there is no data on error stream)
    199222     * @throws IOException in case of I/O error
Note: See TracChangeset for help on using the changeset viewer.