Index: trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTaskTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTaskTest.java	(revision 17190)
+++ 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"))));
     }
 }
