@Test public void testPutCacheItem() { HTTPResponse response = new HTTPResponse(null, Status.OK, new Headers()); response = storage.insert(REQUEST, response); response.consume(); assertEquals(1, storage.size()); }
private CacheItem putAndGet(HTTPRequest request) { HTTPResponse response = new HTTPResponse(null, Status.OK, new Headers()); response = storage.insert(REQUEST, response); response.consume(); assertEquals(1, storage.size()); return storage.get(request); }
@Test public void testInvalidate() { HTTPResponse response = new HTTPResponse(null, Status.OK, new Headers()); URI requestURI = URI.create("foo"); HTTPResponse res = storage.insert(REQUEST, response); res.consume(); assertEquals(1, storage.size()); storage.invalidate(requestURI); assertEquals(0, storage.size()); }
@Test public void testPutUpdatedCacheItem() { CacheItem item = putAndGet(REQUEST); item.getResponse().consume(); HTTPResponse response = new HTTPResponse(null, Status.OK, new Headers()); HTTPResponse res = storage.update(REQUEST, response); res.consume(); final CacheItem cacheItem = storage.get(REQUEST); assertNotSame("Items were the same", cacheItem.getCachedTime(), item.getCachedTime()); cacheItem.getResponse().consume(); }
@After public void after() { if (storage != null) { storage.clear(); } afterTest(); }