Ignore:
Timestamp:
2019-09-04T11:43:24+02:00 (5 years ago)
Author:
GerdP
Message:

fix #18051 and #18106
This is more or less a rewrite of the code, I hope I didn't introduce too many new problems.

  • always consider all ways with matching tag when calculating unconnected nodes
  • for partial tests filter the calculated errors (this means a small additional delay for this test when uploading data)
  • fix recursion problem in isConnectedTo so that it doesn't stop too early
  • remove code which excluded eg. ways with highway=cycleway + railway=abandoned or waterway=river + boundary=administrative
  • improve performance, esp. use HashSet when calculating types of nodes in method addNode() and QuadBuckets only when searching is done. Together with other changes this reduces runtime by ~50%, so I hope the delay for the upload is not too high.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java

    r15034 r15335  
    1414import org.junit.Test;
    1515import org.openstreetmap.josm.JOSMFixture;
     16import org.openstreetmap.josm.TestUtils;
    1617import org.openstreetmap.josm.data.osm.DataSet;
     18import org.openstreetmap.josm.gui.MainApplication;
     19import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1720import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1821import org.openstreetmap.josm.io.IllegalDataException;
     
    3538        JOSMFixture.createUnitTestFixture().init();
    3639        bib.initialize();
    37         bib.startTest(null);
    3840    }
    3941
     
    4850        try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/UnconnectedWaysTest.osm"))) {
    4951            final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
     52            MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null));
     53
     54            bib.startTest(null);
     55            bib.visit(ds.allPrimitives());
     56            bib.endTest();
     57            assertThat(bib.getErrors(), isEmpty());
     58        }
     59    }
     60
     61    /**
     62     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/6313">Bug #18051</a>.
     63     * @throws IOException if any I/O error occurs
     64     * @throws IllegalDataException if the OSM data cannot be parsed
     65     * @throws FileNotFoundException if the data file cannot be found
     66     */
     67    @Test
     68    public void testTicket18051() throws IOException, IllegalDataException, FileNotFoundException {
     69        try (InputStream fis = TestUtils.getRegressionDataStream(18051, "modified-ways.osm.bz2")) {
     70            final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
     71            MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null));
     72
     73            bib.startTest(null);
     74            bib.setBeforeUpload(true);
     75            bib.visit(ds.allModifiedPrimitives());
     76            bib.endTest();
     77            assertThat(bib.getErrors(), isEmpty());
     78        }
     79    }
     80
     81    /**
     82     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/6313">Bug #18106</a>.
     83     * @throws IOException if any I/O error occurs
     84     * @throws IllegalDataException if the OSM data cannot be parsed
     85     * @throws FileNotFoundException if the data file cannot be found
     86     */
     87    @Test
     88    public void testTicket18106() throws IOException, IllegalDataException, FileNotFoundException {
     89        try (InputStream fis = TestUtils.getRegressionDataStream(18106, "uncon3.osm")) {
     90            final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
     91            MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null));
     92
     93            bib.startTest(null);
     94            bib.setBeforeUpload(true);
    5095            bib.visit(ds.allPrimitives());
    5196            bib.endTest();
Note: See TracChangeset for help on using the changeset viewer.