diff --git a/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java b/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java index edf359dc9..db1c475ef 100644 --- a/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java +++ b/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java @@ -59,7 +59,7 @@ public class TestHttpCacheEntry { nineSecondsAgo = new Date(now.getTime() - 9 * 1000L); statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); - mockResource = createMock(Resource.class); + mockResource = createNiceMock(Resource.class); } private HttpCacheEntry makeEntry(Header[] headers) { diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java index b0c3ba56f..e82ec3b29 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java @@ -73,8 +73,8 @@ public abstract class AbstractProtocolTest { params.setMaxCacheEntries(MAX_ENTRIES); params.setMaxObjectSize(MAX_BYTES); cache = new BasicHttpCache(params); - mockBackend = EasyMock.createMock(HttpClient.class); - mockCache = EasyMock.createMock(HttpCache.class); + mockBackend = EasyMock.createNiceMock(HttpClient.class); + mockCache = EasyMock.createNiceMock(HttpCache.class); impl = new CachingHttpClient(mockBackend, cache, params); } @@ -95,8 +95,8 @@ public abstract class AbstractProtocolTest { } protected void emptyMockCacheExpectsNoPuts() throws Exception { - mockBackend = EasyMock.createMock(HttpClient.class); - mockCache = EasyMock.createMock(HttpCache.class); + mockBackend = EasyMock.createNiceMock(HttpClient.class); + mockCache = EasyMock.createNiceMock(HttpCache.class); impl = new CachingHttpClient(mockBackend, mockCache, params); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java index 4ae512b3f..07f686043 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DoNotTestProtocolRequirements.java @@ -79,9 +79,9 @@ public class DoNotTestProtocolRequirements { params.setMaxCacheEntries(MAX_ENTRIES); HttpCache cache = new BasicHttpCache(params); - mockBackend = EasyMock.createMock(HttpClient.class); - mockEntity = EasyMock.createMock(HttpEntity.class); - mockCache = EasyMock.createMock(HttpCache.class); + mockBackend = EasyMock.createNiceMock(HttpClient.class); + mockEntity = EasyMock.createNiceMock(HttpEntity.class); + mockCache = EasyMock.createNiceMock(HttpCache.class); impl = new CachingHttpClient(mockBackend, cache, params); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java index 4821f2fd3..8d652f83d 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java @@ -49,12 +49,12 @@ public class TestAsynchronousValidationRequest { @Before public void setUp() { - mockParent = EasyMock.createMock(AsynchronousValidator.class); - mockClient = EasyMock.createMock(CachingHttpClient.class); + mockParent = EasyMock.createNiceMock(AsynchronousValidator.class); + mockClient = EasyMock.createNiceMock(CachingHttpClient.class); target = new HttpHost("foo.example.com"); request = new HttpGet("/"); - mockContext = EasyMock.createMock(HttpContext.class); - mockCacheEntry = EasyMock.createMock(HttpCacheEntry.class); + mockContext = EasyMock.createNiceMock(HttpContext.class); + mockCacheEntry = EasyMock.createNiceMock(HttpCacheEntry.class); } @Test diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java index 37cb75b4b..43cd97e38 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java @@ -61,13 +61,13 @@ public class TestAsynchronousValidator { @Before public void setUp() { - mockClient = EasyMock.createMock(CachingHttpClient.class); + mockClient = EasyMock.createNiceMock(CachingHttpClient.class); target = new HttpHost("foo.example.com"); request = new HttpGet("/"); - mockContext = EasyMock.createMock(HttpContext.class); - mockCacheEntry = EasyMock.createMock(HttpCacheEntry.class); + mockContext = EasyMock.createNiceMock(HttpContext.class); + mockCacheEntry = EasyMock.createNiceMock(HttpCacheEntry.class); - mockExecutor = EasyMock.createMock(ExecutorService.class); + mockExecutor = EasyMock.createNiceMock(ExecutorService.class); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java index 5ffd37188..9cbf6cf50 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java @@ -73,9 +73,9 @@ public class TestCacheInvalidator { tenSecondsAgo = new Date(now.getTime() - 10 * 1000L); host = new HttpHost("foo.example.com"); - mockStorage = createMock(HttpCacheStorage.class); + mockStorage = createNiceMock(HttpCacheStorage.class); cacheKeyGenerator = new CacheKeyGenerator(); - mockEntry = createMock(HttpCacheEntry.class); + mockEntry = createNiceMock(HttpCacheEntry.class); request = HttpTestUtils.makeDefaultRequest(); response = HttpTestUtils.make200Response(); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java index 6c5436e2d..45b6b5dcd 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java @@ -53,8 +53,8 @@ public class TestCacheKeyGenerator { @Before public void setUp() throws Exception { host = new HttpHost("foo.example.com"); - mockEntry = EasyMock.createMock(HttpCacheEntry.class); - mockRequest = EasyMock.createMock(HttpRequest.class); + mockEntry = EasyMock.createNiceMock(HttpCacheEntry.class); + mockRequest = EasyMock.createNiceMock(HttpRequest.class); extractor = new CacheKeyGenerator(); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java index 558f1f0fc..62df5b412 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java @@ -57,7 +57,7 @@ public class TestCachedHttpResponseGenerator { new BasicHeader("Content-Length", "150") }; entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, sixSecondsAgo, hdrs); - mockValidityPolicy = EasyMock.createMock(CacheValidityPolicy.class); + mockValidityPolicy = EasyMock.createNiceMock(CacheValidityPolicy.class); impl = new CachedHttpResponseGenerator(mockValidityPolicy); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java index b2c7bb086..c61492a20 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java @@ -63,7 +63,7 @@ public class TestCachedResponseSuitabilityChecker { host = new HttpHost("foo.example.com"); request = new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1); - mockValidityPolicy = EasyMock.createMock(CacheValidityPolicy.class); + mockValidityPolicy = EasyMock.createNiceMock(CacheValidityPolicy.class); entry = HttpTestUtils.makeCacheEntry(); impl = new CachedResponseSuitabilityChecker(new CacheConfig()); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java index 91b42f8f5..510953f84 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClient.java @@ -115,25 +115,25 @@ public class TestCachingHttpClient { @SuppressWarnings("unchecked") @Before public void setUp() { - mockRequestPolicy = createMock(CacheableRequestPolicy.class); - mockValidityPolicy = createMock(CacheValidityPolicy.class); - mockBackend = createMock(HttpClient.class); - mockCache = createMock(HttpCache.class); - mockSuitabilityChecker = createMock(CachedResponseSuitabilityChecker.class); - mockResponsePolicy = createMock(ResponseCachingPolicy.class); - mockConnectionManager = createMock(ClientConnectionManager.class); - mockHandler = createMock(ResponseHandler.class); - mockBackendResponse = createMock(HttpResponse.class); - mockUriRequest = createMock(HttpUriRequest.class); - mockCacheEntry = createMock(HttpCacheEntry.class); - mockResponseGenerator = createMock(CachedHttpResponseGenerator.class); - mockCachedResponse = createMock(HttpResponse.class); - mockConditionalRequestBuilder = createMock(ConditionalRequestBuilder.class); - mockConditionalRequest = createMock(HttpRequest.class); - mockStatusLine = createMock(StatusLine.class); - mockResponseProtocolCompliance = createMock(ResponseProtocolCompliance.class); - mockRequestProtocolCompliance = createMock(RequestProtocolCompliance.class); - mockStorage = createMock(HttpCacheStorage.class); + mockRequestPolicy = createNiceMock(CacheableRequestPolicy.class); + mockValidityPolicy = createNiceMock(CacheValidityPolicy.class); + mockBackend = createNiceMock(HttpClient.class); + mockCache = createNiceMock(HttpCache.class); + mockSuitabilityChecker = createNiceMock(CachedResponseSuitabilityChecker.class); + mockResponsePolicy = createNiceMock(ResponseCachingPolicy.class); + mockConnectionManager = createNiceMock(ClientConnectionManager.class); + mockHandler = createNiceMock(ResponseHandler.class); + mockBackendResponse = createNiceMock(HttpResponse.class); + mockUriRequest = createNiceMock(HttpUriRequest.class); + mockCacheEntry = createNiceMock(HttpCacheEntry.class); + mockResponseGenerator = createNiceMock(CachedHttpResponseGenerator.class); + mockCachedResponse = createNiceMock(HttpResponse.class); + mockConditionalRequestBuilder = createNiceMock(ConditionalRequestBuilder.class); + mockConditionalRequest = createNiceMock(HttpRequest.class); + mockStatusLine = createNiceMock(StatusLine.class); + mockResponseProtocolCompliance = createNiceMock(ResponseProtocolCompliance.class); + mockRequestProtocolCompliance = createNiceMock(RequestProtocolCompliance.class); + mockStorage = createNiceMock(HttpCacheStorage.class); requestDate = new Date(System.currentTimeMillis() - 1000); responseDate = new Date(); @@ -2159,7 +2159,7 @@ public class TestCachingHttpClient { mockSuitabilityChecker, mockConditionalRequestBuilder, mockResponseProtocolCompliance, - mockRequestProtocolCompliance).addMockedMethods(methods).createMock(); + mockRequestProtocolCompliance).addMockedMethods(methods).createNiceMock(); } } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java index e7bf759a0..a21af7f25 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java @@ -38,7 +38,7 @@ public class TestCombinedEntity { @Test public void testCombinedEntityBasics() throws Exception { - Resource resource = EasyMock.createMock(Resource.class); + Resource resource = EasyMock.createNiceMock(Resource.class); EasyMock.expect(resource.getInputStream()).andReturn( new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 })); resource.dispose(); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java index 78f80c7ab..ee450147b 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java @@ -91,7 +91,7 @@ public class TestHttpCacheJiraNumber1147 { ResourceFactory resourceFactory = new FileResourceFactory(cacheDir); HttpCacheStorage httpCacheStorage = new ManagedHttpCacheStorage(cacheConfig); - HttpClient client = EasyMock.createMock(HttpClient.class); + HttpClient client = EasyMock.createNiceMock(HttpClient.class); HttpGet get = new HttpGet("http://somehost/"); HttpContext context = new BasicHttpContext(); HttpHost target = new HttpHost("somehost"); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java index 0b79836f4..34f67b257 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java @@ -98,9 +98,9 @@ public class TestProtocolDeviations { params.setMaxCacheEntries(MAX_ENTRIES); HttpCache cache = new BasicHttpCache(params); - mockBackend = EasyMock.createMock(HttpClient.class); - mockEntity = EasyMock.createMock(HttpEntity.class); - mockCache = EasyMock.createMock(HttpCache.class); + mockBackend = EasyMock.createNiceMock(HttpClient.class); + mockEntity = EasyMock.createNiceMock(HttpEntity.class); + mockCache = EasyMock.createNiceMock(HttpCache.class); impl = new CachingHttpClient(mockBackend, cache, params); } @@ -203,7 +203,7 @@ public class TestProtocolDeviations { (new Random()).nextBytes(bytes); HttpEntity mockBody = EasyMock.createMockBuilder(ByteArrayEntity.class).withConstructor( - new Object[] { bytes }).addMockedMethods("getContentLength").createMock(); + new Object[] { bytes }).addMockedMethods("getContentLength").createNiceMock(); org.easymock.EasyMock.expect(mockBody.getContentLength()).andReturn(-1L).anyTimes(); post.setEntity(mockBody); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java index 98c181e61..f6b2773d7 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java @@ -550,7 +550,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest { public void testRequestsExpecting100ContinueBehaviorShouldSetExpectHeader() throws Exception { BasicHttpEntityEnclosingRequest post = EasyMock.createMockBuilder( BasicHttpEntityEnclosingRequest.class).withConstructor("POST", "/", HttpVersion.HTTP_1_1) - .addMockedMethods("expectContinue").createMock(); + .addMockedMethods("expectContinue").createNiceMock(); post.setEntity(new BasicHttpEntity()); post.setHeader("Content-Length", "128"); @@ -595,7 +595,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest { throws Exception { BasicHttpEntityEnclosingRequest post = EasyMock.createMockBuilder( BasicHttpEntityEnclosingRequest.class).withConstructor("POST", "/", HttpVersion.HTTP_1_1) - .addMockedMethods("expectContinue").createMock(); + .addMockedMethods("expectContinue").createNiceMock(); post.setEntity(new BasicHttpEntity()); post.setHeader("Content-Length", "128"); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java index be19c8b39..5002914ae 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java @@ -51,10 +51,10 @@ public class TestEhcacheHttpCacheStorage extends TestCase { @Override public void setUp() { - mockCache = EasyMock.createMock(Ehcache.class); + mockCache = EasyMock.createNiceMock(Ehcache.class); CacheConfig config = new CacheConfig(); config.setMaxUpdateRetries(1); - mockSerializer = EasyMock.createMock(HttpCacheEntrySerializer.class); + mockSerializer = EasyMock.createNiceMock(HttpCacheEntrySerializer.class); impl = new EhcacheHttpCacheStorage(mockCache, config, mockSerializer); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java index 21906b31a..607bd51ac 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java @@ -71,7 +71,7 @@ public class TestEhcacheProtocolRequirements extends TestProtocolRequirements{ } CACHE_MANAGER.addCache(TEST_EHCACHE_NAME); HttpCacheStorage storage = new EhcacheHttpCacheStorage(CACHE_MANAGER.getCache(TEST_EHCACHE_NAME)); - mockBackend = EasyMock.createMock(HttpClient.class); + mockBackend = EasyMock.createNiceMock(HttpClient.class); impl = new CachingHttpClient(mockBackend, new HeapResourceFactory(), storage, params); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java index e6821abe4..d5a288a2e 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java @@ -57,13 +57,13 @@ public class TestMemcachedHttpCacheStorage extends TestCase { @Override @Before public void setUp() throws Exception { - mockMemcachedClient = EasyMock.createMock(MemcachedClientIF.class); - mockKeyHashingScheme = EasyMock.createMock(KeyHashingScheme.class); - mockMemcachedCacheEntryFactory = EasyMock.createMock(MemcachedCacheEntryFactory.class); - mockMemcachedCacheEntry = EasyMock.createMock(MemcachedCacheEntry.class); - mockMemcachedCacheEntry2 = EasyMock.createMock(MemcachedCacheEntry.class); - mockMemcachedCacheEntry3 = EasyMock.createMock(MemcachedCacheEntry.class); - mockMemcachedCacheEntry4 = EasyMock.createMock(MemcachedCacheEntry.class); + mockMemcachedClient = EasyMock.createNiceMock(MemcachedClientIF.class); + mockKeyHashingScheme = EasyMock.createNiceMock(KeyHashingScheme.class); + mockMemcachedCacheEntryFactory = EasyMock.createNiceMock(MemcachedCacheEntryFactory.class); + mockMemcachedCacheEntry = EasyMock.createNiceMock(MemcachedCacheEntry.class); + mockMemcachedCacheEntry2 = EasyMock.createNiceMock(MemcachedCacheEntry.class); + mockMemcachedCacheEntry3 = EasyMock.createNiceMock(MemcachedCacheEntry.class); + mockMemcachedCacheEntry4 = EasyMock.createNiceMock(MemcachedCacheEntry.class); CacheConfig config = new CacheConfig(); config.setMaxUpdateRetries(1); impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,