### Question:
DefaultCacheInvalidator extends CacheInvalidatorBase implements HttpCacheInvalidator { @Override public void flushCacheEntriesInvalidatedByExchange( final HttpHost host, final HttpRequest request, final HttpResponse response, final Resolver<URI, String> cacheKeyResolver, final HttpCacheStorage storage) { final int status = response.getCode(); if (status < 200 || status > 299) { return; } final String s = HttpCacheSupport.getRequestUri(request, host); final URI uri = HttpCacheSupport.normalizeQuetly(s); if (uri == null) { return; } final URI contentLocation = getContentLocationURI(uri, response); if (contentLocation != null && isSameHost(uri, contentLocation)) { flushLocationCacheEntry(response, contentLocation, storage, cacheKeyResolver); } final URI location = getLocationURI(uri, response); if (location != null && isSameHost(uri, location)) { flushLocationCacheEntry(response, location, storage, cacheKeyResolver); } }  @Override void flushCacheEntriesInvalidatedByRequest(
            final HttpHost host,
            final HttpRequest request,
            final Resolver<URI, String> cacheKeyResolver,
            final HttpCacheStorage storage); @Override void flushCacheEntriesInvalidatedByExchange(
            final HttpHost host,
            final HttpRequest request,
            final HttpResponse response,
            final Resolver<URI, String> cacheKeyResolver,
            final HttpCacheStorage storage); static final DefaultCacheInvalidator INSTANCE; }### Answer:
@Test public void doesNotFlushForResponsesWithoutContentLocation() throws Exception { final HttpRequest request = new BasicHttpRequest("POST","/"); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK); impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage); verifyNoMoreInteractions(mockStorage); }
@Test public void doesNotFlushEntryForUnsuccessfulResponse() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_BAD_REQUEST, "Bad Request"); response.setHeader("ETag","\"new-etag\""); response.setHeader("Date", DateUtils.formatDate(now)); final String key = "http: response.setHeader("Content-Location", key); impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage); verifyNoMoreInteractions(mockStorage); }
@Test public void doesNotFlushEntryIfContentLocationFromDifferentHost() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK); response.setHeader("ETag","\"new-etag\""); response.setHeader("Date", DateUtils.formatDate(now)); final String cacheKey = "http: response.setHeader("Content-Location", cacheKey); impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage); verifyNoMoreInteractions(mockStorage); }