aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-java
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahooinc.com>2022-07-27 16:29:19 +0200
committerBjørn Christian Seime <bjorncs@yahooinc.com>2022-07-28 14:51:33 +0200
commitcecd77aabe2fd389803f92d1cfbaa5b93eabdf86 (patch)
tree8f7d82c01dc712b367441056ad2d5f94e67ef2f6 /vespaclient-java
parent6218325aebf0940c351f8d2a2f6b818311c60c3c (diff)
Convert vespaclient-java to junit5
Diffstat (limited to 'vespaclient-java')
-rw-r--r--vespaclient-java/pom.xml16
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespafeeder/BenchmarkProgressPrinterTest.java8
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespafeeder/ProgressPrinterTest.java18
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java62
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java75
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java82
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsPrinterTest.java20
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsRetrieverTest.java39
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java36
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespavisit/StdOutVisitorHandlerTest.java27
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTargetTestCase.java13
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java71
12 files changed, 240 insertions, 227 deletions
diff --git a/vespaclient-java/pom.xml b/vespaclient-java/pom.xml
index d0e04d1e692..3e5e7ca8025 100644
--- a/vespaclient-java/pom.xml
+++ b/vespaclient-java/pom.xml
@@ -13,11 +13,6 @@
<version>8-SNAPSHOT</version>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
@@ -43,6 +38,12 @@
<groupId>com.yahoo.vespa</groupId>
<artifactId>container-dev</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<!-- Added explicitly to get commons-collections, which is excluded from container-dev -->
@@ -69,6 +70,11 @@
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/BenchmarkProgressPrinterTest.java b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/BenchmarkProgressPrinterTest.java
index 5edc9429c74..7268e892c7d 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/BenchmarkProgressPrinterTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/BenchmarkProgressPrinterTest.java
@@ -6,12 +6,12 @@ import com.yahoo.concurrent.Timer;
import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage;
import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage;
import com.yahoo.messagebus.EmptyReply;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class BenchmarkProgressPrinterTest {
@@ -22,7 +22,7 @@ public class BenchmarkProgressPrinterTest {
}
@Test
- public void testSimple() {
+ void testSimple() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
DummyTimer timer = new DummyTimer();
timer.ms = 0;
@@ -72,7 +72,7 @@ public class BenchmarkProgressPrinterTest {
String val = output.toString().split("\n")[1];
String correctPattern = "62000, \\d+, \\d+, \\d+, \\d+, \\d+$";
- assertTrue("Value '" + val + "' does not match pattern '" + correctPattern + "'", val.matches(correctPattern));
+ assertTrue(val.matches(correctPattern), "Value '" + val + "' does not match pattern '" + correctPattern + "'");
}
}
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/ProgressPrinterTest.java b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/ProgressPrinterTest.java
index f1e81fdd3c6..495367ff4c3 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/ProgressPrinterTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/ProgressPrinterTest.java
@@ -7,12 +7,12 @@ import com.yahoo.documentapi.messagebus.protocol.DocumentIgnoredReply;
import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage;
import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage;
import com.yahoo.messagebus.EmptyReply;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ProgressPrinterTest {
@@ -23,7 +23,7 @@ public class ProgressPrinterTest {
}
@Test
- public void testSimple() {
+ void testSimple() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
DummyTimer timer = new DummyTimer();
timer.ms = 0;
@@ -78,12 +78,12 @@ public class ProgressPrinterTest {
String correct =
"\rSuccessfully sent 2 messages so far" +
- "\rSuccessfully sent 3 messages so far" +
- "\n\n" +
- "Messages sent to vespa (route foobar) :\n" +
- "---------------------------------------\n" +
- "PutDocument:\tok: 2 msgs/sec: 0.03 failed: 0 ignored: 1 latency(min, max, avg): 0, 0, 0\n" +
- "UpdateDocument:\tok: 1 msgs/sec: 0.02 failed: 2 ignored: 0 latency(min, max, avg): 0, 0, 0\n";
+ "\rSuccessfully sent 3 messages so far" +
+ "\n\n" +
+ "Messages sent to vespa (route foobar) :\n" +
+ "---------------------------------------\n" +
+ "PutDocument:\tok: 2 msgs/sec: 0.03 failed: 0 ignored: 1 latency(min, max, avg): 0, 0, 0\n" +
+ "UpdateDocument:\tok: 1 msgs/sec: 0.02 failed: 2 ignored: 0 latency(min, max, avg): 0, 0, 0\n";
assertEquals(correct, val);
}
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java
index d6e55a26a39..a26672c5f26 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java
@@ -22,23 +22,15 @@ import com.yahoo.feedhandler.VespaFeedHandler;
import com.yahoo.text.Utf8;
import com.yahoo.vespaclient.config.FeederConfig;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
public class VespaFeederTestCase {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
@Test
- public void testParseArgs() throws Exception {
- String argsS="--abortondataerror false --abortonsenderror false --file foo.xml --maxpending 10" +
+ void testParseArgs() throws Exception {
+ String argsS = "--abortondataerror false --abortonsenderror false --file foo.xml --maxpending 10" +
" --maxfeedrate 29 --mode benchmark --noretry --route e6 --timeout 13 --trace 4" +
" --validate -v bar.xml --priority LOW_1";
@@ -63,23 +55,23 @@ public class VespaFeederTestCase {
}
@Test
- public void requireThatCreateIfNonExistentArgumentCanBeParsed() throws Exception {
- String argsS="--create-if-non-existent --file foo.xml";
+ void requireThatCreateIfNonExistentArgumentCanBeParsed() throws Exception {
+ String argsS = "--create-if-non-existent --file foo.xml";
Arguments arguments = new Arguments(argsS.split(" "), DummySessionFactory.createWithAutoReply());
assertTrue(arguments.getFeederConfig().createifnonexistent());
}
@Test
- public void requireThatnumThreadsBeParsed() throws Exception {
- String argsS="--numthreads 5";
+ void requireThatnumThreadsBeParsed() throws Exception {
+ String argsS = "--numthreads 5";
Arguments arguments = new Arguments(argsS.split(" "), DummySessionFactory.createWithAutoReply());
assertEquals(5, arguments.getNumThreads());
assertEquals(1, new Arguments("".split(" "), DummySessionFactory.createWithAutoReply()).getNumThreads());
}
@Test
- public void testHelp() throws Exception {
- String argsS="-h";
+ void testHelp() throws Exception {
+ String argsS = "-h";
try {
new Arguments(argsS.split(" "), null);
@@ -90,7 +82,7 @@ public class VespaFeederTestCase {
}
@Test
- public void requireCorrectInputTypeDetection() throws IOException {
+ void requireCorrectInputTypeDetection() throws IOException {
{
BufferedInputStream b = new BufferedInputStream(
new ByteArrayInputStream(Utf8.toBytes("[]")));
@@ -114,16 +106,16 @@ public class VespaFeederTestCase {
}
@Test
- public void testRenderErrors() {
+ void testRenderErrors() {
{
- String[] errors = { "foo" };
+ String[] errors = {"foo"};
assertRenderErrorOutput("Errors:\n" +
- "-------\n" +
- " foo\n", errors);
+ "-------\n" +
+ " foo\n", errors);
}
{
- String[] errors = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"};
+ String[] errors = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"};
assertRenderErrorOutput("First 10 errors (of 11):\n" +
"------------------------\n" +
" 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 10\n", errors);
@@ -136,7 +128,7 @@ public class VespaFeederTestCase {
}
@Test
- public void testCreateProgressPrinter() throws Exception {
+ void testCreateProgressPrinter() throws Exception {
assert(getProgressPrinter("--mode benchmark") instanceof BenchmarkProgressPrinter);
assert(getProgressPrinter("") instanceof ProgressPrinter);
}
@@ -151,15 +143,16 @@ public class VespaFeederTestCase {
}
}
+ // TODO: Remove on Vespa 9
@Test
- @SuppressWarnings("removal") // TODO: Remove on Vespa 9
- public void feedFile() throws Exception {
+ @SuppressWarnings("removal")
+ void feedFile() throws Exception {
FeedFixture f = new FeedFixture();
Arguments arguments = new Arguments("--file src/test/files/myfeed.xml --priority LOW_1".split(" "), f.sessionFactory);
new VespaFeeder(arguments, f.typeManager).parseFiles(System.in, f.printStream);
assertEquals(3, f.sessionFactory.messages.size());
- assertEquals(DocumentProtocol.Priority.LOW_1, ((PutDocumentMessage)f.sessionFactory.messages.get(0)).getPriority()); // TODO: Remove on Vespa 9
+ assertEquals(DocumentProtocol.Priority.LOW_1, ((PutDocumentMessage) f.sessionFactory.messages.get(0)).getPriority()); // TODO: Remove on Vespa 9
assertEquals("id:test:news::foo", ((PutDocumentMessage) f.sessionFactory.messages.get(0)).getDocumentPut().getDocument().getId().toString());
DocumentUpdate update = ((UpdateDocumentMessage) f.sessionFactory.messages.get(1)).getDocumentUpdate();
assertEquals("id:test:news::foo", update.getId().toString());
@@ -170,7 +163,7 @@ public class VespaFeederTestCase {
}
@Test
- public void feedJson() throws Exception {
+ void feedJson() throws Exception {
FeedFixture feedFixture = feed("src/test/files/myfeed.json", true);
assertJsonFeedState(feedFixture);
@@ -190,7 +183,7 @@ public class VespaFeederTestCase {
}
@Test
- public void requireThatCreateIfNonExistentArgumentIsUsed() throws Exception {
+ void requireThatCreateIfNonExistentArgumentIsUsed() throws Exception {
FeedFixture f = new FeedFixture();
Arguments arguments = new Arguments("--file src/test/files/myfeed.xml --create-if-non-existent".split(" "), f.sessionFactory);
new VespaFeeder(arguments, f.typeManager).parseFiles(System.in, f.printStream);
@@ -201,10 +194,11 @@ public class VespaFeederTestCase {
}
@Test
- public void feedMalformedJson() throws Exception {
- exception.expect(VespaFeeder.FeedErrorException.class);
- exception.expectMessage("JsonParseException");
- feed("src/test/files/malformedfeed.json", false);
+ void feedMalformedJson() throws Exception {
+ Throwable exception = assertThrows(VespaFeeder.FeedErrorException.class, () -> {
+ feed("src/test/files/malformedfeed.json", false);
+ });
+ assertTrue(exception.getMessage().contains("JsonParseException"));
}
protected FeedFixture feed(String feed, boolean abortOnDataError) throws Exception {
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java
index 0b828c91f91..c448e5d55f5 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java
@@ -5,9 +5,7 @@ import com.yahoo.document.fieldset.AllFields;
import com.yahoo.document.fieldset.DocumentOnly;
import com.yahoo.document.fieldset.DocIdOnly;
import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -17,9 +15,7 @@ import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test class for {@link CommandLineOptions}
@@ -37,10 +33,6 @@ public class CommandLineOptionsTest {
}
};
- @SuppressWarnings("deprecation")
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
private ClientParameters getParsedOptions(InputStream in, String... args) {
CommandLineOptions options = new CommandLineOptions(in);
return options.parseCommandLineArguments(args);
@@ -51,7 +43,7 @@ public class CommandLineOptionsTest {
}
@Test
- public void testDefaultOptions() {
+ void testDefaultOptions() {
ClientParameters params = getParsedOptions();
assertFalse(params.help);
assertFalse(params.documentIds.hasNext());
@@ -68,7 +60,7 @@ public class CommandLineOptionsTest {
}
@Test
- public void testValidOptions() {
+ void testValidOptions() {
ClientParameters params = getParsedOptions(
"--fieldset", "[fieldset]",
"--route", "dummyroute",
@@ -97,73 +89,78 @@ public class CommandLineOptionsTest {
}
@Test
- public void testInvalidCombination3() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Field set option can not be used in combination with print ids option.");
- getParsedOptions("--printids", "--fieldset", AllFields.NAME);
+ void testInvalidCombination3() {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ getParsedOptions("--printids", "--fieldset", AllFields.NAME);
+ });
+ assertTrue(exception.getMessage().contains("Field set option can not be used in combination with print ids option."));
}
@Test
- public void testInvalidCombination4() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Cluster and route options are mutually exclusive.");
- getParsedOptions("--route", "dummyroute", "--cluster", "dummycluster");
+ void testInvalidCombination4() {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ getParsedOptions("--route", "dummyroute", "--cluster", "dummycluster");
+ });
+ assertTrue(exception.getMessage().contains("Cluster and route options are mutually exclusive."));
}
@Test
- public void testInvalidPriority() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Invalid priority: 16");
- getParsedOptions("--priority", "16");
+ void testInvalidPriority() {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ getParsedOptions("--priority", "16");
+ });
+ assertTrue(exception.getMessage().contains("Invalid priority: 16"));
}
@Test
- public void TestHighestPriority() {
+ void TestHighestPriority() {
ClientParameters params = getParsedOptions("--priority", "HIGHEST");
assertEquals(DocumentProtocol.Priority.HIGHEST, params.priority);
}
@Test
- public void TestHigh1PriorityAsNumber() {
+ void TestHigh1PriorityAsNumber() {
ClientParameters params = getParsedOptions("--priority", "2");
assertEquals(DocumentProtocol.Priority.HIGH_1, params.priority);
}
@Test
- public void testInvalidTraceLevel1() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Invalid tracelevel: -1");
- getParsedOptions("--trace", "-1");
+ void testInvalidTraceLevel1() {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ getParsedOptions("--trace", "-1");
+ });
+ assertTrue(exception.getMessage().contains("Invalid tracelevel: -1"));
}
@Test
- public void testInvalidTraceLevel2() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Invalid tracelevel: 10");
- getParsedOptions("--trace", "10");
+ void testInvalidTraceLevel2() {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ getParsedOptions("--trace", "10");
+ });
+ assertTrue(exception.getMessage().contains("Invalid tracelevel: 10"));
}
@Test
- public void testPrintids() {
+ void testPrintids() {
ClientParameters params = getParsedOptions("--printids");
assertEquals(DocIdOnly.NAME, params.fieldSet);
}
@Test
- public void testCluster() {
+ void testCluster() {
ClientParameters params = getParsedOptions("--cluster", "dummycluster");
assertEquals("dummycluster", params.cluster);
assertTrue(params.route.isEmpty());
}
@Test
- public void testHelp() {
+ void testHelp() {
ClientParameters params = getParsedOptions("--help");
assertTrue(params.help);
}
@Test
- public void testDocumentIdsFromInputStream() throws UnsupportedEncodingException {
+ void testDocumentIdsFromInputStream() throws UnsupportedEncodingException {
InputStream in = new ByteArrayInputStream("id:1 id:2 id:3".getBytes("UTF-8"));
ClientParameters params = getParsedOptions(in, "");
@@ -175,7 +172,7 @@ public class CommandLineOptionsTest {
}
@Test
- public void testPrintHelp() {
+ void testPrintHelp() {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
PrintStream oldOut = System.out;
System.setOut(new PrintStream(outContent));
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java
index ce555e2c0f5..24e303d6fce 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java
@@ -15,11 +15,9 @@ import com.yahoo.messagebus.Error;
import com.yahoo.messagebus.Reply;
import com.yahoo.vespaclient.ClusterDef;
import com.yahoo.vespaclient.ClusterList;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatcher;
import java.io.ByteArrayOutputStream;
@@ -31,8 +29,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
@@ -60,11 +57,7 @@ public class DocumentRetrieverTest {
private PrintStream oldOut;
private PrintStream oldErr;
- @SuppressWarnings("deprecation")
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- @Before
+ @BeforeEach
public void setUpStreams() {
oldOut = System.out;
oldErr = System.err;
@@ -72,7 +65,7 @@ public class DocumentRetrieverTest {
System.setErr(new PrintStream(errContent));
}
- @Before
+ @BeforeEach
public void prepareMessageBusMocks() {
this.mockedFactory = mock(DocumentAccessFactory.class);
this.mockedDocumentAccess = mock(MessageBusDocumentAccess.class);
@@ -81,7 +74,7 @@ public class DocumentRetrieverTest {
when(mockedDocumentAccess.createSyncSession(any())).thenReturn(mockedSession);
}
- @After
+ @AfterEach
public void cleanUpStreams() {
System.setOut(oldOut);
System.setErr(oldErr);
@@ -129,9 +122,10 @@ public class DocumentRetrieverTest {
params);
}
+ // TODO: Remove on Vespa 9
@Test
- @SuppressWarnings("removal") // TODO: Remove on Vespa 9
- public void testSendSingleMessage() throws DocumentRetrieverException {
+ @SuppressWarnings("removal")
+ void testSendSingleMessage() throws DocumentRetrieverException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1))
.setPriority(DocumentProtocol.Priority.HIGH_1)
@@ -148,12 +142,12 @@ public class DocumentRetrieverTest {
verify(mockedSession, times(1)).syncSend(argThat((ArgumentMatcher<GetDocumentMessage>) o ->
o.getPriority().equals(DocumentProtocol.Priority.HIGH_1) && // TODO remove on Vespa 9
- !o.getRetryEnabled()));
+ !o.getRetryEnabled()));
assertContainsDocument(DOC_ID_1);
}
@Test
- public void testMultipleMessages() throws DocumentRetrieverException {
+ void testMultipleMessages() throws DocumentRetrieverException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1, DOC_ID_2, DOC_ID_3))
.build();
@@ -173,7 +167,7 @@ public class DocumentRetrieverTest {
}
@Test
- public void testJsonOutput() throws DocumentRetrieverException, IOException {
+ void testJsonOutput() throws DocumentRetrieverException, IOException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1, DOC_ID_2, DOC_ID_3))
.setJsonOutput(true)
@@ -197,7 +191,7 @@ public class DocumentRetrieverTest {
}
@Test
- public void testShutdownHook() throws DocumentRetrieverException {
+ void testShutdownHook() throws DocumentRetrieverException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1))
.build();
@@ -213,7 +207,7 @@ public class DocumentRetrieverTest {
}
@Test
- public void testClusterLookup() throws DocumentRetrieverException {
+ void testClusterLookup() throws DocumentRetrieverException {
final String cluster = "storage",
expectedRoute = "[Content:cluster=storage]";
@@ -230,35 +224,37 @@ public class DocumentRetrieverTest {
}
@Test
- public void testInvalidClusterName() throws DocumentRetrieverException {
- exception.expect(DocumentRetrieverException.class);
- exception.expectMessage("The Vespa cluster contains the content clusters storage, not invalidclustername. Please select a valid vespa cluster.");
+ void testInvalidClusterName() throws DocumentRetrieverException {
+ Throwable exception = assertThrows(DocumentRetrieverException.class, () -> {
- ClientParameters params = createParameters()
- .setCluster("invalidclustername")
- .build();
+ ClientParameters params = createParameters()
+ .setCluster("invalidclustername")
+ .build();
- ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef("storage")));
+ ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef("storage")));
- DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList);
- documentRetriever.retrieveDocuments();
+ DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList);
+ documentRetriever.retrieveDocuments();
+ });
+ assertTrue(exception.getMessage().contains("The Vespa cluster contains the content clusters storage, not invalidclustername. Please select a valid vespa cluster."));
}
@Test
- public void testEmtpyClusterList() throws DocumentRetrieverException {
- exception.expect(DocumentRetrieverException.class);
- exception.expectMessage("The Vespa cluster does not have any content clusters declared.");
+ void testEmtpyClusterList() throws DocumentRetrieverException {
+ Throwable exception = assertThrows(DocumentRetrieverException.class, () -> {
- ClientParameters params = createParameters()
- .setCluster("invalidclustername")
- .build();
+ ClientParameters params = createParameters()
+ .setCluster("invalidclustername")
+ .build();
- DocumentRetriever documentRetriever = createDocumentRetriever(params);
- documentRetriever.retrieveDocuments();
+ DocumentRetriever documentRetriever = createDocumentRetriever(params);
+ documentRetriever.retrieveDocuments();
+ });
+ assertTrue(exception.getMessage().contains("The Vespa cluster does not have any content clusters declared."));
}
@Test
- public void testHandlingErrorFromMessageBus() throws DocumentRetrieverException {
+ void testHandlingErrorFromMessageBus() throws DocumentRetrieverException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1))
.build();
@@ -274,7 +270,7 @@ public class DocumentRetrieverTest {
}
@Test
- public void testShowDocSize() throws DocumentRetrieverException {
+ void testShowDocSize() throws DocumentRetrieverException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1))
.setShowDocSize(true)
@@ -290,7 +286,7 @@ public class DocumentRetrieverTest {
}
@Test
- public void testPrintIdOnly() throws DocumentRetrieverException {
+ void testPrintIdOnly() throws DocumentRetrieverException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1))
.setPrintIdsOnly(true)
@@ -305,7 +301,7 @@ public class DocumentRetrieverTest {
}
@Test
- public void testDocumentNotFound() throws DocumentRetrieverException {
+ void testDocumentNotFound() throws DocumentRetrieverException {
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1))
.setPrintIdsOnly(true)
@@ -321,7 +317,7 @@ public class DocumentRetrieverTest {
}
@Test
- public void testTrace() throws DocumentRetrieverException {
+ void testTrace() throws DocumentRetrieverException {
final int traceLevel = 9;
ClientParameters params = createParameters()
.setDocumentIds(asIterator(DOC_ID_1))
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsPrinterTest.java b/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsPrinterTest.java
index 8120e2f1d77..0a0bca8af0e 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsPrinterTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsPrinterTest.java
@@ -3,9 +3,9 @@ package com.yahoo.vespastat;
import com.yahoo.document.BucketId;
import com.yahoo.documentapi.messagebus.protocol.GetBucketListReply;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
@@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -24,7 +24,7 @@ public class BucketStatsPrinterTest {
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
private final String bucketSpace = "default";
- @Before
+ @BeforeEach
public void mockBucketStatsRetriever() throws BucketStatsException {
retriever = mock(BucketStatsRetriever.class);
when(retriever.getBucketIdForType(any(), any())).thenReturn(new BucketId(0x42));
@@ -32,7 +32,7 @@ public class BucketStatsPrinterTest {
when(retriever.retrieveBucketStats(any(), any(), any(), any())).thenReturn("");
}
- @After
+ @AfterEach
public void resetOutputMock() {
out.reset();
}
@@ -50,7 +50,7 @@ public class BucketStatsPrinterTest {
}
@Test
- public void testShouldPrintBucketIdForUserAndGroup() throws BucketStatsException {
+ void testShouldPrintBucketIdForUserAndGroup() throws BucketStatsException {
String output = retreiveAndPrintBucketStats(ClientParameters.SelectionType.USER, "1234", false);
assertTrue(output.contains("Generated 32-bit bucket id"));
@@ -59,13 +59,13 @@ public class BucketStatsPrinterTest {
}
@Test
- public void testShouldPrintWarningIfBucketListEmpty() throws BucketStatsException {
+ void testShouldPrintWarningIfBucketListEmpty() throws BucketStatsException {
String output = retreiveAndPrintBucketStats(ClientParameters.SelectionType.USER, "1234", false);
assertTrue(output.contains("No actual files were stored for this bucket"));
}
@Test
- public void testShouldPrintBucketList() throws BucketStatsException {
+ void testShouldPrintBucketList() throws BucketStatsException {
List<GetBucketListReply.BucketInfo> bucketList = new ArrayList<>();
String dummyInfoString = "dummyinformation";
bucketList.add(new GetBucketListReply.BucketInfo(new BucketId(0), dummyInfoString));
@@ -76,7 +76,7 @@ public class BucketStatsPrinterTest {
}
@Test
- public void testShouldPrintBucketStats() throws BucketStatsException {
+ void testShouldPrintBucketStats() throws BucketStatsException {
String dummyBucketStats = "dummystats";
GetBucketListReply.BucketInfo bucketInfo = new GetBucketListReply.BucketInfo(new BucketId(0), "dummy");
when(retriever.retrieveBucketList(any(), any())).thenReturn(Collections.singletonList(bucketInfo));
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsRetrieverTest.java b/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsRetrieverTest.java
index 39f8968d209..426c316027a 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsRetrieverTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespastat/BucketStatsRetrieverTest.java
@@ -9,12 +9,13 @@ import com.yahoo.documentapi.messagebus.MessageBusSyncSession;
import com.yahoo.documentapi.messagebus.protocol.GetBucketListReply;
import com.yahoo.documentapi.messagebus.protocol.StatBucketReply;
import com.yahoo.messagebus.Error;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -31,7 +32,7 @@ public class BucketStatsRetrieverTest {
private final String bucketSpace = "default";
- @Before
+ @BeforeEach
public void prepareMessageBusMocks() {
this.mockedFactory = mock(DocumentAccessFactory.class);
this.mockedDocumentAccess = mock(MessageBusDocumentAccess.class);
@@ -41,7 +42,7 @@ public class BucketStatsRetrieverTest {
}
@Test
- public void testGetBucketId() throws BucketStatsException {
+ void testGetBucketId() throws BucketStatsException {
BucketStatsRetriever retriever = createRetriever();
assertEquals("BucketId(0x80000000000004d2)",
@@ -57,7 +58,7 @@ public class BucketStatsRetrieverTest {
}
@Test
- public void testRetrieveBucketList() throws BucketStatsException {
+ void testRetrieveBucketList() throws BucketStatsException {
String bucketInfo = "I like turtles!";
BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId("id:ns:type::another"));
@@ -73,7 +74,7 @@ public class BucketStatsRetrieverTest {
}
@Test
- public void testRetrieveBucketStats() throws BucketStatsException {
+ void testRetrieveBucketStats() throws BucketStatsException {
String docId = "id:ns:type::another";
String bucketInfo = "I like turtles!";
BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId(docId));
@@ -88,9 +89,10 @@ public class BucketStatsRetrieverTest {
}
@Test
- public void testShutdownHook() {
+ void testShutdownHook() {
class MockShutdownRegistrar implements BucketStatsRetriever.ShutdownHookRegistrar {
public Runnable shutdownRunnable;
+
@Override
public void registerShutdownHook(Runnable runnable) {
shutdownRunnable = runnable;
@@ -104,24 +106,27 @@ public class BucketStatsRetrieverTest {
verify(mockedDocumentAccess, times(1)).shutdown();
}
- @Test(expected = BucketStatsException.class)
- public void testShouldFailOnReplyError() throws BucketStatsException {
- GetBucketListReply reply = new GetBucketListReply();
- reply.addError(new Error(0, "errormsg"));
- when(mockedSession.syncSend(any())).thenReturn(reply);
-
- createRetriever().retrieveBucketList(new BucketId(1), bucketSpace);
+ @Test
+ void testShouldFailOnReplyError() throws BucketStatsException {
+ assertThrows(BucketStatsException.class, () -> {
+ GetBucketListReply reply = new GetBucketListReply();
+ reply.addError(new Error(0, "errormsg"));
+ when(mockedSession.syncSend(any())).thenReturn(reply);
+
+ createRetriever().retrieveBucketList(new BucketId(1), bucketSpace);
+ });
}
@Test
- public void testRoute() throws BucketStatsException {
+ void testRoute() throws BucketStatsException {
String route = "default";
BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId("id:ns:type::another"));
GetBucketListReply reply = new GetBucketListReply();
reply.getBuckets().add(new GetBucketListReply.BucketInfo(bucketId, "I like turtles!"));
when(mockedSession.syncSend(any())).thenReturn(reply);
- BucketStatsRetriever retriever = new BucketStatsRetriever(mockedFactory, route, t -> {});
+ BucketStatsRetriever retriever = new BucketStatsRetriever(mockedFactory, route, t -> {
+ });
retriever.retrieveBucketList(new BucketId(0), bucketSpace);
// Route is set at session-level, not per message sent.
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java b/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java
index 4bfe9b68b65..b030120ac52 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespastat/CommandLineOptionsTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespastat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class CommandLineOptionsTest {
@@ -16,12 +16,12 @@ public class CommandLineOptionsTest {
}
@Test
- public void testHelp() {
+ void testHelp() {
assertTrue(getParsedOptions("--help").help);
}
@Test
- public void testMultipleOptions() {
+ void testMultipleOptions() {
ClientParameters params = getParsedOptions("--dump", "--route", "dummyroute", "--user", "userid");
assertTrue(params.dumpData);
assertEquals("dummyroute", params.route);
@@ -30,7 +30,7 @@ public class CommandLineOptionsTest {
}
@Test
- public void testSelectionTypes() {
+ void testSelectionTypes() {
assertEquals(ClientParameters.SelectionType.USER, getParsedOptions("--user", "id").selectionType);
assertEquals(ClientParameters.SelectionType.DOCUMENT, getParsedOptions("--document", "id").selectionType);
assertEquals(ClientParameters.SelectionType.BUCKET, getParsedOptions("--bucket", "id").selectionType);
@@ -38,24 +38,28 @@ public class CommandLineOptionsTest {
assertEquals(ClientParameters.SelectionType.GID, getParsedOptions("--gid", "id").selectionType);
}
- @Test(expected = IllegalArgumentException.class)
- public void testMissingSelectionType() {
- getParsedOptions();
+ @Test
+ void testMissingSelectionType() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ getParsedOptions();
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void testFailOnMultipleDumpTypes() {
- getParsedOptions("--user", "id", "--document", "id", "--group", "id", "--gid", "id");
+ @Test
+ void testFailOnMultipleDumpTypes() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ getParsedOptions("--user", "id", "--document", "id", "--group", "id", "--gid", "id");
+ });
}
@Test
- public void testForceDumpOnDocumentOrGid() {
+ void testForceDumpOnDocumentOrGid() {
assertTrue(getParsedOptions("--document", "docid").dumpData);
assertTrue(getParsedOptions("--gid", "gid").dumpData);
}
@Test
- public void testPrintHelp() {
+ void testPrintHelp() {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
PrintStream oldOut = System.out;
System.setOut(new PrintStream(outContent));
@@ -71,17 +75,17 @@ public class CommandLineOptionsTest {
}
@Test
- public void bucket_space_is_default_unless_specified() {
+ void bucket_space_is_default_unless_specified() {
assertEquals("default", getParsedOptions("--user", "id").bucketSpace);
}
@Test
- public void can_specify_explicit_bucket_space() {
+ void can_specify_explicit_bucket_space() {
assertEquals("global", getParsedOptions("--user", "id", "--bucketspace", "global").bucketSpace);
}
@Test
- public void testDefaultRoute() {
+ void testDefaultRoute() {
assertEquals("default", getParsedOptions("--user", "dummyuser").route);
}
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespavisit/StdOutVisitorHandlerTest.java b/vespaclient-java/src/test/java/com/yahoo/vespavisit/StdOutVisitorHandlerTest.java
index 854d7ae9ad3..f109b0ad56b 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespavisit/StdOutVisitorHandlerTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespavisit/StdOutVisitorHandlerTest.java
@@ -2,33 +2,32 @@
package com.yahoo.vespavisit;
import com.yahoo.documentapi.VisitorDataHandler;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bjorncs
*/
-@RunWith(Parameterized.class)
public class StdOutVisitorHandlerTest {
- private final boolean jsonOutput;
+ private boolean jsonOutput;
- public StdOutVisitorHandlerTest(boolean jsonOutput) {
+ public void initStdOutVisitorHandlerTest(boolean jsonOutput) {
this.jsonOutput = jsonOutput;
}
- @Parameterized.Parameters(name = "jsonOutput={0}")
public static Object[] data() {
- return new Object[] { true, false};
+ return new Object[]{true, false};
}
- @Test
- public void printing_ids_for_zero_documents_produces_empty_output() {
+ @MethodSource("data")
+ @ParameterizedTest(name = "jsonOutput={0}")
+ void printing_ids_for_zero_documents_produces_empty_output(boolean jsonOutput) {
+ initStdOutVisitorHandlerTest(jsonOutput);
ByteArrayOutputStream out = new ByteArrayOutputStream();
StdOutVisitorHandler visitorHandler =
new StdOutVisitorHandler(/*printIds*/true, false, false, false, false, false, 0, jsonOutput, new PrintStream(out, true));
@@ -38,8 +37,10 @@ public class StdOutVisitorHandlerTest {
assertEquals("", output.trim());
}
- @Test
- public void printing_zero_documents_produces_empty_output() {
+ @MethodSource("data")
+ @ParameterizedTest(name = "jsonOutput={0}")
+ void printing_zero_documents_produces_empty_output(boolean jsonOutput) {
+ initStdOutVisitorHandlerTest(jsonOutput);
ByteArrayOutputStream out = new ByteArrayOutputStream();
StdOutVisitorHandler visitorHandler =
new StdOutVisitorHandler(/*printIds*/false, false, false, false, false, false, 0, jsonOutput, new PrintStream(out, true));
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTargetTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTargetTestCase.java
index 42526a38df5..3a74ac39f43 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTargetTestCase.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTargetTestCase.java
@@ -1,13 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespavisit;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
public class VdsVisitTargetTestCase {
@Test
- public void testParametersSlobrok() throws Exception {
+ void testParametersSlobrok() throws Exception {
VdsVisitTarget target = new VdsVisitTarget();
target.parseArguments(new String[]{
"--bindtoslobrok", "myname",
@@ -30,11 +31,11 @@ public class VdsVisitTargetTestCase {
}
@Test
- public void testParametersPort() throws Exception {
+ void testParametersPort() throws Exception {
VdsVisitTarget target = new VdsVisitTarget();
target.parseArguments("--bindtosocket 1234".split(" "));
assertEquals(1234, target.getPort());
- assertEquals(null, target.getSlobrokAddress());
+ assertNull(target.getSlobrokAddress());
}
public void assertException(String params) {
@@ -48,7 +49,7 @@ public class VdsVisitTargetTestCase {
}
@Test
- public void testPortAndSlobrok() {
+ void testPortAndSlobrok() {
assertException("--bindtoslobrok foo --bindtosocket 1234");
assertException("--bindtoport foo");
}
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java
index 55ac7761da3..a67fee0c0d6 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java
@@ -3,22 +3,31 @@ package com.yahoo.vespavisit;
import com.yahoo.document.fieldset.DocIdOnly;
import com.yahoo.document.select.parser.ParseException;
-import com.yahoo.documentapi.*;
+import com.yahoo.documentapi.AckToken;
+import com.yahoo.documentapi.ProgressToken;
+import com.yahoo.documentapi.VisitorControlHandler;
+import com.yahoo.documentapi.VisitorParameters;
+import com.yahoo.documentapi.VisitorResponse;
+import com.yahoo.documentapi.VisitorSession;
import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;
import com.yahoo.messagebus.StaticThrottlePolicy;
import com.yahoo.messagebus.Trace;
import com.yahoo.vespaclient.ClusterDef;
import com.yahoo.vespaclient.ClusterList;
import org.apache.commons.cli.Options;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class VdsVisitTestCase {
@@ -28,9 +37,9 @@ public class VdsVisitTestCase {
}
@Test
- public void testCommandLineShortOptions() throws Exception {
+ void testCommandLineShortOptions() throws Exception {
// short options testing (for options that do not collide with each other)
- String[] args = new String[] {
+ String[] args = new String[]{
"-d", "foo.remote",
"-s", "'id.user=1234'",
"-f", "5678",
@@ -70,9 +79,9 @@ public class VdsVisitTestCase {
* @throws Exception
*/
@Test
- public void testCommandLineShortOptions2() throws Exception {
+ void testCommandLineShortOptions2() throws Exception {
// Short options testing (for options that do not collide with each other)
- String[] args = new String[] {
+ String[] args = new String[]{
"-o", "654321",
"-i"
};
@@ -88,9 +97,9 @@ public class VdsVisitTestCase {
}
@Test
- public void testCommandLineShortOptionsPrintIdsOnly() throws Exception {
+ void testCommandLineShortOptionsPrintIdsOnly() throws Exception {
// Short options testing (for options that do not collide with each other)
- String[] args = new String[] {
+ String[] args = new String[]{
"-i"
};
VdsVisit.ArgumentParser parser = createMockArgumentParser();
@@ -104,9 +113,9 @@ public class VdsVisitTestCase {
}
@Test
- public void testCommandLineLongOptions() throws Exception {
+ void testCommandLineLongOptions() throws Exception {
// short options testing (for options that do not collide with each other)
- String[] args = new String[] {
+ String[] args = new String[]{
"--datahandler", "foo.remote",
"--selection", "'id.user=1234'",
"--from", "5678",
@@ -151,12 +160,12 @@ public class VdsVisitTestCase {
assertEquals("kittens", allParams.getCluster());
assertTrue(params.getThrottlePolicy() instanceof StaticThrottlePolicy);
- assertEquals(3, ((StaticThrottlePolicy)params.getThrottlePolicy()).getMaxPendingCount());
+ assertEquals(3, ((StaticThrottlePolicy) params.getThrottlePolicy()).getMaxPendingCount());
assertTrue(params.visitInconsistentBuckets());
assertEquals("fnord", params.getVisitorLibrary());
// TODO: FIXME? multiple library params doesn't work
- assertTrue(Arrays.equals("rargh".getBytes(), params.getLibraryParameters().get("asdf")));
+ assertArrayEquals("rargh".getBytes(), params.getLibraryParameters().get("asdf"));
//assertTrue(Arrays.equals("pie".getBytes(), params.getLibraryParameters().get("pinkie")));
assertEquals(555, allParams.getProcessTime());
assertEquals(2002, params.getMaxTotalHits());
@@ -171,7 +180,7 @@ public class VdsVisitTestCase {
printStream.flush();
String nl = System.getProperty("line.separator"); // the joys of running tests on windows
assertEquals(
- "Time out visitor after 123456789 ms." + nl +
+ "Time out visitor after 123456789 ms." + nl +
"Visiting documents matching: 'id.user=1234'" + nl +
"Visiting bucket space: outerspace" + nl +
"Visiting in the inclusive timestamp range 5678 - 9012." + nl +
@@ -193,7 +202,7 @@ public class VdsVisitTestCase {
private static String[] emptyArgList() { return new String[]{}; }
@Test
- public void visitor_priority_is_low1_by_default() throws Exception {
+ void visitor_priority_is_low1_by_default() throws Exception {
VdsVisit.VdsVisitParameters allParams = createMockArgumentParser().parse(emptyArgList());
VisitorParameters params = allParams.getVisitorParameters();
@@ -201,8 +210,8 @@ public class VdsVisitTestCase {
}
@Test
- public void testBadPriorityValue() throws Exception {
- String[] args = new String[] {
+ void testBadPriorityValue() throws Exception {
+ String[] args = new String[]{
"--priority", "super_hyper_important"
};
VdsVisit.ArgumentParser parser = createMockArgumentParser();
@@ -215,9 +224,9 @@ public class VdsVisitTestCase {
}
@Test
- public void testCommandLineShortOptionsInvokeHelp() throws Exception {
+ void testCommandLineShortOptionsInvokeHelp() throws Exception {
// Short options testing (for options that do not collide with each other)
- String[] args = new String[] {
+ String[] args = new String[]{
"-h"
};
VdsVisit.ArgumentParser parser = createMockArgumentParser();
@@ -226,7 +235,7 @@ public class VdsVisitTestCase {
}
@Test
- public void testAutoSelectClusterRoute() throws Exception {
+ void testAutoSelectClusterRoute() throws Exception {
List<ClusterDef> clusterDefs = new ArrayList<>();
clusterDefs.add(new ClusterDef("storage"));
ClusterList clusterList = new ClusterList(clusterDefs);
@@ -236,7 +245,7 @@ public class VdsVisitTestCase {
}
@Test
- public void testBadClusterName() throws Exception {
+ void testBadClusterName() throws Exception {
List<ClusterDef> clusterDefs = new ArrayList<>();
clusterDefs.add(new ClusterDef("storage"));
ClusterList clusterList = new ClusterList(clusterDefs);
@@ -244,13 +253,13 @@ public class VdsVisitTestCase {
VdsVisit.resolveClusterRoute(clusterList, "borkbork");
} catch (IllegalArgumentException e) {
assertEquals("Your vespa cluster contains the content clusters 'storage', not 'borkbork'. " +
- "Please select a valid vespa cluster.",
- e.getMessage());
+ "Please select a valid vespa cluster.",
+ e.getMessage());
}
}
@Test
- public void testRequireClusterOptionIfMultipleClusters() {
+ void testRequireClusterOptionIfMultipleClusters() {
List<ClusterDef> clusterDefs = new ArrayList<>();
clusterDefs.add(new ClusterDef("storage"));
clusterDefs.add(new ClusterDef("storage2"));
@@ -263,7 +272,7 @@ public class VdsVisitTestCase {
}
@Test
- public void testExplicitClusterOptionWithMultipleClusters() {
+ void testExplicitClusterOptionWithMultipleClusters() {
List<ClusterDef> clusterDefs = new ArrayList<>();
clusterDefs.add(new ClusterDef("storage"));
clusterDefs.add(new ClusterDef("storage2"));
@@ -274,7 +283,7 @@ public class VdsVisitTestCase {
}
@Test
- public void testFailIfNoContentClustersAvailable() {
+ void testFailIfNoContentClustersAvailable() {
List<ClusterDef> clusterDefs = new ArrayList<>();
ClusterList clusterList = new ClusterList(clusterDefs);
try {
@@ -285,8 +294,8 @@ public class VdsVisitTestCase {
}
@Test
- public void testStatistics() throws Exception {
- String[] args = new String[] {
+ void testStatistics() throws Exception {
+ String[] args = new String[]{
"--statistics", "foo"
};
VdsVisit.ArgumentParser parser = createMockArgumentParser();
@@ -400,7 +409,7 @@ public class VdsVisitTestCase {
}
@Test
- public void testVdsVisitRunLogic() {
+ void testVdsVisitRunLogic() {
MockVisitorSessionAccessorFactory accessorFactory = new MockVisitorSessionAccessorFactory();
MockShutdownHookRegistrar shutdownHookRegistrar = new MockShutdownHookRegistrar();
VdsVisit vdsVisit = new VdsVisit(accessorFactory, shutdownHookRegistrar);
@@ -429,7 +438,7 @@ public class VdsVisitTestCase {
}
@Test
- public void testVdsVisitRunLogicProgressFileNotYetCreated() {
+ void testVdsVisitRunLogicProgressFileNotYetCreated() {
MockVisitorSessionAccessorFactory accessorFactory = new MockVisitorSessionAccessorFactory();
MockShutdownHookRegistrar shutdownHookRegistrar = new MockShutdownHookRegistrar();
VdsVisit vdsVisit = new VdsVisit(accessorFactory, shutdownHookRegistrar);