Ignore:
Timestamp:
2016-03-27T23:17:02+02:00 (9 years ago)
Author:
donvip
Message:

fix #josm12694 - robustness to invalid KML colors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReaderTest.java

    r31990 r32130  
    22package org.openstreetmap.josm.plugins.opendata.core.io.geographic;
    33
    4 import java.io.File;
    5 import java.io.FileInputStream;
     4import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertTrue;
     6
    67import java.io.IOException;
    78import java.io.InputStream;
     
    2829        JOSMFixture.createUnitTestFixture().init();
    2930    }
     31
     32    /**
     33     * Unit test of {@link KmlReader#COLOR_PATTERN}
     34     */
     35    @Test
     36    public void testColorPattern() {
     37        assertTrue(KmlReader.COLOR_PATTERN.matcher("00112233").matches());
     38        assertTrue(KmlReader.COLOR_PATTERN.matcher("44556677").matches());
     39        assertTrue(KmlReader.COLOR_PATTERN.matcher("8899aabb").matches());
     40        assertTrue(KmlReader.COLOR_PATTERN.matcher("CCDDEEFF").matches());
     41        assertFalse(KmlReader.COLOR_PATTERN.matcher("0011223").matches());
     42        assertFalse(KmlReader.COLOR_PATTERN.matcher("001122330").matches());
     43        assertFalse(KmlReader.COLOR_PATTERN.matcher("gg112233").matches());
     44        assertFalse(KmlReader.COLOR_PATTERN.matcher("red").matches());
     45        assertFalse(KmlReader.COLOR_PATTERN.matcher("yellow").matches());
     46    }
    3047   
     48    /**
     49     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12694">#12694</a>
     50     * @throws IOException if an error occurs during reading
     51     */
     52    @Test
     53    public void testTicket12694() throws IOException, XMLStreamException, FactoryConfigurationError {
     54        try (InputStream is = TestUtils.getRegressionDataStream(12694, "Alvinรณpolis_314946.kml")) {
     55            NonRegFunctionalTests.testGeneric("#12694", KmlReader.parseDataSet(is, null));
     56        }
     57    }
     58
    3159    /**
    3260     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/10214">#10214</a>
     
    3967        }
    4068    }
    41    
     69
    4270    /**
    4371     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/7714">#7714</a>
Note: See TracChangeset for help on using the changeset viewer.