Changeset 19709 in josm for trunk/test
- Timestamp:
- 2026-11-27T15:43:57+01:00 (3 days ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data
- Files:
-
- 2 edited
-
cache/JCSCachedTileLoaderJobTest.java (modified) (1 diff)
-
imagery/TMSCachedTileLoaderJobTest.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java
r19693 r19709 608 608 } 609 609 610 /** 611 * A 304 keeps the "no tile at this zoom level" marker of the cache entry: it was found from the response which 612 * delivered the object, and the confirmation does not repeat it. Non-regression test for #24893. 613 * @throws IOException exception 614 */ 615 @Test 616 void testNoTileAtZoomKeptOn304() throws IOException { 617 final String eTag = "\"no-tile\""; 618 ICacheAccess<String, CacheEntry> cache = getCache(); 619 long expires = TimeUnit.DAYS.toMillis(1); 620 long testStart = System.currentTimeMillis(); 621 CacheEntryAttributes attributes = createEntryAttributes(-1 * expires, 200, testStart, eTag); 622 attributes.setNoTileAtZoom(true); 623 cache.put("no-tile", new CacheEntry("cached dummy".getBytes(StandardCharsets.UTF_8)), attributes); 624 tileServer.getWireMock().register(get(urlEqualTo("/no-tile")) 625 .willReturn(status(304).withHeader("ETag", eTag) 626 .withHeader("Expires", TestUtils.getHTTPDate(testStart + expires)))); 627 628 TestCachedTileLoaderJob job = new TestCachedTileLoaderJob( 629 "http://127.0.0.1:" + tileServer.getHttpPort() + "/no-tile", "no-tile"); 630 Listener listener = submitJob(job, false); 631 tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/no-tile"))); 632 assertTrue(listener.attributes.isNoTileAtZoom(), "the no-tile marker was dropped"); 633 assertTrue(((CacheEntryAttributes) cache.getCacheElement("no-tile").getElementAttributes()).isNoTileAtZoom(), 634 "the no-tile marker was dropped from the cache"); 635 assertTrue(listener.attributes.getExpirationTime() >= testStart + expires, "the expiry wasn't updated"); 636 } 637 610 638 private void createHeadGetStub(UrlPattern url, long expires, long lastModified, String eTag, String body) { 611 639 tileServer.getWireMock().register(get(url) -
trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java
r19515 r19709 4 4 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNotSame; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 … … 203 204 TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(listener, tile, key, minimumExpiry); 204 205 job.submit(force); 206 waitFor(listener); 207 return job; 208 } 209 210 private static void waitFor(Listener listener) { 205 211 synchronized (listener) { 206 212 while (!listener.ready) { … … 213 219 } 214 220 } 215 return job;216 221 } 217 222 … … 333 338 assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent()); 334 339 } 340 341 /** 342 * A cached "no tile at this zoom level" entry which the server confirms with a 304 stays a no-tile. 343 * <p> 344 * Non-regression test for #24893: the 304 replaced the cache attributes and dropped the marker, so the empty 345 * entry finished as a loaded tile without an image, which kept showing the hourglass a tile starts with. 346 * @throws IOException exception 347 */ 348 @Test 349 void testNoTileAtZoomKeptOn304() throws IOException { 350 final String eTag = "\"no-tile\""; 351 long testStart = System.currentTimeMillis(); 352 wireMockRuntimeInfo.getWireMock().register( 353 WireMock.get(WireMock.urlEqualTo("/no-tile")) 354 .willReturn(WireMock.status(304).withHeader("ETag", eTag)) 355 ); 356 MockTile tile = new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/no-tile"); 357 Listener listener = new Listener(); 358 TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(listener, tile, "no-tile"); 359 // the entry as cached for a no-tile response, expired since 360 CacheEntryAttributes attributes = new CacheEntryAttributes(); 361 attributes.setNoTileAtZoom(true); 362 attributes.setEtag(eTag); 363 attributes.setLastModification(testStart - TimeUnit.DAYS.toMillis(2)); 364 attributes.setExpirationTime(testStart - TimeUnit.DAYS.toMillis(1)); 365 getCache().put(job.getCacheKey(), new BufferedImageCacheEntry(new byte[0]), attributes); 366 367 job.submit(false); 368 waitFor(listener); 369 370 wireMockRuntimeInfo.getWireMock().verifyThat(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/no-tile"))); 371 assertTrue(job.getAttributes().isNoTileAtZoom(), "the no-tile marker was dropped"); 372 assertEquals("no-tile", tile.getValue("tile-info")); 373 assertNotSame(Tile.LOADING_IMAGE, tile.getImage(), "the tile still shows the hourglass"); 374 } 335 375 }
Note:
See TracChangeset
for help on using the changeset viewer.
