コード例 #1
0
 @Test
 public void testPutCacheItem() {
   HTTPResponse response = new HTTPResponse(null, Status.OK, new Headers());
   response = storage.insert(REQUEST, response);
   response.consume();
   assertEquals(1, storage.size());
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 @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());
 }
コード例 #4
0
 @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();
 }
コード例 #5
0
 @After
 public void after() {
   if (storage != null) {
     storage.clear();
   }
   afterTest();
 }