Changeset 14803 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2019-02-24T20:25:48+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java
r13489 r14803 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 5 6 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assert Null;7 import static org.junit.Assert.assertTrue; 7 8 import static org.openstreetmap.josm.tools.I18n.tr; 9 10 import java.util.List; 8 11 9 12 import org.junit.Rule; … … 51 54 52 55 /** 56 * Test multiple URLs. 57 */ 58 @Test 59 public void testMultipleUrls() { 60 testUrl("url", "http://www.domain-a.com;https://www.domain-b.com", true); // multiple values 61 } 62 63 /** 53 64 * Test of invalid URLs. 54 65 */ … … 82 93 @Test 83 94 public void testInvalidSlashes() { 84 TestError error = testUrl("website", "http:\\\\www.sjoekurs.no", false) ;95 TestError error = testUrl("website", "http:\\\\www.sjoekurs.no", false).get(0); 85 96 assertEquals(tr("''{0}'': {1}", "website", tr("URL contains backslashes instead of slashes")), error.getDescription()); 86 97 assertNotNull(error.getFix()); 87 98 } 88 99 89 private static TestErrortestKey(String key, String value, boolean valid, AbstractValidator validator, int code) {90 TestError error= TEST.validateTag(TestUtils.addFakeDataSet(TestUtils.newNode(key+"="+value+"")), key, validator, code);100 private static List<TestError> testKey(String key, String value, boolean valid, AbstractValidator validator, int code) { 101 List<TestError> errors = TEST.validateTag(TestUtils.addFakeDataSet(TestUtils.newNode(key+"="+value+"")), key, validator, code); 91 102 if (valid) { 92 assert Null(error != null ? error.getMessage() : null, error);103 assertTrue(errors.isEmpty()); 93 104 } else { 94 assertNotNull(error); 105 assertFalse(errors.isEmpty()); 106 assertNotNull(errors.get(0)); 95 107 } 96 return error ;108 return errors; 97 109 } 98 110 99 private static TestErrortestUrl(String key, String value, boolean valid) {111 private static List<TestError> testUrl(String key, String value, boolean valid) { 100 112 return testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL); 101 113 } 102 114 103 private static TestErrortestEmail(String key, String value, boolean valid) {115 private static List<TestError> testEmail(String key, String value, boolean valid) { 104 116 return testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL); 105 117 }
Note:
See TracChangeset
for help on using the changeset viewer.