source: josm/trunk/test/functional/org/openstreetmap/josm/io/OsmServerHistoryReaderTest.java@ 7081

Last change on this file since 7081 was 7079, checked in by Don-vip, 10 years ago

fix some unit tests

File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.junit.Assert.assertTrue;
5
6import org.junit.BeforeClass;
7import org.junit.Test;
8import org.openstreetmap.josm.Main;
9import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
10import org.openstreetmap.josm.data.osm.history.History;
11import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
12import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
13
14/**
15 * History fetching tests. This test operates with production API.
16 */
17public 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}
Note: See TracBrowser for help on using the repository browser.