Changeset 8793 in josm for trunk/test/unit
- Timestamp:
- 2015-09-24T22:29:41+02:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r8514 r8793 107 107 .toString(); 108 108 } 109 110 /** 111 * Returns the Java version as a double value. 112 * @return the Java version as a double value (1.7, 1.8, 1.9, etc.) 113 */ 114 public static double getJavaVersion() { 115 String version = System.getProperty("java.version"); 116 int pos = version.indexOf('.'); 117 pos = version.indexOf('.', pos + 1); 118 return Double.parseDouble(version.substring(0, pos)); 119 } 109 120 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r8540 r8793 15 15 import java.util.HashMap; 16 16 import java.util.HashSet; 17 import java.util.LinkedHashSet;18 17 import java.util.List; 19 18 import java.util.Map; 20 19 import java.util.Random; 21 20 import java.util.Set; 21 import java.util.TreeSet; 22 22 23 23 import org.junit.BeforeClass; 24 24 import org.junit.Test; 25 25 import org.openstreetmap.josm.JOSMFixture; 26 import org.openstreetmap.josm.TestUtils; 26 27 import org.openstreetmap.josm.data.Bounds; 27 28 import org.openstreetmap.josm.data.coor.EastNorth; … … 45 46 46 47 private static final String PROJECTION_DATA_FILE = "data_nodist/projection-regression-test-data.csv"; 48 private static final String PROJECTION_DATA_FILE_JAVA_9 = "data_nodist/projection-regression-test-data-java9.csv"; 47 49 48 50 private static class TestData { … … 53 55 } 54 56 55 public static void main(String[] args) throws IOException, FileNotFoundException { 57 private static String getProjectionDataFile() { 58 return TestUtils.getJavaVersion() >= 1.9 ? PROJECTION_DATA_FILE_JAVA_9 : PROJECTION_DATA_FILE; 59 } 60 61 public static void main(String[] args) throws IOException { 56 62 setUp(); 57 63 … … 62 68 63 69 List<TestData> prevData = new ArrayList<>(); 64 if (new File( PROJECTION_DATA_FILE).exists()) {70 if (new File(getProjectionDataFile()).exists()) { 65 71 prevData = readData(); 66 72 } … … 70 76 } 71 77 72 Set<String> codesToWrite = new LinkedHashSet<>();78 Set<String> codesToWrite = new TreeSet<>(); 73 79 for (TestData data : prevData) { 74 80 if (supportedCodesMap.containsKey(data.code)) { … … 84 90 Random rand = new Random(); 85 91 try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 86 new FileOutputStream( PROJECTION_DATA_FILE), StandardCharsets.UTF_8))) {92 new FileOutputStream(getProjectionDataFile()), StandardCharsets.UTF_8))) { 87 93 out.write("# Data for test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java\n"); 88 94 out.write("# Format: 1. Projection code; 2. lat/lon; 3. lat/lon projected -> east/north; 4. east/north (3.) inverse projected\n"); … … 108 114 109 115 private static List<TestData> readData() throws IOException, FileNotFoundException { 110 try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(PROJECTION_DATA_FILE), StandardCharsets.UTF_8))) { 116 try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(getProjectionDataFile()), 117 StandardCharsets.UTF_8))) { 111 118 List<TestData> result = new ArrayList<>(); 112 119 String line;
Note:
See TracChangeset
for help on using the changeset viewer.