@Test public void testEndToEndReload() throws IOException { String initialETagVal = "\"1\""; String updatedETagVal = "\"2\""; HTTPRequest request = new HTTPRequest(REQUEST_URI).addHeader(HeaderConstants.CACHE_CONTROL, "no-cache"); Headers initialResponseHeaders = new Headers(); initialResponseHeaders = initialResponseHeaders.add(new Header(HeaderConstants.ETAG, initialETagVal)); initialResponseHeaders = initialResponseHeaders.add(new Header(HeaderConstants.CACHE_CONTROL, "private, max-age=60")); HTTPResponse initialResponse = new HTTPResponse(createClosedPayload(), Status.OK, initialResponseHeaders); Headers updatedResponseHeaders = new Headers(); updatedResponseHeaders = updatedResponseHeaders.add(new Header(HeaderConstants.ETAG, updatedETagVal)); HTTPResponse updatedResponse = new HTTPResponse(createClosedPayload(), Status.OK, updatedResponseHeaders); when(cacheStorage.insert(eq(request), eq(initialResponse))).thenReturn(initialResponse); when(cacheStorage.insert(eq(request), eq(updatedResponse))).thenReturn(updatedResponse); when(cacheStorage.get(request)).thenReturn(new DefaultCacheItem(initialResponse)); when(responseResolver.resolve(isA(HTTPRequest.class))).thenReturn(updatedResponse); HTTPResponse response = cache.execute(request); Assert.assertEquals("Wrong status", Status.OK, response.getStatus()); Assert.assertFalse("Got the cached response instead of the updated one.", Tag.parse(initialETagVal).equals(response.getHeaders().getETag())); Assert.assertEquals("Did not get the updated response (ETag does not match)", Tag.parse(updatedETagVal), response.getHeaders().getETag()); }
public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); void clear(); CacheStorage getStorage(); ResponseResolver getResolver(); CacheStatistics getStatistics(); HTTPResponse execute(final HTTPRequest request); HTTPResponse executeRefresh(final HTTPRequest request); void shutdown(); boolean isTranslateHEADToGET(); void setTranslateHEADToGET(boolean translateHEADToGET); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); void clear(); CacheStorage getStorage(); ResponseResolver getResolver(); CacheStatistics getStatistics(); HTTPResponse execute(final HTTPRequest request); HTTPResponse executeRefresh(final HTTPRequest request); void shutdown(); boolean isTranslateHEADToGET(); void setTranslateHEADToGET(boolean translateHEADToGET);  }