You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2026/10/08 18:24:57 UTC
(httpcomponents-client) branch master updated: Use Mockito JUnit extension to wire tests with Mockito mocks
This is an automated email from the ASF dual-hosted git repository.
ok2c pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/master by this push:
new e37a0e316 Use Mockito JUnit extension to wire tests with Mockito mocks
e37a0e316 is described below
commit e37a0e316132b83d0b68f517ac7d59a3553123e0
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Oct 8 15:10:10 2026 +0200
Use Mockito JUnit extension to wire tests with Mockito mocks
---
httpclient5-cache/pom.xml | 5 +++++
.../TestAbstractSerializingAsyncCacheStorage.java | 5 +++--
.../http/impl/cache/TestAsyncCachingExecChain.java | 5 +++--
.../http/impl/cache/TestCacheRevalidatorBase.java | 5 +++--
.../http/impl/cache/TestCachingExecChain.java | 9 ++++-----
.../http/impl/cache/TestProtocolAllowedBehavior.java | 5 +++--
.../http/impl/cache/TestProtocolRecommendations.java | 7 ++++---
.../http/impl/cache/TestProtocolRequirements.java | 7 ++++---
.../http/impl/cache/TestRFC5861Compliance.java | 6 +++---
httpclient5/pom.xml | 5 +++++
.../http/impl/async/TestAsyncConnectExec.java | 5 +++--
.../http/impl/async/TestAsyncProtocolExec.java | 5 +++--
.../impl/async/TestContentCompressionAsyncExec.java | 8 +++-----
.../client5/http/impl/classic/TestConnectExec.java | 5 +++--
.../impl/classic/TestContentCompressionExec.java | 5 +++--
.../http/impl/classic/TestHttpRequestRetryExec.java | 6 +++---
.../http/impl/classic/TestInternalExecRuntime.java | 5 +++--
.../http/impl/classic/TestInternalHttpClient.java | 6 +++---
.../http/impl/classic/TestMainClientExec.java | 5 +++--
.../client5/http/impl/classic/TestProtocolExec.java | 20 +++-----------------
.../client5/http/impl/classic/TestRedirectExec.java | 5 +++--
.../http/impl/classic/TestResponseEntityProxy.java | 11 ++++++-----
.../io/TestBasicHttpClientConnectionManager.java | 13 +++++--------
.../io/TestPoolingHttpClientConnectionManager.java | 10 ++++------
.../client5/http/impl/nio/H2SharingConnPoolTest.java | 11 +++--------
.../hc/client5/http/protocol/TestRequestIfRange.java | 5 +++--
pom.xml | 8 +++++---
27 files changed, 96 insertions(+), 96 deletions(-)
diff --git a/httpclient5-cache/pom.xml b/httpclient5-cache/pom.xml
index 6f507a1e8..a09dfa9df 100644
--- a/httpclient5-cache/pom.xml
+++ b/httpclient5-cache/pom.xml
@@ -74,6 +74,11 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
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 2dd5a9243..b345f6f7f 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
@@ -44,14 +44,16 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
+@ExtendWith(MockitoExtension.class)
class TestAbstractSerializingAsyncCacheStorage {
@Mock
@@ -72,7 +74,6 @@ public static byte[] serialize(final String key, final HttpCacheEntry value) thr
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
- MockitoAnnotations.openMocks(this);
impl = Mockito.mock(AbstractBinaryAsyncCacheStorage.class,
Mockito.withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS).useConstructor(3));
}
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsyncCachingExecChain.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsyncCachingExecChain.java
index 61c4146c4..7b41d9cd7 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsyncCachingExecChain.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsyncCachingExecChain.java
@@ -45,11 +45,13 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestAsyncCachingExecChain {
@Mock
@@ -66,7 +68,6 @@ class TestAsyncCachingExecChain {
@BeforeEach
void setUp() {
- MockitoAnnotations.openMocks(this);
final HttpAsyncCache cache = new BasicHttpAsyncCache(
HeapResourceFactory.INSTANCE, new SimpleHttpAsyncCacheStorage());
impl = new AsyncCachingExec(cache, null, CacheConfig.DEFAULT);
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 0370e3a56..f566eab4d 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
@@ -38,10 +38,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestCacheRevalidatorBase {
@Mock
@@ -56,7 +58,6 @@ class TestCacheRevalidatorBase {
@BeforeEach
void setUp() {
- MockitoAnnotations.openMocks(this);
impl = new CacheRevalidatorBase(mockScheduledExecutor, mockSchedulingStrategy);
}
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
index 6af29565a..a9265e5eb 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
@@ -76,13 +76,15 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestCachingExecChain {
- @Mock
+ @Mock(strictness = Mock.Strictness.LENIENT)
ExecChain mockExecChain;
@Mock
ExecRuntime mockExecRuntime;
@@ -103,7 +105,6 @@ class TestCachingExecChain {
@BeforeEach
void setUp() {
- MockitoAnnotations.openMocks(this);
host = new HttpHost("foo.example.com", 80);
route = new HttpRoute(host);
request = new BasicClassicHttpRequest("GET", "/stuff");
@@ -1384,7 +1385,6 @@ void testReturnssetStaleIfErrorNotEnabled() throws Exception {
execute(req1);
Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(resp2);
- Mockito.when(mockExecRuntime.fork(Mockito.any())).thenReturn(mockExecRuntime);
final ClassicHttpResponse result = execute(req2);
Assertions.assertEquals(HttpStatus.SC_OK, result.getCode());
@@ -1424,7 +1424,6 @@ void testReturnssetStaleIfErrorEnabled() throws Exception {
Assertions.assertEquals(HttpStatus.SC_OK, response1.getCode());
// Execute the second request and assert the response
- Mockito.when(mockExecRuntime.fork(Mockito.any())).thenReturn(mockExecRuntime);
Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(resp2);
final ClassicHttpResponse response2 = execute(req2);
Assertions.assertEquals(HttpStatus.SC_OK, response2.getCode());
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java
index f40f318d1..61eeaeeba 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java
@@ -43,14 +43,16 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
/**
* This class tests behavior that is allowed (MAY) by the HTTP/1.1 protocol
* specification and for which we have implemented the behavior in HTTP cache.
*/
+@ExtendWith(MockitoExtension.class)
class TestProtocolAllowedBehavior {
static final int MAX_BYTES = 1024;
@@ -74,7 +76,6 @@ class TestProtocolAllowedBehavior {
@BeforeEach
void setUp() throws Exception {
- MockitoAnnotations.openMocks(this);
host = new HttpHost("foo.example.com", 80);
route = new HttpRoute(host);
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java
index d85abff19..fc37b0a0c 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java
@@ -57,16 +57,18 @@
import org.apache.hc.core5.http.message.MessageSupport;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
/*
* This test class captures functionality required to achieve unconditional
* compliance with the HTTP/1.1 caching protocol (SHOULD, SHOULD NOT,
* RECOMMENDED, and NOT RECOMMENDED behaviors).
*/
+@ExtendWith(MockitoExtension.class)
class TestProtocolRecommendations {
static final int MAX_BYTES = 1024;
@@ -77,7 +79,7 @@ class TestProtocolRecommendations {
HttpRoute route;
HttpEntity body;
HttpCacheContext context;
- @Mock
+ @Mock(strictness = Mock.Strictness.LENIENT)
ExecChain mockExecChain;
@Mock
ExecRuntime mockExecRuntime;
@@ -92,7 +94,6 @@ class TestProtocolRecommendations {
@BeforeEach
void setUp() throws Exception {
- MockitoAnnotations.openMocks(this);
host = new HttpHost("foo.example.com", 80);
route = new HttpRoute(host);
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java
index 1e96940ac..423bdea2e 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java
@@ -62,15 +62,17 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
/*
* This test class captures functionality required to achieve conditional
* compliance with the HTTP/1.1 caching protocol (MUST and MUST NOT behaviors).
*/
+@ExtendWith(MockitoExtension.class)
class TestProtocolRequirements {
static final int MAX_BYTES = 1024;
@@ -81,7 +83,7 @@ class TestProtocolRequirements {
HttpRoute route;
HttpEntity body;
HttpCacheContext context;
- @Mock
+ @Mock(strictness = Mock.Strictness.LENIENT)
ExecChain mockExecChain;
@Mock
ExecRuntime mockExecRuntime;
@@ -95,7 +97,6 @@ class TestProtocolRequirements {
@BeforeEach
void setUp() throws Exception {
- MockitoAnnotations.openMocks(this);
host = new HttpHost("foo.example.com", 80);
route = new HttpRoute(host);
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java
index 1e2bca433..65bf1bcef 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java
@@ -53,15 +53,17 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
/**
* A suite of acceptance tests for compliance with RFC5861, which
* describes the stale-if-error and stale-while-revalidate
* Cache-Control extensions.
*/
+@ExtendWith(MockitoExtension.class)
class TestRFC5861Compliance {
static final int MAX_BYTES = 1024;
@@ -85,7 +87,6 @@ class TestRFC5861Compliance {
@BeforeEach
void setUp() throws Exception {
- MockitoAnnotations.openMocks(this);
host = new HttpHost("foo.example.com", 80);
@@ -110,7 +111,6 @@ void setUp() throws Exception {
executorService = new ScheduledThreadPoolExecutor(1);
Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse);
- Mockito.when(mockExecRuntime.fork(null)).thenReturn(mockExecRuntime);
}
@AfterEach
diff --git a/httpclient5/pom.xml b/httpclient5/pom.xml
index 89ecf3c81..45508e4fa 100644
--- a/httpclient5/pom.xml
+++ b/httpclient5/pom.xml
@@ -104,6 +104,11 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncConnectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncConnectExec.java
index 0551a69f5..14fd8b4a2 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncConnectExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncConnectExec.java
@@ -50,10 +50,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestAsyncConnectExec {
@Mock
@@ -70,7 +72,6 @@ class TestAsyncConnectExec {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
target = new HttpHost("https", "foo", 443);
proxy = new HttpHost("bar", 8888);
}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncProtocolExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncProtocolExec.java
index d9f993969..dff99e94e 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncProtocolExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestAsyncProtocolExec.java
@@ -55,10 +55,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestAsyncProtocolExec {
@Mock
@@ -75,7 +77,6 @@ class TestAsyncProtocolExec {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
protocolExec = new AsyncProtocolExec(targetAuthStrategy, proxyAuthStrategy, null, true);
target = new HttpHost("http", "foo", 80);
}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestContentCompressionAsyncExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestContentCompressionAsyncExec.java
index be055709a..5ccc26bdc 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestContentCompressionAsyncExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/TestContentCompressionAsyncExec.java
@@ -67,10 +67,12 @@
import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestContentCompressionAsyncExec {
@Mock
@@ -90,7 +92,6 @@ class TestContentCompressionAsyncExec {
@BeforeEach
void init() {
- MockitoAnnotations.openMocks(this);
final HttpHost target = new HttpHost("somehost", 80);
final HttpRequest req = new BasicHttpRequest(Method.GET, "/");
@@ -216,9 +217,6 @@ void testContentEncodingExceedsCodecListLenMax() throws Exception {
final EntityDetails details2 = mock(EntityDetails.class);
when(details2.getContentEncoding()).thenReturn("gzip,gzip,gzip,gzip,gzip,gzip");
- final AsyncDataConsumer downstream2 = new StringAsyncEntityConsumer();
- when(originalCb.handleResponse(same(rsp2), same(details2))).thenReturn(downstream2);
-
final ProtocolException exception = assertThrows(ProtocolException.class, () -> cb.handleResponse(rsp2, details2));
assertEquals("Codec list exceeds maximum of 5 elements", exception.getMessage());
}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
index 57a8f1be0..b1266d0c8 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
@@ -60,13 +60,15 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
@SuppressWarnings({"boxing","static-access"}) // test code
+@ExtendWith(MockitoExtension.class)
class TestConnectExec {
@Mock
@@ -86,7 +88,6 @@ class TestConnectExec {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
exec = new ConnectExec(reuseStrategy, proxyHttpProcessor, proxyAuthStrategy, null, true);
target = new HttpHost("foo", 80);
proxy = new HttpHost("bar", 8888);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
index aef6022b9..2e992a556 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java
@@ -46,10 +46,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestContentCompressionExec {
@Mock
@@ -66,7 +68,6 @@ class TestContentCompressionExec {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
host = new HttpHost("somehost", 80);
context = HttpClientContext.create();
scope = new ExecChain.Scope("test", new HttpRoute(host), originaRequest, execRuntime, context);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java
index 006ef9a50..08c440b4a 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java
@@ -48,11 +48,13 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
@SuppressWarnings({"boxing","static-access"}) // test code
+@ExtendWith(MockitoExtension.class)
class TestHttpRequestRetryExec {
@Mock
@@ -69,7 +71,6 @@ class TestHttpRequestRetryExec {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
retryExec = new HttpRequestRetryExec(retryStrategy);
target = new HttpHost("localhost", 80);
}
@@ -126,7 +127,6 @@ void testRetrySleepOnIOException() throws Exception {
Mockito.anyInt(),
Mockito.any())).thenReturn(nextInterval);
Mockito.when(nextInterval.getDuration()).thenReturn(100L);
- Mockito.when(nextInterval.compareTo(Mockito.any())).thenReturn(-1);
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
retryExec.execute(request, scope, chain);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java
index fa2710f67..6fb1dc3b5 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java
@@ -46,12 +46,14 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
@SuppressWarnings({"static-access"}) // test code
+@ExtendWith(MockitoExtension.class)
class TestInternalExecRuntime {
@Mock
@@ -72,7 +74,6 @@ class TestInternalExecRuntime {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
route = new HttpRoute(new HttpHost("host", 80));
execRuntime = new InternalExecRuntime(log, mgr, requestExecutor, cancellableDependency);
}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java
index a6fdbd8b4..5e9e98003 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java
@@ -55,13 +55,15 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
/**
* Simple tests for {@link InternalHttpClient}.
*/
+@ExtendWith(MockitoExtension.class)
class TestInternalHttpClient {
@Mock
@@ -93,7 +95,6 @@ class TestInternalHttpClient {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
client = new InternalHttpClient(connManager, requestExecutor, exchangeIdGenerator,
new ExecChainElement(execChain, null), routePlanner,
cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider,
@@ -249,7 +250,6 @@ void testClientCloseIOException() throws Exception {
void testDoExecuteThrowsWhenNoTargetOrHost() throws Exception {
final ClassicHttpRequest request = ClassicRequestBuilder.get("/foo").build();
final HttpClientContext context = HttpClientContext.create();
- Mockito.when(exchangeIdGenerator.get()).thenReturn(ExecSupport.getNextExchangeId());
Mockito.when(routePlanner.determineRoute(
Mockito.eq(null),
Mockito.any(),
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
index aa58ff126..59eaf67cc 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
@@ -52,10 +52,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestMainClientExec {
@Mock
@@ -76,7 +78,6 @@ class TestMainClientExec {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
mainClientExec = new MainClientExec(connectionManager, httpProcessor, reuseStrategy, keepAliveStrategy, userTokenHandler);
target = new HttpHost("foo", 80);
}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java
index 7bf32fea5..3417e66ff 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java
@@ -57,12 +57,14 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
@SuppressWarnings({"static-access"}) // test code
+@ExtendWith(MockitoExtension.class)
class TestProtocolExec {
@Mock
@@ -76,14 +78,11 @@ class TestProtocolExec {
private ProtocolExec protocolExec;
private HttpHost target;
- private HttpHost proxy;
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
protocolExec = new ProtocolExec(targetAuthStrategy, proxyAuthStrategy, null, true);
target = new HttpHost("foo", 80);
- proxy = new HttpHost("bar", 8888);
}
@Test
@@ -102,11 +101,6 @@ void testPostProcessHttpException() throws Exception {
final ClassicHttpRequest request = new HttpGet("/test");
final HttpClientContext context = HttpClientContext.create();
- final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
-
- Mockito.when(chain.proceed(
- Mockito.any(),
- Mockito.any())).thenReturn(response);
Mockito.doThrow(new HttpException("Ooopsie")).when(chain).proceed(Mockito.any(), Mockito.any());
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
Assertions.assertThrows(HttpException.class, () ->
@@ -120,10 +114,6 @@ void testPostProcessIOException() throws Exception {
final ClassicHttpRequest request = new HttpGet("/test");
final HttpClientContext context = HttpClientContext.create();
- final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
- Mockito.when(chain.proceed(
- Mockito.any(),
- Mockito.any())).thenReturn(response);
Mockito.doThrow(new IOException("Ooopsie")).when(chain).proceed(Mockito.any(), Mockito.any());
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
Assertions.assertThrows(IOException.class, () ->
@@ -137,10 +127,6 @@ void testPostProcessRuntimeException() throws Exception {
final ClassicHttpRequest request = new HttpGet("/test");
final HttpClientContext context = HttpClientContext.create();
- final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
- Mockito.when(chain.proceed(
- Mockito.any(),
- Mockito.any())).thenReturn(response);
Mockito.doThrow(new RuntimeException("Ooopsie")).when(chain).proceed(Mockito.any(), Mockito.any());
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
Assertions.assertThrows(RuntimeException.class, () ->
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
index 45889442e..3d3b9cee1 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
@@ -62,13 +62,15 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestRedirectExec {
@Mock
@@ -84,7 +86,6 @@ class TestRedirectExec {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
target = new HttpHost("localhost", 80);
redirectStrategy = Mockito.spy(new DefaultRedirectStrategy());
redirectExec = new RedirectExec(httpRoutePlanner, redirectStrategy);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java
index 8e83417bc..94af1d88e 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java
@@ -58,24 +58,25 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.LoggerFactory;
+@ExtendWith(MockitoExtension.class)
class TestResponseEntityProxy {
- @Mock
- private ClassicHttpResponse response;
@Mock
private ExecRuntime execRuntime;
- @Mock
+ @Mock(strictness = Mock.Strictness.LENIENT)
+ private ClassicHttpResponse response;
+ @Mock(strictness = Mock.Strictness.LENIENT)
private HttpEntity entity;
@BeforeEach
void setUp() {
- MockitoAnnotations.openMocks(this);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
Mockito.when(response.getEntity()).thenReturn(entity);
}
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java
index 8bcacfaef..c9c969caa 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java
@@ -56,10 +56,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestBasicHttpClientConnectionManager {
@Mock
@@ -85,7 +87,6 @@ class TestBasicHttpClientConnectionManager {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
mgr = new BasicHttpClientConnectionManager(new DefaultHttpClientConnectionOperator(
detachedSocketFactory, schemePortResolver, dnsResolver, tlsSocketStrategyLookup),
connFactory);
@@ -393,7 +394,7 @@ void testTargetConnect() throws Exception {
Mockito.when(tlsSocketStrategy.upgrade(
Mockito.same(socket),
Mockito.eq("somehost"),
- Mockito.eq(8443),
+ Mockito.eq(443),
Mockito.any(),
Mockito.any())).thenReturn(upgradedSocket);
@@ -444,7 +445,7 @@ void testProxyConnectAndUpgrade() throws Exception {
Mockito.when(dnsResolver.resolve("someproxy", 8080)).thenReturn(Collections.singletonList(new InetSocketAddress(remote, 8080)));
Mockito.when(schemePortResolver.resolve(proxy.getSchemeName(), proxy)).thenReturn(8080);
- Mockito.when(schemePortResolver.resolve(target.getSchemeName(), target)).thenReturn(8443);
+ Mockito.when(tlsSocketStrategyLookup.lookup("http")).thenReturn(null);
Mockito.when(tlsSocketStrategyLookup.lookup("https")).thenReturn(tlsSocketStrategy);
Mockito.when(detachedSocketFactory.create(Mockito.any(), Mockito.any())).thenReturn(socket);
@@ -486,7 +487,6 @@ void shouldCloseStaleConnectionAndCreateNewOne() throws Exception {
Assertions.assertNull(mgr.getState());
final LeaseRequest connRequest2 = mgr.lease("some-id", route, null);
- Mockito.when(conn.isStale()).thenReturn(Boolean.TRUE);
final ConnectionEndpoint conn2 = connRequest2.get(Timeout.ZERO_MILLISECONDS);
Assertions.assertNotNull(conn2);
Assertions.assertTrue(conn2.isConnected());
@@ -516,9 +516,6 @@ void shouldCloseGRACEFULStaleConnection() throws Exception {
// Ensure the connection was closed
Mockito.verify(conn, Mockito.times(1)).close(CloseMode.GRACEFUL);
- // Now, when a new lease request is made, the connection is stale
- Mockito.when(conn.isStale()).thenReturn(Boolean.TRUE);
-
// Attempt to lease a new connection
final LeaseRequest connRequest2 = mgr.lease("some-id", route, null);
final ConnectionEndpoint endpoint2 = connRequest2.get(Timeout.ZERO_MILLISECONDS);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java
index 62f9f7c24..b04562675 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java
@@ -61,13 +61,15 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
/**
* {@link PoolingHttpClientConnectionManager} tests.
*/
+@ExtendWith(MockitoExtension.class)
class TestPoolingHttpClientConnectionManager {
@Mock
@@ -95,7 +97,6 @@ class TestPoolingHttpClientConnectionManager {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
mgr = new PoolingHttpClientConnectionManager(new DefaultHttpClientConnectionOperator(
detachedSocketFactory, schemePortResolver, dnsResolver, tlsSocketStrategyLookup), pool,
null);
@@ -338,7 +339,7 @@ void testProxyConnectAndUpgrade() throws Exception {
Mockito.when(dnsResolver.resolve("someproxy", 8080)).thenReturn(Collections.singletonList(new InetSocketAddress(remote, 8080)));
Mockito.when(schemePortResolver.resolve(proxy.getSchemeName(), proxy)).thenReturn(8080);
- Mockito.when(schemePortResolver.resolve(target.getSchemeName(), target)).thenReturn(8443);
+ Mockito.when(tlsSocketStrategyLookup.lookup("http")).thenReturn(null);
Mockito.when(tlsSocketStrategyLookup.lookup("https")).thenReturn(tlsSocketStrategy);
Mockito.when(detachedSocketFactory.create(Mockito.any(), Mockito.any())).thenReturn(socket);
@@ -383,9 +384,6 @@ void testLeaseAfterShutdown() {
@Test
void testIsShutdown() {
- // Setup phase
- Mockito.when(pool.isShutdown()).thenReturn(false, true); // Simulate changing states
-
// Execution phase: Initially, the manager should not be shutdown
Assertions.assertFalse(mgr.isClosed(), "Connection manager should not be shutdown initially.");
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/nio/H2SharingConnPoolTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/nio/H2SharingConnPoolTest.java
index 077db0ff8..2215b6707 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/nio/H2SharingConnPoolTest.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/nio/H2SharingConnPoolTest.java
@@ -40,10 +40,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
public class H2SharingConnPoolTest {
static final String DEFAULT_ROUTE = "DEFAULT_ROUTE";
@@ -58,7 +60,6 @@ public class H2SharingConnPoolTest {
@BeforeEach
void setup() {
- MockitoAnnotations.openMocks(this);
h2SharingPool = new H2SharingConnPool<>(connPool);
}
@@ -258,7 +259,6 @@ void testLeaseWithStateNewConnectionReturnedAndNotCached() throws Exception {
final PoolEntry<String, HttpConnection> poolEntry = new PoolEntry<>(DEFAULT_ROUTE);
poolEntry.assignConnection(connection);
- Mockito.when(connection.getProtocolVersion()).thenReturn(HttpVersion.HTTP_2);
future.completed(poolEntry);
Assertions.assertTrue(result.isDone());
@@ -279,7 +279,6 @@ void testLeaseWithStateNewConnectionReturnedAndNotCached() throws Exception {
void testReleaseReusableNoCacheReturnedToPool() throws Exception {
final PoolEntry<String, HttpConnection> poolEntry = new PoolEntry<>(DEFAULT_ROUTE);
poolEntry.assignConnection(connection);
- Mockito.when(connection.isOpen()).thenReturn(true);
h2SharingPool.release(poolEntry, true);
@@ -292,7 +291,6 @@ void testReleaseReusableNoCacheReturnedToPool() throws Exception {
void testReleaseReusableNotInCacheReturnedToPool() throws Exception {
final PoolEntry<String, HttpConnection> poolEntry = new PoolEntry<>(DEFAULT_ROUTE);
poolEntry.assignConnection(connection);
- Mockito.when(connection.isOpen()).thenReturn(true);
final H2SharingConnPool.PerRoutePool<String, HttpConnection> routePool = h2SharingPool.getPerRoutePool(DEFAULT_ROUTE);
routePool.track(poolEntry);
@@ -307,7 +305,6 @@ void testReleaseReusableNotInCacheReturnedToPool() throws Exception {
void testReleaseReusableInCacheNotReturnedToPool() throws Exception {
final PoolEntry<String, HttpConnection> poolEntry = new PoolEntry<>(DEFAULT_ROUTE);
poolEntry.assignConnection(connection);
- Mockito.when(connection.isOpen()).thenReturn(true);
final H2SharingConnPool.PerRoutePool<String, HttpConnection> routePool = h2SharingPool.getPerRoutePool(DEFAULT_ROUTE);
routePool.track(poolEntry);
routePool.track(poolEntry);
@@ -330,7 +327,6 @@ void testReleaseReusableInCacheNotReturnedToPool() throws Exception {
void testReleaseNonReusableNotInCacheReturnedToPool() throws Exception {
final PoolEntry<String, HttpConnection> poolEntry = new PoolEntry<>(DEFAULT_ROUTE);
poolEntry.assignConnection(connection);
- Mockito.when(connection.isOpen()).thenReturn(false);
final H2SharingConnPool.PerRoutePool<String, HttpConnection> routePool = h2SharingPool.getPerRoutePool(DEFAULT_ROUTE);
routePool.track(poolEntry);
routePool.track(poolEntry);
@@ -374,7 +370,6 @@ void testLeasePoolClosed() throws Exception {
void testReleasePoolClosed() throws Exception {
final PoolEntry<String, HttpConnection> poolEntry = new PoolEntry<>(DEFAULT_ROUTE);
poolEntry.assignConnection(connection);
- Mockito.when(connection.isOpen()).thenReturn(false);
final H2SharingConnPool.PerRoutePool<String, HttpConnection> routePool = h2SharingPool.getPerRoutePool(DEFAULT_ROUTE);
routePool.track(poolEntry);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestIfRange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestIfRange.java
index 89acd0993..ef91b0d0e 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestIfRange.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestIfRange.java
@@ -42,9 +42,11 @@
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
+@ExtendWith(MockitoExtension.class)
class TestRequestIfRange {
@Mock
private HttpRequest request;
@@ -59,7 +61,6 @@ class TestRequestIfRange {
@BeforeEach
void setUp() {
- MockitoAnnotations.openMocks(this);
requestIfRange = new RequestIfRange();
}
diff --git a/pom.xml b/pom.xml
index 0a5897670..9fdc85403 100644
--- a/pom.xml
+++ b/pom.xml
@@ -193,7 +193,6 @@
<groupId>io.reactivex.rxjava3</groupId>
<artifactId>rxjava</artifactId>
<version>${rxjava3.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
@@ -212,7 +211,11 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
- <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
@@ -258,7 +261,6 @@
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing</artifactId>
<version>${micrometer.tracing.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>