summaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@verizonmedia.com>2019-10-18 15:19:59 +0200
committerHåkon Hallingstad <hakon@verizonmedia.com>2019-10-18 15:19:59 +0200
commit579754fa5b5f4768a75fc3aed08f70ffb29db0e3 (patch)
tree825e5366b8253535bb9366722006ef49c6e83c53 /vespa-http-client
parent19ab63311c9354db919a9a9ac38d34342e1ca204 (diff)
Use mockito-core 3.1.0
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java12
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnectionTest.java3
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/EndpointResultQueueTest.java8
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java23
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/IncompleteResultsThrottlerTest.java6
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java4
6 files changed, 28 insertions, 28 deletions
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java
index e71c54672a9..9abbf916cff 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.http.client.core;
import com.yahoo.vespa.http.client.FeedClient;
import org.apache.commons.lang3.StringEscapeUtils;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -11,11 +10,8 @@ import org.xml.sax.SAXParseException;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -24,8 +20,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -138,7 +134,7 @@ public class XmlFeedReaderTest {
assertThat(docId, is("id:&"));
return null;
}
- }).when(feedClient).stream(anyString(), anyObject());
+ }).when(feedClient).stream(anyString(), any());
XmlFeedReader.read(stream, feedClient, numSent);
assertThat(numSent.get(), is(1));
}
@@ -180,7 +176,7 @@ public class XmlFeedReaderTest {
success.set(true);
return null;
}
- }).when(feedClient).stream(anyString(), anyObject());
+ }).when(feedClient).stream(anyString(), any());
XmlFeedReader.read(stream, feedClient, numSent);
assertThat(numSent.get(), is(1));
assert(success.get());
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnectionTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnectionTest.java
index 90d2fa28833..d49f4093a06 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnectionTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnectionTest.java
@@ -38,7 +38,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.stub;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -306,7 +305,7 @@ public class ApacheGatewayConnectionTest {
mock(ApacheGatewayConnection.HttpClientFactory.class);
HttpClient httpClientMock = mock(HttpClient.class);
when(mockFactory.createClient()).thenReturn(httpClientMock);
- stub(httpClientMock.execute(any())).toAnswer((Answer) invocation -> {
+ when(httpClientMock.execute(any())).thenAnswer((Answer) invocation -> {
Object[] args = invocation.getArguments();
HttpPost post = (HttpPost) args[0];
return httpExecuteMock.execute(post);
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/EndpointResultQueueTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/EndpointResultQueueTest.java
index 4af0b7db07e..0005bddeb73 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/EndpointResultQueueTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/EndpointResultQueueTest.java
@@ -14,8 +14,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -35,7 +35,7 @@ public class EndpointResultQueueTest {
doAnswer(invocationOnMock -> {
resultCount.getAndIncrement();
return null;
- }).when(mockAggregator).resultReceived(anyObject(), eq(0));
+ }).when(mockAggregator).resultReceived(any(), eq(0));
EndpointResultQueue q = new EndpointResultQueue(
mockAggregator, endpoint, 0, new ScheduledThreadPoolExecutor(1), 100L * 1000L);
@@ -79,7 +79,7 @@ public class EndpointResultQueueTest {
doAnswer(invocationOnMock -> {
latch.countDown();
return null;
- }).when(mockAggregator).resultReceived(anyObject(), eq(0));
+ }).when(mockAggregator).resultReceived(any(), eq(0));
EndpointResultQueue q = new EndpointResultQueue(
mockAggregator, endpoint, 0, new ScheduledThreadPoolExecutor(1), 100L);
q.operationSent("1234");
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
index 5a4c6d05185..4fb66082cf4 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
@@ -9,7 +9,6 @@ import com.yahoo.vespa.http.client.V3HttpAPITest;
import com.yahoo.vespa.http.client.config.Endpoint;
import com.yahoo.vespa.http.client.core.Document;
import com.yahoo.vespa.http.client.core.EndpointResult;
-
import com.yahoo.vespa.http.client.core.ServerResponseException;
import org.junit.Test;
@@ -28,9 +27,13 @@ import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.*;
+import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class IOThreadTest {
@@ -71,7 +74,7 @@ public class IOThreadTest {
latch.countDown();
return null;
- }).when(endpointResultQueue).failOperation(anyObject(), eq(0));
+ }).when(endpointResultQueue).failOperation(any(), eq(0));
doAnswer(invocation -> {
EndpointResult endpointResult = (EndpointResult) invocation.getArguments()[0];
@@ -79,7 +82,7 @@ public class IOThreadTest {
assertThat(endpointResult.getDetail().getResultType(), is(Result.ResultType.OPERATION_EXECUTED));
latch.countDown();
return null;
- }).when(endpointResultQueue).resultReceived(anyObject(), eq(0));
+ }).when(endpointResultQueue).resultReceived(any(), eq(0));
}
@Test
@@ -87,7 +90,7 @@ public class IOThreadTest {
when(apacheGatewayConnection.connect()).thenReturn(true);
InputStream serverResponse = new ByteArrayInputStream(
(docId1 + " OK Doc{20}fed").getBytes(StandardCharsets.UTF_8));
- when(apacheGatewayConnection.writeOperations(anyObject())).thenReturn(serverResponse);
+ when(apacheGatewayConnection.writeOperations(any())).thenReturn(serverResponse);
setupEndpointResultQueueMock( "nope", docId1, true, exceptionMessage);
try (IOThread ioThread = new IOThread(null, endpointResultQueue, apacheGatewayConnection, 0, 0, 10000, 10000L, documentQueue, 0)) {
ioThread.post(doc1);
@@ -98,7 +101,7 @@ public class IOThreadTest {
@Test
public void requireThatSingleDocumentWriteErrorIsHandledProperly() throws Exception {
when(apacheGatewayConnection.connect()).thenReturn(true);
- when(apacheGatewayConnection.writeOperations(anyObject())).thenThrow(new IOException(exceptionMessage));
+ when(apacheGatewayConnection.writeOperations(any())).thenThrow(new IOException(exceptionMessage));
setupEndpointResultQueueMock(doc1.getOperationId(), "nope", true, exceptionMessage);
try (IOThread ioThread = new IOThread(null, endpointResultQueue, apacheGatewayConnection, 0, 0, 10000, 10000L, documentQueue, 0)) {
ioThread.post(doc1);
@@ -111,7 +114,7 @@ public class IOThreadTest {
when(apacheGatewayConnection.connect()).thenReturn(true);
InputStream serverResponse = new ByteArrayInputStream(
(docId2 + " OK Doc{20}fed").getBytes(StandardCharsets.UTF_8));
- when(apacheGatewayConnection.writeOperations(anyObject()))
+ when(apacheGatewayConnection.writeOperations(any()))
.thenThrow(new IOException(exceptionMessage))
.thenReturn(serverResponse);
latch = new CountDownLatch(2);
@@ -129,7 +132,7 @@ public class IOThreadTest {
when(apacheGatewayConnection.connect()).thenReturn(false);
InputStream serverResponse = new ByteArrayInputStream(
("").getBytes(StandardCharsets.UTF_8));
- when(apacheGatewayConnection.writeOperations(anyObject()))
+ when(apacheGatewayConnection.writeOperations(any()))
.thenReturn(serverResponse);
setupEndpointResultQueueMock(doc1.getOperationId(), "nope", true,
"java.lang.Exception: Not sending document operation, timed out in queue after");
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/IncompleteResultsThrottlerTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/IncompleteResultsThrottlerTest.java
index 1267514b0d8..baf6e2f2df3 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/IncompleteResultsThrottlerTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/IncompleteResultsThrottlerTest.java
@@ -12,8 +12,10 @@ import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.*;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyDouble;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java
index 15b51dae243..78f616d0e36 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java
@@ -21,8 +21,8 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;