Changeset 14549 in josm for trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
- Timestamp:
- 2018-12-10T22:37:27+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
r14544 r14549 30 30 import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource; 31 31 import org.openstreetmap.josm.TestUtils; 32 import org.openstreetmap.josm.actions.AddImageryLayerAction; 33 import org.openstreetmap.josm.actions.AddImageryLayerAction.LayerSelection; 32 34 import org.openstreetmap.josm.data.Bounds; 33 35 import org.openstreetmap.josm.data.coor.LatLon; … … 37 39 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 38 40 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; 41 import org.openstreetmap.josm.data.imagery.LayerDetails; 39 42 import org.openstreetmap.josm.data.imagery.Shape; 40 43 import org.openstreetmap.josm.data.imagery.TMSCachedTileLoaderJob; 41 44 import org.openstreetmap.josm.data.imagery.TemplatedWMSTileSource; 42 45 import org.openstreetmap.josm.data.imagery.TileJobOptions; 43 import org.openstreetmap.josm.data.imagery.WMSEndpointTileSource;44 46 import org.openstreetmap.josm.data.imagery.WMTSTileSource; 45 47 import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException; … … 47 49 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 48 50 import org.openstreetmap.josm.data.projection.Projections; 51 import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException; 49 52 import org.openstreetmap.josm.testutils.JOSMTestRules; 50 53 import org.openstreetmap.josm.tools.HttpClient; … … 245 248 checkTileUrl(info, tileSource, center, Utils.clamp(12, info.getMinZoom() + 1, info.getMaxZoom())); 246 249 } 247 } catch (IOException | WMTSGetCapabilitiesException | IllegalArgumentException e) {250 } catch (IOException | RuntimeException | WMSGetCapabilitiesException | WMTSGetCapabilitiesException e) { 248 251 addError(info, info.getUrl() + " -> " + e.toString()); 249 252 } … … 264 267 } 265 268 266 private static AbstractTileSource getTileSource(ImageryInfo info) throws IOException, WMTSGetCapabilitiesException { 269 private static AbstractTileSource getTileSource(ImageryInfo info) 270 throws IOException, WMTSGetCapabilitiesException, WMSGetCapabilitiesException { 267 271 switch (info.getImageryType()) { 268 272 case BING: … … 272 276 case TMS: 273 277 return new TemplatedTMSTileSource(info); 278 case WMS_ENDPOINT: 279 info = convertWmsEndpointToWms(info); // fall-through 274 280 case WMS: 275 281 return new TemplatedWMSTileSource(info, getProjection(info)); 276 case WMS_ENDPOINT:277 return new WMSEndpointTileSource(info, getProjection(info));278 282 case WMTS: 279 283 return new WMTSTileSource(info, getProjection(info)); … … 281 285 throw new UnsupportedOperationException(info.toString()); 282 286 } 287 } 288 289 private static ImageryInfo convertWmsEndpointToWms(ImageryInfo info) throws IOException, WMSGetCapabilitiesException { 290 return AddImageryLayerAction.getWMSLayerInfo( 291 info, wms -> new LayerSelection(firstLeafLayer(wms.getLayers()), wms.getPreferredFormat(), true)); 292 } 293 294 private static List<LayerDetails> firstLeafLayer(List<LayerDetails> layers) { 295 for (LayerDetails layer : layers) { 296 if (layer.getChildren().isEmpty()) { 297 return Collections.singletonList(layer); 298 } else { 299 return firstLeafLayer(layer.getChildren()); 300 } 301 } 302 return Collections.emptyList(); 283 303 } 284 304
Note:
See TracChangeset
for help on using the changeset viewer.