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