1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertTrue;
|
---|
6 |
|
---|
7 | import java.io.FileNotFoundException;
|
---|
8 | import java.io.IOException;
|
---|
9 | import java.io.InputStream;
|
---|
10 |
|
---|
11 | import org.junit.BeforeClass;
|
---|
12 | import org.junit.Test;
|
---|
13 | import org.openstreetmap.josm.JOSMFixture;
|
---|
14 | import org.openstreetmap.josm.Main;
|
---|
15 | import org.openstreetmap.josm.TestUtils;
|
---|
16 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
17 | import org.openstreetmap.josm.data.osm.Way;
|
---|
18 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
19 | import org.openstreetmap.josm.io.IllegalDataException;
|
---|
20 | import org.openstreetmap.josm.io.OsmReader;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Unit tests for class {@link PurgeAction}.
|
---|
24 | */
|
---|
25 | public 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 | 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 | }
|
---|
52 | }
|
---|
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 | }
|
---|
59 | }
|
---|
60 | } finally {
|
---|
61 | // Ensure we clean the place before leaving, even if test fails.
|
---|
62 | Main.main.removeLayer(layer);
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|