Index: trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java	(revision 9480)
+++ trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java	(revision 9488)
@@ -7,4 +7,5 @@
 import java.net.HttpURLConnection;
 import java.net.SocketException;
+import java.net.URL;
 import java.net.UnknownHostException;
 
@@ -16,4 +17,5 @@
 import org.openstreetmap.josm.io.MissingOAuthAccessTokenException;
 import org.openstreetmap.josm.io.OfflineAccessException;
+import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.io.OsmApiException;
 import org.openstreetmap.josm.io.OsmApiInitializationException;
@@ -26,5 +28,6 @@
 public class ExceptionUtilTest {
 
-    private static String url;
+    private static String baseUrl;
+    private static String serverUrl;
     private static String host;
     private static String user;
@@ -32,10 +35,14 @@
     /**
      * Setup test.
+     * @throws Exception in case of error
      */
     @BeforeClass
-    public static void setUp() {
+    public static void setUp() throws Exception {
         JOSMFixture.createUnitTestFixture().init();
-        url = new OsmApiException("").getUrl();
-        host = url.replace("http://", "").replace("/api/", "").replace("0.6/", "");
+        OsmApi api = OsmApi.getOsmApi();
+        api.initialize(null);
+        baseUrl = api.getBaseUrl();
+        serverUrl = api.getServerUrl();
+        host = new URL(serverUrl).getHost();
         user = CredentialsManager.getInstance().getUsername();
     }
@@ -46,12 +53,12 @@
     @Test
     public void testExplainBadRequest() {
-        assertEquals("<html>The OSM server '"+url+"' reported a bad request.<br></html>",
+        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br></html>",
                 ExceptionUtil.explainBadRequest(new OsmApiException("")));
 
-        assertEquals("<html>The OSM server '"+url+"' reported a bad request.<br><br>"+
+        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
                 "Error message(untranslated): header</html>",
                 ExceptionUtil.explainBadRequest(new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "header", "")));
 
-        assertEquals("<html>The OSM server '"+url+"' reported a bad request.<br><br>"+
+        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
                 "Error message(untranslated): header</html>",
                 ExceptionUtil.explainBadRequest(new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "header", "", "invalid_url")));
@@ -59,12 +66,12 @@
         assertEquals("<html>The OSM server '"+host+"' reported a bad request.<br><br>"+
                 "Error message(untranslated): header</html>",
-                ExceptionUtil.explainBadRequest(new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "header", "", url)));
-
-        assertEquals("<html>The OSM server '"+url+"' reported a bad request.<br><br>"+
+                ExceptionUtil.explainBadRequest(new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "header", "", baseUrl)));
+
+        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
                 "The area you tried to download is too big or your request was too large.<br>"+
                 "Either request a smaller area or use an export file provided by the OSM community.</html>",
                 ExceptionUtil.explainBadRequest(new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "The maximum bbox", "")));
 
-        assertEquals("<html>The OSM server '"+url+"' reported a bad request.<br><br>"+
+        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>"+
                 "The area you tried to download is too big or your request was too large.<br>"+
                 "Either request a smaller area or use an export file provided by the OSM community.</html>",
@@ -77,5 +84,5 @@
     @Test
     public void testExplainBandwidthLimitExceeded() {
-        assertEquals("<html>Communication with the OSM server '"+url+"'failed. "+
+        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. "+
                 "The server replied<br>the following error code and the following error message:<br>"+
                 "<strong>Error code:<strong> 0<br><strong>Error message (untranslated)</strong>: no error message available</html>",
@@ -100,5 +107,5 @@
     @Test
     public void testExplainClientTimeout() {
-        assertEquals("<html>Communication with the OSM server '"+url+"' timed out. Please retry later.</html>",
+        assertEquals("<html>Communication with the OSM server '"+baseUrl+"' timed out. Please retry later.</html>",
                 ExceptionUtil.explainClientTimeout(new OsmApiException("")));
     }
@@ -160,7 +167,7 @@
                 ExceptionUtil.explainFailedOAuthAuthorisation(new OsmApiException("")));
         assertEquals("<html>Authorisation at the OSM server with the OAuth token 'null' failed.<br>"+
-                "The token is not authorised to access the protected resource<br>'"+url+"'.<br>"+
+                "The token is not authorised to access the protected resource<br>'"+baseUrl+"'.<br>"+
                 "Please launch the preferences dialog and retrieve another OAuth token.</html>",
-                ExceptionUtil.explainFailedOAuthAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "", "", url)));
+                ExceptionUtil.explainFailedOAuthAuthorisation(new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, "", "", baseUrl)));
     }
 
