Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (6 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java

    r17094 r17275  
    22package org.openstreetmap.josm.data.imagery;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
    6 
    7 import org.junit.Rule;
    8 import org.junit.Test;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6
     7import org.junit.jupiter.api.Test;
     8import org.junit.jupiter.api.extension.RegisterExtension;
    99import org.openstreetmap.gui.jmapviewer.TileXY;
    1010import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
     
    2424 * Unit tests for class {@link TemplatedWMSTileSource}.
    2525 */
    26 public class TemplatedWMSTileSourceTest {
     26class TemplatedWMSTileSourceTest {
    2727
    2828    private final ImageryInfo testImageryWMS = new ImageryInfo("test imagery", "http://localhost", "wms", null, null);
     
    3232     * Setup test.
    3333     */
    34     @Rule
     34    @RegisterExtension
    3535    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3636    public JOSMTestRules test = new JOSMTestRules();
     
    4040     */
    4141    @Test
    42     public void testEPSG3857() {
     42    void testEPSG3857() {
    4343        Projection projection = Projections.getProjectionByCode("EPSG:3857");
    4444        ProjectionRegistry.setProjection(projection);
     
    6565     */
    6666    @Test
    67     public void testEPSG4326() {
     67    void testEPSG4326() {
    6868        Projection projection = Projections.getProjectionByCode("EPSG:4326");
    6969        ProjectionRegistry.setProjection(projection);
     
    8181     */
    8282    @Test
    83     public void testEPSG4326widebounds() {
     83    void testEPSG4326widebounds() {
    8484        Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=-180,53,180,54");
    8585        ProjectionRegistry.setProjection(projection);
     
    9494     */
    9595    @Test
    96     public void testEPSG4326narrowbounds() {
     96    void testEPSG4326narrowbounds() {
    9797        Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=18,-90,20,90");
    9898        ProjectionRegistry.setProjection(projection);
     
    107107     */
    108108    @Test
    109     public void testEPSG2180() {
     109    void testEPSG2180() {
    110110        Projection projection = Projections.getProjectionByCode("EPSG:2180");
    111111        ProjectionRegistry.setProjection(projection);
     
    124124     */
    125125    @Test
    126     public void testEPSG3006withbounds() {
     126    void testEPSG3006withbounds() {
    127127        Projection projection =
    128128                new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 "
     
    140140     */
    141141    @Test
    142     public void testEPSG3006withoutbounds() {
     142    void testEPSG3006withoutbounds() {
    143143        Projection projection =
    144144                new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 "
     
    156156     */
    157157    @Test
    158     public void testGetTileUrl() {
     158    void testGetTileUrl() {
    159159        // "https://maps.six.nsw.gov.au/arcgis/services/public/NSW_Imagery_Dates/MapServer/WMSServer?
    160160        // SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height}
     
    206206        ICoordinate expected = verifier.tileXYToLatLon(x, y, z - 1);
    207207        assertEquals(expected.getLat(), result.lat(), 1e-4);
    208         assertEquals(LatLon.normalizeLon(expected.getLon() - result.lon()), 0.0, 1e-4);
     208        assertEquals(0.0, LatLon.normalizeLon(expected.getLon() - result.lon()), 1e-4);
    209209        LatLon tileCenter = new Bounds(result, getTileLatLon(source, x+1, y+1, z)).getCenter();
    210210        TileXY backwardsResult = source.latLonToTileXY(CoordinateConversion.llToCoor(tileCenter), z);
     
    224224    private void verifyLocation(TemplatedWMSTileSource source, LatLon location, int z) {
    225225        Projection projection = ProjectionRegistry.getProjection();
    226         assertTrue(
    227                 "Point outside world bounds",
    228                 projection.getWorldBoundsLatLon().contains(location)
    229                 );
     226        assertTrue(projection.getWorldBoundsLatLon().contains(location), "Point outside world bounds");
    230227
    231228        TileXY tileIndex = source.latLonToTileXY(CoordinateConversion.llToCoor(location), z);
    232229
    233         assertTrue("X index: " + tileIndex.getXIndex() + " greater than tileXmax: " + source.getTileXMax(z) + " at zoom: " + z,
    234                 tileIndex.getXIndex() <= source.getTileXMax(z));
    235 
    236         assertTrue("Y index: " + tileIndex.getYIndex() + " greater than tileYmax: " + source.getTileYMax(z) + " at zoom: " + z,
    237                 tileIndex.getYIndex() <= source.getTileYMax(z));
     230        assertTrue(tileIndex.getXIndex() <= source.getTileXMax(z),
     231                "X index: " + tileIndex.getXIndex() + " greater than tileXmax: " + source.getTileXMax(z) + " at zoom: " + z);
     232
     233        assertTrue(tileIndex.getYIndex() <= source.getTileYMax(z),
     234                "Y index: " + tileIndex.getYIndex() + " greater than tileYmax: " + source.getTileYMax(z) + " at zoom: " + z);
    238235
    239236        ICoordinate x1 = source.tileXYToLatLon(tileIndex.getXIndex(), tileIndex.getYIndex(), z);
     
    245242        bounds.extend(x2.getLat(), x2.getLon());
    246243        // test that location is within tile bounds
    247         assertTrue(location + " not within " + bounds + " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex(),
    248                 bounds.contains(location));
     244        assertTrue(bounds.contains(location),
     245                location + " not within " + bounds + " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex());
    249246        verifyTileSquareness(source, tileIndex.getXIndex(), tileIndex.getYIndex(), z);
    250247    }
Note: See TracChangeset for help on using the changeset viewer.