Changeset 11491 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-01-25T12:57:27+01:00 (8 years ago)
Author:
Don-vip
Message:

see #14287 - add non regression unit test

File:
1 edited

Legend:

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

    r11084 r11491  
    77import static org.junit.Assert.assertTrue;
    88
     9import java.io.InputStream;
    910import java.io.StringReader;
    1011import java.util.Collection;
     
    1415import java.util.Set;
    1516
     17import org.junit.Ignore;
    1618import org.junit.Rule;
    1719import org.junit.Test;
    1820import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.TestUtils;
    1922import org.openstreetmap.josm.command.ChangePropertyCommand;
    2023import org.openstreetmap.josm.command.ChangePropertyKeyCommand;
     
    3033import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.TagCheck;
    3134import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
     35import org.openstreetmap.josm.io.OsmReader;
    3236import org.openstreetmap.josm.testutils.JOSMTestRules;
    3337
     
    4448    @Rule
    4549    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    46     public JOSMTestRules test = new JOSMTestRules();
     50    public JOSMTestRules test = new JOSMTestRules().projection();
    4751
    4852    static MapCSSTagChecker buildTagChecker(String css) throws ParseException {
     
    5862    @Test
    5963    public void testNaturalMarsh() throws ParseException {
    60         ParseResult result = MapCSSTagChecker.TagCheck.readMapCSS(new StringReader(
     64        ParseResult result = TagCheck.readMapCSS(new StringReader(
    6165                "*[natural=marsh] {\n" +
    6266                "   group: tr(\"deprecated\");\n" +
     
    6670                "   fixAdd: \"wetland=marsh\";\n" +
    6771                "}"));
    68         final List<MapCSSTagChecker.TagCheck> checks = result.parseChecks;
     72        final List<TagCheck> checks = result.parseChecks;
    6973        assertEquals(1, checks.size());
    7074        assertTrue(result.parseErrors.isEmpty());
    71         final MapCSSTagChecker.TagCheck check = checks.get(0);
     75        final TagCheck check = checks.get(0);
    7276        assertNotNull(check);
    7377        assertEquals("{0.key}=null is deprecated", check.getDescription(null));
     
    8791        assertFalse(check.test(n2));
    8892        assertEquals("The key is natural and the value is marsh",
    89                 MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}", null));
     93                TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}", null));
    9094    }
    9195
     
    145149    @Test
    146150    public void testTicket13630() throws ParseException {
    147         ParseResult result = MapCSSTagChecker.TagCheck.readMapCSS(new StringReader(
     151        ParseResult result = TagCheck.readMapCSS(new StringReader(
    148152                "node[crossing=zebra] {fixRemove: \"crossing=zebra\";}"));
    149153        assertTrue(result.parseChecks.isEmpty());
     
    151155    }
    152156
     157    /**
     158     * Unit test of {@code min-josm-version} processing.
     159     * @throws ParseException if a parsing error occurs
     160     */
    153161    @Test
    154162    public void testPreprocessing() throws ParseException {
     
    160168    }
    161169
     170    /**
     171     * Unit test of {@link MapCSSTagChecker#initialize}.
     172     * @throws Exception if an error occurs
     173     */
    162174    @Test
    163175    public void testInit() throws Exception {
     
    187199        assertTrue(parseResult.parseErrors.isEmpty());
    188200    }
     201
     202    /**
     203     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14287">Bug #14287</a>.
     204     * @throws Exception if an error occurs
     205     */
     206    @Test
     207    @Ignore("not fixed yet")
     208    public void testTicket14287() throws Exception {
     209        final MapCSSTagChecker test = buildTagChecker(
     210                "node[amenity=parking] ∈ *[amenity=parking] {" +
     211                "  throwWarning: tr(\"{0} inside {1}\", \"amenity=parking\", \"amenity=parking\");" +
     212                "}");
     213        try (InputStream is = TestUtils.getRegressionDataStream(14287, "example.osm")) {
     214            test.visit(OsmReader.parseDataSet(is, null).allPrimitives());
     215            assertEquals(6, test.getErrors().size());
     216        }
     217    }
    189218}
Note: See TracChangeset for help on using the changeset viewer.