Index: /trunk/test/data/__files/invalid_api/0.6/capabilities
===================================================================
--- /trunk/test/data/__files/invalid_api/0.6/capabilities	(revision 17192)
+++ /trunk/test/data/__files/invalid_api/0.6/capabilities	(revision 17192)
@@ -0,0 +1,2 @@
+This is a dummy file used to test malformed API capabilities.
+It must be named capabilities in a directory named 0.6
Index: /trunk/test/data/__files/osm_api/0.6/capabilities
===================================================================
--- /trunk/test/data/__files/osm_api/0.6/capabilities	(revision 17192)
+++ /trunk/test/data/__files/osm_api/0.6/capabilities	(revision 17192)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
+  <api>
+    <version minimum="0.6" maximum="0.6"/>
+    <area maximum="0.25"/>
+    <note_area maximum="25"/>
+    <tracepoints per_page="5000"/>
+    <waynodes maximum="2000"/>
+    <changesets maximum_elements="10000"/>
+    <timeout seconds="300"/>
+    <status database="online" api="online" gpx="online"/>
+  </api>
+  <policy>
+    <imagery>
+      <blacklist regex=".*\.google(apis)?\..*/(vt|kh)[\?/].*([xyz]=.*){3}.*"/>
+    </imagery>
+  </policy>
+</osm>
Index: unk/test/data/invalid_api/0.6/capabilities
===================================================================
--- /trunk/test/data/invalid_api/0.6/capabilities	(revision 17191)
+++ 	(revision )
@@ -1,2 +1,0 @@
-This is a dummy file used to test malformed API capabilities.
-It must be named capabilities in a directory named 0.6
Index: /trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTaskTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTaskTest.java	(revision 17191)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTaskTest.java	(revision 17192)
@@ -2,4 +2,10 @@
 package org.openstreetmap.josm.gui.preferences.server;
 
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -11,8 +17,11 @@
 import org.junit.Rule;
 import org.junit.Test;
-import org.openstreetmap.josm.spi.preferences.Config;
+import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
+import org.openstreetmap.josm.tools.Logging;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
 
 /**
@@ -27,4 +36,10 @@
     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     public JOSMTestRules test = new JOSMTestRules().preferences().timeout(30000);
+
+    /**
+     * HTTP mock.
+     */
+    @Rule
+    public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot()));
 
     private static final Component PARENT = new JLabel();
@@ -43,5 +58,5 @@
     @Test
     public void testNominalUrl() {
-        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, Config.getUrls().getDefaultOsmApiUrl());
+        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockRule.url("/__files/osm_api"));
         task.run();
         assertTrue(task.isSuccess());
@@ -53,7 +68,10 @@
     @Test
     public void testAlertInvalidUrl() {
+        Logging.clearLastErrorAndWarnings();
         ApiUrlTestTask task = new ApiUrlTestTask(PARENT, "malformed url");
         task.run();
         assertFalse(task.isSuccess());
+        assertThat(Logging.getLastErrorAndWarnings().toString(), containsString(
+                "<html>'malformed url' is not a valid OSM API URL.<br>Please check the spelling and validate again.</html>"));
     }
 
@@ -63,7 +81,10 @@
     @Test
     public void testUnknownHost() {
+        Logging.clearLastErrorAndWarnings();
         ApiUrlTestTask task = new ApiUrlTestTask(PARENT, "http://unknown");
         task.run();
         assertFalse(task.isSuccess());
+        assertThat(Logging.getLastErrorAndWarnings().toString(), containsString(
+                "java.net.UnknownHostException: unknown"));
     }
 
@@ -73,7 +94,13 @@
     @Test
     public void testAlertInvalidServerResult() {
-        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, "http://www.openstreetmap.org");
+        Logging.clearLastErrorAndWarnings();
+        wireMockRule.stubFor(get(urlEqualTo("/does-not-exist/0.6/capabilities"))
+                .willReturn(aResponse().withStatus(404)));
+
+        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockRule.url("/does-not-exist"));
         task.run();
         assertFalse(task.isSuccess());
+        assertThat(Logging.getLastErrorAndWarnings().toString(), containsString(
+                "The server responded with the return code 404 instead of 200."));
     }
 
@@ -83,7 +110,11 @@
     @Test
     public void testAlertInvalidCapabilities() {
-        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, "https://josm.openstreetmap.de/export/10979/josm/trunk/test/data/invalid_api");
+        Logging.clearLastErrorAndWarnings();
+        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockRule.url("/__files/invalid_api"));
         task.run();
         assertFalse(task.isSuccess());
+        assertThat(Logging.getLastErrorAndWarnings().toString(), containsString(
+                "The OSM API server at 'XXX' did not return a valid response.<br>It is likely that 'XXX' is not an OSM API server."
+                        .replace("XXX", wireMockRule.url("/__files/invalid_api"))));
     }
 }
