Changeset 17384 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2020-12-02T08:30:13+01:00 (4 years ago)
Author:
GerdP
Message:

fix #20182: NumberFormatException in ConnectivityRelations.parseConnectivityTag

  • fix crash with invalid connectivity=right_turn or a single number like connectivity=1
  • remove code which looks for "bw" after "bw" was replaced by -1000.
  • some more cleanup and code simplifications
  • use JOSMTestRules() instead of JOSMFixture

I don't like that method parseConnectivityTag() is public but didn't change it so far. It seems a bit strange to return an empty map for different kinds of problems found in the connectivity tag.

File:
1 edited

Legend:

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

    r17275 r17384  
    55import org.junit.jupiter.api.BeforeEach;
    66import org.junit.jupiter.api.Test;
    7 import org.openstreetmap.josm.JOSMFixture;
     7import org.junit.jupiter.api.extension.RegisterExtension;
    88import org.openstreetmap.josm.TestUtils;
    99import org.openstreetmap.josm.data.coor.LatLon;
     
    1111import org.openstreetmap.josm.data.osm.Relation;
    1212import org.openstreetmap.josm.data.osm.RelationMember;
     13import org.openstreetmap.josm.testutils.JOSMTestRules;
     14
     15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1316
    1417/**
     
    2023    private ConnectivityRelations check;
    2124    private static final String CONNECTIVITY = "connectivity";
     25
    2226    /**
    2327     * Setup test.
    24      *
    25      * @throws Exception if an error occurs
    2628     */
     29    @RegisterExtension
     30    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     31    public JOSMTestRules rule = new JOSMTestRules();
     32
    2733    @BeforeEach
    28     public void setUp() throws Exception {
    29         JOSMFixture.createUnitTestFixture().init();
     34    public void setUpCheck() throws Exception {
    3035        check = new ConnectivityRelations();
    3136    }
     
    8691    }
    8792
     93    /**
     94     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/201821">Bug #20182</a>.
     95     * @throws Exception if an error occurs
     96     */
     97    @Test
     98    void testTicket20182() throws Exception {
     99        Relation relation = createDefaultTestRelation();
     100        check.visit(relation);
     101        int expectedFailures = 0;
     102
     103        Assert.assertEquals(expectedFailures, check.getErrors().size());
     104
     105        relation.put(CONNECTIVITY, "left_turn");
     106        check.visit(relation);
     107        Assert.assertEquals(++expectedFailures, check.getErrors().size());
     108
     109        relation.put(CONNECTIVITY, "1");
     110        check.visit(relation);
     111        Assert.assertEquals(++expectedFailures, check.getErrors().size());
     112    }
    88113}
Note: See TracChangeset for help on using the changeset viewer.