summaryrefslogtreecommitdiff
path: root/0001-Port-to-mockito-2.patch
blob: 78aeb3d7901faa01ab5bcf487c8e8804734f4dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
From 85107ca9057cda2ed4d72ba1fd3c2c09be404af6 Mon Sep 17 00:00:00 2001
From: Mat Booth <mat.booth@redhat.com>
Date: Fri, 7 Dec 2018 19:50:08 +0000
Subject: [PATCH] Port to mockito 2

For details, see:
https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2#incompatible
---
 .../impl/nio/pool/TestBasicNIOConnPool.java   |  2 +-
 .../apache/http/nio/pool/TestNIOConnPool.java | 68 +++++++++----------
 .../nio/protocol/TestHttpAsyncService.java    |  8 +--
 3 files changed, 39 insertions(+), 39 deletions(-)

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
index 25e2781cf..ee277c69d 100644
--- 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
@@ -115,7 +115,7 @@ public void testTimeoutOnLeaseRelease() throws Exception {
         Mockito.when(sessionRequest.getAttachment()).thenReturn(host);
         Mockito.when(reactor.connect(
                 Matchers.any(SocketAddress.class),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.eq(host),
                 Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest);
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
index 9672db6db..20f230acb 100644
--- 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
@@ -176,7 +176,7 @@ public void testSuccessfulConnect() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.any(SocketAddress.class),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest);
         final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
@@ -209,7 +209,7 @@ public void testFailedConnect() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.any(SocketAddress.class),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest);
         final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
@@ -246,7 +246,7 @@ public void testCencelledConnect() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.any(SocketAddress.class),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest);
         Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
@@ -285,7 +285,7 @@ public void testTimeoutConnect() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.any(SocketAddress.class),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest);
         final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
@@ -350,12 +350,12 @@ public void testLeaseRelease() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest2);
 
@@ -424,12 +424,12 @@ public void testMaxLimits() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest2);
 
@@ -482,7 +482,7 @@ public void testMaxLimits() throws Exception {
         Assert.assertFalse(future9.isDone());
 
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.release(entry4, true);
@@ -494,7 +494,7 @@ public void testMaxLimits() throws Exception {
         Assert.assertTrue(future9.isDone());
 
         Mockito.verify(ioReactor, Mockito.times(4)).connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
     }
 
@@ -523,12 +523,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1, sessionRequest2, sessionRequest1);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest3, sessionRequest4, sessionRequest3);
 
@@ -544,12 +544,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         Mockito.verify(ioReactor, Mockito.never()).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.requestCompleted(sessionRequest1);
@@ -575,12 +575,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.requestCompleted(sessionRequest3);
@@ -603,12 +603,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.release(entry3, true);
@@ -616,12 +616,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
 
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.requestCompleted(sessionRequest1);
@@ -643,12 +643,12 @@ public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
 
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         totals = pool.getTotalStats();
@@ -677,7 +677,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1, sessionRequest2, sessionRequest3);
 
@@ -690,7 +690,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.requestCompleted(sessionRequest1);
@@ -725,7 +725,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
 
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.release(entry3, true);
@@ -742,7 +742,7 @@ public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exce
 
         Mockito.verify(ioReactor, Mockito.times(3)).connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         Mockito.verify(ioSession2).close();
@@ -765,7 +765,7 @@ public void testCreateNewIfExpired() throws Exception {
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
                 Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
-                Matchers.any(SocketAddress.class),
+                Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1);
 
@@ -774,7 +774,7 @@ public void testCreateNewIfExpired() throws Exception {
         final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
 
         Mockito.verify(ioReactor, Mockito.times(1)).connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         pool.requestCompleted(sessionRequest1);
@@ -794,7 +794,7 @@ public void testCreateNewIfExpired() throws Exception {
 
         Mockito.verify(ioSession1).close();
         Mockito.verify(ioReactor, Mockito.times(2)).connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class));
 
         final PoolStats totals = pool.getTotalStats();
@@ -823,7 +823,7 @@ public void testCloseExpired() throws Exception {
 
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1, sessionRequest2);
 
@@ -879,7 +879,7 @@ public void testCloseIdle() throws Exception {
 
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1, sessionRequest2);
 
@@ -944,7 +944,7 @@ public void testLeaseRequestTimeout() throws Exception {
 
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1);
 
@@ -1048,7 +1048,7 @@ public void testLeaseRequestCanceled() throws Exception {
 
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1);
         Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
@@ -1082,7 +1082,7 @@ public void testLeaseRequestCanceledWhileConnecting() throws Exception {
 
         final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
         Mockito.when(ioReactor.connect(
-                Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
+                Matchers.any(SocketAddress.class), Matchers.<SocketAddress>isNull(),
                 Matchers.any(), Matchers.any(SessionRequestCallback.class))).
                 thenReturn(sessionRequest1);
         Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
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
index dcb92a629..947b05fa9 100644
--- 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
@@ -502,8 +502,8 @@ public void testEntityEnclosingRequestContinueWithoutVerification() throws Excep
         Mockito.verify(this.conn).submitResponse(Matchers.argThat(new ArgumentMatcher<HttpResponse>() {
 
             @Override
-            public boolean matches(final Object argument) {
-                final int status = ((HttpResponse) argument).getStatusLine().getStatusCode();
+            public boolean matches(final HttpResponse argument) {
+                final int status = argument.getStatusLine().getStatusCode();
                 return status == 100;
             }
 
@@ -1019,8 +1019,8 @@ public void testResponseContinue() throws Exception {
         Mockito.verify(this.conn).submitResponse(Matchers.argThat(new ArgumentMatcher<HttpResponse>() {
 
             @Override
-            public boolean matches(final Object argument) {
-                final int status = ((HttpResponse) argument).getStatusLine().getStatusCode();
+            public boolean matches(final HttpResponse argument) {
+                final int status = argument.getStatusLine().getStatusCode();
                 return status == 100;
             }
 
-- 
2.21.0