Index: trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java	(revision 17074)
+++ trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java	(revision 17075)
@@ -2,4 +2,12 @@
 package org.openstreetmap.josm.data.cache;
 
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.head;
+import static com.github.tomakehurst.wiremock.client.WireMock.headRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.status;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -24,5 +32,4 @@
 import org.openstreetmap.josm.tools.Logging;
 
-import com.github.tomakehurst.wiremock.client.WireMock;
 import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
 import com.github.tomakehurst.wiremock.junit.WireMockRule;
@@ -120,5 +127,4 @@
     public void testStatusCodes() throws IOException, InterruptedException {
         doTestStatusCode(200);
-        // can't test for 3xx, as httpstat.us redirects finally to 200 page
         doTestStatusCode(401);
         doTestStatusCode(402);
@@ -156,4 +162,5 @@
 
     private void doTestStatusCode(int responseCode) throws IOException {
+        tileServer.stubFor(get(urlEqualTo("/httpstat/" + responseCode)).willReturn(aResponse().withStatus(responseCode)));
         TestCachedTileLoaderJob job = getStatusLoaderJob(responseCode);
         Listener listener = submitJob(job);
@@ -194,9 +201,9 @@
                 createEntryAttributes(expires, 200, testStart, "eTag")
                 );
-        createHeadGetStub(WireMock.urlEqualTo("/test"), expires, testStart, "eTag", "mock entry");
+        createHeadGetStub(urlEqualTo("/test"), expires, testStart, "eTag", "mock entry");
 
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
         Listener listener = submitJob(job, false);
-        tileServer.verify(0, WireMock.getRequestedFor(WireMock.anyUrl()));
+        tileServer.verify(0, getRequestedFor(anyUrl()));
         assertArrayEquals("cached entry".getBytes(StandardCharsets.UTF_8), listener.data);
     }
@@ -215,9 +222,9 @@
                 createEntryAttributes(expires, 200, testStart + expires, "eTag")
                 );
-        createHeadGetStub(WireMock.urlEqualTo("/test"), expires, testStart, "eTag", "mock entry");
+        createHeadGetStub(urlEqualTo("/test"), expires, testStart, "eTag", "mock entry");
 
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
         Listener listener = submitJob(job, true);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
     }
@@ -231,14 +238,9 @@
     public void testSettingMinimumExpiryWhenNoExpires() throws IOException {
         long testStart = System.currentTimeMillis();
-        tileServer.stubFor(
-                WireMock.get(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
-                        .withBody("mock entry")
-                        )
-                );
+        tileServer.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withBody("mock entry")));
 
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
         Listener listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
 
         assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - testStart) + " which is not larger than " +
@@ -265,7 +267,6 @@
         long testStart = System.currentTimeMillis();
         long expires = TimeUnit.DAYS.toSeconds(1);
