Ignore:
Timestamp:
2019-05-02T04:33:57+02:00 (6 years ago)
Author:
Don-vip
Message:

checkstyle/PMD

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  
    44import static org.junit.Assert.assertEquals;
    55
    6 import java.io.FileInputStream;
     6import java.nio.file.Files;
     7import java.nio.file.Paths;
    78import java.util.Collection;
    89import java.util.Map;
     
    7475    @Test
    7576    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);
    7778        Pair<SequenceCommand, Relation> mp = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), null);
    7879        assertEquals("Sequence: Create multipolygon", mp.a.getDescriptionText());
     
    8283    @Test
    8384    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);
    8586        Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.", null, true);
    8687        assertEquals("{1=outer, 1.1.1=inner, 1.1.2=inner}", getRefToRoleMap(mp).toString());
     
    8990    @Test
    9091    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);
    9293        Relation mp = createMultipolygon(ds.getWays(), "ref=\".*1$\"", null, true);
    9394        assertEquals(3, mp.getMembersCount());
     
    100101    @Test
    101102    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);
    103104        Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.1", null, true);
    104105        assertEquals("{1=outer, 1.1.1=inner}", getRefToRoleMap(mp).toString());
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r14138 r15034  
    55import static org.junit.Assert.assertTrue;
    66
    7 import java.io.FileInputStream;
    87import java.io.IOException;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.nio.file.Paths;
    1011import java.util.Arrays;
    1112import java.util.Collection;
     
    106107    public void testExamples() throws Exception {
    107108        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"))) {
    109110            dsToJoin = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE);
    110111        }
    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"))) {
    112113            dsExpected = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE);
    113114        }
  • trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java

    r12656 r15034  
    44import static org.junit.Assert.assertEquals;
    55
    6 import java.io.FileInputStream;
     6import java.io.InputStream;
     7import java.nio.file.Files;
     8import java.nio.file.Paths;
    79import java.util.ArrayList;
    810import java.util.List;
     
    9799
    98100    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"))) {
    100102            final DataSet ds = OsmReader.parseDataSet(in, null);
    101103            // TODO: Executing commands depends on active edit layer
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r13079 r15034  
    66import static org.junit.Assert.assertTrue;
    77
    8 import java.io.FileInputStream;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.nio.file.Paths;
    1011import java.util.Arrays;
    1112import java.util.Collection;
     
    7374        for (int i : new int[] {1, 2, 3, 11, 12, 13, 14, 15}) {
    7475            DataSet ds;
    75             try (InputStream is = new FileInputStream("data_nodist/filterTests.osm")) {
     76            try (InputStream is = Files.newInputStream(Paths.get("data_nodist/filterTests.osm"))) {
    7677                ds = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE);
    7778            }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r14120 r15034  
    44import static org.openstreetmap.josm.TestUtils.getPrivateField;
    55
    6 import java.io.FileInputStream;
    76import java.io.InputStream;
     7import java.nio.file.Files;
     8import java.nio.file.Paths;
    89import java.security.SecureRandom;
    910import java.util.ArrayList;
     
    8485    public void testRemove() throws Exception {
    8586        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"))) {
    8788            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    8889            removeAllTest(ds);
     
    9798    public void testMove() throws Exception {
    9899        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"))) {
    100101            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    101102
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

    r14273 r15034  
    55import java.io.BufferedWriter;
    66import java.io.File;
    7 import java.io.FileInputStream;
    8 import java.io.FileOutputStream;
    97import java.io.IOException;
    108import java.io.InputStream;
     
    1513import java.lang.reflect.Method;
    1614import java.nio.charset.StandardCharsets;
     15import java.nio.file.Files;
     16import java.nio.file.Paths;
    1717import java.security.SecureRandom;
    1818import java.util.ArrayList;
     
    121121        }
    122122        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))) {
    124124            String line;
    125125            Pattern projPattern = Pattern.compile("<(.+?)>(.*)<>");
     
    357357        }
    358358        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))) {
    360360            for (Map.Entry<String, RefEntry> e : refsMap.entrySet()) {
    361361                RefEntry ref = e.getValue();
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r13702 r15034  
    55import java.io.BufferedWriter;
    66import java.io.File;
    7 import java.io.FileInputStream;
    87import java.io.FileNotFoundException;
    9 import java.io.FileOutputStream;
    108import java.io.IOException;
    119import java.io.InputStreamReader;
    1210import java.io.OutputStreamWriter;
    1311import java.nio.charset.StandardCharsets;
     12import java.nio.file.Files;
     13import java.nio.file.Paths;
    1414import java.security.SecureRandom;
    1515import java.util.ArrayList;
     
    8989        Random rand = new SecureRandom();
    9090        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))) {
    9292            out.write("# Data for test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java\n");
    9393            out.write("# Format: 1. Projection code; 2. lat/lon; 3. lat/lon projected -> east/north; 4. east/north (3.) inverse projected\n");
     
    114114
    115115    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)),
    117117                StandardCharsets.UTF_8))) {
    118118            List<TestData> result = new ArrayList<>();
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java

    r8926 r15034  
    55import static org.junit.Assert.assertThat;
    66
    7 import java.io.FileInputStream;
    87import java.io.FileNotFoundException;
    98import java.io.IOException;
    109import java.io.InputStream;
     10import java.nio.file.Files;
     11import java.nio.file.Paths;
    1112
    1213import org.junit.Before;
     
    4546    @Test
    4647    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"))) {
    4849            final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    4950            bib.visit(ds.allPrimitives());
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ValidatorTestUtils.java

    r14966 r15034  
    66import static org.junit.Assert.fail;
    77
    8 import java.io.FileInputStream;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.nio.file.Paths;
    1011import java.util.ArrayList;
    1112import java.util.Collections;
     
    3536            Function<DataSet, Iterable<T>> provider, Predicate<String> namePredicate,
    3637            Test... tests) throws Exception {
    37         try (InputStream is = new FileInputStream(sampleFile)) {
     38        try (InputStream is = Files.newInputStream(Paths.get(sampleFile))) {
    3839            for (T t: provider.apply(OsmReader.parseDataSet(is, null))) {
    3940                String name = DefaultNameFormatter.getInstance().format(t);
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java

    r10876 r15034  
    22package org.openstreetmap.josm.gui.dialogs.relation.sort;
    33
    4 import java.io.FileInputStream;
    54import java.io.IOException;
    65import java.io.InputStream;
     6import java.nio.file.Files;
     7import java.nio.file.Paths;
    78import java.util.List;
    89
     
    4445    public void loadData() throws IllegalDataException, IOException {
    4546        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"))) {
    4748                testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    4849            }
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java

    r11886 r15034  
    22package org.openstreetmap.josm.gui.dialogs.relation.sort;
    33
    4 import java.io.FileInputStream;
    54import java.io.IOException;
    65import java.io.InputStream;
     6import java.nio.file.Files;
     7import java.nio.file.Paths;
    78import java.util.ArrayList;
    89import java.util.Arrays;
     
    4647    public void loadData() throws IllegalDataException, IOException {
    4748        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"))) {
    4950                testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
    5051            }
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.java

    r14064 r15034  
    66import static org.junit.Assert.assertTrue;
    77
    8 import java.io.FileInputStream;
     8import java.nio.file.Files;
     9import java.nio.file.Paths;
    910import java.util.Arrays;
    1011
     
    188189    @Test
    189190    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);
    191192        ChildOrParentSelector css = parse("node[tag(\"amenity\") = parent_tag(\"amenity\")] ∈ *[amenity] {}");
    192193        assertTrue(css.matches(new Environment(ds.getPrimitiveById(123, OsmPrimitiveType.WAY))));
  • trunk/test/unit/org/openstreetmap/josm/io/GeoJSONWriterTest.java

    r13232 r15034  
    55import static org.junit.Assert.assertTrue;
    66
    7 import java.io.FileInputStream;
     7import java.io.InputStream;
     8import java.nio.file.Files;
     9import java.nio.file.Paths;
    810import java.util.Arrays;
    911
     
    113115    @Test
    114116    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"))) {
    116118            DataSet ds = OsmReader.parseDataSet(in, null);
    117119            final GeoJSONWriter writer = new GeoJSONWriter(ds);
     
    126128    @Test
    127129    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"))) {
    129131            DataSet ds = OsmReader.parseDataSet(in, null);
    130132            final GeoJSONWriter writer = new GeoJSONWriter(ds);
  • trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java

    r14219 r15034  
    99
    1010import java.io.ByteArrayInputStream;
    11 import java.io.FileInputStream;
    1211import java.io.InputStream;
    1312import java.nio.charset.StandardCharsets;
     13import java.nio.file.Files;
     14import java.nio.file.Paths;
    1415
    1516import org.junit.Rule;
     
    5960        OsmReader.deregisterPostprocessor(unregistered);
    6061
    61         try (InputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "empty.osm")) {
     62        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "empty.osm"))) {
    6263            OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
    6364            assertTrue(registered.called);
  • trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java

    r14456 r15034  
    77
    88import java.io.ByteArrayInputStream;
    9 import java.io.FileInputStream;
    109import java.io.IOException;
    1110import java.nio.charset.StandardCharsets;
     11import java.nio.file.Files;
     12import java.nio.file.Paths;
    1213import java.text.SimpleDateFormat;
    1314import java.util.ArrayList;
     
    6162    public void testReader() throws Exception {
    6263        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")));
    6465        in.parse(true);
    6566        assertEquals(30, in.getNumberOfCoordinates());
     
    8788    private static void compareWithReference(int ticket, String filename, int numCoor) throws IOException, SAXException {
    8889        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"))));
    9091        in.parse(true);
    9192        assertEquals(numCoor, in.getNumberOfCoordinates());
  • trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    r15022 r15034  
    77import static org.junit.Assert.assertTrue;
    88
    9 import java.io.FileInputStream;
     9import java.io.InputStream;
     10import java.nio.file.Files;
     11import java.nio.file.Paths;
    1012import java.util.Arrays;
    1113import java.util.List;
     
    7880    @Test
    7981    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"))) {
    8183            DataSet ds = OsmReader.parseDataSet(in, null);
    8284            Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(),
     
    9496    @Test
    9597    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"))) {
    9799            DataSet ds = OsmReader.parseDataSet(in, null);
    98100            final Relation r = ds.getRelations().iterator().next();
     
    109111    @Test
    110112    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"))) {
    112114            DataSet ds = OsmReader.parseDataSet(in, null);
    113115            Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(),
Note: See TracChangeset for help on using the changeset viewer.