Upgraded Mockito dependency to version 2.7

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1793693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2017-05-03 18:31:58 +00:00
parent 3ca727176e
commit 28058b8f85
12 changed files with 34 additions and 39 deletions

View File

@ -26,7 +26,7 @@
*/
package org.apache.hc.client5.http.impl.cache;
import static org.mockito.Matchers.isA;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@ -40,9 +40,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.cache.HeaderConstants;
import org.apache.hc.client5.http.cache.HttpCacheEntry;
import org.apache.hc.client5.http.sync.ExecRuntime;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.sync.ExecChain;
import org.apache.hc.client5.http.sync.ExecRuntime;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.Header;

View File

@ -26,8 +26,8 @@
*/
package org.apache.hc.client5.http.impl.cache;
import static org.mockito.Matchers.isA;
import static org.mockito.Matchers.same;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

View File

@ -26,7 +26,7 @@
*/
package org.apache.hc.client5.http.impl.cache;
import static org.mockito.Matchers.isA;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;

View File

@ -26,8 +26,8 @@
*/
package org.apache.hc.client5.http.impl.cache.ehcache;
import static org.mockito.Matchers.isA;
import static org.mockito.Matchers.same;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

View File

@ -57,7 +57,7 @@ import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
/**
@ -96,14 +96,14 @@ public class TestSPNegoScheme extends LocalServerTestBase {
NegotiateSchemeWithMockGssManager() throws Exception {
super(true);
Mockito.when(context.initSecContext(
Matchers.any(byte[].class), Matchers.anyInt(), Matchers.anyInt()))
ArgumentMatchers.<byte[]>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
.thenReturn("12345678".getBytes());
Mockito.when(manager.createName(
Matchers.any(String.class), Matchers.any(Oid.class)))
ArgumentMatchers.anyString(), ArgumentMatchers.<Oid>any()))
.thenReturn(name);
Mockito.when(manager.createContext(
Matchers.any(GSSName.class), Matchers.any(Oid.class),
Matchers.any(GSSCredential.class), Matchers.anyInt()))
ArgumentMatchers.<GSSName>any(), ArgumentMatchers.<Oid>any(),
ArgumentMatchers.<GSSCredential>any(), ArgumentMatchers.anyInt()))
.thenReturn(context);
}

View File

@ -126,10 +126,10 @@ public class TestSystemDefaultCredentialsProvider {
private AuthenticatorDelegate installAuthenticator(final PasswordAuthentication returedAuthentication) {
final AuthenticatorDelegate authenticatorDelegate = Mockito.mock(AuthenticatorDelegate.class);
Mockito.when(authenticatorDelegate.getPasswordAuthentication(Mockito.anyString(),
Mockito.any(InetAddress.class), Mockito.anyInt(),
Mockito.<InetAddress>any(), Mockito.anyInt(),
Mockito.anyString(), Mockito.anyString(),
Mockito.anyString(), Mockito.any(URL.class),
Mockito.any(RequestorType.class))).thenReturn(returedAuthentication);
Mockito.anyString(), Mockito.<URL>any(),
Mockito.<RequestorType>any())).thenReturn(returedAuthentication);
Authenticator.setDefault(new DelegatedAuthenticator(authenticatorDelegate));
return authenticatorDelegate;
}

View File

@ -43,7 +43,7 @@ import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
/**
@ -73,7 +73,7 @@ public class TestSystemDefaultRoutePlanner {
Assert.assertEquals(target, route.getTargetHost());
Assert.assertEquals(1, route.getHopCount());
Assert.assertFalse(route.isSecure());
Mockito.verify(schemePortResolver, Mockito.never()).resolve(Matchers.<HttpHost>any());
Mockito.verify(schemePortResolver, Mockito.never()).resolve(ArgumentMatchers.<HttpHost>any());
}
@Test

View File

@ -48,7 +48,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class TestContentCompressionExec {

View File

@ -164,7 +164,7 @@ public class TestExecRuntimeImpl {
Mockito.verify(connectionEndpoint, Mockito.times(1)).shutdown(ShutdownType.IMMEDIATE);
Mockito.verify(mgr, Mockito.times(1)).release(
Mockito.<ConnectionEndpoint>any(),
Mockito.anyObject(),
Mockito.any(),
Mockito.<TimeValue>any());
}
@ -191,7 +191,7 @@ public class TestExecRuntimeImpl {
Mockito.verify(connectionEndpoint, Mockito.times(1)).shutdown(ShutdownType.IMMEDIATE);
Mockito.verify(mgr, Mockito.times(1)).release(
Mockito.<ConnectionEndpoint>any(),
Mockito.anyObject(),
Mockito.any(),
Mockito.<TimeValue>any());
}
@ -221,7 +221,7 @@ public class TestExecRuntimeImpl {
Mockito.verify(mgr, Mockito.times(1)).release(
Mockito.<ConnectionEndpoint>any(),
Mockito.anyObject(),
Mockito.any(),
Mockito.<TimeValue>any());
}
@ -251,7 +251,7 @@ public class TestExecRuntimeImpl {
Mockito.verify(mgr, Mockito.times(1)).release(
Mockito.<ConnectionEndpoint>any(),
Mockito.anyObject(),
Mockito.any(),
Mockito.<TimeValue>any());
}

View File

@ -155,7 +155,7 @@ public class TestProtocolExec {
Mockito.<ClassicHttpRequest>any(),
Mockito.<ExecChain.Scope>any())).thenReturn(response);
Mockito.doThrow(new HttpException("Ooopsie")).when(httpProcessor).process(
Mockito.same(response), Mockito.isNull(EntityDetails.class), Mockito.<HttpContext>any());
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
try {
protocolExec.execute(request, scope, chain);
@ -176,7 +176,7 @@ public class TestProtocolExec {
Mockito.<ClassicHttpRequest>any(),
Mockito.<ExecChain.Scope>any())).thenReturn(response);
Mockito.doThrow(new IOException("Ooopsie")).when(httpProcessor).process(
Mockito.same(response), Mockito.isNull(EntityDetails.class), Mockito.<HttpContext>any());
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
try {
protocolExec.execute(request, scope, chain);
@ -197,7 +197,7 @@ public class TestProtocolExec {
Mockito.<ClassicHttpRequest>any(),
Mockito.<ExecChain.Scope>any())).thenReturn(response);
Mockito.doThrow(new RuntimeException("Ooopsie")).when(httpProcessor).process(
Mockito.same(response), Mockito.isNull(EntityDetails.class), Mockito.<HttpContext>any());
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
final ExecChain.Scope scope = new ExecChain.Scope(route, request, execRuntime, context);
try {
protocolExec.execute(request, scope, chain);

View File

@ -50,7 +50,6 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.ProtocolException;
import org.junit.Assert;
@ -58,7 +57,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.Matchers;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@ -324,7 +323,7 @@ public class TestRedirectExec {
}
}
private static class HttpRequestMatcher extends ArgumentMatcher<ClassicHttpRequest> {
private static class HttpRequestMatcher implements ArgumentMatcher<ClassicHttpRequest> {
private final URI requestUri;
@ -332,22 +331,18 @@ public class TestRedirectExec {
super();
this.requestUri = requestUri;
}
@Override
public boolean matches(final Object obj) {
if (obj instanceof HttpRequest) {
final HttpRequest request = (HttpRequest) obj;
public boolean matches(final ClassicHttpRequest argument) {
try {
return requestUri.equals(request.getUri());
return requestUri.equals(argument.getUri());
} catch (URISyntaxException e) {
return false;
}
} else {
return false;
}
}
static ClassicHttpRequest matchesRequestUri(final URI requestUri) {
return Matchers.argThat(new HttpRequestMatcher(requestUri));
return ArgumentMatchers.argThat(new HttpRequestMatcher(requestUri));
}
}

View File

@ -75,7 +75,7 @@
<slf4j.version>1.7.13</slf4j.version>
<junit.version>4.12</junit.version>
<easymock.version>2.5.2</easymock.version>
<mockito.version>1.10.19</mockito.version>
<mockito.version>2.7.22</mockito.version>
<jna.version>4.2.1</jna.version>
<hc.stylecheck.version>1</hc.stylecheck.version>
<hc.rat.version>0.12</hc.rat.version>