aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--athenz-identity-provider-service/pom.xml5
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java4
-rw-r--r--container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java5
-rw-r--r--controller-api/pom.xml6
-rw-r--r--controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java15
-rw-r--r--documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java10
-rw-r--r--fileacquirer/src/test/java/MockFileAcquirerTest.java30
-rw-r--r--http-utils/pom.xml5
-rw-r--r--http-utils/src/test/java/ai/vespa/util/http/retry/DelayedResponseLevelRetryHandlerTest.java6
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java8
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java4
-rw-r--r--predicate-search-core/src/test/java/com/yahoo/search/predicate/PredicateQueryParserTest.java7
-rw-r--r--vdslib/src/test/java/com/yahoo/vdslib/distribution/GroupTestCase.java35
-rw-r--r--vespa-hadoop/src/test/java/com/yahoo/vespa/hadoop/pig/VespaDocumentOperationTest.java21
-rw-r--r--vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java6
-rw-r--r--vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java13
-rw-r--r--vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java26
-rw-r--r--zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java11
-rw-r--r--zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java11
19 files changed, 97 insertions, 131 deletions
diff --git a/athenz-identity-provider-service/pom.xml b/athenz-identity-provider-service/pom.xml
index daedc1d0b9b..e5f1d7737a1 100644
--- a/athenz-identity-provider-service/pom.xml
+++ b/athenz-identity-provider-service/pom.xml
@@ -107,11 +107,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java
index 4604eea62c1..8e5622e6c2f 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/identitydocument/IdentityDocumentGeneratorTest.java
@@ -32,9 +32,7 @@ import java.util.Set;
import static com.yahoo.vespa.hosted.athenz.instanceproviderservice.TestUtils.getAthenzProviderConfig;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -94,7 +92,7 @@ public class IdentityDocumentGeneratorTest {
assertEquals(expectedProviderUniqueId, signedIdentityDocument.providerUniqueId());
// Validate that container ips are present
- assertThat(signedIdentityDocument.ipAddresses(), hasItem("::1"));
+ assertTrue(signedIdentityDocument.ipAddresses().contains("::1"));
IdentityDocumentSigner signer = new IdentityDocumentSigner();
diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java
index 394f1b858b2..1f5ccf4bb10 100644
--- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java
+++ b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java
@@ -5,9 +5,8 @@ import com.yahoo.container.servlet.jersey.ResourceOrProviderClassVisitor;
import org.junit.Test;
import org.objectweb.asm.ClassReader;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class ResourceOrProviderClassVisitorTest {
@@ -53,7 +52,7 @@ public class ResourceOrProviderClassVisitorTest {
@Test
public void className_is_equal_to_getName() throws Exception {
- assertThat(analyzeClass(com.yahoo.container.servlet.jersey.classvisitor.Resource.class).getClassName(), is(com.yahoo.container.servlet.jersey.classvisitor.Resource.class.getName()));
+ assertEquals(com.yahoo.container.servlet.jersey.classvisitor.Resource.class.getName(), analyzeClass(com.yahoo.container.servlet.jersey.classvisitor.Resource.class).getClassName());
}
public void assert_is_accepted(Class<?> clazz) throws Exception {
diff --git a/controller-api/pom.xml b/controller-api/pom.xml
index 5d0bbff1c62..2f01f45edaa 100644
--- a/controller-api/pom.xml
+++ b/controller-api/pom.xml
@@ -89,12 +89,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
-
</dependencies>
<build>
diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java
index fad1e944e36..4cdbe5241bc 100644
--- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java
+++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java
@@ -32,7 +32,6 @@ import java.util.Map;
import java.util.Set;
import static java.util.stream.Collectors.toList;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -52,10 +51,10 @@ public class SystemFlagsDataArchiveTest {
@Rule
public final ExpectedException expectedException = ExpectedException.none();
- private static FlagsTarget mainControllerTarget = FlagsTarget.forController(SYSTEM);
- private static FlagsTarget prodUsWestCfgTarget = createConfigserverTarget(Environment.prod, "us-west-1");
- private static FlagsTarget prodUsEast3CfgTarget = createConfigserverTarget(Environment.prod, "us-east-3");
- private static FlagsTarget devUsEast1CfgTarget = createConfigserverTarget(Environment.dev, "us-east-1");
+ private static final FlagsTarget mainControllerTarget = FlagsTarget.forController(SYSTEM);
+ private static final FlagsTarget prodUsWestCfgTarget = createConfigserverTarget(Environment.prod, "us-west-1");
+ private static final FlagsTarget prodUsEast3CfgTarget = createConfigserverTarget(Environment.prod, "us-east-3");
+ private static final FlagsTarget devUsEast1CfgTarget = createConfigserverTarget(Environment.dev, "us-east-1");
private static FlagsTarget createConfigserverTarget(Environment environment, String region) {
return new ConfigServerFlagsTarget(
@@ -233,15 +232,15 @@ public class SystemFlagsDataArchiveTest {
private static void assertFlagDataHasValue(SystemFlagsDataArchive archive, FlagId flagId, FlagsTarget target, String value) {
List<FlagData> data = getData(archive, flagId, target);
- assertThat(data).hasSize(1);
+ assertEquals(1, data.size());
FlagData flagData = data.get(0);
RawFlag rawFlag = flagData.resolve(FetchVector.fromMap(Map.of())).get();
- assertThat(rawFlag.asJson()).isEqualTo(String.format("\"%s\"", value));
+ assertEquals(String.format("\"%s\"", value), rawFlag.asJson());
}
private static void assertNoFlagData(SystemFlagsDataArchive archive, FlagId flagId, FlagsTarget target) {
List<FlagData> data = getData(archive, flagId, target);
- assertThat(data).isEmpty();
+ assertTrue(data.isEmpty());
}
private static List<FlagData> getData(SystemFlagsDataArchive archive, FlagId flagId, FlagsTarget target) {
diff --git a/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java b/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java
index 91b786e20f5..b3ae9d2bd0c 100644
--- a/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java
+++ b/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java
@@ -39,8 +39,6 @@ import com.yahoo.document.datatypes.WeightedSet;
import com.yahoo.document.serialization.DocumentDeserializerFactory;
import com.yahoo.document.serialization.DocumentSerializer;
import com.yahoo.document.serialization.DocumentSerializerFactory;
-import com.yahoo.document.serialization.VespaDocumentDeserializerHead;
-import com.yahoo.document.serialization.VespaDocumentSerializerHead;
import com.yahoo.io.GrowableByteBuffer;
import com.yahoo.searchdefinition.derived.Deriver;
import com.yahoo.tensor.Tensor;
@@ -74,16 +72,14 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import static junit.framework.TestCase.assertFalse;
-import static junit.framework.TestCase.assertNotSame;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertThat;
/**
* Tests vespa-documentgen-plugin
@@ -448,7 +444,7 @@ public class DocumentGenPluginTest {
final Field field = book.getField("ref");
final FieldValue value = book.getFieldValue(field);
- assertThat(value, instanceOf(ReferenceFieldValue.class));
+ assertTrue(value instanceof ReferenceFieldValue);
final ReferenceFieldValue refValue = (ReferenceFieldValue)value;
assertEquals(field.getDataType(), refValue.getDataType());
assertTrue(refValue.getDocumentId().isPresent());
diff --git a/fileacquirer/src/test/java/MockFileAcquirerTest.java b/fileacquirer/src/test/java/MockFileAcquirerTest.java
index b03c3f6ed3d..4b48bffe24b 100644
--- a/fileacquirer/src/test/java/MockFileAcquirerTest.java
+++ b/fileacquirer/src/test/java/MockFileAcquirerTest.java
@@ -1,17 +1,18 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
import com.yahoo.config.FileReference;
-
-import com.yahoo.filedistribution.fileacquirer.*;
+import com.yahoo.filedistribution.fileacquirer.FileAcquirer;
+import com.yahoo.filedistribution.fileacquirer.FileReferenceDoesNotExistException;
+import com.yahoo.filedistribution.fileacquirer.MockFileAcquirer;
+import com.yahoo.filedistribution.fileacquirer.TimeoutException;
+import org.junit.Test;
import java.io.File;
import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
-import java.util.Map;
import java.util.concurrent.TimeUnit;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+
/**
* Test of public API of MockFileAcquirer, since it is intended to be used by 3rd parties.
@@ -19,14 +20,13 @@ import static org.junit.Assert.assertThat;
* @author Tony Vaagenes
*/
public class MockFileAcquirerTest {
- @org.junit.Test
+ @Test
public void testReturnFile() throws Exception {
File file = new File("/test");
- assertThat(waitFor(MockFileAcquirer.returnFile(file)),
- equalTo(file));
+ assertEquals(file, waitFor(MockFileAcquirer.returnFile(file)));
}
- @org.junit.Test
+ @Test
public void testReturnFiles() throws Exception {
File file1 = new File("/test1");
File file2 = new File("/test2");
@@ -37,18 +37,16 @@ public class MockFileAcquirerTest {
FileAcquirer fileAcquirer = MockFileAcquirer.returnFiles(map);
- assertThat(waitFor(fileAcquirer, createFileReference("1")),
- equalTo(file1));
- assertThat(waitFor(fileAcquirer, createFileReference("2")),
- equalTo(file2));
+ assertEquals(file1, waitFor(fileAcquirer, createFileReference("1")));
+ assertEquals(file2, waitFor(fileAcquirer, createFileReference("2")));
}
- @org.junit.Test(expected = TimeoutException.class)
+ @Test(expected = TimeoutException.class)
public void testThrowTimeoutException() throws Exception {
waitFor(MockFileAcquirer.throwTimeoutException());
}
- @org.junit.Test(expected = FileReferenceDoesNotExistException.class)
+ @Test(expected = FileReferenceDoesNotExistException.class)
public void testThrowFileReferenceDoesNotExistException() throws Exception {
waitFor(MockFileAcquirer.throwFileReferenceDoesNotExistException());
}
diff --git a/http-utils/pom.xml b/http-utils/pom.xml
index 0d340922042..6d2e009cf8c 100644
--- a/http-utils/pom.xml
+++ b/http-utils/pom.xml
@@ -46,11 +46,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
diff --git a/http-utils/src/test/java/ai/vespa/util/http/retry/DelayedResponseLevelRetryHandlerTest.java b/http-utils/src/test/java/ai/vespa/util/http/retry/DelayedResponseLevelRetryHandlerTest.java
index 7be1e143078..dbc93f28d6b 100644
--- a/http-utils/src/test/java/ai/vespa/util/http/retry/DelayedResponseLevelRetryHandlerTest.java
+++ b/http-utils/src/test/java/ai/vespa/util/http/retry/DelayedResponseLevelRetryHandlerTest.java
@@ -11,7 +11,7 @@ import org.junit.Test;
import java.time.Duration;
import java.util.List;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -64,7 +64,7 @@ public class DelayedResponseLevelRetryHandlerTest {
int lastExecutionCount = maxRetries + 1;
for (int i = 1; i <= lastExecutionCount; i++) {
handler.retryRequest(response, i, ctx);
- assertThat(handler.getRetryInterval()).isEqualTo(delay.toMillis());
+ assertEquals(delay.toMillis(), handler.getRetryInterval());
}
}
@@ -88,7 +88,7 @@ public class DelayedResponseLevelRetryHandlerTest {
Duration.ofSeconds(5), Duration.ofSeconds(5), Duration.ofSeconds(5));
for (int i = 1; i <= lastExecutionCount; i++) {
handler.retryRequest(response, i, ctx);
- assertThat(handler.getRetryInterval()).isEqualTo(expectedIntervals.get(i-1).toMillis());
+ assertEquals(expectedIntervals.get(i-1).toMillis(), handler.getRetryInterval());
}
}
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java
index edcbe430d59..2aa4f094119 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java
@@ -3,9 +3,7 @@ package com.yahoo.jdisc;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.sameInstance;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -19,8 +17,8 @@ public class ReferencedResourceTestCase {
final SharedResource resource = mock(SharedResource.class);
final ResourceReference reference = mock(ResourceReference.class);
final ReferencedResource<SharedResource> referencedResource = new ReferencedResource<>(resource, reference);
- assertThat(referencedResource.getResource(), is(sameInstance(resource)));
- assertThat(referencedResource.getReference(), is(sameInstance(reference)));
+ assertSame(resource, referencedResource.getResource());
+ assertSame(reference, referencedResource.getReference());
}
@Test
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java
index f8aed27dcdf..d7829df4152 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java
@@ -17,10 +17,8 @@ import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
-import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -107,7 +105,7 @@ public class NodeRepositoryTest {
tester.nodeRepository().markNodeAvailableForNewAllocation("host2", Agent.system, getClass().getSimpleName());
fail();
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage(), containsString("hardware failure"));
+ assertTrue(e.getMessage().contains("hardware failure"));
}
}
diff --git a/predicate-search-core/src/test/java/com/yahoo/search/predicate/PredicateQueryParserTest.java b/predicate-search-core/src/test/java/com/yahoo/search/predicate/PredicateQueryParserTest.java
index 806cae89333..35fc7399dfb 100644
--- a/predicate-search-core/src/test/java/com/yahoo/search/predicate/PredicateQueryParserTest.java
+++ b/predicate-search-core/src/test/java/com/yahoo/search/predicate/PredicateQueryParserTest.java
@@ -7,8 +7,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author bjorncs
@@ -35,9 +34,9 @@ public class PredicateQueryParserTest {
(k, v, s) -> result.add(String.format("%s:%s:%#x", k, v, s)),
(k, v, s) -> result.add(String.format("%s:%d:%#x", k, v, s)));
- assertThat(result, is(Arrays.asList(
+ assertEquals(result, Arrays.asList(
"k1:value1:0x1", "k2:value2:0x3",
- "range1:123456789123:0xffff", "range2:0:0xffffffffffffffff")));
+ "range1:123456789123:0xffff", "range2:0:0xffffffffffffffff"));
}
}
diff --git a/vdslib/src/test/java/com/yahoo/vdslib/distribution/GroupTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/distribution/GroupTestCase.java
index e81d77d5972..d1f270eb40b 100644
--- a/vdslib/src/test/java/com/yahoo/vdslib/distribution/GroupTestCase.java
+++ b/vdslib/src/test/java/com/yahoo/vdslib/distribution/GroupTestCase.java
@@ -4,13 +4,16 @@ package com.yahoo.vdslib.distribution;
import org.junit.Test;
import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class GroupTestCase {
@@ -18,7 +21,7 @@ public class GroupTestCase {
Group.Distribution distribution = new Group.Distribution(spec, redundancy);
assertEquals(spec, distribution.toString());
int[] resultArray = distribution.getRedundancyArray(redundancy);
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for (int i=0; i<resultArray.length; ++i) {
if (i != 0) sb.append(',');
sb.append(resultArray[i]);
@@ -29,7 +32,7 @@ public class GroupTestCase {
private void assertDistributionFailure(String spec, int redundancy, String expectedError) {
try{
Group.Distribution distribution = new Group.Distribution(spec, redundancy);
- assertTrue("Failed to fail parsing of spec \"" + spec + "\", redundancy " + redundancy + " with failure: " + expectedError, false);
+ fail("Failed to fail parsing of spec \"" + spec + "\", redundancy " + redundancy + " with failure: " + expectedError);
} catch (Exception e) {
assertEquals(expectedError, e.getMessage());
}
@@ -73,7 +76,7 @@ public class GroupTestCase {
private Group buildGroupTree() throws ParseException {
Group root = new Group(5, "myroot", new Group.Distribution("2|*", 7));
- List<Group> level_one = new ArrayList<Group>();
+ List<Group> level_one = new ArrayList<>();
level_one.add(new Group(0, "br0", new Group.Distribution("1|1|*", 7)));
level_one.add(new Group(1, "br1", new Group.Distribution("*", 7)));
level_one.add(new Group(3, "br3", new Group.Distribution("8|*", 7)));
@@ -97,7 +100,7 @@ public class GroupTestCase {
try{
Group br8 = new Group(5, "br8", new Group.Distribution("*", 5));
root.addSubGroup(br8);
- assertTrue(false); // Should fail index 5 is in use at that level
+ fail(); // Should fail index 5 is in use at that level
} catch (Exception e) {
assertEquals("A subgroup with index 5 already exist.", e.getMessage());
}
@@ -105,19 +108,19 @@ public class GroupTestCase {
Group br8 = new Group(5, "br8");
Group br9 = new Group(2, "br9");
br8.addSubGroup(br9);
- assertTrue(false); // Should fail as we want distribution to be set on non-leaf node
+ fail(); // Should fail as we want distribution to be set on non-leaf node
} catch (Exception e) {
assertEquals("Cannot add sub groups to a node without distribution set.", e.getMessage());
}
try{
Group br8 = new Group(5, "br8", new Group.Distribution("*", 5));
setNodes(br8, "1,2,3");
- assertTrue(false); // Should fail as we can't have distribution on leaf node.
+ fail(); // Should fail as we can't have distribution on leaf node.
} catch (Exception e) {
assertEquals("Cannot add nodes to non-leaf group with distribution set", e.getMessage());
}
root.calculateDistributionHashValues();
- Set<Integer> distributionHashes = new HashSet<Integer>();
+ Set<Integer> distributionHashes = new HashSet<>();
verifyUniqueHashes(root, distributionHashes);
return root;
}
@@ -157,7 +160,7 @@ public class GroupTestCase {
@Test
public void testRootGroupDoesNotIncludeGroupNameWhenNoChildren() {
Group g = new Group(0, "donkeykong");
- assertThat(g.getUnixStylePath(), is("/"));
+ assertEquals("/", g.getUnixStylePath());
}
@Test
@@ -165,7 +168,7 @@ public class GroupTestCase {
Group g = new Group(0, "donkeykong", dummyDistribution());
Group child = new Group(1, "mario");
g.addSubGroup(child);
- assertThat(child.getUnixStylePath(), is("/mario"));
+ assertEquals("/mario", child.getUnixStylePath());
}
@Test
@@ -176,7 +179,7 @@ public class GroupTestCase {
mario.addSubGroup(toad);
g.addSubGroup(mario);
- assertThat(toad.getUnixStylePath(), is("/mario/toad"));
+ assertEquals("/mario/toad", toad.getUnixStylePath());
}
@Test
@@ -191,9 +194,9 @@ public class GroupTestCase {
Group luigi = new Group(4, "luigi");
g.addSubGroup(luigi);
- assertThat(toad.getUnixStylePath(), is("/mario/toad"));
- assertThat(yoshi.getUnixStylePath(), is("/mario/yoshi"));
- assertThat(luigi.getUnixStylePath(), is("/luigi"));
+ assertEquals("/mario/toad", toad.getUnixStylePath());
+ assertEquals("/mario/yoshi", yoshi.getUnixStylePath());
+ assertEquals("/luigi", luigi.getUnixStylePath());
}
}
diff --git a/vespa-hadoop/src/test/java/com/yahoo/vespa/hadoop/pig/VespaDocumentOperationTest.java b/vespa-hadoop/src/test/java/com/yahoo/vespa/hadoop/pig/VespaDocumentOperationTest.java
index e278026b00d..bafeb593e4f 100644
--- a/vespa-hadoop/src/test/java/com/yahoo/vespa/hadoop/pig/VespaDocumentOperationTest.java
+++ b/vespa-hadoop/src/test/java/com/yahoo/vespa/hadoop/pig/VespaDocumentOperationTest.java
@@ -1,12 +1,17 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hadoop.pig;
-import org.apache.pig.data.*;
+import org.apache.pig.data.BagFactory;
+import org.apache.pig.data.DataBag;
+import org.apache.pig.data.DataByteArray;
+import org.apache.pig.data.DataType;
+import org.apache.pig.data.SortedDataBag;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.logicalLayer.FrontendException;
import org.apache.pig.impl.logicalLayer.schema.Schema;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
-import org.hamcrest.CoreMatchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -21,7 +26,7 @@ import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
@SuppressWarnings("serial")
public class VespaDocumentOperationTest {
@@ -88,7 +93,7 @@ public class VespaDocumentOperationTest {
JsonNode fields = root.path("fields");
assertEquals("id:testapp:metrics::clicks-20160112", root.get("update").getTextValue());
- assertEquals(true, root.get("create").getBooleanValue());
+ assertTrue(root.get("create").getBooleanValue());
assertEquals("testapp", fields.get("application").get("assign").getTextValue());
assertEquals("clicks", fields.get("name").get("assign").getTextValue());
assertEquals(3, fields.get("value").get("assign").getIntValue());
@@ -345,7 +350,7 @@ public class VespaDocumentOperationTest {
assertEquals("value", map.get("string").getTextValue());
assertEquals(3, map.get("int").getIntValue());
assertEquals(3.145, map.get("float").getDoubleValue(), 1e-6);
- assertEquals(true, map.get("bool").getBooleanValue());
+ assertTrue(map.get("bool").getBooleanValue());
assertEquals("dGVzdGRhdGE=", map.get("byte").getTextValue());
assertEquals("string", map.get("map").get("a").getTextValue());
@@ -491,9 +496,7 @@ public class VespaDocumentOperationTest {
VespaDocumentOperation docOp = new VespaDocumentOperation(params);
docOp.setInputSchema(schema);
- String json = docOp.exec(tuple);
-
- return json;
+ return docOp.exec(tuple);
}
@@ -581,7 +584,7 @@ public class VespaDocumentOperationTest {
docOp.setInputSchema(schema);
String json = docOp.exec(tuple);
- assertThat(outContent.toString(), CoreMatchers.containsString("Processing docId: 7654321"));
+ assertTrue(outContent.toString().contains("Processing docId: 7654321"));
}
@Test
diff --git a/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java b/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java
index e449e7135d3..63fe2fd8d70 100644
--- a/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java
+++ b/vespalog/src/test/java/com/yahoo/log/FileLogTargetTest.java
@@ -8,10 +8,8 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -43,6 +41,6 @@ public class FileLogTargetTest {
assertNotNull(out1);
OutputStream out2 = logTarget.open();
assertNotNull(out2);
- assertThat(out1, is(not(out2)));
+ assertNotEquals(out1, out2);
}
}
diff --git a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
index 230744bb26f..d1863d1ad6d 100644
--- a/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
+++ b/vespalog/src/test/java/com/yahoo/log/LogSetupTestCase.java
@@ -9,16 +9,13 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
-import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -128,12 +125,12 @@ public class LogSetupTestCase {
public void testZooKeeperFilter() throws IOException {
final File file = folder.newFile("zookeeper");
LogSetup.ZooKeeperFilter filter = new LogSetup.ZooKeeperFilter(file.getAbsolutePath());
- assertThat(filter.isLoggable(zookeeperLogRecord), is(false));
- //assertThat(filter.isLoggable(zookeeperLogRecordError), is(true));
- assertThat(filter.isLoggable(notzookeeperLogRecord), is(true));
+ assertFalse(filter.isLoggable(zookeeperLogRecord));
+ //assertTrue(filter.isLoggable(zookeeperLogRecordError));
+ assertTrue(filter.isLoggable(notzookeeperLogRecord));
File actualLogFile = new File(file.getParent(), "zookeeper.0.log"); // Real file name will have .0.log appended
String[] lines = VespaLogHandlerTestCase.readFile(actualLogFile.getAbsolutePath());
- assertThat(lines.length, is(1));
+ assertEquals(1, lines.length);
assertEquals(zookeeperLogRecordString, lines[0]);
}
@@ -146,7 +143,7 @@ public class LogSetupTestCase {
Logger.getLogger("TEST").log(LogLevel.DEBUG, "DEBUG");
LevelController levelController = LogSetup.getLogHandler().getLevelControl("TST");
assertNotNull(levelController);
- assertThat(levelController.getOnOffString(), is(expectedOnOffString));
+ assertEquals(expectedOnOffString, levelController.getOnOffString());
if (shouldLog != null) {
assertTrue(levelController.shouldLog(shouldLog));
}
diff --git a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
index 220e5e9271e..7a45cd8b1fb 100644
--- a/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
+++ b/vespalog/src/test/java/com/yahoo/log/VespaLogHandlerTestCase.java
@@ -22,10 +22,8 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import static java.time.Instant.ofEpochSecond;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -33,20 +31,20 @@ import static org.junit.Assert.fail;
* @author Bjorn Borud
*/
public class VespaLogHandlerTestCase {
- private static String hostname;
- private static String pid;
+ private final static String hostname;
+ private final static String pid;
- static LogRecord record1;
- static String record1String;
+ static final LogRecord record1;
+ static final String record1String;
- static LogRecord record2;
- private static String record2String;
+ static final LogRecord record2;
+ private static final String record2String;
- private static LogRecord record3;
- private static String record3String;
+ private static final LogRecord record3;
+ private static final String record3String;
- private static LogRecord record4;
- private static String record4String;
+ private static final LogRecord record4;
+ private static final String record4String;
static {
hostname = Util.getHostName();
@@ -191,7 +189,7 @@ public class VespaLogHandlerTestCase {
h.close();
String [] lines = target.getLines();
- assertThat(lines.length, is(4));
+ assertEquals(4, lines.length);
assertEquals(record1String, lines[0]);
assertEquals(record3String, lines[1]);
//assertEquals(record4String, lines[2]);
@@ -375,7 +373,7 @@ public class VespaLogHandlerTestCase {
}
private static class MockLevelControllerRepo implements LevelControllerRepo {
- private LevelController levelController;
+ private final LevelController levelController;
MockLevelControllerRepo(LevelController controller) {
this.levelController = controller;
}
diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
index d428540f8c1..2bf40c4e2bb 100644
--- a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
+++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
@@ -11,8 +11,7 @@ import org.junit.Test;
import java.io.IOException;
import java.util.Optional;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* Sets up actual ZooKeeper servers and verifies we can talk to them.
@@ -55,8 +54,8 @@ public class CuratorTest {
@Test
public void require_curator_is_created_from_config() {
try (Curator curator = createCurator(createTestConfig())) {
- assertThat(curator.zooKeeperEnsembleConnectionSpec(), is(spec1 + "," + spec2));
- assertThat(curator.zooKeeperEnsembleCount(), is(2));
+ assertEquals(spec1 + "," + spec2, curator.zooKeeperEnsembleConnectionSpec());
+ assertEquals(2, curator.zooKeeperEnsembleCount());
}
}
@@ -65,7 +64,7 @@ public class CuratorTest {
ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
builder.zookeeperserver(createZKBuilder(localhost, port1));
try (Curator curator = createCurator(new ConfigserverConfig(builder))) {
- assertThat(curator.zooKeeperEnsembleCount(), is(1));
+ assertEquals(1, curator.zooKeeperEnsembleCount());
}
}
@@ -82,7 +81,7 @@ public class CuratorTest {
HostName.setHostNameForTestingOnly(localhostHostName);
String localhostSpec = localhostHostName + ":" + localhostPort;
- assertThat(Curator.createConnectionSpecForLocalhost(config), is(localhostSpec));
+ assertEquals(localhostSpec, Curator.createConnectionSpecForLocalhost(config));
}
private ConfigserverConfig createTestConfig() {
diff --git a/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java b/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java
index 74e21339022..3838b10d914 100644
--- a/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java
+++ b/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java
@@ -29,9 +29,8 @@ import static com.yahoo.security.SignatureAlgorithm.SHA256_WITH_ECDSA;
import static com.yahoo.vespa.zookeeper.Configurator.ZOOKEEPER_JUTE_MAX_BUFFER;
import static java.time.Instant.EPOCH;
import static java.time.temporal.ChronoUnit.DAYS;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static com.yahoo.vespa.defaults.Defaults.getDefaults;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -140,12 +139,12 @@ public class ConfiguratorTest {
builder.myidFile(idFile.getAbsolutePath());
new Configurator(builder.build()).writeConfigToDisk(Optional.empty());
- assertThat(System.getProperty(ZOOKEEPER_JUTE_MAX_BUFFER), is("" + new ZookeeperServerConfig(builder).juteMaxBuffer()));
+ assertEquals("" + new ZookeeperServerConfig(builder).juteMaxBuffer(), System.getProperty(ZOOKEEPER_JUTE_MAX_BUFFER));
final int max_buffer = 1;
builder.juteMaxBuffer(max_buffer);
new Configurator(builder.build()).writeConfigToDisk(Optional.empty());
- assertThat(System.getProperty(ZOOKEEPER_JUTE_MAX_BUFFER), is("" + max_buffer));
+ assertEquals("" + max_buffer, System.getProperty(ZOOKEEPER_JUTE_MAX_BUFFER));
}
private ZookeeperServerConfig.Server.Builder newServer(int id, String hostName, int electionPort, int quorumPort) {
@@ -159,7 +158,7 @@ public class ConfiguratorTest {
private void validateIdFile(File idFile, String expected) throws IOException {
String actual = IOUtils.readFile(idFile);
- assertThat(actual, is(expected));
+ assertEquals(expected, actual);
}
private String commonConfig() {
@@ -285,7 +284,7 @@ public class ConfiguratorTest {
private void validateConfigFile(File cfgFile, String expected) throws IOException {
String actual = IOUtils.readFile(cfgFile);
- assertThat(actual, is(expected));
+ assertEquals(expected, actual);
}
private void validateThatJksKeyStoreFileExists(File cfgFile) {