Upgraded Mockito to version 3.10.0
This commit is contained in:
parent
e02467e363
commit
2072651983
|
@ -63,13 +63,15 @@ import org.apache.hc.core5.http.protocol.HttpProcessor;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
@SuppressWarnings({"boxing","static-access"}) // test code
|
@SuppressWarnings({"boxing","static-access"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestConnectExec {
|
public class TestConnectExec {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -89,7 +91,6 @@ public class TestConnectExec {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
exec = new ConnectExec(reuseStrategy, proxyHttpProcessor, proxyAuthStrategy);
|
exec = new ConnectExec(reuseStrategy, proxyHttpProcessor, proxyAuthStrategy);
|
||||||
target = new HttpHost("foo", 80);
|
target = new HttpHost("foo", 80);
|
||||||
proxy = new HttpHost("bar", 8888);
|
proxy = new HttpHost("bar", 8888);
|
||||||
|
@ -107,14 +108,6 @@ public class TestConnectExec {
|
||||||
context.setUserToken("Blah");
|
context.setUserToken("Blah");
|
||||||
|
|
||||||
Mockito.when(execRuntime.isEndpointAcquired()).thenReturn(false);
|
Mockito.when(execRuntime.isEndpointAcquired()).thenReturn(false);
|
||||||
Mockito.when(execRuntime.execute(
|
|
||||||
Mockito.eq("test"),
|
|
||||||
Mockito.same(request),
|
|
||||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
|
||||||
Mockito.when(reuseStrategy.keepAlive(
|
|
||||||
Mockito.same(request),
|
|
||||||
Mockito.same(response),
|
|
||||||
Mockito.<HttpClientContext>any())).thenReturn(false);
|
|
||||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||||
exec.execute(request, scope, execChain);
|
exec.execute(request, scope, execChain);
|
||||||
Mockito.verify(execRuntime).acquireEndpoint("test", route, "Blah", context);
|
Mockito.verify(execRuntime).acquireEndpoint("test", route, "Blah", context);
|
||||||
|
|
|
@ -52,11 +52,13 @@ import org.apache.hc.core5.util.Timeout;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
@SuppressWarnings({"boxing","static-access"}) // test code
|
@SuppressWarnings({"boxing","static-access"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestHttpRequestRetryExec {
|
public class TestHttpRequestRetryExec {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -71,7 +73,6 @@ public class TestHttpRequestRetryExec {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
retryExec = new HttpRequestRetryExec(retryStrategy);
|
retryExec = new HttpRequestRetryExec(retryStrategy);
|
||||||
target = new HttpHost("localhost", 80);
|
target = new HttpHost("localhost", 80);
|
||||||
}
|
}
|
||||||
|
@ -207,10 +208,6 @@ public class TestHttpRequestRetryExec {
|
||||||
Mockito.when(chain.proceed(
|
Mockito.when(chain.proceed(
|
||||||
Mockito.<ClassicHttpRequest>any(),
|
Mockito.<ClassicHttpRequest>any(),
|
||||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||||
Mockito.when(retryStrategy.retryRequest(
|
|
||||||
Mockito.<HttpResponse>any(),
|
|
||||||
Mockito.anyInt(),
|
|
||||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
|
||||||
|
|
||||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||||
final ClassicHttpResponse finalResponse = retryExec.execute(request, scope, chain);
|
final ClassicHttpResponse finalResponse = retryExec.execute(request, scope, chain);
|
||||||
|
@ -303,11 +300,6 @@ public class TestHttpRequestRetryExec {
|
||||||
req.getEntity().writeTo(new ByteArrayOutputStream());
|
req.getEntity().writeTo(new ByteArrayOutputStream());
|
||||||
throw new IOException("Ka-boom");
|
throw new IOException("Ka-boom");
|
||||||
});
|
});
|
||||||
Mockito.when(retryStrategy.retryRequest(
|
|
||||||
Mockito.<HttpRequest>any(),
|
|
||||||
Mockito.<IOException>any(),
|
|
||||||
Mockito.eq(1),
|
|
||||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE);
|
|
||||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, originalRequest, endpoint, context);
|
final ExecChain.Scope scope = new ExecChain.Scope("test", route, originalRequest, endpoint, context);
|
||||||
final ClassicHttpRequest request = ClassicRequestBuilder.copy(originalRequest).build();
|
final ClassicHttpRequest request = ClassicRequestBuilder.copy(originalRequest).build();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -47,12 +47,14 @@ import org.apache.hc.core5.util.Timeout;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@SuppressWarnings({"static-access"}) // test code
|
@SuppressWarnings({"static-access"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestInternalExecRuntime {
|
public class TestInternalExecRuntime {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -73,7 +75,6 @@ public class TestInternalExecRuntime {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
route = new HttpRoute(new HttpHost("host", 80));
|
route = new HttpRoute(new HttpHost("host", 80));
|
||||||
execRuntime = new InternalExecRuntime(log, mgr, requestExecutor, cancellableDependency);
|
execRuntime = new InternalExecRuntime(log, mgr, requestExecutor, cancellableDependency);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,14 +51,16 @@ import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple tests for {@link InternalHttpClient}.
|
* Simple tests for {@link InternalHttpClient}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"static-access"}) // test code
|
@SuppressWarnings({"static-access"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestInternalHttpClient {
|
public class TestInternalHttpClient {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -88,7 +90,6 @@ public class TestInternalHttpClient {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
client = new InternalHttpClient(connManager, requestExecutor, new ExecChainElement(execChain, null), routePlanner,
|
client = new InternalHttpClient(connManager, requestExecutor, new ExecChainElement(execChain, null), routePlanner,
|
||||||
cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider,
|
cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider,
|
||||||
defaultConfig, Arrays.asList(closeable1, closeable2));
|
defaultConfig, Arrays.asList(closeable1, closeable2));
|
||||||
|
|
|
@ -50,12 +50,14 @@ import org.apache.hc.core5.util.TimeValue;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
@SuppressWarnings({"boxing","static-access"}) // test code
|
@SuppressWarnings({"boxing","static-access"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestMainClientExec {
|
public class TestMainClientExec {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -74,7 +76,6 @@ public class TestMainClientExec {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mainClientExec = new MainClientExec(connectionManager, reuseStrategy, keepAliveStrategy, userTokenHandler);
|
mainClientExec = new MainClientExec(connectionManager, reuseStrategy, keepAliveStrategy, userTokenHandler);
|
||||||
target = new HttpHost("foo", 80);
|
target = new HttpHost("foo", 80);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +90,6 @@ public class TestMainClientExec {
|
||||||
.setStream(new ByteArrayInputStream(new byte[]{}))
|
.setStream(new ByteArrayInputStream(new byte[]{}))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
Mockito.when(endpoint.isEndpointAcquired()).thenReturn(false);
|
|
||||||
Mockito.when(endpoint.execute(
|
Mockito.when(endpoint.execute(
|
||||||
Mockito.anyString(),
|
Mockito.anyString(),
|
||||||
Mockito.same(request),
|
Mockito.same(request),
|
||||||
|
@ -118,7 +118,6 @@ public class TestMainClientExec {
|
||||||
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
|
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
|
||||||
response.setEntity(null);
|
response.setEntity(null);
|
||||||
|
|
||||||
Mockito.when(endpoint.isEndpointAcquired()).thenReturn(false);
|
|
||||||
Mockito.when(endpoint.execute(
|
Mockito.when(endpoint.execute(
|
||||||
Mockito.anyString(),
|
Mockito.anyString(),
|
||||||
Mockito.same(request),
|
Mockito.same(request),
|
||||||
|
@ -151,8 +150,6 @@ public class TestMainClientExec {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
final ConnectionState connectionState = new ConnectionState();
|
final ConnectionState connectionState = new ConnectionState();
|
||||||
Mockito.doAnswer(connectionState.connectAnswer()).when(endpoint).connectEndpoint(Mockito.<HttpClientContext>any());
|
|
||||||
Mockito.when(endpoint.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
|
||||||
Mockito.when(endpoint.execute(
|
Mockito.when(endpoint.execute(
|
||||||
Mockito.anyString(),
|
Mockito.anyString(),
|
||||||
Mockito.same(request),
|
Mockito.same(request),
|
||||||
|
@ -183,9 +180,6 @@ public class TestMainClientExec {
|
||||||
final ClassicHttpRequest request = new HttpGet("http://bar/test");
|
final ClassicHttpRequest request = new HttpGet("http://bar/test");
|
||||||
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
|
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
|
||||||
|
|
||||||
final ConnectionState connectionState = new ConnectionState();
|
|
||||||
Mockito.doAnswer(connectionState.connectAnswer()).when(endpoint).connectEndpoint(Mockito.<HttpClientContext>any());
|
|
||||||
Mockito.when(endpoint.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
|
||||||
Mockito.when(endpoint.execute(
|
Mockito.when(endpoint.execute(
|
||||||
Mockito.anyString(),
|
Mockito.anyString(),
|
||||||
Mockito.same(request),
|
Mockito.same(request),
|
||||||
|
@ -220,8 +214,6 @@ public class TestMainClientExec {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
final ConnectionState connectionState = new ConnectionState();
|
final ConnectionState connectionState = new ConnectionState();
|
||||||
Mockito.doAnswer(connectionState.connectAnswer()).when(endpoint).connectEndpoint(Mockito.<HttpClientContext>any());
|
|
||||||
Mockito.when(endpoint.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
|
||||||
Mockito.when(endpoint.execute(
|
Mockito.when(endpoint.execute(
|
||||||
Mockito.anyString(),
|
Mockito.anyString(),
|
||||||
Mockito.same(request),
|
Mockito.same(request),
|
||||||
|
|
|
@ -67,12 +67,14 @@ import org.apache.hc.core5.http.protocol.HttpProcessor;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
@SuppressWarnings({"static-access"}) // test code
|
@SuppressWarnings({"static-access"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestProtocolExec {
|
public class TestProtocolExec {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -92,7 +94,6 @@ public class TestProtocolExec {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
protocolExec = new ProtocolExec(httpProcessor, targetAuthStrategy, proxyAuthStrategy);
|
protocolExec = new ProtocolExec(httpProcessor, targetAuthStrategy, proxyAuthStrategy);
|
||||||
target = new HttpHost("foo", 80);
|
target = new HttpHost("foo", 80);
|
||||||
proxy = new HttpHost("bar", 8888);
|
proxy = new HttpHost("bar", 8888);
|
||||||
|
@ -323,11 +324,6 @@ public class TestProtocolExec {
|
||||||
return response1;
|
return response1;
|
||||||
});
|
});
|
||||||
|
|
||||||
Mockito.when(targetAuthStrategy.select(
|
|
||||||
Mockito.eq(ChallengeType.TARGET),
|
|
||||||
Mockito.<Map<String, AuthChallenge>>any(),
|
|
||||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
|
||||||
|
|
||||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||||
final ClassicHttpResponse response = protocolExec.execute(request, scope, chain);
|
final ClassicHttpResponse response = protocolExec.execute(request, scope, chain);
|
||||||
Assert.assertEquals(401, response.getCode());
|
Assert.assertEquals(401, response.getCode());
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
|
|
||||||
package org.apache.hc.client5.http.impl.classic;
|
package org.apache.hc.client5.http.impl.classic;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.hc.client5.http.classic.ExecRuntime;
|
import org.apache.hc.client5.http.classic.ExecRuntime;
|
||||||
import org.apache.hc.core5.function.Supplier;
|
import org.apache.hc.core5.function.Supplier;
|
||||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||||
|
@ -38,15 +42,13 @@ import org.apache.hc.core5.http.io.SessionInputBuffer;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestResponseEntityProxy {
|
public class TestResponseEntityProxy {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -58,7 +60,6 @@ public class TestResponseEntityProxy {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
|
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
|
||||||
Mockito.when(response.getEntity()).thenReturn(entity);
|
Mockito.when(response.getEntity()).thenReturn(entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,13 @@ import org.apache.hc.core5.util.Timeout;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
@SuppressWarnings({"boxing","static-access"}) // test code
|
@SuppressWarnings({"boxing","static-access"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestBasicHttpClientConnectionManager {
|
public class TestBasicHttpClientConnectionManager {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -79,7 +81,6 @@ public class TestBasicHttpClientConnectionManager {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mgr = new BasicHttpClientConnectionManager(
|
mgr = new BasicHttpClientConnectionManager(
|
||||||
socketFactoryRegistry, connFactory, schemePortResolver, dnsResolver);
|
socketFactoryRegistry, connFactory, schemePortResolver, dnsResolver);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,14 +56,16 @@ import org.apache.hc.core5.util.Timeout;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link PoolingHttpClientConnectionManager} tests.
|
* {@link PoolingHttpClientConnectionManager} tests.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"boxing","static-access","resource"}) // test code
|
@SuppressWarnings({"boxing","static-access","resource"}) // test code
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestPoolingHttpClientConnectionManager {
|
public class TestPoolingHttpClientConnectionManager {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -88,7 +90,6 @@ public class TestPoolingHttpClientConnectionManager {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mgr = new PoolingHttpClientConnectionManager(
|
mgr = new PoolingHttpClientConnectionManager(
|
||||||
new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver), pool, null);
|
new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver), pool, null);
|
||||||
}
|
}
|
||||||
|
@ -102,9 +103,6 @@ public class TestPoolingHttpClientConnectionManager {
|
||||||
entry.assignConnection(conn);
|
entry.assignConnection(conn);
|
||||||
|
|
||||||
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
|
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
|
||||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
|
||||||
Mockito.when(schemePortResolver.resolve(target)).thenReturn(80);
|
|
||||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
|
||||||
|
|
||||||
Mockito.when(conn.isOpen()).thenReturn(true);
|
Mockito.when(conn.isOpen()).thenReturn(true);
|
||||||
Mockito.when(conn.isConsistent()).thenReturn(true);
|
Mockito.when(conn.isConsistent()).thenReturn(true);
|
||||||
|
@ -135,11 +133,7 @@ public class TestPoolingHttpClientConnectionManager {
|
||||||
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
|
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
|
||||||
|
|
||||||
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
|
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
|
||||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
|
||||||
Mockito.when(schemePortResolver.resolve(target)).thenReturn(80);
|
|
||||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
|
||||||
|
|
||||||
Mockito.when(conn.isOpen()).thenReturn(true);
|
|
||||||
Mockito.when(future.isCancelled()).thenReturn(false);
|
Mockito.when(future.isCancelled()).thenReturn(false);
|
||||||
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
|
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
|
||||||
Mockito.when(pool.lease(
|
Mockito.when(pool.lease(
|
||||||
|
@ -185,7 +179,6 @@ public class TestPoolingHttpClientConnectionManager {
|
||||||
final HttpHost target = new HttpHost("localhost", 80);
|
final HttpHost target = new HttpHost("localhost", 80);
|
||||||
final HttpRoute route = new HttpRoute(target);
|
final HttpRoute route = new HttpRoute(target);
|
||||||
|
|
||||||
Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
|
|
||||||
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenThrow(new TimeoutException());
|
Mockito.when(future.get(1, TimeUnit.SECONDS)).thenThrow(new TimeoutException());
|
||||||
Mockito.when(pool.lease(
|
Mockito.when(pool.lease(
|
||||||
Mockito.eq(route),
|
Mockito.eq(route),
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -71,7 +71,7 @@
|
||||||
<slf4j.version>1.7.25</slf4j.version>
|
<slf4j.version>1.7.25</slf4j.version>
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<easymock.version>3.6</easymock.version>
|
<easymock.version>3.6</easymock.version>
|
||||||
<mockito.version>2.23.0</mockito.version>
|
<mockito.version>3.10.0</mockito.version>
|
||||||
<jna.version>5.2.0</jna.version>
|
<jna.version>5.2.0</jna.version>
|
||||||
<hc.stylecheck.version>1</hc.stylecheck.version>
|
<hc.stylecheck.version>1</hc.stylecheck.version>
|
||||||
<rxjava.version>2.2.7</rxjava.version>
|
<rxjava.version>2.2.7</rxjava.version>
|
||||||
|
|
Loading…
Reference in New Issue