f279b1
From 85107ca9057cda2ed4d72ba1fd3c2c09be404af6 Mon Sep 17 00:00:00 2001
f279b1
From: Mat Booth <mat.booth@redhat.com>
f279b1
Date: Fri, 7 Dec 2018 19:50:08 +0000
f279b1
Subject: [PATCH] Port to mockito 2
f279b1
f279b1
For details, see:
f279b1
https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2#incompatible
f279b1
---
f279b1
 .../impl/nio/pool/TestBasicNIOConnPool.java   |  2 +-
f279b1
 .../apache/http/nio/pool/TestNIOConnPool.java | 68 +++++++++----------
f279b1
 .../nio/protocol/TestHttpAsyncService.java    |  8 +--
f279b1
 3 files changed, 39 insertions(+), 39 deletions(-)
f279b1
f279b1
diff --git a/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java b/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
f279b1
index 25e2781cf..ee277c69d 100644
f279b1
--- a/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
f279b1
+++ b/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
f279b1
@@ -115,7 +115,7 @@ public void testTimeoutOnLeaseRelease() throws Exception {
f279b1
         Mockito.when(sessionRequest.getAttachment()).thenReturn(host);
f279b1
         Mockito.when(reactor.connect(
f279b1
                 Matchers.any(SocketAddress.class),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.eq(host),
f279b1
                 Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest);
f279b1
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
f279b1
index 9672db6db..20f230acb 100644
f279b1
--- a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
f279b1
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
f279b1
@@ -176,7 +176,7 @@ public void testSuccessfulConnect() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.any(SocketAddress.class),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest);
f279b1
         final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
f279b1
@@ -209,7 +209,7 @@ public void testFailedConnect() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.any(SocketAddress.class),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest);
f279b1
         final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
f279b1
@@ -246,7 +246,7 @@ public void testCencelledConnect() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.any(SocketAddress.class),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest);
f279b1
         Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
f279b1
@@ -285,7 +285,7 @@ public void testTimeoutConnect() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.any(SocketAddress.class),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest);
f279b1
         final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
f279b1
@@ -350,12 +350,12 @@ public void testLeaseRelease() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest2);
f279b1
 
f279b1
@@ -424,12 +424,12 @@ public void testMaxLimits() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest2);
f279b1
 
f279b1
@@ -482,7 +482,7 @@ public void testMaxLimits() throws Exception {
f279b1
         Assert.assertFalse(future9.isDone());
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.release(entry4, true);
f279b1
@@ -494,7 +494,7 @@ public void testMaxLimits() throws Exception {
f279b1
         Assert.assertTrue(future9.isDone());
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(4)).connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
     }
f279b1
 
f279b1
@@ -523,12 +523,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1, sessionRequest2, sessionRequest1);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest3, sessionRequest4, sessionRequest3);
f279b1
 
f279b1
@@ -544,12 +544,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.never()).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.requestCompleted(sessionRequest1);
f279b1
@@ -575,12 +575,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.requestCompleted(sessionRequest3);
f279b1
@@ -603,12 +603,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.release(entry3, true);
f279b1
@@ -616,12 +616,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.requestCompleted(sessionRequest1);
f279b1
@@ -643,12 +643,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         totals = pool.getTotalStats();
f279b1
@@ -677,7 +677,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1, sessionRequest2, sessionRequest3);
f279b1
 
f279b1
@@ -690,7 +690,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.requestCompleted(sessionRequest1);
f279b1
@@ -725,7 +725,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.release(entry3, true);
f279b1
@@ -742,7 +742,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         Mockito.verify(ioSession2).close();
f279b1
@@ -765,7 +765,7 @@ public void testCreateNewIfExpired() throws Exception {
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
f279b1
-                Matchers.any(SocketAddress.class),
f279b1
+                Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1);
f279b1
 
f279b1
@@ -774,7 +774,7 @@ public void testCreateNewIfExpired() throws Exception {
f279b1
         final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
f279b1
 
f279b1
         Mockito.verify(ioReactor, Mockito.times(1)).connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         pool.requestCompleted(sessionRequest1);
f279b1
@@ -794,7 +794,7 @@ public void testCreateNewIfExpired() throws Exception {
f279b1
 
f279b1
         Mockito.verify(ioSession1).close();
f279b1
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
f279b1
 
f279b1
         final PoolStats totals = pool.getTotalStats();
f279b1
@@ -823,7 +823,7 @@ public void testCloseExpired() throws Exception {
f279b1
 
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1, sessionRequest2);
f279b1
 
f279b1
@@ -879,7 +879,7 @@ public void testCloseIdle() throws Exception {
f279b1
 
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1, sessionRequest2);
f279b1
 
f279b1
@@ -944,7 +944,7 @@ public void testLeaseRequestTimeout() throws Exception {
f279b1
 
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1);
f279b1
 
f279b1
@@ -1048,7 +1048,7 @@ public void testLeaseRequestCanceled() throws Exception {
f279b1
 
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1);
f279b1
         Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
f279b1
@@ -1082,7 +1082,7 @@ public void testLeaseRequestCanceledWhileConnecting() throws Exception {
f279b1
 
f279b1
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
f279b1
         Mockito.when(ioReactor.connect(
f279b1
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
f279b1
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
f279b1
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
f279b1
                 thenReturn(sessionRequest1);
f279b1
         Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
f279b1
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
f279b1
index dcb92a629..947b05fa9 100644
f279b1
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
f279b1
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
f279b1
@@ -502,8 +502,8 @@ public void testEntityEnclosingRequestContinueWithoutVerification() throws Excep
f279b1
         Mockito.verify(this.conn).submitResponse(Matchers.argThat(new ArgumentMatcher<HttpResponse>() {
f279b1
 
f279b1
             @Override
f279b1
-            public boolean matches(final Object argument) {
f279b1
-                final int status = ((HttpResponse) argument).getStatusLine().getStatusCode();
f279b1
+            public boolean matches(final HttpResponse argument) {
f279b1
+                final int status = argument.getStatusLine().getStatusCode();
f279b1
                 return status == 100;
f279b1
             }
f279b1
 
f279b1
@@ -1019,8 +1019,8 @@ public void testResponseContinue() throws Exception {
f279b1
         Mockito.verify(this.conn).submitResponse(Matchers.argThat(new ArgumentMatcher<HttpResponse>() {
f279b1
 
f279b1
             @Override
f279b1
-            public boolean matches(final Object argument) {
f279b1
-                final int status = ((HttpResponse) argument).getStatusLine().getStatusCode();
f279b1
+            public boolean matches(final HttpResponse argument) {
f279b1
+                final int status = argument.getStatusLine().getStatusCode();
f279b1
                 return status == 100;
f279b1
             }
f279b1
 
f279b1
-- 
f279b1
2.21.0
f279b1