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

Last change on this file since 12636 was 12636, checked in by Don-vip, 7 years ago

see #15182 - deprecate Main.getLayerManager(). Replacement: gui.MainApplication.getLayerManager()

  • Property svn:eol-style set to native
File size: 2.3 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.Rule;
12import org.junit.Test;
13import org.openstreetmap.josm.TestUtils;
14import org.openstreetmap.josm.data.osm.DataSet;
15import org.openstreetmap.josm.data.osm.Way;
16import org.openstreetmap.josm.gui.MainApplication;
17import org.openstreetmap.josm.gui.layer.OsmDataLayer;
18import org.openstreetmap.josm.io.IllegalDataException;
19import org.openstreetmap.josm.io.OsmReader;
20import org.openstreetmap.josm.testutils.JOSMTestRules;
21
22import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
23
24/**
25 * Unit tests for class {@link PurgeAction}.
26 */
27public class PurgeActionTest {
28
29 /**
30 * Setup test.
31 */
32 @Rule
33 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
34 public JOSMTestRules test = new JOSMTestRules().platform().main();
35
36 /**
37 * Non-regression test for ticket #12038.
38 * @throws IOException if any I/O error occurs
39 * @throws FileNotFoundException if the data file cannot be found
40 * @throws IllegalDataException if OSM parsing fails
41 */
42 @Test
43 public void testCopyStringWayRelation() throws FileNotFoundException, IOException, IllegalDataException {
44 try (InputStream is = TestUtils.getRegressionDataStream(12038, "data.osm")) {
45 DataSet ds = OsmReader.parseDataSet(is, null);
46 OsmDataLayer layer = new OsmDataLayer(ds, null, null);
47 MainApplication.getLayerManager().addLayer(layer);
48 try {
49 for (Way w : ds.getWays()) {
50 if (w.getId() == 222191929L) {
51 ds.addSelected(w);
52 }
53 }
54 new PurgeAction().actionPerformed(null);
55 for (Way w : ds.getWays()) {
56 if (w.getId() == 222191929L) {
57 assertTrue(w.isIncomplete());
58 assertEquals(0, w.getNodesCount());
59 }
60 }
61 } finally {
62 // Ensure we clean the place before leaving, even if test fails.
63 MainApplication.getLayerManager().removeLayer(layer);
64 }
65 }
66 }
67}
Note: See TracBrowser for help on using the repository browser.