You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/08/04 16:40:11 UTC
[2/2] httpcomponents-client git commit: Static methods should be
accessed directly. Remove redundant type arguments. Remove exceptions not
thrown from method signatures. Add missing @Override. Remove unnecessary
semicolons. Don't nest unnecessarily.
Static methods should be accessed directly. Remove redundant type
arguments. Remove exceptions not thrown from method signatures. Add
missing @Override. Remove unnecessary semicolons. Don't nest
unnecessarily.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/8d87cf51
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/8d87cf51
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/8d87cf51
Branch: refs/heads/master
Commit: 8d87cf515b324e36355fe4652633fa0e8a7aea92
Parents: 5080210
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 10:40:01 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 10:40:01 2018 -0600
----------------------------------------------------------------------
.../http/impl/cache/AsyncCachingExec.java | 16 ++-
.../http/impl/cache/BasicHttpAsyncCache.java | 10 +-
.../hc/client5/http/impl/cache/CachingExec.java | 13 +--
.../http/impl/cache/CachingExecBase.java | 3 +-
.../cache/DefaultAsyncCacheInvalidator.java | 3 +-
.../cache/DefaultAsyncCacheRevalidator.java | 5 +-
.../impl/cache/DefaultCacheInvalidator.java | 3 +-
.../client5/http/impl/cache/FileResource.java | 3 +-
.../client5/http/impl/cache/HeapResource.java | 3 +-
.../MemcachedHttpAsyncCacheStorage.java | 3 +-
.../memcached/MemcachedHttpCacheStorage.java | 3 +-
.../ExponentialBackOffSchedulingStrategy.java | 3 +-
.../http/impl/cache/HttpCacheEntryMatcher.java | 13 +--
...estAbstractSerializingAsyncCacheStorage.java | 111 ++++++++++---------
.../TestAbstractSerializingCacheStorage.java | 23 ++--
.../impl/cache/TestCacheRevalidatorBase.java | 22 ++--
.../http/impl/cache/TestCachingExec.java | 4 +-
.../cache/TestConditionalRequestBuilder.java | 5 +-
.../cache/TestDefaultAsyncCacheInvalidator.java | 105 +++++++++---------
.../impl/cache/TestDefaultCacheInvalidator.java | 4 +-
.../hc/client5/http/osgi/impl/WeakList.java | 9 +-
.../hc/client5/http/osgi/impl/WeakListTest.java | 4 +-
.../AbstractHttpAsyncClientAuthentication.java | 9 +-
.../AbstractHttpAsyncFundamentalsTest.java | 3 +-
...CachingHttpAsyncClientCompatibilityTest.java | 2 +-
.../CachingHttpClientCompatibilityTest.java | 2 +-
.../HttpAsyncClientCompatibilityTest.java | 2 +-
.../external/HttpClientCompatibilityTest.java | 2 +-
.../testing/sync/TestClientAuthentication.java | 12 +-
.../org/apache/hc/client5/http/HttpRoute.java | 3 +-
.../client5/http/async/methods/SimpleBody.java | 7 +-
.../apache/hc/client5/http/auth/AuthScope.java | 3 +-
.../http/entity/DecompressingEntity.java | 3 +-
.../http/entity/mime/FormBodyPartBuilder.java | 2 +-
.../client5/http/entity/mime/MinimalField.java | 2 +-
.../hc/client5/http/impl/AuthSupport.java | 3 +-
.../apache/hc/client5/http/impl/Operations.java | 26 ++---
.../http/impl/async/AsyncConnectExec.java | 14 +--
.../http/impl/async/AsyncProtocolExec.java | 5 +-
.../impl/async/AsyncPushConsumerRegistry.java | 3 +-
.../http/impl/async/AsyncRedirectExec.java | 3 +-
.../Http2AsyncClientEventHandlerFactory.java | 15 ++-
.../HttpAsyncClientEventHandlerFactory.java | 39 ++++---
.../async/InternalHttp2AsyncExecRuntime.java | 55 +++++----
.../async/InternalHttpAsyncExecRuntime.java | 67 ++++++-----
.../client5/http/impl/auth/CredSspScheme.java | 5 +-
.../client5/http/impl/auth/NTLMEngineImpl.java | 58 +++++-----
.../impl/classic/HttpRequestTaskCallable.java | 3 +-
.../http/impl/classic/MainClientExec.java | 5 +-
.../http/impl/classic/MinimalHttpClient.java | 5 +-
.../hc/client5/http/impl/classic/RetryExec.java | 3 +-
.../http/impl/cookie/LaxExpiresHandler.java | 5 +-
.../io/DefaultHttpClientConnectionOperator.java | 3 +-
.../io/PoolingHttpClientConnectionManager.java | 3 +-
.../impl/nio/MultihomeIOSessionRequester.java | 105 +++++++++---------
.../PoolingAsyncClientConnectionManager.java | 14 +--
...lingAsyncClientConnectionManagerBuilder.java | 1 -
.../http/io/ManagedHttpClientConnection.java | 1 +
.../http/protocol/HttpClientContext.java | 1 -
.../hc/client5/http/routing/RoutingSupport.java | 3 +-
.../http/ssl/SSLConnectionSocketFactory.java | 3 +-
.../apache/hc/client5/http/entity/TestGZip.java | 3 +-
.../entity/mime/TestMultipartEntityBuilder.java | 2 +-
.../http/impl/TestIdleConnectionEvictor.java | 3 +-
.../http/impl/auth/TestDigestScheme.java | 2 +-
.../TestSystemDefaultCredentialsProvider.java | 11 +-
.../impl/classic/TestCloseableHttpClient.java | 3 -
.../http/impl/classic/TestConnectExec.java | 2 +-
.../impl/classic/TestInternalHttpClient.java | 2 -
.../http/impl/classic/TestMainClientExec.java | 2 +-
.../http/impl/classic/TestRedirectExec.java | 64 +++++------
.../http/impl/cookie/TestRFC6265CookieSpec.java | 13 ++-
.../io/TestHttpClientConnectionOperator.java | 1 -
.../http/protocol/TestRequestAddCookies.java | 3 +-
74 files changed, 453 insertions(+), 526 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
index f8860c7..f45c1f2 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
@@ -399,13 +399,12 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
}
}
return Integer.MAX_VALUE;
+ }
+ final AsyncDataConsumer dataConsumer = dataConsumerRef.get();
+ if (dataConsumer != null) {
+ return dataConsumer.consume(src);
} else {
- final AsyncDataConsumer dataConsumer = dataConsumerRef.get();
- if (dataConsumer != null) {
- return dataConsumer.consume(src);
- } else {
- return Integer.MAX_VALUE;
- }
+ return Integer.MAX_VALUE;
}
}
@@ -425,7 +424,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
}
}
- };
+ }
class BackendResponseHandler implements AsyncExecCallback {
@@ -501,9 +500,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
if (cachingDataConsumer != null) {
log.debug("Caching backend response");
return cachingDataConsumer;
- } else {
- return asyncExecCallback.handleResponse(backendResponse, entityDetails);
}
+ return asyncExecCallback.handleResponse(backendResponse, entityDetails);
}
void triggerNewCacheEntryResponse(final HttpResponse backendResponse, final Date responseDate, final ByteArrayBuffer buffer) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
index a8bb75b..2620da2 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
@@ -127,10 +127,9 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
}
});
- } else {
- callback.completed(Boolean.TRUE);
- return Operations.nonCancellable();
}
+ callback.completed(Boolean.TRUE);
+ return Operations.nonCancellable();
}
@Override
@@ -150,10 +149,9 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
}
if (!StandardMethods.isSafe(request.getMethod())) {
return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback);
- } else {
- callback.completed(Boolean.TRUE);
- return Operations.nonCancellable();
}
+ callback.completed(Boolean.TRUE);
+ return Operations.nonCancellable();
}
Cancellable storeInCache(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
index 66796b4..ebf5b72 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
@@ -261,10 +261,9 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler {
recordCacheFailure(target, request);
if (!mayCallBackend(request)) {
return convert(generateGatewayTimeout(context), scope);
- } else {
- setResponseStatus(scope.clientContext, CacheResponseStatus.FAILURE);
- return chain.proceed(request, scope);
}
+ setResponseStatus(scope.clientContext, CacheResponseStatus.FAILURE);
+ return chain.proceed(request, scope);
}
} else if (!mayCallBackend(request)) {
log.debug("Cache entry not suitable but only-if-cached requested");
@@ -295,9 +294,8 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler {
});
return convert(response, scope);
- } else {
- return revalidateCacheEntry(target, request, scope, chain, entry);
}
+ return revalidateCacheEntry(target, request, scope, chain, entry);
} catch (final IOException ioex) {
return convert(handleRevalidationFailure(request, context, entry, now), scope);
}
@@ -380,10 +378,9 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler {
if (cacheable) {
storeRequestIfModifiedSinceFor304Response(request, backendResponse);
return cacheAndReturnResponse(target, request, backendResponse, scope, requestDate, responseDate);
- } else {
- log.debug("Backend response is not cacheable");
- responseCache.flushCacheEntriesFor(target, request);
}
+ log.debug("Backend response is not cacheable");
+ responseCache.flushCacheEntriesFor(target, request);
return backendResponse;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
index 9fd6f56..95f1497 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
@@ -145,9 +145,8 @@ public class CachingExecBase {
if (fatalError != null && !fatalError.isEmpty()) {
setResponseStatus(context, CacheResponseStatus.CACHE_MODULE_RESPONSE);
return responseGenerator.getErrorForRequest(fatalError.get(0));
- } else {
- return null;
}
+ return null;
}
void recordCacheMiss(final HttpHost target, final HttpRequest request) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
index 6043a54..246a11a 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
@@ -174,9 +174,8 @@ public class DefaultAsyncCacheInvalidator extends CacheInvalidatorBase implement
if (uri != null && isSameHost(requestUri, uri)) {
removeEntry(storage, cacheKeyResolver.resolve(uri));
return true;
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
index fd24741..446dc7a 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
@@ -51,7 +51,7 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
interface RevalidationCall {
- void execute(AsyncExecCallback asyncExecCallback);;
+ void execute(AsyncExecCallback asyncExecCallback);
}
static class InternalScheduledExecutor implements ScheduledExecutor {
@@ -67,9 +67,8 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
if (timeValue.toMillis() <= 0) {
command.run();
return new Operations.CompletedFuture<Void>(null);
- } else {
- return executor.schedule(command, timeValue);
}
+ return executor.schedule(command, timeValue);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
index 7313080..c305b91 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
@@ -143,9 +143,8 @@ public class DefaultCacheInvalidator extends CacheInvalidatorBase implements Htt
if (uri != null && isSameHost(requestUri, uri)) {
removeEntry(storage, cacheKeyResolver.resolve(uri));
return true;
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
index fa0e2c8..cd240a6 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
@@ -92,9 +92,8 @@ public class FileResource extends Resource {
} catch (final FileNotFoundException ex) {
throw new ResourceIOException(ex.getMessage(), ex);
}
- } else {
- throw new ResourceIOException("Resouce already dispoased");
}
+ throw new ResourceIOException("Resouce already dispoased");
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
index 2473205..5c7aab1 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
@@ -55,9 +55,8 @@ public class HeapResource extends Resource {
final byte[] byteArray = this.arrayRef.get();
if (byteArray != null) {
return byteArray;
- } else {
- throw new ResourceIOException("Resouce already dispoased");
}
+ throw new ResourceIOException("Resouce already dispoased");
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
index b59529d..36d075c 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
@@ -150,9 +150,8 @@ public class MemcachedHttpAsyncCacheStorage extends AbstractBinaryAsyncCacheStor
}
if (storageObject instanceof byte[]) {
return (byte[]) storageObject;
- } else {
- throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
+ throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
index 7df45b9..dc40e89 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
@@ -145,9 +145,8 @@ public class MemcachedHttpCacheStorage extends AbstractBinaryCacheStorage<CASVal
}
if (storageObject instanceof byte[]) {
return (byte[]) storageObject;
- } else {
- throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
+ throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
index 2bccc9c..ee17f1f 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
@@ -110,9 +110,8 @@ public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy
if (consecutiveFailedAttempts > 0) {
final long delay = (long) (initialExpiry.toMillis() * Math.pow(backOffRate, consecutiveFailedAttempts - 1));
return Math.min(delay, maxExpiry.toMillis());
- } else {
- return 0;
}
+ return 0;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
index 9c4a52c..04ac26f 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
@@ -72,13 +72,12 @@ public class HttpCacheEntryMatcher extends BaseMatcher<HttpCacheEntry> {
final Header[] otherHeaders = otherValue.getAllHeaders();
if (expectedHeaders.length != otherHeaders.length) {
return false;
- } else {
- for (int i = 0; i < expectedHeaders.length; i++) {
- final Header h1 = expectedHeaders[i];
- final Header h2 = otherHeaders[i];
- if (!h1.getName().equals(h2.getName()) || !LangUtils.equals(h1.getValue(), h2.getValue())) {
- return false;
- }
+ }
+ for (int i = 0; i < expectedHeaders.length; i++) {
+ final Header h1 = expectedHeaders[i];
+ final Header h2 = otherHeaders[i];
+ if (!h1.getName().equals(h2.getName()) || !LangUtils.equals(h1.getValue(), h2.getValue())) {
+ return false;
}
}
final Resource expectedResource = expectedValue.getResource();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
index 8c0097a..f0b1ad6 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
@@ -49,6 +49,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
@@ -87,9 +88,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
Mockito.when(impl.store(
- Mockito.eq("bar"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -103,7 +104,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
impl.putEntry(key, value, operationCallback);
final ArgumentCaptor<byte[]> argumentCaptor = ArgumentCaptor.forClass(byte[].class);
- Mockito.verify(impl).store(Mockito.eq("bar"), argumentCaptor.capture(), Mockito.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), argumentCaptor.capture(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Assert.assertArrayEquals(serialize(key, value), argumentCaptor.getValue());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -113,7 +114,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final String key = "foo";
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -128,7 +129,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final ArgumentCaptor<HttpCacheEntry> argumentCaptor = ArgumentCaptor.forClass(HttpCacheEntry.class);
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
Assert.assertThat(argumentCaptor.getValue(), CoreMatchers.nullValue());
- Mockito.verify(impl).restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any());
+ Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
}
@Test
@@ -137,7 +138,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -153,7 +154,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
final HttpCacheEntry resultingEntry = argumentCaptor.getValue();
Assert.assertThat(resultingEntry, HttpCacheEntryMatcher.equivalent(value));
- Mockito.verify(impl).restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any());
+ Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
}
@Test
@@ -161,7 +162,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final String key = "foo";
final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -176,7 +177,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final ArgumentCaptor<HttpCacheEntry> argumentCaptor = ArgumentCaptor.forClass(HttpCacheEntry.class);
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
Assert.assertThat(argumentCaptor.getValue(), CoreMatchers.nullValue());
- Mockito.verify(impl).restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any());
+ Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
}
@Test
@@ -185,8 +186,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
Mockito.when(impl.delete(
- Mockito.eq("bar"),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -208,7 +209,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -219,9 +220,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
});
Mockito.when(impl.store(
- Mockito.eq("bar"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -242,8 +243,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
- Mockito.verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
+ Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -254,7 +255,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -266,10 +267,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
});
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
Mockito.when(impl.updateCAS(
- Mockito.eq("bar"),
- Mockito.eq("stuff"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.eq("stuff"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -289,9 +290,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl).getStorageObject("stuff");
- Mockito.verify(impl).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -302,7 +303,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
new Answer<Cancellable>() {
@Override
@@ -315,9 +316,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
});
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize("not-foo", existingValue));
Mockito.when(impl.store(
- Mockito.eq("bar"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -338,11 +339,11 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl).getStorageObject("stuff");
Mockito.verify(impl, Mockito.never()).updateCAS(
- Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
- Mockito.verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -353,7 +354,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
new Answer<Cancellable>() {
@Override
@@ -367,10 +368,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
final AtomicInteger count = new AtomicInteger(0);
Mockito.when(impl.updateCAS(
- Mockito.eq("bar"),
- Mockito.eq("stuff"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.eq("stuff"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -394,10 +395,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl, Mockito.times(2)).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl, Mockito.times(2)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl, Mockito.times(2)).getStorageObject("stuff");
Mockito.verify(impl, Mockito.times(2)).updateCAS(
- Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -408,7 +409,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
new Answer<Cancellable>() {
@Override
@@ -422,10 +423,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
final AtomicInteger count = new AtomicInteger(0);
Mockito.when(impl.updateCAS(
- Mockito.eq("bar"),
- Mockito.eq("stuff"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.eq("stuff"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -449,11 +450,11 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl, Mockito.times(3)).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl, Mockito.times(3)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl, Mockito.times(3)).getStorageObject("stuff");
Mockito.verify(impl, Mockito.times(3)).updateCAS(
- Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
- Mockito.verify(operationCallback).failed(Mockito.<HttpCacheUpdateException>any());
+ ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ Mockito.verify(operationCallback).failed(ArgumentMatchers.<HttpCacheUpdateException>any());
}
@Test
@@ -470,8 +471,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
when(impl.bulkRestore(
- Mockito.<String>anyCollection(),
- Mockito.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.<String>anyCollection(),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -501,8 +502,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
verify(impl, Mockito.times(2)).digestToStorageKey(key1);
verify(impl, Mockito.times(2)).digestToStorageKey(key2);
verify(impl).bulkRestore(
- Mockito.eq(Arrays.asList(storageKey1, storageKey2)),
- Mockito.<FutureCallback<Map<String, byte[]>>>any());
+ ArgumentMatchers.eq(Arrays.asList(storageKey1, storageKey2)),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any());
}
@Test
@@ -519,8 +520,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
when(impl.bulkRestore(
- Mockito.<String>anyCollection(),
- Mockito.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.<String>anyCollection(),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -550,8 +551,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
verify(impl, Mockito.times(2)).digestToStorageKey(key1);
verify(impl, Mockito.times(2)).digestToStorageKey(key2);
verify(impl).bulkRestore(
- Mockito.eq(Arrays.asList(storageKey1, storageKey2)),
- Mockito.<FutureCallback<Map<String, byte[]>>>any());
+ ArgumentMatchers.eq(Arrays.asList(storageKey1, storageKey2)),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any());
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
index a6bb2dc..5fd0b03 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
@@ -46,6 +46,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -153,7 +154,7 @@ public class TestAbstractSerializingCacheStorage {
});
verify(impl).getForUpdateCAS("bar");
- verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any());
+ verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -165,7 +166,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(true);
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -178,7 +179,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl).getForUpdateCAS("bar");
verify(impl).getStorageObject("stuff");
- verify(impl).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any());
+ verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -190,7 +191,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize("not-foo", existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(true);
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -204,7 +205,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl).getForUpdateCAS("bar");
verify(impl).getStorageObject("stuff");
- verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any());
+ verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -216,7 +217,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(false, true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(false, true);
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -229,7 +230,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl, Mockito.times(2)).getForUpdateCAS("bar");
verify(impl, Mockito.times(2)).getStorageObject("stuff");
- verify(impl, Mockito.times(2)).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any());
+ verify(impl, Mockito.times(2)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -241,7 +242,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(false, false, false, true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(false, false, false, true);
try {
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -258,7 +259,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl, Mockito.times(3)).getForUpdateCAS("bar");
verify(impl, Mockito.times(3)).getStorageObject("stuff");
- verify(impl, Mockito.times(3)).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any());
+ verify(impl, Mockito.times(3)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -273,7 +274,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key1)).thenReturn(storageKey1);
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
- when(impl.bulkRestore(Mockito.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
+ when(impl.bulkRestore(ArgumentMatchers.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
@Override
public Map<String, byte[]> answer(final InvocationOnMock invocation) throws Throwable {
@@ -311,7 +312,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key1)).thenReturn(storageKey1);
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
- when(impl.bulkRestore(Mockito.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
+ when(impl.bulkRestore(ArgumentMatchers.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
@Override
public Map<String, byte[]> answer(final InvocationOnMock invocation) throws Throwable {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
index 0326aba..f4dd4c5 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
@@ -44,8 +44,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
@@ -68,26 +68,26 @@ public class TestCacheRevalidatorBase {
@Test
public void testRevalidateCacheEntrySchedulesExecutionAndPopulatesIdentifier() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(1));
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(1));
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
verify(mockSchedulingStrategy).schedule(0);
- verify(mockScheduledExecutor).schedule(Mockito.same(mockOperation), Mockito.eq(TimeValue.ofSeconds(1)));
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.same(mockOperation), ArgumentMatchers.eq(TimeValue.ofSeconds(1)));
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
}
@Test
public void testMarkCompleteRemovesIdentifier() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(3));
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(3));
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
verify(mockSchedulingStrategy).schedule(0);
- verify(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.eq(TimeValue.ofSeconds(3)));
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(3)));
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
Assert.assertTrue(impl.getScheduledIdentifiers().contains(cacheKey));
@@ -99,27 +99,27 @@ public class TestCacheRevalidatorBase {
@Test
public void testRevalidateCacheEntryDoesNotPopulateIdentifierOnRejectedExecutionException() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(2));
- doThrow(new RejectedExecutionException()).when(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.<TimeValue>any());
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(2));
+ doThrow(new RejectedExecutionException()).when(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.<TimeValue>any());
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
Assert.assertEquals(0, impl.getScheduledIdentifiers().size());
- verify(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.eq(TimeValue.ofSeconds(2)));
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
}
@Test
public void testRevalidateCacheEntryProperlyCollapsesRequest() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(2));
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(2));
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
impl.scheduleRevalidation(cacheKey, mockOperation);
impl.scheduleRevalidation(cacheKey, mockOperation);
- verify(mockSchedulingStrategy).schedule(Mockito.anyInt());
- verify(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.eq(TimeValue.ofSeconds(2)));
+ verify(mockSchedulingStrategy).schedule(ArgumentMatchers.anyInt());
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
----------------------------------------------------------------------
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 95969a3..c001396 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
@@ -415,11 +415,11 @@ public class TestCachingExec extends TestCachingExecChain {
return EasyMock.expect(resp).andReturn(response);
}
- private void getVariantCacheEntriesReturns(final Map<String,Variant> result) throws IOException {
+ private void getVariantCacheEntriesReturns(final Map<String,Variant> result) {
expect(mockCache.getVariantCacheEntriesWithEtags(host, request)).andReturn(result);
}
- private void cacheInvalidatorWasCalled() throws IOException {
+ private void cacheInvalidatorWasCalled() {
mockCache.flushCacheEntriesInvalidatedByRequest((HttpHost)anyObject(), (HttpRequest)anyObject());
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
index 3592f65..8fb62f7 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
@@ -38,7 +38,6 @@ import org.apache.hc.client5.http.utils.DateUtils;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HeaderElement;
import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.message.MessageSupport;
@@ -58,7 +57,7 @@ public class TestConditionalRequestBuilder {
}
@Test
- public void testBuildConditionalRequestWithLastModified() throws ProtocolException {
+ public void testBuildConditionalRequestWithLastModified() {
final String theMethod = "GET";
final String theUri = "/theuri";
final String lastModified = "this is my last modified date";
@@ -111,7 +110,7 @@ public class TestConditionalRequestBuilder {
}
@Test
- public void testBuildConditionalRequestWithETag() throws ProtocolException {
+ public void testBuildConditionalRequestWithETag() {
final String theMethod = "GET";
final String theUri = "/theuri";
final String theETag = "this is my eTag";
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
index 5845d36..73660e9 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
@@ -52,6 +52,7 @@ import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
@@ -82,7 +83,7 @@ public class TestDefaultAsyncCacheInvalidator {
now = new Date();
tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
- when(cacheKeyResolver.resolve(Mockito.<URI>any())).thenAnswer(new Answer<String>() {
+ when(cacheKeyResolver.resolve(ArgumentMatchers.<URI>any())).thenAnswer(new Answer<String>() {
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
@@ -109,8 +110,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -130,9 +131,9 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq("http://foo.example.com:80/content"), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -152,9 +153,9 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq("http://foo.example.com:80/content"), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -174,9 +175,9 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq("http://foo.example.com:80/content"), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -196,8 +197,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -205,7 +206,7 @@ public class TestDefaultAsyncCacheInvalidator {
final HttpRequest request = new BasicHttpRequest("GET","/");
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -214,7 +215,7 @@ public class TestDefaultAsyncCacheInvalidator {
final HttpRequest request = new BasicHttpRequest("HEAD","/");
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -232,8 +233,8 @@ public class TestDefaultAsyncCacheInvalidator {
verify(mockEntry).getRequestMethod();
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -253,9 +254,9 @@ public class TestDefaultAsyncCacheInvalidator {
verify(mockEntry).getRequestMethod();
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq(theVariantURI), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(theVariantURI), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -268,7 +269,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -282,7 +283,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -298,7 +299,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getRequestMethod();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -309,7 +310,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -320,7 +321,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -337,10 +338,10 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verify(mockEntry).getVariantMap();
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq(variantUri), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(variantUri), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -370,8 +371,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -392,8 +393,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -428,8 +429,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -450,8 +451,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -492,7 +493,7 @@ public class TestDefaultAsyncCacheInvalidator {
cacheReturnsEntryForUri(key, entry);
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -514,7 +515,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -531,7 +532,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -553,7 +554,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -574,7 +575,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -596,8 +597,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -618,8 +619,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -641,8 +642,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -664,8 +665,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -677,8 +678,8 @@ public class TestDefaultAsyncCacheInvalidator {
private void cacheReturnsEntryForUri(final String key, final HttpCacheEntry cacheEntry) {
Mockito.when(mockStorage.getEntry(
- Mockito.eq(key),
- Mockito.<FutureCallback<HttpCacheEntry>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq(key),
+ ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
index 45ea326..1d2dee9 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
@@ -51,8 +51,8 @@ import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
@@ -77,7 +77,7 @@ public class TestDefaultCacheInvalidator {
now = new Date();
tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
- when(cacheKeyResolver.resolve(Mockito.<URI>any())).thenAnswer(new Answer<String>() {
+ when(cacheKeyResolver.resolve(ArgumentMatchers.<URI>any())).thenAnswer(new Answer<String>() {
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
----------------------------------------------------------------------
diff --git a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java b/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
index 77b3dc7..815bc04 100644
--- a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
+++ b/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
@@ -43,7 +43,7 @@ class WeakList<T> extends AbstractList<T> {
private final List<WeakReference<T>> innerList;
public WeakList() {
- this.innerList = new ArrayList<WeakReference<T>>();
+ this.innerList = new ArrayList<>();
}
@Override
@@ -59,7 +59,7 @@ class WeakList<T> extends AbstractList<T> {
@Override
public boolean add(final T t) {
- return innerList.add(new WeakReference<T>(t));
+ return innerList.add(new WeakReference<>(t));
}
@Override
@@ -79,7 +79,7 @@ class WeakList<T> extends AbstractList<T> {
@Override
public Iterator<T> iterator() {
- return new WeakIterator<T>(innerList.iterator());
+ return new WeakIterator<>(innerList.iterator());
}
private class WeakIterator<T> implements Iterator<T> {
@@ -104,9 +104,8 @@ class WeakList<T> extends AbstractList<T> {
final T result = next.get();
fetchNext();
return result;
- } else {
- throw new NoSuchElementException();
}
+ throw new NoSuchElementException();
}
private void fetchNext() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java b/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
index a28e09c..ff0f9c7 100644
--- a/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
+++ b/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
@@ -39,7 +39,7 @@ public class WeakListTest {
@Test
public void testWeakList() {
- final WeakList<Object> list = new WeakList<Object>();
+ final WeakList<Object> list = new WeakList<>();
list.add("hello");
list.add(null);
@@ -61,7 +61,7 @@ public class WeakListTest {
@Test
public void clearSupported() {
- final WeakList<Object> list = new WeakList<Object>();
+ final WeakList<Object> list = new WeakList<>();
list.add("hello");
assertEquals(1, list.size());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
index 611c660..817fb50 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
@@ -477,14 +477,9 @@ public abstract class AbstractHttpAsyncClientAuthentication<T extends CloseableH
public boolean authenticate(final URIAuthority authority, final String requestUri, final String credentials) {
final boolean authenticated = super.authenticate(authority, requestUri, credentials);
if (authenticated) {
- if (this.count.incrementAndGet() % 4 != 0) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
+ return this.count.incrementAndGet() % 4 != 0;
}
+ return false;
}
};
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
index 4070d7f..3100812 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
@@ -196,9 +196,8 @@ public abstract class AbstractHttpAsyncFundamentalsTest<T extends CloseableHttpA
final SimpleHttpResponse response = resultQueue.poll();
if (response == null) {
break;
- } else {
- Assert.assertThat(response.getCode(), CoreMatchers.equalTo(200));
}
+ Assert.assertThat(response.getCode(), CoreMatchers.equalTo(200));
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
index 2d6de60..3302c51 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
@@ -108,7 +108,7 @@ public class CachingHttpAsyncClientCompatibilityTest {
client.close();
}
- enum TestResult {OK, NOK};
+ enum TestResult {OK, NOK}
private void logResult(final TestResult result, final HttpRequest request, final String message) {
final StringBuilder buf = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
index 4b9b0ef..ee3ba86 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
@@ -95,7 +95,7 @@ public class CachingHttpClientCompatibilityTest {
client.close();
}
- enum TestResult {OK, NOK};
+ enum TestResult {OK, NOK}
private void logResult(final TestResult result, final HttpRequest request, final String message) {
final StringBuilder buf = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
index cbeba3a..f0eb887 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
@@ -140,7 +140,7 @@ public class HttpAsyncClientCompatibilityTest {
client.close();
}
- enum TestResult {OK, NOK};
+ enum TestResult {OK, NOK}
private void logResult(final TestResult result, final HttpRequest request, final String message) {
final StringBuilder buf = new StringBuilder();