source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackActionTest.java@ 12358

Last change on this file since 12358 was 12358, checked in by michael2402, 7 years ago

DownloadAlongTrackActionTest: Change to test rules to get a cleaner test environment

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer.gpx;
3
4import static org.junit.Assert.assertNotNull;
5import static org.junit.Assert.assertNull;
6
7import org.junit.Rule;
8import org.junit.Test;
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.TestUtils;
11import org.openstreetmap.josm.data.gpx.GpxData;
12import org.openstreetmap.josm.data.osm.DataSet;
13import org.openstreetmap.josm.gui.PleaseWaitRunnable;
14import org.openstreetmap.josm.gui.layer.OsmDataLayer;
15import org.openstreetmap.josm.io.GpxReaderTest;
16import org.openstreetmap.josm.testutils.JOSMTestRules;
17
18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19
20/**
21 * Unit tests of {@link DownloadAlongTrackAction} class.
22 */
23public class DownloadAlongTrackActionTest {
24
25 /**
26 * The test rules for this test
27 */
28 @Rule
29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
30 public JOSMTestRules test = new JOSMTestRules().preferences().platform();
31
32 private static PleaseWaitRunnable createTask(String file) throws Exception {
33 final OsmDataLayer layer = new OsmDataLayer(new DataSet(), DownloadAlongTrackActionTest.class.getName(), null);
34 try {
35 Main.getLayerManager().addLayer(layer);
36 // Perform action
37 final GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + file);
38 return new DownloadAlongTrackAction(gpx).createTask();
39 } finally {
40 // Ensure we clean the place before leaving, even if test fails.
41 Main.getLayerManager().removeLayer(layer);
42 }
43 }
44
45 /**
46 * Test action with nominal data set.
47 * @throws Exception if an error occurs
48 */
49 @Test
50 public void testDownload() throws Exception {
51 assertNotNull(createTask("minimal.gpx"));
52 }
53
54 /**
55 * Test action with empty data set.
56 * @throws Exception if an error occurs
57 */
58 @Test
59 public void testDownloadEmpty() throws Exception {
60 assertNull(createTask("empty.gpx"));
61 }
62}
Note: See TracBrowser for help on using the repository browser.