-        tileServer.stubFor(
-                WireMock.get(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(get(urlEqualTo("/test"))
+                .willReturn(aResponse()
                         .withHeader("Cache-control", "max-age=" + expires)
                         .withBody("mock entry")
@@ -275,5 +276,5 @@
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
         Listener listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
 
         assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - testStart) + " which is not larger than " +
@@ -301,9 +302,9 @@
         int minimumExpiryTimeSeconds = (int) (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 2);
 
-        createHeadGetStub(WireMock.urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
+        createHeadGetStub(urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
 
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
         Listener listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
 
@@ -332,9 +333,9 @@
         int minimumExpiryTimeSeconds = (int) (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME * 2);
 
-        createHeadGetStub(WireMock.urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
+        createHeadGetStub(urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
 
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
         Listener listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
 
@@ -368,7 +369,6 @@
         int minimumExpiryTimeSeconds = 0;
 
-        tileServer.stubFor(
-                WireMock.get(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(get(urlEqualTo("/test"))
+                .willReturn(aResponse()
                         .withHeader("Expires", TestUtils.getHTTPDate(testStart + (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10)))
                         .withHeader("Cache-Control", "max-age=" +
@@ -377,7 +377,6 @@
                         )
                 );
-        tileServer.stubFor(
-                WireMock.head(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(head(urlEqualTo("/test"))
+                .willReturn(aResponse()
                         .withHeader("Expires", TestUtils.getHTTPDate(testStart + (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10)))
                         .withHeader("Cache-Control", "max-age=" +
@@ -387,5 +386,5 @@
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
         Listener listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
 
@@ -410,5 +409,4 @@
      * @throws IOException exception
      */
-
     @Test
     public void testMaxAgeVsSMaxAge() throws IOException {
@@ -416,8 +414,6 @@
         int minimumExpiryTimeSeconds = 0;
 
-
-        tileServer.stubFor(
-                WireMock.get(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(get(urlEqualTo("/test"))
+                .willReturn(aResponse()
                         .withHeader("Cache-Control", "" +
                                 "max-age=" + TimeUnit.MILLISECONDS.toSeconds((JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10)) + "," +
@@ -427,7 +423,6 @@
                         )
                 );
-        tileServer.stubFor(
-                WireMock.head(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(head(urlEqualTo("/test"))
+                .willReturn(aResponse()
                         .withHeader("Cache-Control", "" +
                                 "max-age=" + TimeUnit.MILLISECONDS.toSeconds((JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10)) + "," +
@@ -437,7 +432,6 @@
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
         Listener listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
-        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
-
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
+        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
 
         assertTrue("Cache entry expiration is " + (listener.attributes.getExpirationTime() - testStart) + " which is not larger than " +
@@ -453,5 +447,4 @@
     }
 
-
     /**
      * Check if verifying cache entries using HEAD requests work properly
@@ -468,7 +461,6 @@
                 );
 
-        tileServer.stubFor(
-                WireMock.get(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(get(urlEqualTo("/test"))
+                .willReturn(aResponse()
                         .withHeader("Expires", TestUtils.getHTTPDate(testStart + expires))
                         .withHeader("Last-Modified", Long.toString(testStart))
@@ -477,7 +469,6 @@
                         )
                 );
-        tileServer.stubFor(
-                WireMock.head(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(head(urlEqualTo("/test"))
+                .willReturn(aResponse()
                         .withHeader("Expires", TestUtils.getHTTPDate(testStart + expires))
                         .withHeader("Last-Modified", Long.toString(testStart))
@@ -488,10 +479,10 @@
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
         Listener listener = submitJob(job, false); // cache entry is expired, no need to force refetch
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
 
         // cache entry should be retrieved from cache
         listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
 
@@ -503,8 +494,8 @@
 
         // because cache entry is invalid - HEAD request shall be made
-        tileServer.verify(0, WireMock.headRequestedFor(WireMock.urlEqualTo("/test"))); // no head requests were made until now
+        tileServer.verify(0, headRequestedFor(urlEqualTo("/test"))); // no head requests were made until now
         listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.headRequestedFor(WireMock.urlEqualTo("/test"))); // verify head requests were made
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test"))); // verify no more get requests were made
+        tileServer.verify(1, headRequestedFor(urlEqualTo("/test"))); // verify head requests were made
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test"))); // verify no more get requests were made
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
         assertTrue(listener.attributes.getExpirationTime() >= testStart + expires);
@@ -512,6 +503,6 @@
         // cache entry should be retrieved from cache
         listener = submitJob(job, false); // cache entry is expired, no need to force refetch
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
     }
@@ -531,7 +522,6 @@
                 );
 
-        tileServer.stubFor(
-                WireMock.get(WireMock.urlEqualTo("/test"))
-                .willReturn(WireMock.status(304)
+        tileServer.stubFor(get(urlEqualTo("/test"))
+                .willReturn(status(304)
                         .withHeader("Expires", TestUtils.getHTTPDate(testStart + expires))
                         .withHeader("Last-Modified", Long.toString(testStart))
@@ -542,15 +532,14 @@
         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
         Listener listener = submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
         assertArrayEquals("cached dummy".getBytes(StandardCharsets.UTF_8), listener.data);
         assertTrue(testStart + expires <= listener.attributes.getExpirationTime());
         submitJob(job, false);
-        tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test"))); // no more requests were made
+        tileServer.verify(1, getRequestedFor(urlEqualTo("/test"))); // no more requests were made
     }
 
     private void createHeadGetStub(UrlPattern url, long expires, long lastModified, String eTag, String body) {
-        tileServer.stubFor(
-                WireMock.get(url)
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(get(url)
+                .willReturn(aResponse()
                         .withHeader("Expires", TestUtils.getHTTPDate(lastModified + expires))
                         .withHeader("Last-Modified", Long.toString(lastModified))
@@ -559,7 +548,6 @@
                         )
                 );
-        tileServer.stubFor(
-                WireMock.head(url)
-                .willReturn(WireMock.aResponse()
+        tileServer.stubFor(head(url)
+                .willReturn(aResponse()
                         .withHeader("Expires", TestUtils.getHTTPDate(lastModified + expires))
                         .withHeader("Last-Modified", Long.toString(lastModified))
@@ -567,9 +555,4 @@
                         )
                 );
-    }
-
-    private CacheEntryAttributes createEntryAttributes(long maxAge, int responseCode, String eTag) {
-        long validTo = maxAge + System.currentTimeMillis();
-        return createEntryAttributes(maxAge, responseCode, validTo, eTag);
     }
 
@@ -583,6 +566,6 @@
     }
 
-    private static TestCachedTileLoaderJob getStatusLoaderJob(int responseCode) {
-        return new TestCachedTileLoaderJob("http://httpstat.us/" + responseCode, "key_" + responseCode);
+    private TestCachedTileLoaderJob getStatusLoaderJob(int responseCode) {
+        return new TestCachedTileLoaderJob(tileServer.url("/httpstat/" + responseCode), "key_" + responseCode);
     }
 
