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