source: josm/trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java@ 16618

Last change on this file since 16618 was 16618, checked in by simon04, 4 years ago

see #16567 - Fix deprecations related to JUnit 5 (patch by taylor.smock)

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.validation.tests;
3
4import static org.CustomMatchers.hasSize;
5import static org.CustomMatchers.isEmpty;
6import static org.hamcrest.MatcherAssert.assertThat;
7
8import java.io.FileNotFoundException;
9import java.io.IOException;
10import java.io.InputStream;
11import java.nio.file.Files;
12import java.nio.file.Paths;
13
14import org.junit.Before;
15import org.junit.Test;
16import org.openstreetmap.josm.JOSMFixture;
17import org.openstreetmap.josm.TestUtils;
18import org.openstreetmap.josm.data.osm.DataSet;
19import org.openstreetmap.josm.gui.MainApplication;
20import org.openstreetmap.josm.gui.layer.OsmDataLayer;
21import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
22import org.openstreetmap.josm.io.IllegalDataException;
23import org.openstreetmap.josm.io.OsmReader;
24
25/**
26 * Unit tests of {@code UnconnectedWays} class.
27 */
28public class UnconnectedWaysTest {
29
30 private UnconnectedWays bib;
31
32 /**
33 * Setup test.
34 * @throws Exception if the test cannot be initialized
35 */
36 @Before
37 public void setUp() throws Exception {
38 bib = new UnconnectedWays.UnconnectedHighways();
39 JOSMFixture.createUnitTestFixture().init();
40 bib.initialize();
41 }
42
43 /**
44 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/6313">Bug #6313</a>.
45 * @throws IOException if any I/O error occurs
46 * @throws IllegalDataException if the OSM data cannot be parsed
47 * @throws FileNotFoundException if the data file cannot be found
48 */
49 @Test
50 public void testTicket6313() throws IOException, IllegalDataException, FileNotFoundException {
51 try (InputStream fis = Files.newInputStream(Paths.get("nodist/data/UnconnectedWaysTest.osm"))) {
52 final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
53 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null));
54
55 bib.startTest(null);
56 bib.visit(ds.allPrimitives());
57 bib.endTest();
58 assertThat(bib.getErrors(), isEmpty());
59 }
60 }
61
62 /**
63 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/18051">Bug #18051</a>.
64 * @throws IOException if any I/O error occurs
65 * @throws IllegalDataException if the OSM data cannot be parsed
66 * @throws FileNotFoundException if the data file cannot be found
67 */
68 @Test
69 public void testTicket18051() throws IOException, IllegalDataException, FileNotFoundException {
70 try (InputStream fis = TestUtils.getRegressionDataStream(18051, "modified-ways.osm.bz2")) {
71 final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
72 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null));
73
74 bib.startTest(null);
75 bib.setBeforeUpload(true);
76 bib.visit(ds.allModifiedPrimitives());
77 bib.endTest();
78 assertThat(bib.getErrors(), isEmpty());
79 }
80 }
81
82 /**
83 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/18136">Bug #18106</a>.
84 * @throws IOException if any I/O error occurs
85 * @throws IllegalDataException if the OSM data cannot be parsed
86 * @throws FileNotFoundException if the data file cannot be found
87 */
88 @Test
89 public void testTicket18106() throws IOException, IllegalDataException, FileNotFoundException {
90 try (InputStream fis = TestUtils.getRegressionDataStream(18106, "uncon3.osm")) {
91 final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
92 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null));
93
94 bib.startTest(null);
95 bib.setBeforeUpload(true);
96 bib.visit(ds.allPrimitives());
97 bib.endTest();
98 assertThat(bib.getErrors(), isEmpty());
99 }
100 }
101
102 /**
103 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/18137">Bug #18137</a>.
104 * @throws IOException if any I/O error occurs
105 * @throws IllegalDataException if the OSM data cannot be parsed
106 * @throws FileNotFoundException if the data file cannot be found
107 */
108 @Test
109 public void testTicket18137() throws IOException, IllegalDataException, FileNotFoundException {
110 try (InputStream fis = TestUtils.getRegressionDataStream(18137, "18137_npe.osm")) {
111 final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
112 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null));
113
114 bib.startTest(null);
115 bib.setBeforeUpload(true);
116 bib.visit(ds.allPrimitives());
117 bib.endTest();
118 assertThat(bib.getErrors(), hasSize(2));
119 }
120 }
121}
Note: See TracBrowser for help on using the repository browser.