Changeset 13489 in josm for trunk/test/unit/org/openstreetmap/josm/data/validation
- Timestamp:
- 2018-03-03T20:33:09+01:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java
r10945 r13489 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.Assert.assertNotNull; 5 6 import static org.junit.Assert.assertNull; 7 import static org.openstreetmap.josm.tools.I18n.tr; 6 8 7 9 import org.junit.Rule; 8 10 import org.junit.Test; 9 import org.openstreetmap.josm. data.osm.OsmUtils;11 import org.openstreetmap.josm.TestUtils; 10 12 import org.openstreetmap.josm.data.validation.TestError; 11 13 import org.openstreetmap.josm.data.validation.routines.AbstractValidator; … … 75 77 } 76 78 77 private static void testKey(String key, String value, boolean valid, AbstractValidator validator, int code) { 78 TestError error = TEST.validateTag(OsmUtils.createPrimitive("node "+key+"="+value+""), key, validator, code); 79 /** 80 * Test of invalid slashes. 81 */ 82 @Test 83 public void testInvalidSlashes() { 84 TestError error = testUrl("website", "http:\\\\www.sjoekurs.no", false); 85 assertEquals(tr("''{0}'': {1}", "website", tr("URL contains backslashes instead of slashes")), error.getDescription()); 86 assertNotNull(error.getFix()); 87 } 88 89 private static TestError testKey(String key, String value, boolean valid, AbstractValidator validator, int code) { 90 TestError error = TEST.validateTag(TestUtils.addFakeDataSet(TestUtils.newNode(key+"="+value+"")), key, validator, code); 79 91 if (valid) { 80 92 assertNull(error != null ? error.getMessage() : null, error); … … 82 94 assertNotNull(error); 83 95 } 96 return error; 84 97 } 85 98 86 private static voidtestUrl(String key, String value, boolean valid) {87 testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL);99 private static TestError testUrl(String key, String value, boolean valid) { 100 return testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL); 88 101 } 89 102 90 private static voidtestEmail(String key, String value, boolean valid) {91 testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL);103 private static TestError testEmail(String key, String value, boolean valid) { 104 return testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL); 92 105 } 93 106 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r13195 r13489 102 102 @Test 103 103 public void testTicket10913() throws ParseException { 104 final OsmPrimitive p = OsmUtils.createPrimitive("way highway=tertiary construction=yes");104 final OsmPrimitive p = TestUtils.addFakeDataSet(TestUtils.newWay("highway=tertiary construction=yes")); 105 105 final TagCheck check = TagCheck.readMapCSS(new StringReader("way {" + 106 106 "throwError: \"error\";" + … … 108 108 "fixAdd: \"highway=construction\";\n" + 109 109 "}")).parseChecks.get(0); 110 new DataSet(p);111 110 final Command command = check.fixPrimitive(p); 112 111 assertTrue(command instanceof SequenceCommand); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r13435 r13489 12 12 import org.junit.Rule; 13 13 import org.junit.Test; 14 import org.openstreetmap.josm. data.osm.DataSet;14 import org.openstreetmap.josm.TestUtils; 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 16 import org.openstreetmap.josm.data.osm.OsmUtils; … … 34 34 35 35 List<TestError> test(OsmPrimitive primitive) throws IOException { 36 new DataSet(primitive);37 36 final TagChecker checker = new TagChecker(); 38 37 checker.initialize(); 39 38 checker.startTest(null); 40 checker.check( primitive);39 checker.check(TestUtils.addFakeDataSet(primitive)); 41 40 return checker.getErrors(); 42 41 }
Note:
See TracChangeset
for help on using the changeset viewer.