source: josm/trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTaskTest.java@ 10956

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

convert more unit tests to JOSMTestRules

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.downloadtasks;
3
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertTrue;
7
8import java.util.concurrent.ExecutionException;
9
10import org.junit.Rule;
11import org.junit.Test;
12import org.openstreetmap.josm.data.gpx.GpxData;
13import org.openstreetmap.josm.testutils.JOSMTestRules;
14
15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
16
17/**
18 * Unit tests for class {@link DownloadGpsTask}.
19 */
20public class DownloadGpsTaskTest {
21
22 private static final String REMOTE_FILE = "https://josm.openstreetmap.de/export/head/josm/trunk/data_nodist/munich.gpx";
23
24 /**
25 * Setup test.
26 */
27 @Rule
28 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
29 public JOSMTestRules test = new JOSMTestRules();
30
31 /**
32 * Unit test of {@code DownloadGpsTask#acceptsUrl} method.
33 */
34 @Test
35 public void testAcceptsURL() {
36 DownloadGpsTask task = new DownloadGpsTask();
37 assertFalse(task.acceptsUrl(null));
38 assertFalse(task.acceptsUrl(""));
39 assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/trackpoints?bbox=0,51.5,0.25,51.75"));
40 assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/trackpoints?bbox=0,51.5,0.25,51.75&page=0"));
41 assertTrue(task.acceptsUrl("http://api.openstreetmap.org/trace/5000/data"));
42 assertTrue(task.acceptsUrl("http://www.openstreetmap.org/trace/5000/data"));
43 assertTrue(task.acceptsUrl("http://www.trackmyjourney.co.uk/exportgpx.php?session=S6rZR2Bh6GwX1wpB0C&trk=79292"));
44 assertTrue(task.acceptsUrl(REMOTE_FILE));
45 }
46
47 /**
48 * Unit test of {@code DownloadGpsTask#loadUrl} method with an external file.
49 * @throws ExecutionException if the computation threw an exception
50 * @throws InterruptedException if the current thread was interrupted while waiting
51 */
52 @Test
53 public void testDownloadExternalFile() throws InterruptedException, ExecutionException {
54 DownloadGpsTask task = new DownloadGpsTask();
55 task.loadUrl(false, REMOTE_FILE, null).get();
56 GpxData data = task.getDownloadedData();
57 assertNotNull(data);
58 assertFalse(data.waypoints.isEmpty());
59 assertFalse(data.tracks.isEmpty());
60 }
61}
Note: See TracBrowser for help on using the repository browser.