Changeset 7033 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2014-05-01T02:34:43+02:00 (11 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r7005 r7033 5 5 6 6 import java.io.FileInputStream; 7 import java.io.FileNotFoundException; 7 import java.io.IOException; 8 import java.io.InputStream; 8 9 import java.util.Arrays; 9 10 import java.util.Collection; … … 63 64 64 65 @Test 65 public void filter_test() throws ParseError, IllegalDataException, FileNotFoundException {66 public void filter_test() throws ParseError, IllegalDataException, IOException { 66 67 for (int i : new int [] {1,2,3, 11,12,13,14, 15}) { 67 DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/filterTests.osm"), NullProgressMonitor.INSTANCE); 68 DataSet ds; 69 try (InputStream is = new FileInputStream("data_nodist/filterTests.osm")) { 70 ds = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE); 71 } 68 72 69 73 List<Filter> filters = new LinkedList<>(); -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r7005 r7033 3 3 4 4 import java.io.FileInputStream; 5 import java.io.InputStream; 5 6 import java.util.ArrayList; 6 7 import java.util.Collection; … … 66 67 public void testRemove() throws Exception { 67 68 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 68 DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE); 69 removeAllTest(ds); 69 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) { 70 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 71 removeAllTest(ds); 72 } 70 73 } 71 74 … … 73 76 public void testMove() throws Exception { 74 77 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 75 DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE); 76 77 for (Node n: ds.getNodes()) { 78 n.setCoor(new LatLon(10, 10)); 78 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) { 79 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 80 81 for (Node n: ds.getNodes()) { 82 n.setCoor(new LatLon(10, 10)); 83 } 84 85 removeAllTest(ds); 79 86 } 80 81 removeAllTest(ds);82 87 } 83 88 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
r7005 r7033 49 49 @Test 50 50 public void test() throws IOException, FileNotFoundException { 51 BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("data_nodist/projection-reference-data.csv"), Utils.UTF_8));52 StringBuilder fail = new StringBuilder();53 String line;54 while ((line = in.readLine()) != null) {55 if (line.startsWith("#")) {56 continue;57 }58 String[] f = line.split(",");59 String code = f[0];60 double lat = Double.parseDouble(f[1]);61 double lon = Double.parseDouble(f[2]);62 double east = Double.parseDouble(f[3]);63 double north = Double.parseDouble(f[4]);64 Projection p = Projections.getProjectionByCode(code);65 {51 try (BufferedReader in = new BufferedReader(new InputStreamReader( 52 new FileInputStream("data_nodist/projection-reference-data.csv"), Utils.UTF_8))) { 53 StringBuilder fail = new StringBuilder(); 54 String line; 55 while ((line = in.readLine()) != null) { 56 if (line.startsWith("#")) { 57 continue; 58 } 59 String[] f = line.split(","); 60 String code = f[0]; 61 double lat = Double.parseDouble(f[1]); 62 double lon = Double.parseDouble(f[2]); 63 double east = Double.parseDouble(f[3]); 64 double north = Double.parseDouble(f[4]); 65 Projection p = Projections.getProjectionByCode(code); 66 66 EastNorth en = p.latlon2eastNorth(new LatLon(lat, lon)); 67 String error = String.format("%s (%s): Projecting latlon(%s,%s):%n" +67 String errorEN = String.format("%s (%s): Projecting latlon(%s,%s):%n" + 68 68 " expected: eastnorth(%s,%s),%n" + 69 69 " but got: eastnorth(%s,%s)!%n", 70 70 p.toString(), code, lat, lon, east, north, en.east(), en.north()); 71 double EPSILON = 1e-3; // 1 mm accuracy72 if (Math.abs(east - en.east()) > EPSILON || Math.abs(north - en.north()) > EPSILON) {73 fail.append(error );71 double EPSILON_EN = 1e-3; // 1 mm accuracy 72 if (Math.abs(east - en.east()) > EPSILON_EN || Math.abs(north - en.north()) > EPSILON_EN) { 73 fail.append(errorEN); 74 74 } 75 }76 {77 75 LatLon ll = p.eastNorth2latlon(new EastNorth(east, north)); 78 String error = String.format("%s (%s): Inverse projecting eastnorth(%s,%s):%n" +76 String errorLL = String.format("%s (%s): Inverse projecting eastnorth(%s,%s):%n" + 79 77 " expected: latlon(%s,%s),%n" + 80 78 " but got: latlon(%s,%s)!%n", 81 79 p.toString(), code, east, north, lat, lon, ll.lat(), ll.lon()); 82 double EPSILON = Math.toDegrees(1e-3 / 6378137); // 1 mm accuracy (or better)83 if (Math.abs(lat - ll.lat()) > EPSILON || Math.abs(lon - ll.lon()) > EPSILON) {80 double EPSILON_LL = Math.toDegrees(1e-3 / 6378137); // 1 mm accuracy (or better) 81 if (Math.abs(lat - ll.lat()) > EPSILON_LL || Math.abs(lon - ll.lon()) > EPSILON_LL) { 84 82 if (!("yes".equals(System.getProperty("suppressPermanentFailure")) && code.equals("EPSG:21781"))) { 85 fail.append(error );83 fail.append(errorLL); 86 84 } 87 85 } 88 86 } 89 } 90 Utils.close(in); 91 if (fail.length() > 0) { 92 System.err.println(fail.toString()); 93 throw new AssertionError(fail.toString()); 87 if (fail.length() > 0) { 88 System.err.println(fail.toString()); 89 throw new AssertionError(fail.toString()); 90 } 94 91 } 95 92 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java
r6881 r7033 6 6 7 7 import java.io.FileInputStream; 8 import java.io.InputStream; 8 9 9 10 import org.junit.Before; … … 33 34 @Test 34 35 public void testTicket6313() throws Exception { 35 final DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/UnconnectedWaysTest.osm"), NullProgressMonitor.INSTANCE); 36 bib.visit(ds.allPrimitives()); 37 bib.endTest(); 38 assertThat(bib.getErrors(), isEmpty()); 36 try (InputStream fis = new FileInputStream("data_nodist/UnconnectedWaysTest.osm")) { 37 final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 38 bib.visit(ds.allPrimitives()); 39 bib.endTest(); 40 assertThat(bib.getErrors(), isEmpty()); 41 } 39 42 } 40 43 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r7005 r7033 3 3 4 4 import java.io.FileInputStream; 5 import java.io.FileNotFoundException; 5 import java.io.IOException; 6 import java.io.InputStream; 6 7 import java.util.List; 7 8 … … 24 25 25 26 @BeforeClass 26 public static void loadData() throws FileNotFoundException, IllegalDataException {27 public static void loadData() throws IllegalDataException, IOException { 27 28 Main.initApplicationPreferences(); 28 29 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 29 testDataset = OsmReader.parseDataSet(new FileInputStream("data_nodist/relation_sort.osm"), NullProgressMonitor.INSTANCE); 30 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) { 31 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 32 } 30 33 } 31 34 -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r7005 r7033 3 3 4 4 import java.io.FileInputStream; 5 import java.io.FileNotFoundException; 5 import java.io.IOException; 6 import java.io.InputStream; 6 7 import java.util.Arrays; 7 8 import java.util.List; … … 25 26 26 27 @BeforeClass 27 public static void loadData() throws FileNotFoundException, IllegalDataException {28 public static void loadData() throws IllegalDataException, IOException { 28 29 Main.initApplicationPreferences(); 29 30 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 30 testDataset = OsmReader.parseDataSet(new FileInputStream("data_nodist/relation_sort.osm"), NullProgressMonitor.INSTANCE); 31 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) { 32 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 33 } 31 34 } 32 35
Note:
See TracChangeset
for help on using the changeset viewer.