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

Last change on this file since 8622 was 8622, checked in by bastiK, 9 years ago

fix unit test: preference file is read-only

  • 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.io;
3
4import static org.junit.Assert.assertTrue;
5
6import org.junit.BeforeClass;
7import org.junit.Test;
8import org.openstreetmap.josm.JOSMFixture;
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
11import org.openstreetmap.josm.data.osm.history.History;
12import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
13import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
14
15/**
16 * History fetching tests. This test operates with production API.
17 */
18public 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}
Note: See TracBrowser for help on using the repository browser.