source: josm/trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java@ 8857

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

improve/cleanup unit tests

File size: 2.0 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;
9import java.util.HashSet;
10import java.util.List;
11import java.util.Set;
12
13import org.junit.BeforeClass;
14import org.junit.Test;
15import org.openstreetmap.josm.JOSMFixture;
16import org.openstreetmap.josm.TestUtils;
17import org.openstreetmap.josm.actions.CombineWayAction.NodeGraph;
18import org.openstreetmap.josm.data.osm.DataSet;
19import org.openstreetmap.josm.data.osm.Node;
20import org.openstreetmap.josm.io.IllegalDataException;
21import org.openstreetmap.josm.io.OsmReader;
22
23/**
24 * Unit tests for class {@link CombineWayAction}.
25 */
26public class CombineWayActionTest {
27
28 /**
29 * Setup test.
30 */
31 @BeforeClass
32 public static void setUp() {
33 JOSMFixture.createUnitTestFixture().init();
34 }
35
36 /**
37 * Non-regression test for bug #11957.
38 * @throws IOException if any I/O error occurs
39 * @throws IllegalDataException if OSM parsing fails
40 */
41 @Test
42 public void testTicket11957() throws IOException, IllegalDataException {
43 try (InputStream is = new FileInputStream(TestUtils.getRegressionDataFile(11957, "data.osm"))) {
44 DataSet ds = OsmReader.parseDataSet(is, null);
45 NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ds.getWays());
46 List<Node> path = graph.buildSpanningPath();
47 assertEquals(10, path.size());
48 Set<Long> firstAndLastObtained = new HashSet<>();
49 firstAndLastObtained.add(path.get(0).getId());
50 firstAndLastObtained.add(path.get(path.size()-1).getId());
51 Set<Long> firstAndLastExpected = new HashSet<>();
52 firstAndLastExpected.add(1618969016L);
53 firstAndLastExpected.add(35213705L);
54 assertEquals(firstAndLastExpected, firstAndLastObtained);
55 }
56 }
57}
Note: See TracBrowser for help on using the repository browser.