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

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

fix/cleanup unit tests

  • Property svn:eol-style set to native
File size: 2.2 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 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}
Note: See TracBrowser for help on using the repository browser.