1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertTrue;
|
---|
5 |
|
---|
6 | import org.junit.BeforeClass;
|
---|
7 | import org.junit.Test;
|
---|
8 | import org.openstreetmap.josm.Main;
|
---|
9 | import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
|
---|
10 | import org.openstreetmap.josm.data.osm.history.History;
|
---|
11 | import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
|
---|
12 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * History fetching tests. This test operates with production API.
|
---|
16 | */
|
---|
17 | public class OsmServerHistoryReaderTest {
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Setup tests.
|
---|
21 | */
|
---|
22 | @BeforeClass
|
---|
23 | public static void init() {
|
---|
24 | Main.initApplicationPreferences();
|
---|
25 | Main.pref.put("osm-server.url", OsmApi.DEFAULT_API_URL);
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Tests node history fetching.
|
---|
30 | * @throws OsmTransferException if any error occurs
|
---|
31 | */
|
---|
32 | @Test
|
---|
33 | public void testNode() throws OsmTransferException {
|
---|
34 | OsmServerHistoryReader reader = new OsmServerHistoryReader(OsmPrimitiveType.NODE, 266187);
|
---|
35 | HistoryDataSet ds = reader.parseHistory(NullProgressMonitor.INSTANCE);
|
---|
36 | History h = ds.getHistory(266187, OsmPrimitiveType.NODE);
|
---|
37 | assertTrue("NumVersions", h.getNumVersions() >= 4);
|
---|
38 | }
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Tests way history fetching.
|
---|
42 | * @throws OsmTransferException if any error occurs
|
---|
43 | */
|
---|
44 | @Test
|
---|
45 | public void testWay() throws OsmTransferException {
|
---|
46 | OsmServerHistoryReader reader = new OsmServerHistoryReader(OsmPrimitiveType.WAY, 3058844);
|
---|
47 | HistoryDataSet ds = reader.parseHistory(NullProgressMonitor.INSTANCE);
|
---|
48 | History h = ds.getHistory(3058844, OsmPrimitiveType.WAY);
|
---|
49 | assertTrue("NumVersions", h.getNumVersions() >= 13);
|
---|
50 | }
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Tests relation history fetching.
|
---|
54 | * @throws OsmTransferException if any error occurs
|
---|
55 | */
|
---|
56 | @Test
|
---|
57 | public void testRelation() throws OsmTransferException {
|
---|
58 | OsmServerHistoryReader reader = new OsmServerHistoryReader(OsmPrimitiveType.RELATION, 49);
|
---|
59 | HistoryDataSet ds = reader.parseHistory(NullProgressMonitor.INSTANCE);
|
---|
60 | History h = ds.getHistory(49, OsmPrimitiveType.RELATION);
|
---|
61 | assertTrue("NumVersions", h.getNumVersions() >= 3);
|
---|
62 | }
|
---|
63 | }
|
---|