### Question:
CacheValidityPolicy { public boolean isRevalidatable(final HttpCacheEntry entry) { return entry.getFirstHeader(HeaderConstants.ETAG) != null || entry.getFirstHeader(HeaderConstants.LAST_MODIFIED) != null; } CacheValidityPolicy(); TimeValue getCurrentAge(final HttpCacheEntry entry, final Date now); TimeValue getFreshnessLifetime(final HttpCacheEntry entry); boolean isResponseFresh(final HttpCacheEntry entry, final Date now); boolean isResponseHeuristicallyFresh(final HttpCacheEntry entry,
            final Date now, final float coefficient, final TimeValue defaultLifetime); TimeValue getHeuristicFreshnessLifetime(final HttpCacheEntry entry,
            final float coefficient, final TimeValue defaultLifetime); boolean isRevalidatable(final HttpCacheEntry entry); boolean mustRevalidate(final HttpCacheEntry entry); boolean proxyRevalidate(final HttpCacheEntry entry); boolean mayReturnStaleWhileRevalidating(final HttpCacheEntry entry, final Date now); boolean mayReturnStaleIfError(final HttpRequest request, final HttpCacheEntry entry, final Date now); boolean hasCacheControlDirective(final HttpCacheEntry entry, final String directive); TimeValue getStaleness(final HttpCacheEntry entry, final Date now); static final TimeValue MAX_AGE; }### Answer:
@Test public void testCacheEntryIsRevalidatableIfHeadersIncludeETag() { final Header[] headers = { new BasicHeader("Expires", DateUtils.formatDate(new Date())), new BasicHeader("ETag", "somevalue")}; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers); assertTrue(impl.isRevalidatable(entry)); }
@Test public void testCacheEntryIsRevalidatableIfHeadersIncludeLastModifiedDate() { final Header[] headers = { new BasicHeader("Expires", DateUtils.formatDate(new Date())), new BasicHeader("Last-Modified", DateUtils.formatDate(new Date())) }; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers); assertTrue(impl.isRevalidatable(entry)); }
@Test public void testCacheEntryIsNotRevalidatableIfNoAppropriateHeaders() { final Header[] headers = { new BasicHeader("Expires", DateUtils.formatDate(new Date())), new BasicHeader("Cache-Control", "public") }; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers); assertFalse(impl.isRevalidatable(entry)); }