Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (4 years ago)
Author:
Don-vip
Message:

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

Location:
trunk/test/unit/org/openstreetmap/josm/data/projection
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/projection/CustomProjectionTest.java

    r13602 r17275  
    22package org.openstreetmap.josm.data.projection;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
    6 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6import static org.junit.jupiter.api.Assertions.fail;
    77
    88import java.util.stream.Stream;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.extension.RegisterExtension;
     11import org.junit.jupiter.api.Test;
    1212import org.openstreetmap.josm.data.coor.LatLon;
    1313import org.openstreetmap.josm.data.projection.CustomProjection.Polarity;
     
    2020 * @author Michael Zangl
    2121 */
    22 public class CustomProjectionTest {
     22class CustomProjectionTest {
    2323    /**
    2424     * Need pref to load pref.
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3333     */
    3434    @Test
    35     public void testParseAngle() throws ProjectionConfigurationException {
     35    void testParseAngle() throws ProjectionConfigurationException {
    3636        assertEquals(0, CustomProjection.parseAngle("0", "xxx"), 1e-10);
    3737        assertEquals(1, CustomProjection.parseAngle("1", "xxx"), 1e-10);
     
    8686     */
    8787    @Test
    88     public void testPolarity() {
     88    void testPolarity() {
    8989        assertEquals(LatLon.NORTH_POLE, Polarity.NORTH.getLatLon());
    9090        assertEquals(LatLon.SOUTH_POLE, Polarity.SOUTH.getLatLon());
  • trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java

    r11324 r17275  
    66
    77import org.junit.Assert;
    8 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    99import org.openstreetmap.josm.data.coor.LatLon;
    1010
     
    1212 * Unit tests for class {@link Ellipsoid}.
    1313 */
    14 public class EllipsoidTest {
     14class EllipsoidTest {
    1515
    1616    private static final double EPSILON = 1e-8;
     
    2020     */
    2121    @Test
    22     public void testLatLon2Cart2LatLon() {
     22    void testLatLon2Cart2LatLon() {
    2323        Random r = new SecureRandom();
    2424        double maxErrLat = 0, maxErrLon = 0;
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

    r16643 r17275  
    3434import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3535import org.junit.Assert;
    36 import org.junit.Rule;
    37 import org.junit.Test;
     36import org.junit.jupiter.api.extension.RegisterExtension;
     37import org.junit.jupiter.api.Test;
    3838import org.openstreetmap.josm.data.Bounds;
    3939import org.openstreetmap.josm.data.coor.EastNorth;
     
    5959 * of the algorithm, given a certain definition.
    6060 */
    61 public class ProjectionRefTest {
     61class ProjectionRefTest {
    6262
    6363    private static final String CS2CS_EXE = "cs2cs";
     
    8686     * Setup test.
    8787     */
    88     @Rule
     88    @RegisterExtension
    8989    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    9090    public JOSMTestRules test = new JOSMTestRules().projectionNadGrids().timeout(90_000);
     
    373373     */
    374374    @Test
    375     public void testProjections() throws IOException {
     375    void testProjections() throws IOException {
    376376        StringBuilder fail = new StringBuilder();
    377377        Map<String, Set<String>> failingProjs = new HashMap<>();
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r16643 r17275  
    1919import java.util.stream.Collectors;
    2020
    21 import org.junit.BeforeClass;
    22 import org.junit.Test;
     21import org.junit.jupiter.api.BeforeAll;
     22import org.junit.jupiter.api.Test;
    2323import org.openstreetmap.josm.JOSMFixture;
    2424import org.openstreetmap.josm.data.Bounds;
     
    3939 * test data, by running the main method of this class and commit the new data file.
    4040 */
    41 public class ProjectionRegressionTest {
     41class ProjectionRegressionTest {
    4242
    4343    private static final String PROJECTION_DATA_FILE = "nodist/data/projection/projection-regression-test-data";
     
    136136     * Setup test.
    137137     */
    138     @BeforeClass
     138    @BeforeAll
    139139    public static void setUp() {
    140140        JOSMFixture.createUnitTestFixture().init();
     
    146146     */
    147147    @Test
    148     public void testNonRegression() throws IOException {
     148    void testNonRegression() throws IOException {
    149149        List<TestData> allData = readData();
    150150        Set<String> dataCodes = allData.stream().map(data -> data.code).collect(Collectors.toSet());
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java

    r16913 r17275  
    22package org.openstreetmap.josm.data.projection;
    33
    4 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertTrue;
    55
    66import java.security.SecureRandom;
     
    1111
    1212import org.junit.Assert;
    13 import org.junit.Test;
     13import org.junit.jupiter.api.Test;
    1414import org.openstreetmap.josm.data.Bounds;
    1515import org.openstreetmap.josm.data.coor.EastNorth;
     
    1919 * Unit tests for class {@link Projection}.
    2020 */
    21 public class ProjectionTest {
     21class ProjectionTest {
    2222
    2323    private static final Random rand = new SecureRandom();
     
    3030     */
    3131    @Test
    32     public void testProjections() {
     32    void testProjections() {
    3333        error = false;
    3434        text = "";
     
    120120     */
    121121    @Test
    122     public void testProjs() {
     122    void testProjs() {
    123123        error2 = false;
    124124        text2 = "";
     
    150150            Assert.fail();
    151151        }
    152         assertTrue("missing test: "+projIds, projIds.isEmpty());
     152        assertTrue(projIds.isEmpty(), "missing test: "+projIds);
    153153    }
    154154
     
    170170            EastNorth en = p.latlon2eastNorth(ll1);
    171171            LatLon ll2 = p.eastNorth2latlon(en);
    172             assertTrue(p.toCode() + " at " + ll1 + " is " + ll2, ll2.isValid());
     172            assertTrue(ll2.isValid(), p.toCode() + " at " + ll1 + " is " + ll2);
    173173            double dist = ll1.greatCircleDistance(ll2);
    174174            if (dist > eps) {
     
    189189     */
    190190    @Test
    191     public void testSwedishProjections() {
     191    void testSwedishProjections() {
    192192        for (int code = 3006; code <= 3018; code++) {
    193193            assertTrue(Projections.getProjectionByCode("EPSG:"+code).switchXY());
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ShiftedProjectionTest.java

    r12161 r17275  
    22package org.openstreetmap.josm.data.projection;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.util.Comparator;
     
    1111import java.util.stream.Collectors;
    1212
    13 import org.junit.Test;
     13import org.junit.jupiter.api.Test;
    1414import org.openstreetmap.josm.data.ProjectionBounds;
    1515import org.openstreetmap.josm.data.coor.EastNorth;
     
    2121 * @author Michael Zangl
    2222 */
    23 public class ShiftedProjectionTest {
     23class ShiftedProjectionTest {
    2424    private static final class ProjectingBase implements Projecting {
    2525        @Override
     
    5757     */
    5858    @Test
    59     public void testLatlon2eastNorth() {
     59    void testLatlon2eastNorth() {
    6060        Projecting base = new ProjectingBase();
    6161
     
    8181     */
    8282    @Test
    83     public void testEastNorth2latlonClamped() {
     83    void testEastNorth2latlonClamped() {
    8484        Projecting base = new ProjectingBase();
    8585
     
    105105     */
    106106    @Test
    107     public void testGetProjectingsForArea() {
     107    void testGetProjectingsForArea() {
    108108        Projecting base = new ProjectingBase();
    109109        ShiftedProjecting shifted = new ShiftedProjecting(base, new EastNorth(5, 7));
     
    124124     */
    125125    @Test
    126     public void testGetProjectingsForAreaMultiple() {
     126    void testGetProjectingsForAreaMultiple() {
    127127        Projecting base = new ProjectingBase();
    128128        ShiftedProjecting shifted = new ShiftedProjecting(base, new EastNorth(5, 7));
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r16913 r17275  
    22package org.openstreetmap.josm.data.projection;
    33
    4 import static org.junit.Assert.assertSame;
    5 import static org.junit.Assert.assertTrue;
    6 
    7 import org.junit.BeforeClass;
    8 import org.junit.Rule;
    9 import org.junit.Test;
     4import static org.junit.jupiter.api.Assertions.assertSame;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6
     7import org.junit.jupiter.api.BeforeAll;
     8import org.junit.jupiter.api.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
    1010import org.openstreetmap.josm.data.coor.EastNorth;
    1111import org.openstreetmap.josm.data.coor.LatLon;
     
    1717 * Unit tests for the Swiss projection grid.
    1818 */
    19 public class SwissGridTest {
     19class SwissGridTest {
    2020    private static final String SWISS_EPSG_CODE = "EPSG:21781";
    2121    private final boolean debug = false;
     
    2424     * Setup test.
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules().projectionNadGrids();
     
    3131     * Setup test.
    3232     */
    33     @BeforeClass
     33    @BeforeAll
    3434    public static void setUp() {
    3535        ProjectionRegistry.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid
     
    7979            }
    8080        }
    81         assertSame(errs.toString(), errs.length(), 0);
     81        assertSame(errs.length(), 0, errs::toString);
    8282    }
    8383
     
    8686     */
    8787    @Test
    88     public void testProjReferenceTestAccurate() {
     88    void testProjReferenceTestAccurate() {
    8989        projReferenceTest(EPSILON_ACCURATE);
    9090    }
     
    9494     */
    9595    @Test
    96     public void testAlatlon2eastNorth() {
     96    void testAlatlon2eastNorth() {
    9797        LatLon ll = new LatLon(46.518, 6.567);
    9898        EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
     
    100100            System.out.println(en);
    101101        }
    102         assertTrue("Lausanne", Math.abs(en.east() - 533112.13) < 0.1);
    103         assertTrue("Lausanne", Math.abs(en.north() - 152227.35) < 0.1);
     102        assertTrue(Math.abs(en.east() - 533112.13) < 0.1, "Lausanne");
     103        assertTrue(Math.abs(en.north() - 152227.35) < 0.1, "Lausanne");
    104104
    105105        ll = new LatLon(47.78, 8.58);
     
    108108            System.out.println(en);
    109109        }
    110         assertTrue("Schafouse", Math.abs(en.east() - 685542.97) < 0.1);
    111         assertTrue("Schafouse", Math.abs(en.north() - 292783.21) < 0.1);
     110        assertTrue(Math.abs(en.east() - 685542.97) < 0.1, "Schafouse");
     111        assertTrue(Math.abs(en.north() - 292783.21) < 0.1, "Schafouse");
    112112
    113113        ll = new LatLon(46.58, 10.48);
     
    116116            System.out.println(en);
    117117        }
    118         assertTrue("Grinson", Math.abs(en.east() - 833066.95) < 0.1);
    119         assertTrue("Grinson", Math.abs(en.north() - 163265.32) < 0.1);
     118        assertTrue(Math.abs(en.east() - 833066.95) < 0.1, "Grinson");
     119        assertTrue(Math.abs(en.north() - 163265.32) < 0.1, "Grinson");
    120120
    121121        ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600);
     
    124124            System.out.println(en);
    125125        }
    126         assertTrue("Berne", Math.abs(en.east() - 600000.0) < 0.1);
    127         assertTrue("Berne", Math.abs(en.north() - 200000.0) < 0.1);
     126        assertTrue(Math.abs(en.east() - 600000.0) < 0.1, "Berne");
     127        assertTrue(Math.abs(en.north() - 200000.0) < 0.1, "Berne");
    128128
    129129        // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000
     
    133133            System.out.println(en);
    134134        }
    135         assertTrue("Ref", Math.abs(en.east() - 700000.0) < 0.1);
    136         assertTrue("Ref", Math.abs(en.north() - 100000.0) < 0.1);
     135        assertTrue(Math.abs(en.east() - 700000.0) < 0.1, "Ref");
     136        assertTrue(Math.abs(en.north() - 100000.0) < 0.1, "Ref");
    137137    }
    138138
     
    141141     */
    142142    @Test
    143     public void testBeastNorth2latlon() {
     143    void testBeastNorth2latlon() {
    144144        EastNorth en = new EastNorth(533112.13, 152227.35);
    145145        LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     
    147147            System.out.println(ll);
    148148        }
    149         assertTrue("Lausanne", Math.abs(ll.lat() - 46.518) < 0.00001);
    150         assertTrue("Lausanne", Math.abs(ll.lon() - 6.567) < 0.00001);
     149        assertTrue(Math.abs(ll.lat() - 46.518) < 0.00001, "Lausanne");
     150        assertTrue(Math.abs(ll.lon() - 6.567) < 0.00001, "Lausanne");
    151151
    152152        en = new EastNorth(685542.97, 292783.21);
     
    155155            System.out.println(ll);
    156156        }
    157         assertTrue("Schafouse", Math.abs(ll.lat() - 47.78) < 0.00001);
    158         assertTrue("Schafouse", Math.abs(ll.lon() - 8.58) < 0.00001);
     157        assertTrue(Math.abs(ll.lat() - 47.78) < 0.00001, "Schafouse");
     158        assertTrue(Math.abs(ll.lon() - 8.58) < 0.00001, "Schafouse");
    159159
    160160        en = new EastNorth(833066.95, 163265.32);
     
    163163            System.out.println(ll);
    164164        }
    165         assertTrue("Grinson", Math.abs(ll.lat() - 46.58) < 0.00001);
    166         assertTrue("Grinson", Math.abs(ll.lon() - 10.48) < 0.00001);
     165        assertTrue(Math.abs(ll.lat() - 46.58) < 0.00001, "Grinson");
     166        assertTrue(Math.abs(ll.lon() - 10.48) < 0.00001, "Grinson");
    167167
    168168        en = new EastNorth(600000.0, 200000.0);
     
    171171            System.out.println(ll);
    172172        }
    173         assertTrue("Berne", Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001);
    174         assertTrue("Berne", Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001);
     173        assertTrue(Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001, "Berne");
     174        assertTrue(Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001, "Berne");
    175175
    176176        // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000
     
    180180            System.out.println(ll);
    181181        }
    182         assertTrue("Ref", Math.abs(ll.lat() - 46.04412093223244) < 0.00001);
    183         assertTrue("Ref", Math.abs(ll.lon() - 8.730497366167727) < 0.00001);
     182        assertTrue(Math.abs(ll.lat() - 46.04412093223244) < 0.00001, "Ref");
     183        assertTrue(Math.abs(ll.lon() - 8.730497366167727) < 0.00001, "Ref");
    184184    }
    185185
     
    188188     */
    189189    @Test
    190     public void testCsendandreturn() {
     190    void testCsendandreturn() {
    191191        EastNorth en = new EastNorth(533111.69, 152227.85);
    192192        LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     
    198198            System.out.println(en.north() - en2.north());
    199199        }
    200         assertTrue("Lausanne", Math.abs(en.east() - en2.east()) < 0.002);
    201         assertTrue("Lausanne", Math.abs(en.north() - en2.north()) < 0.002);
     200        assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Lausanne");
     201        assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Lausanne");
    202202
    203203        en = new EastNorth(685544.16, 292782.91);
     
    210210            System.out.println(en.north() - en2.north());
    211211        }
    212         assertTrue("Schafouse", Math.abs(en.east() - en2.east()) < 0.002);
    213         assertTrue("Schafouse", Math.abs(en.north() - en2.north()) < 0.002);
     212        assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Schafouse");
     213        assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Schafouse");
    214214
    215215        en = new EastNorth(833068.04, 163265.39);
     
    222222            System.out.println(en.north() - en2.north());
    223223        }
    224         assertTrue("Grinson", Math.abs(en.east() - en2.east()) < 0.002);
    225         assertTrue("Grinson", Math.abs(en.north() - en2.north()) < 0.002);
     224        assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Grinson");
     225        assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Grinson");
    226226
    227227        en = new EastNorth(600000.0, 200000.0);
     
    234234            System.out.println(en.north() - en2.north());
    235235        }
    236         assertTrue("Berne", Math.abs(en.east() - en2.east()) < 0.002);
    237         assertTrue("Berne", Math.abs(en.north() - en2.north()) < 0.002);
     236        assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Berne");
     237        assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Berne");
    238238
    239239        en = new EastNorth(700000.0, 100000.0);
     
    246246            System.out.println(en.north() - en2.north());
    247247        }
    248         assertTrue("Ref", Math.abs(en.east() - en2.east()) < 0.002);
    249         assertTrue("Ref", Math.abs(en.north() - en2.north()) < 0.002);
     248        assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Ref");
     249        assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Ref");
    250250    }
    251251}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/proj/LonLatTest.java

    r11931 r17275  
    22package org.openstreetmap.josm.data.projection.proj;
    33
    4 import static org.junit.Assert.assertFalse;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
    55
    6 import org.junit.Rule;
    7 import org.junit.Test;
     6import org.junit.jupiter.api.extension.RegisterExtension;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
     
    1313 * Tests for {@link LonLat}.
    1414 */
    15 public class LonLatTest {
     15class LonLatTest {
    1616    /**
    1717     * Setup rule.
    1818     */
    19     @Rule
     19    @RegisterExtension
    2020    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2121    public JOSMTestRules test = new JOSMTestRules();
     
    2525     */
    2626    @Test
    27     public void testLonIsLinearToEast() {
     27    void testLonIsLinearToEast() {
    2828        assertFalse(new LonLat().lonIsLinearToEast());
    2929    }
  • trunk/test/unit/org/openstreetmap/josm/data/projection/proj/MercatorTest.java

    r11931 r17275  
    22package org.openstreetmap.josm.data.projection.proj;
    33
    4 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertTrue;
    55
    6 import org.junit.Rule;
    7 import org.junit.Test;
     6import org.junit.jupiter.api.extension.RegisterExtension;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
     
    1313 * Tests for {@link Mercator}.
    1414 */
    15 public class MercatorTest {
     15class MercatorTest {
    1616    /**
    1717     * Setup rule.
    1818     */
    19     @Rule
     19    @RegisterExtension
    2020    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2121    public JOSMTestRules test = new JOSMTestRules();
     
    2525     */
    2626    @Test
    27     public void testLonIsLinearToEast() {
     27    void testLonIsLinearToEast() {
    2828        assertTrue(new Mercator().lonIsLinearToEast());
    2929    }
Note: See TracChangeset for help on using the changeset viewer.