Ignore:
Timestamp:
2023-03-13T21:59:27+01:00 (3 years ago)
Author:
taylor.smock
Message:

See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)

The modifications are as follows:

  • Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
  • Update some tests to use @ParameterizedTest (DomainValidatorTest)
  • Replace various exception blocks with assertThrows. These typically looked like
        try {
            // Something that should throw an exception here
            fail("An exception should have been thrown");
        } catch (Exception e) {
            // Verify the exception matches expectations here
        }
    
  • Replace assertTrue(val instanceof Clazz) with assertInstanceOf
  • Replace JUnit 4 @Suite with JUnit 5 @Suite

Both the original patch and the modified patch fix various lint issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r17275 r18690  
    77import static org.junit.jupiter.api.Assertions.assertThrows;
    88
    9 import org.junit.Assert;
    109import org.junit.jupiter.api.Test;
    1110import org.junit.jupiter.api.extension.RegisterExtension;
     
    6261        BBox bbox = new BBox(w1);
    6362        bbox.add(n3.getBBox());
    64         Assert.assertEquals(bbox, r1.getBBox());
    65         Assert.assertEquals(bbox, r2.getBBox());
     63        assertEquals(bbox, r1.getBBox());
     64        assertEquals(bbox, r2.getBBox());
    6665
    6766        n3.setCoor(new LatLon(40, 40));
    6867        bbox.add(n3.getBBox());
    69         Assert.assertEquals(bbox, r1.getBBox());
    70         Assert.assertEquals(bbox, r2.getBBox());
     68        assertEquals(bbox, r1.getBBox());
     69        assertEquals(bbox, r2.getBBox());
    7170
    7271        r1.removeMembersFor(r2);
    73         Assert.assertEquals(w1.getBBox(), r1.getBBox());
    74         Assert.assertEquals(bbox, r2.getBBox());
     72        assertEquals(w1.getBBox(), r1.getBBox());
     73        assertEquals(bbox, r2.getBBox());
    7574
    7675        w1.addNode(n3);
    77         Assert.assertEquals(w1.getBBox(), r1.getBBox());
    78         Assert.assertEquals(w1.getBBox(), r2.getBBox());
     76        assertEquals(w1.getBBox(), r1.getBBox());
     77        assertEquals(w1.getBBox(), r2.getBBox());
    7978
    8079        // create incomplete node and add it to the relation, this must not change the bbox
     
    8584        r2.addMember(new RelationMember("", n4));
    8685
    87         Assert.assertEquals(oldBBox, r2.getBBox());
     86        assertEquals(oldBBox, r2.getBBox());
    8887    }
    8988
     
    9998        r1.addMember(new RelationMember("", w1));
    10099
    101         Assert.assertEquals(new BBox(w1), r1.getBBox());
     100        assertEquals(new BBox(w1), r1.getBBox());
    102101
    103102        DataSet ds = new DataSet();
     
    107106        ds.addPrimitive(r1);
    108107
    109         Assert.assertEquals(new BBox(w1), r1.getBBox());
     108        assertEquals(new BBox(w1), r1.getBBox());
    110109
    111110        ds.removePrimitive(r1);
    112111
    113112        n1.setCoor(new LatLon(30, 40));
    114         Assert.assertEquals(new BBox(w1), r1.getBBox());
     113        assertEquals(new BBox(w1), r1.getBBox());
    115114
    116115        ds.addPrimitive(r1);
    117         Assert.assertEquals(new BBox(w1), r1.getBBox());
     116        assertEquals(new BBox(w1), r1.getBBox());
    118117    }
    119118
    120119    /**
    121120     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12467">Bug #12467</a>.
    122      * @throws Exception if any error occurs
    123121     */
    124122    @Test
    125     void testTicket12467() throws Exception {
     123    void testTicket12467() {
    126124        Relation r = new Relation();
    127125        r.put("type", "boundary");
     
    146144    @Test
    147145    void testCloneFromIAE() {
    148         assertThrows(IllegalArgumentException.class, () -> new Relation().cloneFrom(new Node()));
     146        final Relation relation = new Relation();
     147        final Node node = new Node();
     148        assertThrows(IllegalArgumentException.class, () -> relation.cloneFrom(node));
    149149    }
    150150
     
    154154    @Test
    155155    void testLoadIAE() {
    156         assertThrows(IllegalArgumentException.class, () -> new Relation().load(new NodeData()));
     156        final Relation relation = new Relation();
     157        final NodeData nodeData = new NodeData();
     158        assertThrows(IllegalArgumentException.class, () -> relation.load(nodeData));
    157159    }
    158160}
Note: See TracChangeset for help on using the changeset viewer.