Changeset 15034 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2019-05-02T04:33:57+02:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java
r12740 r15034 4 4 import static org.junit.Assert.assertEquals; 5 5 6 import java.io.FileInputStream; 6 import java.nio.file.Files; 7 import java.nio.file.Paths; 7 8 import java.util.Collection; 8 9 import java.util.Map; … … 74 75 @Test 75 76 public void testCreate1() throws Exception { 76 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);77 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 77 78 Pair<SequenceCommand, Relation> mp = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), null); 78 79 assertEquals("Sequence: Create multipolygon", mp.a.getDescriptionText()); … … 82 83 @Test 83 84 public void testCreate2() throws Exception { 84 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);85 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 85 86 Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.", null, true); 86 87 assertEquals("{1=outer, 1.1.1=inner, 1.1.2=inner}", getRefToRoleMap(mp).toString()); … … 89 90 @Test 90 91 public void testUpdate1() throws Exception { 91 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);92 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 92 93 Relation mp = createMultipolygon(ds.getWays(), "ref=\".*1$\"", null, true); 93 94 assertEquals(3, mp.getMembersCount()); … … 100 101 @Test 101 102 public void testUpdate2() throws Exception { 102 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm"), null);103 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 103 104 Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.1", null, true); 104 105 assertEquals("{1=outer, 1.1.1=inner}", getRefToRoleMap(mp).toString()); -
trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java
r14138 r15034 5 5 import static org.junit.Assert.assertTrue; 6 6 7 import java.io.FileInputStream;8 7 import java.io.IOException; 9 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.nio.file.Paths; 10 11 import java.util.Arrays; 11 12 import java.util.Collection; … … 106 107 public void testExamples() throws Exception { 107 108 DataSet dsToJoin, dsExpected; 108 try (InputStream is = new FileInputStream("data_nodist/Join_Areas_Tests.osm")) {109 try (InputStream is = Files.newInputStream(Paths.get("data_nodist/Join_Areas_Tests.osm"))) { 109 110 dsToJoin = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE); 110 111 } 111 try (InputStream is = new FileInputStream("data_nodist/Join_Areas_Tests_joined.osm")) {112 try (InputStream is = Files.newInputStream(Paths.get("data_nodist/Join_Areas_Tests_joined.osm"))) { 112 113 dsExpected = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE); 113 114 } -
trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java
r12656 r15034 4 4 import static org.junit.Assert.assertEquals; 5 5 6 import java.io.FileInputStream; 6 import java.io.InputStream; 7 import java.nio.file.Files; 8 import java.nio.file.Paths; 7 9 import java.util.ArrayList; 8 10 import java.util.List; … … 97 99 98 100 DataSet performTest(String... search) throws Exception { 99 try ( FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "orthogonalize.osm")) {101 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "orthogonalize.osm"))) { 100 102 final DataSet ds = OsmReader.parseDataSet(in, null); 101 103 // TODO: Executing commands depends on active edit layer -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r13079 r15034 6 6 import static org.junit.Assert.assertTrue; 7 7 8 import java.io.FileInputStream;9 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.nio.file.Paths; 10 11 import java.util.Arrays; 11 12 import java.util.Collection; … … 73 74 for (int i : new int[] {1, 2, 3, 11, 12, 13, 14, 15}) { 74 75 DataSet ds; 75 try (InputStream is = new FileInputStream("data_nodist/filterTests.osm")) {76 try (InputStream is = Files.newInputStream(Paths.get("data_nodist/filterTests.osm"))) { 76 77 ds = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE); 77 78 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r14120 r15034 4 4 import static org.openstreetmap.josm.TestUtils.getPrivateField; 5 5 6 import java.io.FileInputStream;7 6 import java.io.InputStream; 7 import java.nio.file.Files; 8 import java.nio.file.Paths; 8 9 import java.security.SecureRandom; 9 10 import java.util.ArrayList; … … 84 85 public void testRemove() throws Exception { 85 86 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 86 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {87 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/restriction.osm"))) { 87 88 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 88 89 removeAllTest(ds); … … 97 98 public void testMove() throws Exception { 98 99 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 99 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {100 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/restriction.osm"))) { 100 101 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 101 102 -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
r14273 r15034 5 5 import java.io.BufferedWriter; 6 6 import java.io.File; 7 import java.io.FileInputStream;8 import java.io.FileOutputStream;9 7 import java.io.IOException; 10 8 import java.io.InputStream; … … 15 13 import java.lang.reflect.Method; 16 14 import java.nio.charset.StandardCharsets; 15 import java.nio.file.Files; 16 import java.nio.file.Paths; 17 17 import java.security.SecureRandom; 18 18 import java.util.ArrayList; … … 121 121 } 122 122 try (BufferedReader in = new BufferedReader(new InputStreamReader( 123 new FileInputStream(REFERENCE_DATA_FILE), StandardCharsets.UTF_8))) {123 Files.newInputStream(Paths.get(REFERENCE_DATA_FILE)), StandardCharsets.UTF_8))) { 124 124 String line; 125 125 Pattern projPattern = Pattern.compile("<(.+?)>(.*)<>"); … … 357 357 } 358 358 try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 359 new FileOutputStream(REFERENCE_DATA_FILE), StandardCharsets.UTF_8))) {359 Files.newOutputStream(Paths.get(REFERENCE_DATA_FILE)), StandardCharsets.UTF_8))) { 360 360 for (Map.Entry<String, RefEntry> e : refsMap.entrySet()) { 361 361 RefEntry ref = e.getValue(); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r13702 r15034 5 5 import java.io.BufferedWriter; 6 6 import java.io.File; 7 import java.io.FileInputStream;8 7 import java.io.FileNotFoundException; 9 import java.io.FileOutputStream;10 8 import java.io.IOException; 11 9 import java.io.InputStreamReader; 12 10 import java.io.OutputStreamWriter; 13 11 import java.nio.charset.StandardCharsets; 12 import java.nio.file.Files; 13 import java.nio.file.Paths; 14 14 import java.security.SecureRandom; 15 15 import java.util.ArrayList; … … 89 89 Random rand = new SecureRandom(); 90 90 try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 91 new FileOutputStream(PROJECTION_DATA_FILE), StandardCharsets.UTF_8))) {91 Files.newOutputStream(Paths.get(PROJECTION_DATA_FILE)), StandardCharsets.UTF_8))) { 92 92 out.write("# Data for test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java\n"); 93 93 out.write("# Format: 1. Projection code; 2. lat/lon; 3. lat/lon projected -> east/north; 4. east/north (3.) inverse projected\n"); … … 114 114 115 115 private static List<TestData> readData() throws IOException, FileNotFoundException { 116 try (BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(PROJECTION_DATA_FILE),116 try (BufferedReader in = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(PROJECTION_DATA_FILE)), 117 117 StandardCharsets.UTF_8))) { 118 118 List<TestData> result = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java
r8926 r15034 5 5 import static org.junit.Assert.assertThat; 6 6 7 import java.io.FileInputStream;8 7 import java.io.FileNotFoundException; 9 8 import java.io.IOException; 10 9 import java.io.InputStream; 10 import java.nio.file.Files; 11 import java.nio.file.Paths; 11 12 12 13 import org.junit.Before; … … 45 46 @Test 46 47 public void testTicket6313() throws IOException, IllegalDataException, FileNotFoundException { 47 try (InputStream fis = new FileInputStream("data_nodist/UnconnectedWaysTest.osm")) {48 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/UnconnectedWaysTest.osm"))) { 48 49 final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 49 50 bib.visit(ds.allPrimitives()); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ValidatorTestUtils.java
r14966 r15034 6 6 import static org.junit.Assert.fail; 7 7 8 import java.io.FileInputStream;9 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.nio.file.Paths; 10 11 import java.util.ArrayList; 11 12 import java.util.Collections; … … 35 36 Function<DataSet, Iterable<T>> provider, Predicate<String> namePredicate, 36 37 Test... tests) throws Exception { 37 try (InputStream is = new FileInputStream(sampleFile)) {38 try (InputStream is = Files.newInputStream(Paths.get(sampleFile))) { 38 39 for (T t: provider.apply(OsmReader.parseDataSet(is, null))) { 39 40 String name = DefaultNameFormatter.getInstance().format(t); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r10876 r15034 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 3 4 import java.io.FileInputStream;5 4 import java.io.IOException; 6 5 import java.io.InputStream; 6 import java.nio.file.Files; 7 import java.nio.file.Paths; 7 8 import java.util.List; 8 9 … … 44 45 public void loadData() throws IllegalDataException, IOException { 45 46 if (testDataset == null) { 46 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) {47 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/relation_sort.osm"))) { 47 48 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 48 49 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r11886 r15034 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 3 4 import java.io.FileInputStream;5 4 import java.io.IOException; 6 5 import java.io.InputStream; 6 import java.nio.file.Files; 7 import java.nio.file.Paths; 7 8 import java.util.ArrayList; 8 9 import java.util.Arrays; … … 46 47 public void loadData() throws IllegalDataException, IOException { 47 48 if (testDataset == null) { 48 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) {49 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/relation_sort.osm"))) { 49 50 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 50 51 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.java
r14064 r15034 6 6 import static org.junit.Assert.assertTrue; 7 7 8 import java.io.FileInputStream; 8 import java.nio.file.Files; 9 import java.nio.file.Paths; 9 10 import java.util.Arrays; 10 11 … … 188 189 @Test 189 190 public void testContains() throws Exception { 190 ds = OsmReader.parseDataSet( new FileInputStream("data_nodist/amenity-in-amenity.osm"), null);191 ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get("data_nodist/amenity-in-amenity.osm")), null); 191 192 ChildOrParentSelector css = parse("node[tag(\"amenity\") = parent_tag(\"amenity\")] ∈ *[amenity] {}"); 192 193 assertTrue(css.matches(new Environment(ds.getPrimitiveById(123, OsmPrimitiveType.WAY)))); -
trunk/test/unit/org/openstreetmap/josm/io/GeoJSONWriterTest.java
r13232 r15034 5 5 import static org.junit.Assert.assertTrue; 6 6 7 import java.io.FileInputStream; 7 import java.io.InputStream; 8 import java.nio.file.Files; 9 import java.nio.file.Paths; 8 10 import java.util.Arrays; 9 11 … … 113 115 @Test 114 116 public void testMultipolygon() throws Exception { 115 try ( FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "multipolygon.osm")) {117 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) { 116 118 DataSet ds = OsmReader.parseDataSet(in, null); 117 119 final GeoJSONWriter writer = new GeoJSONWriter(ds); … … 126 128 @Test 127 129 public void testMultipolygonRobustness() throws Exception { 128 try ( FileInputStream in = new FileInputStream("data_nodist/multipolygon.osm")) {130 try (InputStream in = Files.newInputStream(Paths.get("data_nodist/multipolygon.osm"))) { 129 131 DataSet ds = OsmReader.parseDataSet(in, null); 130 132 final GeoJSONWriter writer = new GeoJSONWriter(ds); -
trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java
r14219 r15034 9 9 10 10 import java.io.ByteArrayInputStream; 11 import java.io.FileInputStream;12 11 import java.io.InputStream; 13 12 import java.nio.charset.StandardCharsets; 13 import java.nio.file.Files; 14 import java.nio.file.Paths; 14 15 15 16 import org.junit.Rule; … … 59 60 OsmReader.deregisterPostprocessor(unregistered); 60 61 61 try (InputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "empty.osm")) {62 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "empty.osm"))) { 62 63 OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE); 63 64 assertTrue(registered.called); -
trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java
r14456 r15034 7 7 8 8 import java.io.ByteArrayInputStream; 9 import java.io.FileInputStream;10 9 import java.io.IOException; 11 10 import java.nio.charset.StandardCharsets; 11 import java.nio.file.Files; 12 import java.nio.file.Paths; 12 13 import java.text.SimpleDateFormat; 13 14 import java.util.ArrayList; … … 61 62 public void testReader() throws Exception { 62 63 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); 63 final NmeaReader in = new NmeaReader( new FileInputStream("data_nodist/btnmeatrack_2016-01-25.nmea"));64 final NmeaReader in = new NmeaReader(Files.newInputStream(Paths.get("data_nodist/btnmeatrack_2016-01-25.nmea"))); 64 65 in.parse(true); 65 66 assertEquals(30, in.getNumberOfCoordinates()); … … 87 88 private static void compareWithReference(int ticket, String filename, int numCoor) throws IOException, SAXException { 88 89 GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(ticket, filename+".gpx")); 89 NmeaReader in = new NmeaReader( new FileInputStream(TestUtils.getRegressionDataFile(ticket, filename+".nmea")));90 NmeaReader in = new NmeaReader(Files.newInputStream(Paths.get(TestUtils.getRegressionDataFile(ticket, filename+".nmea")))); 90 91 in.parse(true); 91 92 assertEquals(numCoor, in.getNumberOfCoordinates()); -
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r15022 r15034 7 7 import static org.junit.Assert.assertTrue; 8 8 9 import java.io.FileInputStream; 9 import java.io.InputStream; 10 import java.nio.file.Files; 11 import java.nio.file.Paths; 10 12 import java.util.Arrays; 11 13 import java.util.List; … … 78 80 @Test 79 81 public void testClosedWayArea() throws Exception { 80 try ( FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm")) {82 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) { 81 83 DataSet ds = OsmReader.parseDataSet(in, null); 82 84 Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(), … … 94 96 @Test 95 97 public void testMultipolygonArea() throws Exception { 96 try ( FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "multipolygon.osm")) {98 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) { 97 99 DataSet ds = OsmReader.parseDataSet(in, null); 98 100 final Relation r = ds.getRelations().iterator().next(); … … 109 111 @Test 110 112 public void testAreaAndPerimeter() throws Exception { 111 try ( FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm")) {113 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) { 112 114 DataSet ds = OsmReader.parseDataSet(in, null); 113 115 Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(),
Note:
See TracChangeset
for help on using the changeset viewer.