Ignore:
Timestamp:
2019-02-24T20:25:48+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #17376 - allows multiple values in URL validator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java

    r13489 r14803  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
    56import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     7import static org.junit.Assert.assertTrue;
    78import static org.openstreetmap.josm.tools.I18n.tr;
     9
     10import java.util.List;
    811
    912import org.junit.Rule;
     
    5154
    5255    /**
     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    /**
    5364     * Test of invalid URLs.
    5465     */
     
    8293    @Test
    8394    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);
    8596        assertEquals(tr("''{0}'': {1}", "website", tr("URL contains backslashes instead of slashes")), error.getDescription());
    8697        assertNotNull(error.getFix());
    8798    }
    8899
    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);
     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);
    91102        if (valid) {
    92             assertNull(error != null ? error.getMessage() : null, error);
     103            assertTrue(errors.isEmpty());
    93104        } else {
    94             assertNotNull(error);
     105            assertFalse(errors.isEmpty());
     106            assertNotNull(errors.get(0));
    95107        }
    96         return error;
     108        return errors;
    97109    }
    98110
    99     private static TestError testUrl(String key, String value, boolean valid) {
     111    private static List<TestError> testUrl(String key, String value, boolean valid) {
    100112        return testKey(key, value, valid, UrlValidator.getInstance(), InternetTags.INVALID_URL);
    101113    }
    102114
    103     private static TestError testEmail(String key, String value, boolean valid) {
     115    private static List<TestError> testEmail(String key, String value, boolean valid) {
    104116        return testKey(key, value, valid, EmailValidator.getInstance(), InternetTags.INVALID_EMAIL);
    105117    }
Note: See TracChangeset for help on using the changeset viewer.