Changeset 12130 in josm for trunk/test/unit
- Timestamp:
- 2017-05-13T00:56:58+02:00 (8 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r12045 r12130 154 154 155 155 /** 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-ea166 // 9-ea167 // 9168 // 9.0.1169 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 /**176 156 * Returns a private field value. 177 157 * @param obj object -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r12022 r12130 25 25 import org.junit.Test; 26 26 import org.openstreetmap.josm.JOSMFixture; 27 import org.openstreetmap.josm.TestUtils;28 27 import org.openstreetmap.josm.data.Bounds; 29 28 import org.openstreetmap.josm.data.coor.EastNorth; 30 29 import org.openstreetmap.josm.data.coor.LatLon; 31 30 import org.openstreetmap.josm.tools.Pair; 31 import org.openstreetmap.josm.tools.Utils; 32 32 33 33 /** … … 180 180 } 181 181 182 final boolean java9 = TestUtils.getJavaVersion() >= 9;182 final boolean java9 = Utils.getJavaVersion() >= 9; 183 183 for (TestData data : allData) { 184 184 Projection proj = Projections.getProjectionByCode(data.code); -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r11921 r12130 196 196 197 197 /** 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 /** 198 221 * Tests if readBytesFromStream handles null streams (might happen when there is no data on error stream) 199 222 * @throws IOException in case of I/O error
Note:
See TracChangeset
for help on using the changeset viewer.