Changeset 9671 in josm for trunk/test


Ignore:
Timestamp:
2016-01-29T19:36:59+01:00 (9 years ago)
Author:
Don-vip
Message:

fix/cleanup unit tests

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r9669 r9671  
    4343        try (InputStream is = TestUtils.getRegressionDataStream(12038, "data.osm")) {
    4444            DataSet ds = OsmReader.parseDataSet(is, null);
    45             Main.map.mapView.addLayer(new OsmDataLayer(ds, null, null));
    46             for (Way w : ds.getWays()) {
    47                 if (w.getId() == 222191929L) {
    48                     ds.addSelected(w);
     45            OsmDataLayer layer = new OsmDataLayer(ds, null, null);
     46            Main.main.addLayer(layer);
     47            try {
     48                for (Way w : ds.getWays()) {
     49                    if (w.getId() == 222191929L) {
     50                        ds.addSelected(w);
     51                    }
    4952                }
    50             }
    51             new PurgeAction().actionPerformed(null);
    52             for (Way w : ds.getWays()) {
    53                 if (w.getId() == 222191929L) {
    54                     assertTrue(w.isIncomplete());
    55                     assertEquals(0, w.getNodesCount());
     53                new PurgeAction().actionPerformed(null);
     54                for (Way w : ds.getWays()) {
     55                    if (w.getId() == 222191929L) {
     56                        assertTrue(w.isIncomplete());
     57                        assertEquals(0, w.getNodesCount());
     58                    }
    5659                }
     60            } finally {
     61                // Ensure we clean the place before leaving, even if test fails.
     62                Main.main.removeLayer(layer);
    5763            }
    5864        }
  • trunk/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java

    r9666 r9671  
    55import static org.junit.Assert.assertNotNull;
    66import static org.junit.Assert.assertTrue;
    7 import nl.jqno.equalsverifier.EqualsVerifier;
    8 import nl.jqno.equalsverifier.Warning;
    97
     8import org.junit.AfterClass;
    109import org.junit.BeforeClass;
    1110import org.junit.Test;
     
    1817import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1918
     19import nl.jqno.equalsverifier.EqualsVerifier;
     20import nl.jqno.equalsverifier.Warning;
     21
    2022/**
    2123 * Unit tests of {@link ConflictAddCommand} class.
    2224 */
    2325public class ConflictAddCommandTest {
     26
     27    private static OsmDataLayer layer;
    2428
    2529    /**
     
    2933    public static void setUpBeforeClass() {
    3034        JOSMFixture.createUnitTestFixture().init(true);
    31         Main.map.mapView.addLayer(new OsmDataLayer(new DataSet(), null, null));
     35        layer = new OsmDataLayer(new DataSet(), null, null);
     36        Main.main.addLayer(layer);
     37    }
     38
     39    /**
     40     * Cleanup test resources.
     41     */
     42    @AfterClass
     43    public static void tearDownAfterClass() {
     44        Main.main.removeLayer(layer);
    3245    }
    3346
  • trunk/test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java

    r9666 r9671  
    55import static org.junit.Assert.assertNotNull;
    66import static org.junit.Assert.assertTrue;
    7 import nl.jqno.equalsverifier.EqualsVerifier;
    8 import nl.jqno.equalsverifier.Warning;
    97
     8import org.junit.AfterClass;
    109import org.junit.BeforeClass;
    1110import org.junit.Test;
     
    2019import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2120
     21import nl.jqno.equalsverifier.EqualsVerifier;
     22import nl.jqno.equalsverifier.Warning;
     23
    2224/**
    2325 * Unit tests of {@link CoordinateConflictResolveCommand} class.
    2426 */
    2527public class CoordinateConflictResolveCommandTest {
     28
     29    private static OsmDataLayer layer;
    2630
    2731    /**
     
    3135    public static void setUpBeforeClass() {
    3236        JOSMFixture.createUnitTestFixture().init(true);
    33         Main.map.mapView.addLayer(new OsmDataLayer(new DataSet(), null, null));
     37        layer = new OsmDataLayer(new DataSet(), null, null);
     38        Main.main.addLayer(layer);
     39    }
     40
     41    /**
     42     * Cleanup test resources.
     43     */
     44    @AfterClass
     45    public static void tearDownAfterClass() {
     46        Main.main.removeLayer(layer);
    3447    }
    3548
Note: See TracChangeset for help on using the changeset viewer.