source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java@ 14129

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

code refactoring

File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer.gpx;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6
7import java.io.IOException;
8
9import org.junit.Rule;
10import org.junit.Test;
11import org.openstreetmap.josm.TestUtils;
12import org.openstreetmap.josm.data.gpx.GpxData;
13import org.openstreetmap.josm.data.osm.DataSet;
14import org.openstreetmap.josm.data.osm.TagMap;
15import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
16import org.openstreetmap.josm.io.GpxReaderTest;
17import org.openstreetmap.josm.testutils.JOSMTestRules;
18import org.xml.sax.SAXException;
19
20import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
21
22/**
23 * Unit tests of {@link ConvertToDataLayerAction} class.
24 */
25public class ConvertToDataLayerActionTest {
26
27 /**
28 * Setup test.
29 */
30 @Rule
31 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
32 public JOSMTestRules test = new JOSMTestRules();
33
34 /**
35 * Tests a conversion from a GPX marker layer to a OSM dataset
36 * @throws Exception if the parsing fails
37 */
38 @Test
39 public void testFromMarkerLayer() throws Exception {
40 final GpxData data = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + "minimal.gpx");
41 final MarkerLayer markers = new MarkerLayer(data, "Markers", data.storageFile, null);
42 final DataSet osm = new ConvertFromMarkerLayerAction(markers).convert();
43 assertEquals(1, osm.getNodes().size());
44 assertEquals(new TagMap("name", "Schranke", "description", "Pfad", "note", "Pfad", "gpxicon", "Toll Booth"),
45 osm.getNodes().iterator().next().getKeys());
46 }
47
48 /**
49 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/14275">#14275</a>
50 * @throws IOException if an error occurs during reading
51 * @throws SAXException if any XML error occurs
52 */
53 @Test
54 public void testTicket14275() throws IOException, SAXException {
55 assertNotNull(GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(14275, "1485101437.8189685.gpx")));
56 }
57}
Note: See TracBrowser for help on using the repository browser.