source: josm/trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTaskTest.java @ 12248

Last change on this file since 12248 was 12248, checked in by Don-vip, 5 months ago

add missing https rules in unit tests

  • 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.osm.NoteData;
13import org.openstreetmap.josm.testutils.JOSMTestRules;
14
15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
16
17/**
18 * Unit tests for class {@link DownloadNotesTask}.
19 */
20public class DownloadNotesTaskTest {
21
22    private static final String REMOTE_FILE = "https://josm.openstreetmap.de/export/head/josm/trunk/test/data/planet-notes-extract.osn";
23
24    /**
25     * Setup test.
26     */
27    @Rule
28    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
29    public JOSMTestRules test = new JOSMTestRules().platform().https();
30
31    /**
32     * Unit test of {@code DownloadNotesTask#acceptsUrl} method.
33     */
34    @Test
35    public void testAcceptsURL() {
36        DownloadNotesTask task = new DownloadNotesTask();
37        assertFalse(task.acceptsUrl(null));
38        assertFalse(task.acceptsUrl(""));
39        assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes?bbox=-0.65094,51.312159,0.374908,51.669148"));
40        assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes.json?bbox=-0.65094,51.312159,0.374908,51.669148"));
41        assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes.xml?bbox=-0.65094,51.312159,0.374908,51.669148"));
42        assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes.gpx?bbox=-0.65094,51.312159,0.374908,51.669148"));
43        assertTrue(task.acceptsUrl(REMOTE_FILE));
44    }
45
46    /**
47     * Unit test of {@code DownloadNotesTask#loadUrl} method with an external file.
48     * @throws ExecutionException if the computation threw an exception
49     * @throws InterruptedException if the current thread was interrupted while waiting
50     */
51    @Test
52    public void testDownloadExternalFile() throws InterruptedException, ExecutionException {
53        DownloadNotesTask task = new DownloadNotesTask();
54        task.loadUrl(false, REMOTE_FILE, null).get();
55        NoteData data = task.getDownloadedData();
56        assertNotNull(data);
57        assertFalse(data.getNotes().isEmpty());
58    }
59}
Note: See TracBrowser for help on using the repository browser.