Removing unnecessary checks for cache invalidation calls.

This commit is contained in:
Leandro Nunes 2017-05-19 12:16:40 +01:00
parent 4bd79fb3dd
commit e07fd9abed
3 changed files with 1 additions and 15 deletions

View File

@ -166,7 +166,6 @@ public class TestCachingExec extends TestCachingExecChain {
@Test
public void testCacheMissCausesBackendRequest() throws Exception {
mockImplMethods(CALL_BACKEND);
cacheInvalidatorWasCalled();
requestPolicyAllowsCaching(true);
getCacheEntryReturns(null);
getVariantCacheEntriesReturns(new HashMap<String,Variant>());
@ -188,7 +187,6 @@ public class TestCachingExec extends TestCachingExecChain {
@Test
public void testUnsuitableUnvalidatableCacheEntryCausesBackendRequest() throws Exception {
mockImplMethods(CALL_BACKEND);
cacheInvalidatorWasCalled();
requestPolicyAllowsCaching(true);
requestIsFatallyNonCompliant(null);
@ -214,7 +212,6 @@ public class TestCachingExec extends TestCachingExecChain {
@Test
public void testUnsuitableValidatableCacheEntryCausesRevalidation() throws Exception {
mockImplMethods(REVALIDATE_CACHE_ENTRY);
cacheInvalidatorWasCalled();
requestPolicyAllowsCaching(true);
requestIsFatallyNonCompliant(null);

View File

@ -47,6 +47,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import junit.framework.AssertionFailedError;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.cache.CacheResponseStatus;
import org.apache.hc.client5.http.cache.HttpCacheContext;
@ -84,8 +85,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import junit.framework.AssertionFailedError;
@SuppressWarnings("boxing") // test code
public abstract class TestCachingExecChain {
@ -310,7 +309,6 @@ public abstract class TestCachingExecChain {
@Test
public void testSuitableCacheEntryDoesNotCauseBackendRequest() throws Exception {
cacheInvalidatorWasCalled();
requestPolicyAllowsCaching(true);
getCacheEntryReturns(mockCacheEntry);
cacheEntrySuitable(true);
@ -351,7 +349,6 @@ public abstract class TestCachingExecChain {
public void testResponseIsGeneratedWhenCacheEntryIsUsable() throws Exception {
requestIsFatallyNonCompliant(null);
cacheInvalidatorWasCalled();
requestPolicyAllowsCaching(true);
cacheEntrySuitable(true);
getCacheEntryReturns(mockCacheEntry);
@ -1313,7 +1310,6 @@ public abstract class TestCachingExecChain {
"must-revalidate") });
requestIsFatallyNonCompliant(null);
cacheInvalidatorWasCalled();
requestPolicyAllowsCaching(true);
getCacheEntryReturns(entry);
cacheEntrySuitable(false);
@ -1331,7 +1327,6 @@ public abstract class TestCachingExecChain {
request.setHeader("Cache-Control", "only-if-cached");
requestIsFatallyNonCompliant(null);
cacheInvalidatorWasCalled();
requestPolicyAllowsCaching(true);
getCacheEntryReturns(entry);
cacheEntrySuitable(true);

View File

@ -2263,8 +2263,6 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
notModified.setHeader("Date", DateUtils.formatDate(now));
notModified.setHeader("ETag", "\"etag\"");
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host),
eqRequest(request));
EasyMock.expect(
mockCache.getCacheEntry(EasyMock.eq(host), eqRequest(request)))
.andReturn(entry);
@ -2308,7 +2306,6 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
impl = new CachingExec(mockCache, config);
request = new BasicClassicHttpRequest("GET", "/thing");
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request));
EasyMock.expect(mockCache.getCacheEntry(EasyMock.eq(host), eqRequest(request))).andReturn(entry);
replayMocks();
@ -2355,7 +2352,6 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
impl = new CachingExec(mockCache, config);
request = new BasicClassicHttpRequest("GET", "/thing");
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request));
EasyMock.expect(mockCache.getCacheEntry(EasyMock.eq(host), eqRequest(request))).andReturn(entry);
EasyMock.expect(
mockExecChain.proceed(
@ -2564,7 +2560,6 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
impl = new CachingExec(mockCache, config);
request = new BasicClassicHttpRequest("GET", "/thing");
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request));
EasyMock.expect(mockCache.getCacheEntry(EasyMock.eq(host), eqRequest(request))).andReturn(entry);
replayMocks();
@ -2626,7 +2621,6 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Capture<ClassicHttpRequest> cap = new Capture<>();
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request));
mockCache.flushInvalidatedCacheEntriesFor(
EasyMock.isA(HttpHost.class),
EasyMock.isA(ClassicHttpRequest.class),