### Question:
AbstractHttpCache implements HttpCache { public HttpResponse addResponse(HttpRequest request, HttpResponse response) { HttpResponseBuilder responseBuilder; boolean storeStrictNoCacheResources = (refetchStrictNoCacheAfterMs >= 0); if (isCacheable(request, response, storeStrictNoCacheResources)) { if (storeStrictNoCacheResources && response.isStrictNoCache()) { responseBuilder = buildStrictNoCacheHttpResponse(response); } else { responseBuilder = new HttpResponseBuilder(response); } } else { return null; } int forcedTtl = request.getCacheTtl(); if (forcedTtl != -1 && !response.isError()) { responseBuilder.setCacheTtl(forcedTtl); } response = responseBuilder.create(); String keyString = createKey(request); addResponseImpl(keyString, response); return response; }  HttpResponse getResponse(HttpRequest request); HttpResponse addResponse(HttpRequest request, HttpResponse response); @VisibleForTesting void setRefetchStrictNoCacheAfterMs(long refetchStrictNoCacheAfterMs); HttpResponse removeResponse(HttpRequest request); String createKey(HttpRequest request); @Inject(optional = true) @Named("shindig.cache.http.strict-no-cache-resource.refetch-after-ms")
  static long REFETCH_STRICT_NO_CACHE_AFTER_MS_DEFAULT; }### Answer:
@Test public void addResponse() { HttpRequest request = new HttpRequest(DEFAULT_URI); HttpResponse response = new HttpResponse("normal"); String key = cache.createKey(request); assertNotNull("response should have been cached", cache.addResponse(request, response)); assertEquals(response, cache.map.get(key)); assertNotNull("response should have been cached", extendedStrictNoCacheTtlCache.addResponse(request, response)); assertEquals(response, extendedStrictNoCacheTtlCache.map.get(key)); }
@Test public void addResponseIgnoreCache() { HttpRequest request = new HttpRequest(DEFAULT_URI) .setIgnoreCache(true); HttpResponse response = new HttpResponse("does not matter"); assertNull("response should not have been cached", cache.addResponse(request, response)); assertEquals(0, cache.map.size()); assertNull("response should not have been cached", extendedStrictNoCacheTtlCache.addResponse(request, response)); assertEquals(0, extendedStrictNoCacheTtlCache.map.size()); }
@Test public void addResponseIfModifiedSince() { HttpRequest request = new HttpRequest(DEFAULT_URI); HttpResponse response = new HttpResponseBuilder().setHttpStatusCode(HttpResponse.SC_NOT_MODIFIED).create(); assertNull(cache.addResponse(request, response)); assertEquals(0, cache.map.size()); assertNull(extendedStrictNoCacheTtlCache.addResponse(request, response)); assertEquals(0, extendedStrictNoCacheTtlCache.map.size()); }
@Test public void addResponseUsingPost() { HttpRequest request = new HttpRequest(DEFAULT_URI) .setMethod("POST"); HttpResponse response = new HttpResponse("does not matter"); assertNull(cache.addResponse(request, response)); assertEquals(0, cache.map.size()); assertNull(extendedStrictNoCacheTtlCache.addResponse(request, response)); assertEquals(0, extendedStrictNoCacheTtlCache.map.size()); }