Ignore:
Timestamp:
2014-05-01T02:34:43+02:00 (12 years ago)
Author:
Don-vip
Message:

see #8465 - global use of try-with-resources, according to

Location:
trunk/test/unit/org/openstreetmap/josm/data/osm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r7005 r7033  
    55
    66import java.io.FileInputStream;
    7 import java.io.FileNotFoundException;
     7import java.io.IOException;
     8import java.io.InputStream;
    89import java.util.Arrays;
    910import java.util.Collection;
    … …  
    6364
    6465    @Test
    65     public void filter_test() throws ParseError, IllegalDataException, FileNotFoundException {
     66    public void filter_test() throws ParseError, IllegalDataException, IOException {
    6667        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            }
    6872
    6973            List<Filter> filters = new LinkedList<>();
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r7005 r7033  
    33
    44import java.io.FileInputStream;
     5import java.io.InputStream;
    56import java.util.ArrayList;
    67import java.util.Collection;
    … …  
    6667    public void testRemove() throws Exception {
    6768        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        }
    7073    }
    7174
    … …  
    7376    public void testMove() throws Exception {
    7477        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);
    7986        }
    80 
    81         removeAllTest(ds);
    8287    }
    8388}
Note: See TracChangeset for help on using the changeset viewer.