From e07fd9abed6fd47e9356dbf258676cef1347224f Mon Sep 17 00:00:00 2001 From: Leandro Nunes Date: Fri, 19 May 2017 12:16:40 +0100 Subject: [PATCH] Removing unnecessary checks for cache invalidation calls. --- .../apache/hc/client5/http/impl/cache/TestCachingExec.java | 3 --- .../hc/client5/http/impl/cache/TestCachingExecChain.java | 7 +------ .../client5/http/impl/cache/TestProtocolRequirements.java | 6 ------ 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java index d0df9b6c0..727b338da 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java @@ -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()); @@ -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); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java index 5f5f01a18..7a848cd26 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java @@ -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); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java index aec6e42c7..f0325cd48 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java @@ -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 cap = new Capture<>(); - mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request)); mockCache.flushInvalidatedCacheEntriesFor( EasyMock.isA(HttpHost.class), EasyMock.isA(ClassicHttpRequest.class),