@@ -190,15 +197,15 @@
     @Test
     public void testExplainGenericOsmApiException() {
-        assertEquals("<html>Communication with the OSM server '"+url+"'failed. The server replied<br>"+
+        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
                 "the following error code and the following error message:<br><strong>Error code:<strong> 0<br>"+
                 "<strong>Error message (untranslated)</strong>: no error message available</html>",
                 ExceptionUtil.explainGenericOsmApiException(new OsmApiException("")));
 
-        assertEquals("<html>Communication with the OSM server '"+url+"'failed. The server replied<br>"+
+        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
                 "the following error code and the following error message:<br><strong>Error code:<strong> 500<br>"+
                 "<strong>Error message (untranslated)</strong>: header</html>",
                 ExceptionUtil.explainGenericOsmApiException(new OsmApiException(HttpURLConnection.HTTP_INTERNAL_ERROR, "header", null)));
 
-        assertEquals("<html>Communication with the OSM server '"+url+"'failed. The server replied<br>"+
+        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
                 "the following error code and the following error message:<br><strong>Error code:<strong> 500<br>"+
                 "<strong>Error message (untranslated)</strong>: body</html>",
@@ -223,5 +230,5 @@
     @Test
     public void testExplainInternalServerError() {
-        assertEquals("<html>The OSM server<br>'"+url+"'<br>reported an internal server error.<br>"+
+        assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+
                 "This is most likely a temporary problem. Please try again later.</html>",
                 ExceptionUtil.explainInternalServerError(new OsmApiException("")));
@@ -258,9 +265,9 @@
     @Test
     public void testExplainNestedIOException() {
-        assertEquals("<html>Failed to upload data to or download data from<br>'"+url+"'<br>"+
+        assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
                 "due to a problem with transferring data.<br>Details (untranslated): null</html>",
                 ExceptionUtil.explainNestedIOException(new OsmApiException("")));
 
-        assertEquals("<html>Failed to upload data to or download data from<br>'"+url+"'<br>"+
+        assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
                 "due to a problem with transferring data.<br>Details (untranslated): test</html>",
                 ExceptionUtil.explainNestedIOException(new OsmApiException(new IOException("test"))));
@@ -272,5 +279,5 @@
     @Test
     public void testExplainNestedSocketException() {
-        assertEquals("<html>Failed to open a connection to the remote server<br>'"+url+"'.<br>"+
+        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
                 "Please check your internet connection.</html>",
                 ExceptionUtil.explainNestedSocketException(new OsmApiException("")));
@@ -282,5 +289,5 @@
     @Test
     public void testExplainNestedUnknownHostException() {
-        assertEquals("<html>Failed to open a connection to the remote server<br>'"+url+"'.<br>"+
+        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
                 "Host name '"+host+"' could not be resolved. <br>"+
                 "Please check the API URL in your preferences and your internet connection.</html>",
@@ -293,8 +300,8 @@
     @Test
     public void testExplainNotFound() {
-        assertEquals("<html>The OSM server '"+url+"' does not know about an object<br>"+
+        assertEquals("<html>The OSM server '"+baseUrl+"' does not know about an object<br>"+
                 "you tried to read, update, or delete. Either the respective object<br>"+
                 "does not exist on the server or you are using an invalid URL to access<br>"+
-                "it. Please carefully check the server's address '"+url+"' for typos.</html>",
+                "it. Please carefully check the server's address '"+baseUrl+"' for typos.</html>",
                 ExceptionUtil.explainNotFound(new OsmApiException("")));
     }
@@ -316,5 +323,5 @@
     @Test
     public void testExplainOsmApiInitializationException() {
-        assertEquals("<html>Failed to initialize communication with the OSM server "+url.substring(0, url.length()-1)+".<br>"+
+        assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+
                 "Check the server URL in your preferences and your internet connection.</html>",
                 ExceptionUtil.explainOsmApiInitializationException(new OsmApiInitializationException("")));
@@ -326,23 +333,23 @@
     @Test
     public void testExplainOsmTransferException() {
-        assertEquals("<html>Failed to open a connection to the remote server<br>'"+url+"'<br>"+
+        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'<br>"+
                 "for security reasons. This is most likely because you are running<br>"+
                 "in an applet and because you did not load your applet from '"+host+"'.</html>",
                 ExceptionUtil.explainOsmTransferException(new OsmApiException(new SecurityException("test"))));
 
-        assertEquals("<html>Failed to open a connection to the remote server<br>'"+url+"'.<br>"+
+        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
                 "Please check your internet connection.</html>",
                 ExceptionUtil.explainOsmTransferException(new OsmApiException(new SocketException("test"))));
 
-        assertEquals("<html>Failed to open a connection to the remote server<br>'"+url+"'.<br>"+
+        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
                 "Host name '"+host+"' could not be resolved. <br>"+
                 "Please check the API URL in your preferences and your internet connection.</html>",
                 ExceptionUtil.explainOsmTransferException(new OsmApiException(new UnknownHostException("test"))));
 
-        assertEquals("<html>Failed to upload data to or download data from<br>'"+url+"'<br>"+
+        assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
                 "due to a problem with transferring data.<br>Details (untranslated): test</html>",
                 ExceptionUtil.explainOsmTransferException(new OsmApiException(new IOException("test"))));
 
-        assertEquals("<html>Failed to initialize communication with the OSM server "+url.substring(0, url.length()-1)+".<br>"+
+        assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+
                 "Check the server URL in your preferences and your internet connection.</html>",
                 ExceptionUtil.explainOsmTransferException(new OsmApiInitializationException("")));
@@ -361,12 +368,12 @@
                 ExceptionUtil.explainOsmTransferException(new OsmApiException(HttpURLConnection.HTTP_GONE, "", "")));
 
-        assertEquals("<html>The OSM server<br>'"+url+"'<br>reported an internal server error.<br>"+
+        assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+
                 "This is most likely a temporary problem. Please try again later.</html>",
                 ExceptionUtil.explainOsmTransferException(new OsmApiException(HttpURLConnection.HTTP_INTERNAL_ERROR, "", "")));
 
-        assertEquals("<html>The OSM server '"+url+"' reported a bad request.<br><br>Error message(untranslated): </html>",
+        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br><br>Error message(untranslated): </html>",
                 ExceptionUtil.explainOsmTransferException(new OsmApiException(HttpURLConnection.HTTP_BAD_REQUEST, "", "")));
 
-        assertEquals("<html>Communication with the OSM server '"+url+"'failed. The server replied<br>"+
+        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
                 "the following error code and the following error message:<br><strong>Error code:<strong> 509<br>"+
                 "<strong>Error message (untranslated)</strong>: </html>",
