source: josm/trunk/test/unit/org/openstreetmap/josm/data/osm/OsmUtilsTest.java@ 8857

Last change on this file since 8857 was 8857, checked in by Don-vip, 9 years ago

improve/cleanup unit tests

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertTrue;
6
7import org.junit.BeforeClass;
8import org.junit.Test;
9import org.openstreetmap.josm.JOSMFixture;
10
11public class OsmUtilsTest {
12
13 /**
14 * Setup test.
15 */
16 @BeforeClass
17 public static void setUp() {
18 JOSMFixture.createUnitTestFixture().init();
19 }
20
21 @Test
22 public void testCreatePrimitive() throws Exception {
23 final OsmPrimitive p = OsmUtils.createPrimitive("way name=Foo railway=rail");
24 assertTrue(p instanceof Way);
25 assertEquals(2, p.keySet().size());
26 assertEquals("Foo", p.get("name"));
27 assertEquals("rail", p.get("railway"));
28 }
29
30 @Test
31 public void testArea() throws Exception {
32 final OsmPrimitive p = OsmUtils.createPrimitive("area name=Foo railway=rail");
33 assertEquals(OsmPrimitiveType.WAY, p.getType());
34 assertTrue(p.getKeys().equals(OsmUtils.createPrimitive("way name=Foo railway=rail").getKeys()));
35 }
36
37 @Test(expected = IllegalArgumentException.class)
38 public void testCreatePrimitiveFail() throws Exception {
39 OsmUtils.createPrimitive("noway name=Foo");
40 }
41}
Note: See TracBrowser for help on using the repository browser.