source: josm/trunk/test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java@ 9504

Last change on this file since 9504 was 9489, checked in by Don-vip, 8 years ago

unit tests code refactoring/cleanup

File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertTrue;
6
7import java.io.FileNotFoundException;
8import java.io.IOException;
9import java.io.InputStream;
10
11import org.junit.BeforeClass;
12import org.junit.Test;
13import org.openstreetmap.josm.JOSMFixture;
14import org.openstreetmap.josm.Main;
15import org.openstreetmap.josm.TestUtils;
16import org.openstreetmap.josm.data.osm.DataSet;
17import org.openstreetmap.josm.data.osm.Way;
18import org.openstreetmap.josm.gui.layer.OsmDataLayer;
19import org.openstreetmap.josm.io.IllegalDataException;
20import org.openstreetmap.josm.io.OsmReader;
21
22/**
23 * Unit tests for class {@link PurgeAction}.
24 */
25public class PurgeActionTest {
26
27 /**
28 * Setup test.
29 */
30 @BeforeClass
31 public static void setUpBeforeClass() {
32 JOSMFixture.createUnitTestFixture().init(true);
33 }
34
35 /**
36 * Non-regression test for ticket #12038.
37 * @throws IOException if any I/O error occurs
38 * @throws FileNotFoundException if the data file cannot be found
39 * @throws IllegalDataException if OSM parsing fails
40 */
41 @Test
42 public void testCopyStringWayRelation() throws FileNotFoundException, IOException, IllegalDataException {
43 try (InputStream is = TestUtils.getRegressionDataStream(12038, "data.osm")) {
44 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);
49 }
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());
56 }
57 }
58 }
59 }
60}
Note: See TracBrowser for help on using the repository browser.