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

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

fix #21150 - Add JUnit5 annotation for WireMockServer (patch by taylor.smock)

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.downloadtasks;
3
4import static org.junit.jupiter.api.Assertions.assertFalse;
5import static org.junit.jupiter.api.Assertions.assertNotNull;
6import static org.junit.jupiter.api.Assertions.assertTrue;
7
8import java.util.concurrent.ExecutionException;
9
10import org.junit.jupiter.api.Test;
11import org.openstreetmap.josm.data.osm.NoteData;
12import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
13
14/**
15 * Unit tests for class {@link DownloadNotesTask}.
16 */
17@BasicWiremock
18class DownloadNotesTaskTest extends AbstractDownloadTaskTestParent {
19
20 /**
21 * Unit test of {@code DownloadNotesTask#acceptsUrl} method.
22 */
23 @Test
24 void testAcceptsURL() {
25 DownloadNotesTask task = new DownloadNotesTask();
26 assertFalse(task.acceptsUrl(null));
27 assertFalse(task.acceptsUrl(""));
28 assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes?bbox=-0.65094,51.312159,0.374908,51.669148"));
29 assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes.json?bbox=-0.65094,51.312159,0.374908,51.669148"));
30 assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes.xml?bbox=-0.65094,51.312159,0.374908,51.669148"));
31 assertTrue(task.acceptsUrl("http://api.openstreetmap.org/api/0.6/notes.gpx?bbox=-0.65094,51.312159,0.374908,51.669148"));
32 assertTrue(task.acceptsUrl(getRemoteFileUrl()));
33 }
34
35 /**
36 * Unit test of {@code DownloadNotesTask#loadUrl} method with an external file.
37 * @throws ExecutionException if the computation threw an exception
38 * @throws InterruptedException if the current thread was interrupted while waiting
39 */
40 @Test
41 void testDownloadExternalFile() throws InterruptedException, ExecutionException {
42 mockHttp();
43 DownloadNotesTask task = new DownloadNotesTask();
44 task.loadUrl(new DownloadParams(), getRemoteFileUrl(), null).get();
45 NoteData data = task.getDownloadedData();
46 assertNotNull(data);
47 assertFalse(data.getNotes().isEmpty());
48 }
49
50 @Override
51 protected String getRemoteFile() {
52 return "samples/data.osn";
53 }
54}
Note: See TracBrowser for help on using the repository browser.