Changeset 18766 in josm for trunk/test/unit/org
- Timestamp:
- 2023-06-21T16:50:47+02:00 (18 months ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data/imagery
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java
r18381 r18766 8 8 9 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.extension.RegisterExtension;11 10 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; 12 11 import org.openstreetmap.gui.jmapviewer.TileXY; 13 12 import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 13 import org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource; 14 14 import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource; 15 15 import org.openstreetmap.josm.data.Bounds; … … 20 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.data.projection.Projections; 22 import org.openstreetmap.josm.testutils.JOSMTestRules;23 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 22 26 23 /** 27 24 * Unit tests for class {@link TemplatedWMSTileSource}. 28 25 */ 29 class TemplatedWMSTileSourceTest { 26 @org.openstreetmap.josm.testutils.annotations.Projection 27 class TemplatedWMSTileSourceTest implements TileSourceTest { 30 28 31 29 private final ImageryInfo testImageryWMS = new ImageryInfo("test imagery", "http://localhost", "wms", null, null); 32 30 private final ImageryInfo testImageryTMS = new ImageryInfo("test imagery", "http://localhost", "tms", null, null); 33 31 34 /** 35 * Setup test. 36 */ 37 @RegisterExtension 38 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 39 public JOSMTestRules test = new JOSMTestRules(); 32 @Override 33 public ImageryInfo getInfo() { 34 return new ImageryInfo(testImageryWMS); 35 } 36 37 @Override 38 public TemplatedTileSource getTileSource(ImageryInfo info) { 39 return new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection()); 40 } 40 41 41 42 /** -
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java
r18106 r18766 2 2 package org.openstreetmap.josm.data.imagery; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 8 import java.io.IOException; 7 9 import java.nio.file.Files; 8 10 import java.nio.file.Paths; 9 import java.util. Arrays;11 import java.util.Collections; 10 12 11 13 import org.junit.jupiter.api.Test; 12 import org. junit.jupiter.api.extension.RegisterExtension;14 import org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource; 13 15 import org.openstreetmap.josm.TestUtils; 14 16 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; … … 16 18 import org.openstreetmap.josm.data.projection.Projections; 17 19 import org.openstreetmap.josm.spi.preferences.Config; 18 import org.openstreetmap.josm.testutils.JOSMTestRules;19 20 import org.openstreetmap.josm.testutils.annotations.BasicWiremock; 20 21 … … 22 23 import com.github.tomakehurst.wiremock.client.WireMock; 23 24 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;25 import org.openstreetmap.josm.testutils.annotations.Projection; 25 26 26 27 @BasicWiremock 27 class WMSEndpointTileSourceTest { 28 /** 29 * Setup test 30 */ 31 @RegisterExtension 32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 33 public JOSMTestRules test = new JOSMTestRules().projection(); 34 28 @Projection 29 class WMSEndpointTileSourceTest implements TileSourceTest { 35 30 @BasicWiremock 36 31 WireMockServer tileServer; 32 33 private void basicMock() { 34 final byte[] response = assertDoesNotThrow(() -> Files.readAllBytes( 35 Paths.get(TestUtils.getTestDataRoot() + "wms/geofabrik-osm-inspector.xml"))); 36 tileServer.stubFor( 37 WireMock.get(WireMock.urlEqualTo("/capabilities?SERVICE=WMS&REQUEST=GetCapabilities")) 38 .willReturn(WireMock.aResponse().withBody(response)) 39 ); 40 } 41 42 @Override 43 public ImageryInfo getInfo() { 44 this.basicMock(); 45 final ImageryInfo info = new ImageryInfo("WMSEndpointTileSourceTest"); 46 info.setExtendedUrl(tileServer.url("/capabilities")); 47 info.setDefaultLayers(Collections.singletonList(new DefaultLayer(ImageryType.WMS_ENDPOINT, 48 "single_node_in_way", "default", null))); 49 info.setImageryType(ImageryType.WMS_ENDPOINT); 50 return info; 51 } 52 53 @Override 54 public TemplatedTileSource getTileSource(ImageryInfo info) { 55 return new WMSEndpointTileSource(info, ProjectionRegistry.getProjection()); 56 } 37 57 38 58 @Test … … 73 93 ))); 74 94 75 Config.getPref().putList("imagery.layers.sites", Arrays.asList(tileServer.url("//maps")));95 Config.getPref().putList("imagery.layers.sites", Collections.singletonList(tileServer.url("//maps"))); 76 96 ImageryLayerInfo.instance.loadDefaults(true, null, false); 77 97 assertEquals(1, ImageryLayerInfo.instance.getDefaultLayers().size()); … … 87 107 88 108 @Test 89 void testCustomHeaders () throwsException {109 void testCustomHeadersServerSide() throws IOException { 90 110 tileServer.stubFor( 91 111 WireMock.get(WireMock.urlEqualTo("/capabilities?SERVICE=WMS&REQUEST=GetCapabilities")) … … 118 138 ))); 119 139 120 Config.getPref().putList("imagery.layers.sites", Arrays.asList(tileServer.url("//maps")));140 Config.getPref().putList("imagery.layers.sites", Collections.singletonList(tileServer.url("//maps"))); 121 141 ImageryLayerInfo.instance.loadDefaults(true, null, false); 122 142 ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0); 123 wmsImageryInfo.setDefaultLayers( Arrays.asList(new DefaultLayer(ImageryType.WMS_ENDPOINT, "historiske-ortofoto", "", "")));143 wmsImageryInfo.setDefaultLayers(Collections.singletonList(new DefaultLayer(ImageryType.WMS_ENDPOINT, "historiske-ortofoto", "", ""))); 124 144 WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, ProjectionRegistry.getProjection()); 125 145 tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857")); -
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java
r18568 r18766 25 25 import com.github.tomakehurst.wiremock.WireMockServer; 26 26 import com.github.tomakehurst.wiremock.client.WireMock; 27 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;28 27 import org.apache.commons.io.FileUtils; 29 28 import org.junit.jupiter.api.Disabled; 30 29 import org.junit.jupiter.api.Test; 31 import org.junit.jupiter.api. extension.RegisterExtension;30 import org.junit.jupiter.api.Timeout; 32 31 import org.junit.jupiter.api.io.TempDir; 33 32 import org.junit.jupiter.params.ParameterizedTest; … … 44 43 import org.openstreetmap.josm.data.projection.Projections; 45 44 import org.openstreetmap.josm.spi.preferences.Config; 46 import org.openstreetmap.josm.testutils.JOSMTestRules;47 45 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 48 46 import org.openstreetmap.josm.testutils.annotations.BasicWiremock; 47 import org.openstreetmap.josm.testutils.annotations.Projection; 49 48 import org.openstreetmap.josm.tools.ReflectionUtils; 50 49 … … 54 53 @BasicWiremock 55 54 @BasicPreferences 55 @Projection 56 @Timeout(value = 5, unit = TimeUnit.MINUTES) 56 57 class WMTSTileSourceTest { 57 58 /**59 * Setup test.60 */61 @RegisterExtension62 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")63 public static JOSMTestRules test = new JOSMTestRules().projection().timeout((int) TimeUnit.MINUTES.toMillis(5));64 65 58 @BasicWiremock 66 59 WireMockServer tileServer; -
trunk/test/unit/org/openstreetmap/josm/data/imagery/vectortile/mapbox/MapboxVectorTileSourceTest.java
r17867 r18766 6 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 7 8 9 8 import java.util.stream.Stream; 10 11 import org.junit.jupiter.api.extension.RegisterExtension;12 import org.openstreetmap.josm.TestUtils;13 import org.openstreetmap.josm.data.imagery.ImageryInfo;14 import org.openstreetmap.josm.data.imagery.vectortile.mapbox.style.MapboxVectorStyle;15 import org.openstreetmap.josm.data.imagery.vectortile.mapbox.style.Source;16 import org.openstreetmap.josm.gui.ExtendedDialog;17 import org.openstreetmap.josm.gui.widgets.JosmComboBox;18 import org.openstreetmap.josm.testutils.JOSMTestRules;19 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;20 9 21 10 import org.junit.jupiter.api.Test; … … 23 12 import org.junit.jupiter.params.provider.Arguments; 24 13 import org.junit.jupiter.params.provider.MethodSource; 14 import org.openstreetmap.josm.TestUtils; 15 import org.openstreetmap.josm.data.imagery.ImageryInfo; 16 import org.openstreetmap.josm.data.imagery.TileSourceTest; 17 import org.openstreetmap.josm.data.imagery.vectortile.mapbox.style.MapboxVectorStyle; 18 import org.openstreetmap.josm.data.imagery.vectortile.mapbox.style.Source; 19 import org.openstreetmap.josm.gui.ExtendedDialog; 20 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 21 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 25 22 26 23 /** … … 29 26 * @since 17862 30 27 */ 31 class MapboxVectorTileSourceTest { 32 @RegisterExtension 33 JOSMTestRules rule = new JOSMTestRules(); 28 class MapboxVectorTileSourceTest implements TileSourceTest { 34 29 private static class SelectLayerDialogMocker extends ExtendedDialogMocker { 35 30 int index; … … 45 40 } 46 41 42 @Override 43 public ImageryInfo getInfo() { 44 return new ImageryInfo("Test Mapillary", "file:/" + TestUtils.getTestDataRoot() + "pbf/mapillary/{z}/{x}/{y}.mvt"); 45 } 46 47 @Override 48 public MapboxVectorTileSource getTileSource(ImageryInfo info) { 49 return new MapboxVectorTileSource(info); 50 } 51 47 52 @Test 48 53 void testNoStyle() { 49 MapboxVectorTileSource tileSource = new MapboxVectorTileSource( 50 new ImageryInfo("Test Mapillary", "file:/" + TestUtils.getTestDataRoot() + "pbf/mapillary/{z}/{x}/{y}.mvt")); 54 MapboxVectorTileSource tileSource = getTileSource(getInfo()); 51 55 assertNull(tileSource.getStyleSource()); 52 56 } … … 69 73 extendedDialogMocker.index = index; 70 74 extendedDialogMocker.getMockResultMap().put(dialogMockerText, "Add layers"); 71 MapboxVectorTileSource tileSource = new MapboxVectorTileSource(75 MapboxVectorTileSource tileSource = getTileSource( 72 76 new ImageryInfo("Test Mapillary", "file:/" + TestUtils.getTestDataRoot() + "mapillary.json")); 73 77 MapboxVectorStyle styleSource = tileSource.getStyleSource();
Note:
See TracChangeset
for help on using the changeset viewer.