source: josm/trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java@ 8937

Last change on this file since 8937 was 8930, checked in by Don-vip, 9 years ago

see #10730 - see #11992 - add regression unit test

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.junit.Assert.assertEquals;
5
6import java.io.FileInputStream;
7import java.io.IOException;
8import java.io.InputStream;
9
10import org.junit.BeforeClass;
11import org.junit.Test;
12import org.openstreetmap.josm.JOSMFixture;
13import org.openstreetmap.josm.Main;
14import org.openstreetmap.josm.TestUtils;
15import org.openstreetmap.josm.actions.search.SearchAction;
16import org.openstreetmap.josm.data.osm.DataSet;
17import org.openstreetmap.josm.gui.layer.OsmDataLayer;
18import org.openstreetmap.josm.io.IllegalDataException;
19import org.openstreetmap.josm.io.OsmReader;
20
21/**
22 * Unit tests of {@link JoinAreasAction} class.
23 */
24public class JoinAreasActionTest {
25
26 /**
27 * Setup test.
28 */
29 @BeforeClass
30 public static void setUp() {
31 JOSMFixture.createUnitTestFixture().init(true);
32 }
33
34 /**
35 * Non-regression test for bug #10511.
36 * @throws IOException if any I/O error occurs
37 * @throws IllegalDataException if OSM parsing fails
38 */
39 @Test
40 public void testTicket10511() throws IOException, IllegalDataException {
41 try (InputStream is = new FileInputStream(TestUtils.getRegressionDataFile(10511, "10511_mini.osm"))) {
42 DataSet ds = OsmReader.parseDataSet(is, null);
43 Main.map.mapView.addLayer(new OsmDataLayer(ds, null, null));
44 // FIXME enable this test after we fix the bug. Test disabled for now
45 // new JoinAreasAction().join(ds.getWays());
46 }
47 }
48
49 /**
50 * Non-regression test for bug #11992.
51 * @throws IOException if any I/O error occurs
52 * @throws IllegalDataException if OSM parsing fails
53 */
54 @Test
55 public void testTicket11992() throws IOException, IllegalDataException {
56 try (InputStream is = new FileInputStream(TestUtils.getRegressionDataFile(11992, "shapes.osm"))) {
57 DataSet ds = OsmReader.parseDataSet(is, null);
58 assertEquals(10, ds.getWays().size());
59 Main.map.mapView.addLayer(new OsmDataLayer(ds, null, null));
60 for (String ref : new String[]{"A", "B", "C", "D", "E"}) {
61 System.out.print("Joining ways " + ref);
62 SearchAction.search("type:way ref="+ref, SearchAction.SearchMode.replace);
63 assertEquals(2, ds.getSelectedWays().size());
64 Main.main.menu.joinAreas.join(ds.getSelectedWays());
65 assertEquals(1, ds.getSelectedWays().size());
66 System.out.println(" ==> OK");
67 }
68 }
69 }
70}
Note: See TracBrowser for help on using the repository browser.