Index: trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java	(revision 14544)
+++ trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java	(revision 14549)
@@ -30,4 +30,6 @@
 import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
 import org.openstreetmap.josm.TestUtils;
+import org.openstreetmap.josm.actions.AddImageryLayerAction;
+import org.openstreetmap.josm.actions.AddImageryLayerAction.LayerSelection;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.LatLon;
@@ -37,9 +39,9 @@
 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
+import org.openstreetmap.josm.data.imagery.LayerDetails;
 import org.openstreetmap.josm.data.imagery.Shape;
 import org.openstreetmap.josm.data.imagery.TMSCachedTileLoaderJob;
 import org.openstreetmap.josm.data.imagery.TemplatedWMSTileSource;
 import org.openstreetmap.josm.data.imagery.TileJobOptions;
-import org.openstreetmap.josm.data.imagery.WMSEndpointTileSource;
 import org.openstreetmap.josm.data.imagery.WMTSTileSource;
 import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException;
@@ -47,4 +49,5 @@
 import org.openstreetmap.josm.data.projection.ProjectionRegistry;
 import org.openstreetmap.josm.data.projection.Projections;
+import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
 import org.openstreetmap.josm.tools.HttpClient;
@@ -245,5 +248,5 @@
                 checkTileUrl(info, tileSource, center, Utils.clamp(12, info.getMinZoom() + 1, info.getMaxZoom()));
             }
-        } catch (IOException | WMTSGetCapabilitiesException | IllegalArgumentException e) {
+        } catch (IOException | RuntimeException | WMSGetCapabilitiesException | WMTSGetCapabilitiesException e) {
             addError(info, info.getUrl() + " -> " + e.toString());
         }
@@ -264,5 +267,6 @@
     }
 
-    private static AbstractTileSource getTileSource(ImageryInfo info) throws IOException, WMTSGetCapabilitiesException {
+    private static AbstractTileSource getTileSource(ImageryInfo info)
+            throws IOException, WMTSGetCapabilitiesException, WMSGetCapabilitiesException {
         switch (info.getImageryType()) {
             case BING:
@@ -272,8 +276,8 @@
             case TMS:
                 return new TemplatedTMSTileSource(info);
+            case WMS_ENDPOINT:
+                info = convertWmsEndpointToWms(info); // fall-through
             case WMS:
                 return new TemplatedWMSTileSource(info, getProjection(info));
-            case WMS_ENDPOINT:
-                return new WMSEndpointTileSource(info, getProjection(info));
             case WMTS:
                 return new WMTSTileSource(info, getProjection(info));
@@ -281,4 +285,20 @@
                 throw new UnsupportedOperationException(info.toString());
         }
+    }
+
+    private static ImageryInfo convertWmsEndpointToWms(ImageryInfo info) throws IOException, WMSGetCapabilitiesException {
+        return AddImageryLayerAction.getWMSLayerInfo(
+                info, wms -> new LayerSelection(firstLeafLayer(wms.getLayers()), wms.getPreferredFormat(), true));
+    }
+
+    private static List<LayerDetails> firstLeafLayer(List<LayerDetails> layers) {
+        for (LayerDetails layer : layers) {
+            if (layer.getChildren().isEmpty()) {
+                return Collections.singletonList(layer);
+            } else {
+                return firstLeafLayer(layer.getChildren());
+            }
+        }
+        return Collections.emptyList();
     }
 
