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

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

unit tests code refactoring/cleanup

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