Changeset 9663 in josm for trunk/test/unit


Ignore:
Timestamp:
2016-01-28T22:04:34+01:00 (9 years ago)
Author:
Don-vip
Message:

fix/cleanup unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r9489 r9663  
    1414import org.openstreetmap.josm.actions.search.SearchAction;
    1515import org.openstreetmap.josm.data.osm.DataSet;
     16import org.openstreetmap.josm.gui.layer.Layer;
    1617import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1718import org.openstreetmap.josm.io.IllegalDataException;
     
    4041        try (InputStream is = TestUtils.getRegressionDataStream(10511, "10511_mini.osm")) {
    4142            DataSet ds = OsmReader.parseDataSet(is, null);
    42             Main.map.mapView.addLayer(new OsmDataLayer(ds, null, null));
     43            Layer layer = new OsmDataLayer(ds, null, null);
     44            Main.main.addLayer(layer);
    4345            // FIXME enable this test after we fix the bug. Test disabled for now
    44             // new JoinAreasAction().join(ds.getWays());
     46            // try {
     47            //     new JoinAreasAction().join(ds.getWays());
     48            // } finally {
     49            // Ensure we clean the place before leaving, even if test fails.
     50            Main.main.removeLayer(layer);
     51            // }
    4552        }
    4653    }
     
    5663            DataSet ds = OsmReader.parseDataSet(is, null);
    5764            assertEquals(10, ds.getWays().size());
    58             Main.map.mapView.addLayer(new OsmDataLayer(ds, null, null));
    59             for (String ref : new String[]{"A", "B", "C", "D", "E"}) {
    60                 System.out.print("Joining ways " + ref);
    61                 SearchAction.search("type:way ref="+ref, SearchAction.SearchMode.replace);
    62                 assertEquals(2, ds.getSelectedWays().size());
    63                 Main.main.menu.joinAreas.join(ds.getSelectedWays());
    64                 assertEquals(1, ds.getSelectedWays().size());
    65                 System.out.println(" ==> OK");
     65            Layer layer = new OsmDataLayer(ds, null, null);
     66            Main.main.addLayer(layer);
     67            try {
     68                for (String ref : new String[]{"A", "B", "C", "D", "E"}) {
     69                    System.out.print("Joining ways " + ref);
     70                    SearchAction.search("type:way ref="+ref, SearchAction.SearchMode.replace);
     71                    assertEquals(2, ds.getSelectedWays().size());
     72                    Main.main.menu.joinAreas.join(ds.getSelectedWays());
     73                    assertEquals(1, ds.getSelectedWays().size());
     74                    System.out.println(" ==> OK");
     75                }
     76            } finally {
     77                // Ensure we clean the place before leaving, even if test fails.
     78                Main.main.removeLayer(layer);
    6679            }
    6780        }
Note: See TracChangeset for help on using the changeset viewer.