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

Last change on this file since 12764 was 10945, checked in by Don-vip, 8 years ago

convert more unit tests to JOSMTestRules

  • Property svn:eol-style set to native
File size: 1.3 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.Rule;
8import org.junit.Test;
9import org.openstreetmap.josm.testutils.JOSMTestRules;
10
11import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
12
13public class OsmUtilsTest {
14
15 /**
16 * Setup test.
17 */
18 @Rule
19 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
20 public JOSMTestRules test = new JOSMTestRules();
21
22 @Test
23 public void testCreatePrimitive() throws Exception {
24 final OsmPrimitive p = OsmUtils.createPrimitive("way name=Foo railway=rail");
25 assertTrue(p instanceof Way);
26 assertEquals(2, p.keySet().size());
27 assertEquals("Foo", p.get("name"));
28 assertEquals("rail", p.get("railway"));
29 }
30
31 @Test
32 public void testArea() throws Exception {
33 final OsmPrimitive p = OsmUtils.createPrimitive("area name=Foo railway=rail");
34 assertEquals(OsmPrimitiveType.WAY, p.getType());
35 assertTrue(p.getKeys().equals(OsmUtils.createPrimitive("way name=Foo railway=rail").getKeys()));
36 }
37
38 @Test(expected = IllegalArgumentException.class)
39 public void testCreatePrimitiveFail() throws Exception {
40 OsmUtils.createPrimitive("noway name=Foo");
41 }
42}
Note: See TracBrowser for help on using the repository browser.