summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-12-20 18:38:08 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2021-12-21 01:18:09 +0100
commite8f31cbe437ee969f4dd0490a0409b62b2fd045d (patch)
tree694203ae0423448b259c924c167ecb5584c36229
parent5d6f586ccff9880a40366d51f75db5234795c0fc (diff)
GC deprecated junit assertThat.
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java6
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java7
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java66
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java30
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java46
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java18
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java16
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MonitoringElementTest.java15
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/TelegrafTest.java12
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComponentValidatorTest.java9
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSchemaClusterChangeValidatorTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java9
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java30
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomComponentBuilderTest.java13
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java21
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/LegacyConfigModelBuilderTest.java3
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomFederationSearcherBuilderTest.java7
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java15
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/ContainerIncludeTest.java67
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java30
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/docproc/StandaloneDocprocContainerTest.java12
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterChainsTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterConfigTest.java24
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcherTest.java7
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationTest.java14
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SchemaChainsTest.java7
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SourceGroupTest.java18
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java41
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java43
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/DocprocBuilderTest.java103
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java21
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java14
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/ClusterResourceLimitsTest.java35
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java15
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/GenericConfigTest.java7
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java41
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java25
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/IndexedTest.java13
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java36
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/MonitoringConfigSnoopTest.java19
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java36
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/generic/GenericServicesModelTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaNodeTest.java5
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/storage/test/StorageModelTestCase.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java21
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java39
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java8
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java39
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java19
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java7
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java38
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java5
-rwxr-xr-xconfig/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java7
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java11
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/FunctionTest.java6
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java5
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java15
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java2
-rwxr-xr-xconfig/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java13
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java6
-rwxr-xr-xconfig/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java35
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java44
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java63
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java25
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java3
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java3
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java13
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java5
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java16
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java2
-rw-r--r--container-core/src/test/java/com/yahoo/container/di/ConfigRetrieverTest.java27
-rw-r--r--container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ComponentGraphTest.java63
-rw-r--r--container-core/src/test/java/com/yahoo/container/di/componentgraph/core/FallbackToGuiceInjectorTest.java32
-rw-r--r--container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ReuseComponentsTest.java26
-rw-r--r--container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/CycleFinderTest.java22
-rw-r--r--container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/GraphTest.java36
-rw-r--r--container-core/src/test/java/com/yahoo/container/handler/AccessLogRequestHandlerTest.java9
-rw-r--r--container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java14
-rw-r--r--container-core/src/test/java/com/yahoo/container/logging/CircularArrayAccessLogKeeperTest.java2
-rw-r--r--container-core/src/test/java/com/yahoo/osgi/provider/model/ComponentModelTest.java15
-rw-r--r--container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java207
-rw-r--r--container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java56
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java1
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentIdTestCase.java37
-rw-r--r--document/src/test/java/com/yahoo/document/datatypes/ReferenceFieldValueTestCase.java17
-rw-r--r--document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java44
-rw-r--r--document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java17
-rw-r--r--document/src/test/java/com/yahoo/document/update/TensorModifyUpdateTest.java18
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyRepositoryTest.java17
-rw-r--r--jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzAuthorizationFilterTest.java22
-rw-r--r--jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzPrincipalFilterTest.java17
-rw-r--r--jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/base/JsonSecurityRequestFilterBaseTest.java13
-rw-r--r--vespajlib/src/main/java/com/yahoo/io/TeeInputStream.java100
-rw-r--r--vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java79
-rw-r--r--vespajlib/src/test/java/com/yahoo/io/TeeInputStreamTest.java101
-rw-r--r--vespajlib/src/test/java/com/yahoo/path/PathTest.java119
-rw-r--r--vespajlib/src/test/java/com/yahoo/reflection/CastingTest.java6
-rw-r--r--vespajlib/src/test/java/com/yahoo/slime/BinaryFormatTestCase.java3
-rw-r--r--vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java21
-rw-r--r--vespajlib/src/test/java/com/yahoo/slime/SlimeTestCase.java5
-rw-r--r--vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java14
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/TensorTypeTestCase.java4
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/TypeResolverTestCase.java3
-rw-r--r--vespajlib/src/test/java/com/yahoo/text/LowercaseTestCase.java16
-rw-r--r--vespajlib/src/test/java/com/yahoo/text/StringUtilitiesTest.java31
-rw-r--r--vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java2
-rw-r--r--vespajlib/src/test/java/com/yahoo/vespa/objects/FieldBaseTestCase.java4
-rw-r--r--vespajlib/src/test/java/com/yahoo/vespa/objects/ObjectDumperTestCase.java45
-rw-r--r--vespajlib/src/test/java/com/yahoo/vespa/objects/SerializeTestCase.java2
117 files changed, 1195 insertions, 1522 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java
index f842ca72d92..31d089d64db 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/HostPortsTest.java
@@ -12,7 +12,7 @@ import java.util.List;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author arnej
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java b/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java
index a0f988f7f3b..80a388a822e 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java
@@ -9,13 +9,11 @@ import com.yahoo.config.provision.HostSpec;
import com.yahoo.config.provision.NodeResources;
import org.junit.Test;
-import java.util.List;
import java.util.Optional;
import static com.yahoo.config.provision.ClusterSpec.Type.container;
-import static org.hamcrest.Matchers.endsWith;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* @author gjoranv
@@ -30,7 +28,7 @@ public class HostResourceTest {
try {
service.initService(root.deployLogger());
} catch (RuntimeException e) {
- assertThat(e.getMessage(), endsWith("No host found for service 'hostresourcetest$testservice0'. " +
+ assertTrue(e.getMessage().endsWith("No host found for service 'hostresourcetest$testservice0'. " +
"The hostalias is probably missing from hosts.xml."));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java
index bf9ffb13a7a..bff90080115 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java
@@ -26,9 +26,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -122,10 +121,10 @@ public class VespaModelFactoryTest {
Model model = new VespaModelFactory(new NullConfigModelRegistry()).createModel(modelContext);
List<HostInfo> allocatedHosts = new ArrayList<>(model.getHosts());
- assertThat(allocatedHosts.size(), is(1));
+ assertEquals(1, allocatedHosts.size());
HostInfo hostInfo = allocatedHosts.get(0);
- assertThat(hostInfo.getHostname(), is(hostName));
+ assertEquals(hostName, hostInfo.getHostname());
assertTrue("Routing service should run on host " + hostName,
hostInfo.getServices().stream()
.map(ServiceInfo::getConfigId)
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java
index f296b0e83e2..7d12b9d6386 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java
@@ -30,12 +30,10 @@ import org.junit.Test;
import java.util.Set;
import static com.yahoo.config.model.api.container.ContainerServiceType.METRICS_PROXY_CONTAINER;
-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.assertNotSame;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -55,7 +53,7 @@ public class AdminTestCase {
VespaModel vespaModel = getVespaModel(TESTDIR + "adminconfig20");
// Verify that the admin plugin has been loaded (always loads routing).
- assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
+ assertEquals(2, vespaModel.configModelRepo().asMap().size());
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertNotNull(root);
@@ -102,12 +100,12 @@ public class AdminTestCase {
SentinelConfig.Builder b = new SentinelConfig.Builder();
vespaModel.getConfig(b, localhostConfigId);
SentinelConfig sentinelConfig = new SentinelConfig(b);
- assertThat(sentinelConfig.service().size(), is(5));
- assertThat(sentinelConfig.service(0).name(), is("logserver"));
- assertThat(sentinelConfig.service(1).name(), is("slobrok"));
- assertThat(sentinelConfig.service(2).name(), is("slobrok2"));
- assertThat(sentinelConfig.service(3).name(), is(METRICS_PROXY_CONTAINER.serviceName));
- assertThat(sentinelConfig.service(4).name(), is("logd"));
+ assertEquals(5, sentinelConfig.service().size());
+ assertEquals("logserver", sentinelConfig.service(0).name());
+ assertEquals("slobrok", sentinelConfig.service(1).name());
+ assertEquals("slobrok2", sentinelConfig.service(2).name());
+ assertEquals(METRICS_PROXY_CONTAINER.serviceName, sentinelConfig.service(3).name());
+ assertEquals("logd", sentinelConfig.service(4).name());
}
/**
@@ -119,7 +117,7 @@ public class AdminTestCase {
VespaModel vespaModel = getVespaModel(TESTDIR + "simpleadminconfig20");
// Verify that the admin plugin has been loaded (always loads routing).
- assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
+ assertEquals(2, vespaModel.configModelRepo().asMap().size());
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertNotNull(root);
@@ -138,12 +136,12 @@ public class AdminTestCase {
SentinelConfig.Builder b = new SentinelConfig.Builder();
vespaModel.getConfig(b, localhostConfigId);
SentinelConfig sentinelConfig = new SentinelConfig(b);
- assertThat(sentinelConfig.service().size(), is(4));
- assertThat(sentinelConfig.service(0).name(), is("logserver"));
- assertThat(sentinelConfig.service(1).name(), is("slobrok"));
- assertThat(sentinelConfig.service(2).name(), is(METRICS_PROXY_CONTAINER.serviceName));
- assertThat(sentinelConfig.service(3).name(), is("logd"));
- assertThat(sentinelConfig.service(0).affinity().cpuSocket(), is(-1));
+ assertEquals(4, sentinelConfig.service().size());
+ assertEquals("logserver", sentinelConfig.service(0).name());
+ assertEquals("slobrok", sentinelConfig.service(1).name());
+ assertEquals(METRICS_PROXY_CONTAINER.serviceName, sentinelConfig.service(2).name());
+ assertEquals("logd", sentinelConfig.service(3).name());
+ assertEquals(-1, sentinelConfig.service(0).affinity().cpuSocket());
assertTrue(sentinelConfig.service(0).preShutdownCommand().isEmpty());
// Confirm slobrok config
@@ -168,11 +166,11 @@ public class AdminTestCase {
TestRoot root = new TestDriver().buildModel(state);
String localhost = HostName.getLocalhost();
SentinelConfig config = root.getConfig(SentinelConfig.class, "hosts/" + localhost);
- assertThat(config.application().tenant(), is("quux"));
- assertThat(config.application().name(), is("foo"));
- assertThat(config.application().environment(), is("dev"));
- assertThat(config.application().region(), is("baz"));
- assertThat(config.application().instance(), is("bim"));
+ assertEquals("quux", config.application().tenant());
+ assertEquals("foo", config.application().name());
+ assertEquals("dev", config.application().environment());
+ assertEquals("baz", config.application().region());
+ assertEquals("bim", config.application().instance());
}
@Test
@@ -180,7 +178,7 @@ public class AdminTestCase {
VespaModel vespaModel = getVespaModel(TESTDIR + "multipleconfigservers");
// Verify that the admin plugin has been loaded (always loads routing).
- assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
+ assertEquals(2, vespaModel.configModelRepo().asMap().size());
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertNotNull(root);
@@ -196,14 +194,14 @@ public class AdminTestCase {
assertTrue(configIds.contains("admin/configservers/configserver.0"));
assertTrue(configIds.contains("admin/configservers/configserver.1"));
- assertThat(admin.getConfigservers().size(), is(2));
+ assertEquals(2, admin.getConfigservers().size());
// Default configserver is the first one in the list and should have the default ports too
Configserver server1 = admin.getConfigservers().get(0);
assertEquals(admin.getConfigserver(), server1);
- assertThat(server1.getPortCount(), is(2));
- assertThat(server1.getRelativePort(0), is(19070));
- assertThat(server1.getRelativePort(1), is(19071));
+ assertEquals(2, server1.getPortCount());
+ assertEquals(19070, server1.getRelativePort(0));
+ assertEquals(19071, server1.getRelativePort(1));
// Second configserver should be on second host but have the same port number
@@ -212,9 +210,9 @@ public class AdminTestCase {
assertNotSame(server1, server2);
assertNotSame(server1.getHostName(), server2.getHostName());
- assertThat(server2.getPortCount(), is(2));
- assertThat(server2.getRelativePort(0), is(19070));
- assertThat(server2.getRelativePort(1), is(19071));
+ assertEquals(2, server2.getPortCount());
+ assertEquals(19070, server2.getRelativePort(0));
+ assertEquals(19071, server2.getRelativePort(1));
}
@Test
@@ -293,11 +291,11 @@ public class AdminTestCase {
TestRoot root = new TestDriver().buildModel(state);
String localhost = HostName.getLocalhost();
SentinelConfig sentinelConfig = root.getConfig(SentinelConfig.class, "hosts/" + localhost);
- assertThat(sentinelConfig.service().size(), is(4));
- assertThat(sentinelConfig.service(0).name(), is("logserver"));
- assertThat(sentinelConfig.service(1).name(), is("slobrok"));
- assertThat(sentinelConfig.service(2).name(), is(METRICS_PROXY_CONTAINER.serviceName));
- assertThat(sentinelConfig.service(3).name(), is("logd"));
+ assertEquals(4, sentinelConfig.service().size());
+ assertEquals("logserver", sentinelConfig.service(0).name());
+ assertEquals("slobrok", sentinelConfig.service(1).name());
+ assertEquals(METRICS_PROXY_CONTAINER.serviceName, sentinelConfig.service(2).name());
+ assertEquals("logd", sentinelConfig.service(3).name());
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java
index 55eb452d7b7..474013c17fc 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java
@@ -43,11 +43,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -106,11 +104,11 @@ public class ClusterControllerTestCase extends DomBuilderTest {
model.getConfig(builder, "admin/cluster-controllers/" + i + "/components/clustercontroller-bar-configurer");
FleetcontrollerConfig cfg = new FleetcontrollerConfig(builder);
- assertThat(cfg.index(), is(i));
- assertThat(cfg.fleet_controller_count(), is(3));
- assertThat(cfg.init_progress_time(), is(34567000));
- assertThat(cfg.storage_transition_time(), is(4000));
- assertThat(cfg.stable_state_time_period(), is(3600000));
+ assertEquals(i, cfg.index());
+ assertEquals(3, cfg.fleet_controller_count());
+ assertEquals(34567000, cfg.init_progress_time());
+ assertEquals(4000, cfg.storage_transition_time());
+ assertEquals(3600000, cfg.stable_state_time_period());
}
}
@@ -222,15 +220,15 @@ public class ClusterControllerTestCase extends DomBuilderTest {
ZookeepersConfig.Builder builder = new ZookeepersConfig.Builder();
root.getConfig(builder, "admin/standalone");
ZookeepersConfig config = new ZookeepersConfig(builder);
- assertThat(config.zookeeperserverlist().split(",").length, is(3));
+ assertEquals(3, config.zookeeperserverlist().split(",").length);
}
private void assertZookeeperServerConfig(TestRoot root, int id) {
ZookeeperServerConfig.Builder builder = new ZookeeperServerConfig.Builder();
root.getConfig(builder, "admin/standalone/cluster-controllers/" + id);
ZookeeperServerConfig config = new ZookeeperServerConfig(builder);
- assertThat(config.server().size(), is(3));
- assertThat(config.myid(), is(id));
+ assertEquals(3, config.server().size());
+ assertEquals(id, config.myid());
Collection<Integer> serverIds = Collections2.transform(config.server(), ZookeeperServerConfig.Server::id);
assertTrue(serverIds.contains(id));
}
@@ -281,15 +279,15 @@ public class ClusterControllerTestCase extends DomBuilderTest {
assertTrue(existsHostsWithClusterControllerConfigId(model));
assertGroupSize(model, "admin/cluster-controllers/0/components/clustercontroller-bar-configurer", 1);
- assertThat(model.getAdmin().getClusterControllers().getContainers().size(), is(1));
+ assertEquals(1, model.getAdmin().getClusterControllers().getContainers().size());
FleetcontrollerConfig.Builder builder = new FleetcontrollerConfig.Builder();
model.getConfig(builder, "admin/cluster-controllers/0/components/clustercontroller-bar-configurer");
FleetcontrollerConfig cfg = new FleetcontrollerConfig(builder);
- assertThat(cfg.index(), is(0));
- assertThat(cfg.fleet_controller_count(), is(1));
- assertThat(cfg.init_progress_time(), is(34567000));
+ assertEquals(0, cfg.index());
+ assertEquals(1, cfg.fleet_controller_count());
+ assertEquals(34567000, cfg.init_progress_time());
Service cc = model.getService("admin/cluster-controllers/0").get();
assertTrue(cc instanceof ClusterControllerContainer);
@@ -344,7 +342,7 @@ public class ClusterControllerTestCase extends DomBuilderTest {
VespaModel model = createVespaModel(xml);
- assertThat(model.getAdmin().getClusterControllers().getContainers().size(), is(3));
+ assertEquals(3, model.getAdmin().getClusterControllers().getContainers().size());
assertGroupSize(model, "admin/cluster-controllers/0/components/clustercontroller-bar-configurer", 1);
assertGroupSize(model, "admin/cluster-controllers/1/components/clustercontroller-bar-configurer", 1);
assertGroupSize(model, "admin/cluster-controllers/2/components/clustercontroller-bar-configurer", 1);
@@ -475,7 +473,7 @@ public class ClusterControllerTestCase extends DomBuilderTest {
StorDistributionConfig.Builder builder = new StorDistributionConfig.Builder();
model.getConfig(builder, configId);
StorDistributionConfig cfg = new StorDistributionConfig(builder);
- assertThat(cfg.group().size(), is(size));
+ assertEquals(size, cfg.group().size());
}
private VespaModel createVespaModel(String servicesXml) throws IOException, SAXException {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java
index 38e4afaf74b..b5dd4552023 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java
@@ -6,9 +6,7 @@ import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.admin.monitoring.Metric;
import com.yahoo.vespa.model.admin.monitoring.MetricSet;
import com.yahoo.vespa.model.admin.monitoring.MetricsConsumer;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.hosted;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.self_hosted;
@@ -26,6 +24,7 @@ import static com.yahoo.vespa.model.admin.monitoring.VespaMetricSet.vespaMetricS
import static java.util.Collections.singleton;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Tests for {@link MetricsProxyContainerCluster} related to metrics consumers.
@@ -34,15 +33,12 @@ import static org.junit.Assert.assertTrue;
*/
public class MetricsConsumersTest {
- private static int numPublicDefaultMetrics = defaultMetricSet.getMetrics().size();
- private static int numDefaultVespaMetrics = defaultVespaMetricSet.getMetrics().size();
- private static int numVespaMetrics = vespaMetricSet.getMetrics().size();
- private static int numSystemMetrics = systemMetricSet.getMetrics().size();
- private static int numNetworkMetrics = networkMetricSet.getMetrics().size();
- private static int numMetricsForVespaConsumer = numVespaMetrics + numSystemMetrics + numNetworkMetrics;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
+ private static final int numPublicDefaultMetrics = defaultMetricSet.getMetrics().size();
+ private static final int numDefaultVespaMetrics = defaultVespaMetricSet.getMetrics().size();
+ private static final int numVespaMetrics = vespaMetricSet.getMetrics().size();
+ private static final int numSystemMetrics = systemMetricSet.getMetrics().size();
+ private static final int numNetworkMetrics = networkMetricSet.getMetrics().size();
+ private static final int numMetricsForVespaConsumer = numVespaMetrics + numSystemMetrics + numNetworkMetrics;
@Test
public void default_public_consumer_is_set_up_for_self_hosted() {
@@ -103,9 +99,12 @@ public class MetricsConsumersTest {
" </admin>",
"</services>"
);
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("'" + consumerId + "' is not allowed as metrics consumer id");
- consumersConfigFromXml(services, self_hosted);
+ try {
+ consumersConfigFromXml(services, self_hosted);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("'" + consumerId + "' is not allowed as metrics consumer id (case is ignored.)", e.getMessage());
+ }
}
@Test
@@ -147,9 +146,13 @@ public class MetricsConsumersTest {
" </admin>",
"</services>"
);
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("'a' is used as id for two metrics consumers");
- consumersConfigFromXml(services, self_hosted);
+
+ try {
+ consumersConfigFromXml(services, self_hosted);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("'a' is used as id for two metrics consumers (case is ignored.)", e.getMessage());
+ }
}
@Test
@@ -166,9 +169,12 @@ public class MetricsConsumersTest {
" </admin>",
"</services>"
);
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("No such metric-set: non-existent");
- consumersConfigFromXml(services, self_hosted);
+ try {
+ consumersConfigFromXml(services, self_hosted);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("No such metric-set: non-existent", e.getMessage());
+ }
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java
index 6a7008f4ba2..c00a5f65d08 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java
@@ -20,6 +20,7 @@ import com.yahoo.vespa.model.container.component.Handler;
import org.junit.Test;
import java.util.Collection;
+import java.util.stream.Collectors;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.METRICS_PROXY_BUNDLE_FILE;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.zoneString;
@@ -34,10 +35,8 @@ import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.g
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getModel;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.servicesWithAdminOnly;
import static java.util.stream.Collectors.toList;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@@ -51,7 +50,10 @@ public class MetricsProxyContainerClusterTest {
var builder = new PlatformBundlesConfig.Builder();
model.getConfig(builder, CLUSTER_CONFIG_ID);
PlatformBundlesConfig config = builder.build();
- assertThat(config.bundlePaths(), hasItem(endsWith(METRICS_PROXY_BUNDLE_FILE.toString())));
+ assertFalse(config.bundlePaths().stream()
+ .filter(p -> p.endsWith(METRICS_PROXY_BUNDLE_FILE.toString()))
+ .collect(Collectors.toList())
+ .isEmpty());
}
@Test
@@ -71,10 +73,10 @@ public class MetricsProxyContainerClusterTest {
Collection<Handler<?>> handlers = model.getAdmin().getMetricsProxyCluster().getHandlers();
Collection<ComponentSpecification> handlerClasses = handlers.stream().map(Component::getClassId).collect(toList());
- assertThat(handlerClasses, hasItem(ComponentSpecification.fromString(MetricsV1Handler.class.getName())));
- assertThat(handlerClasses, hasItem(ComponentSpecification.fromString(PrometheusHandler.class.getName())));
- assertThat(handlerClasses, hasItem(ComponentSpecification.fromString(YamasHandler.class.getName())));
- assertThat(handlerClasses, hasItem(ComponentSpecification.fromString(ApplicationMetricsHandler.class.getName())));
+ assertTrue(handlerClasses.contains(ComponentSpecification.fromString(MetricsV1Handler.class.getName())));
+ assertTrue(handlerClasses.contains(ComponentSpecification.fromString(PrometheusHandler.class.getName())));
+ assertTrue(handlerClasses.contains(ComponentSpecification.fromString(YamasHandler.class.getName())));
+ assertTrue(handlerClasses.contains(ComponentSpecification.fromString(ApplicationMetricsHandler.class.getName())));
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java
index 6a5a1aad7a1..ad3a163f052 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java
@@ -20,10 +20,8 @@ import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.g
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getNodeDimensionsConfig;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getRpcConnectorConfig;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getVespaServicesConfig;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
@@ -38,15 +36,15 @@ public class MetricsProxyContainerTest {
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(hostedServicesWithManyNodes(), true);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
for (var host : model.hostSystem().getHosts()) {
- assertThat(host.getService(METRICS_PROXY_CONTAINER.serviceName), notNullValue());
+ assertNotNull(host.getService(METRICS_PROXY_CONTAINER.serviceName));
long metricsProxies = host.getServices().stream()
.filter(s -> s.getClass().equals(MetricsProxyContainer.class))
.count();
- assertThat(metricsProxies, is(1L));
+ assertEquals(1, metricsProxies);
}
}
@@ -57,15 +55,15 @@ public class MetricsProxyContainerTest {
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(hostedServicesWithManyNodes(), true);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
for (var host : model.hostSystem().getHosts()) {
- assertThat(host.getService(METRICS_PROXY_CONTAINER.serviceName), notNullValue());
+ assertNotNull(host.getService(METRICS_PROXY_CONTAINER.serviceName));
long metricsProxies = host.getServices().stream()
.filter(s -> s.getClass().equals(MetricsProxyContainer.class))
.count();
- assertThat(metricsProxies, is(1L));
+ assertEquals(1, metricsProxies);
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MonitoringElementTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MonitoringElementTest.java
index ee3496aa7bd..734844c9c7c 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MonitoringElementTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MonitoringElementTest.java
@@ -3,30 +3,29 @@ package com.yahoo.vespa.model.admin.metricsproxy;
import ai.vespa.metricsproxy.core.MonitoringConfig;
import com.yahoo.vespa.model.VespaModel;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.CLUSTER_CONFIG_ID;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.hosted;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.self_hosted;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getModel;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author gjoranv
*/
public class MonitoringElementTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void monitoring_element_is_disallowed_for_hosted_vespa() {
String services = servicesWithMonitoringElement();
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("The 'monitoring' element cannot be used");
- getModel(services, hosted);
+ try {
+ getModel(services, hosted);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("The 'monitoring' element cannot be used on hosted Vespa.", e.getMessage());
+ }
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/TelegrafTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/TelegrafTest.java
index 4db7bf302b5..5bd364f4e21 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/TelegrafTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/TelegrafTest.java
@@ -12,10 +12,8 @@ import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.C
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.hosted;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.self_hosted;
import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getModel;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@@ -29,8 +27,8 @@ public class TelegrafTest {
VespaModel hostedModel = getModel(services, hosted);
var clusterComponents = hostedModel.getAdmin().getMetricsProxyCluster().getComponentsMap();
- assertThat(clusterComponents.keySet(), hasItem(ComponentId.fromString(Telegraf.class.getName())));
- assertThat(clusterComponents.keySet(), hasItem(ComponentId.fromString(TelegrafRegistry.class.getName())));
+ assertTrue(clusterComponents.containsKey(ComponentId.fromString(Telegraf.class.getName())));
+ assertTrue(clusterComponents.containsKey(ComponentId.fromString(TelegrafRegistry.class.getName())));
}
@Test
@@ -47,8 +45,8 @@ public class TelegrafTest {
VespaModel hostedModel = getModel(services, hosted);
var clusterComponents = hostedModel.getAdmin().getMetricsProxyCluster().getComponentsMap();
- assertThat(clusterComponents.keySet(), not(hasItem(ComponentId.fromString(Telegraf.class.getName()))));
- assertThat(clusterComponents.keySet(), not(hasItem(ComponentId.fromString(TelegrafRegistry.class.getName()))));
+ assertFalse(clusterComponents.containsKey(ComponentId.fromString(Telegraf.class.getName())));
+ assertFalse(clusterComponents.containsKey(ComponentId.fromString(TelegrafRegistry.class.getName())));
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComponentValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComponentValidatorTest.java
index dec223562a4..a375621d391 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComponentValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComponentValidatorTest.java
@@ -11,9 +11,8 @@ import java.io.IOException;
import java.util.jar.JarFile;
import java.util.logging.Level;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class ComponentValidatorTest {
private static final String JARS_DIR = "src/test/cfg/application/validation/testjars/";
@@ -36,7 +35,7 @@ public class ComponentValidatorTest {
componentValidator.validateAll(new BaseDeployLogger());
assert (false);
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage(), is(exceptionMessage));
+ assertEquals(e.getMessage(), exceptionMessage);
}
}
@@ -52,6 +51,6 @@ public class ComponentValidatorTest {
};
new ComponentValidator(new JarFile(JARS_DIR + "snapshot_bundle.jar")).validateAll(logger);
- assertThat(buffer.toString(), containsString("Deploying snapshot bundle"));
+ assertTrue(buffer.toString().contains("Deploying snapshot bundle"));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java
index 7d84a4a844e..00a1ec7e6d8 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java
@@ -10,8 +10,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
public class ConfigChangeTestUtils {
@@ -63,7 +62,7 @@ public class ConfigChangeTestUtils {
var mutableAct = new ArrayList<>(act);
mutableExp.sort((lhs, rhs) -> lhs.getMessage().compareTo(rhs.getMessage()));
mutableAct.sort((lhs, rhs) -> lhs.getMessage().compareTo(rhs.getMessage()));
- assertThat(mutableAct, equalTo(mutableExp));
+ assertEquals(mutableExp, mutableAct);
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSchemaClusterChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSchemaClusterChangeValidatorTest.java
index dddb6a38db1..2e5b27bee6f 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSchemaClusterChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSchemaClusterChangeValidatorTest.java
@@ -19,8 +19,7 @@ import java.util.List;
import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.assertEqualActions;
import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.normalizeServicesInActions;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public class StreamingSchemaClusterChangeValidatorTest {
@@ -77,7 +76,7 @@ public class StreamingSchemaClusterChangeValidatorTest {
}
public void assertValidation() {
- assertThat(validate().size(), is(0));
+ assertTrue(validate().isEmpty());
}
public void assertValidation(ConfigChangeAction exp) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java
index 6a9c3025e79..030f1d7d85d 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java
@@ -12,9 +12,8 @@ import com.yahoo.vespa.model.search.DocumentDatabase;
import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Test fixture to setup current and next content clusters used for change validation.
@@ -62,7 +61,7 @@ public abstract class ContentClusterFixture {
public void assertValidation() {
List<VespaConfigChangeAction> act = validate();
- assertThat(act.size(), is(0));
+ assertTrue(act.isEmpty());
}
public void assertValidation(VespaConfigChangeAction exp) {
@@ -71,7 +70,7 @@ public abstract class ContentClusterFixture {
public void assertValidation(List<VespaConfigChangeAction> exp) {
List<VespaConfigChangeAction> act = validate();
- assertThat(act, equalTo(exp));
+ assertEquals(exp, act);
}
public abstract List<VespaConfigChangeAction> validate();
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java
index cfcf06702c7..1a41d2689a2 100755
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java
@@ -20,10 +20,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.CoreMatchers.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.assertEquals;
/**
@@ -122,12 +120,12 @@ public class DomAdminV2BuilderTest extends DomBuilderTest {
new TestProperties.Spec("test2", 19070, 2181),
new TestProperties.Spec("test3", 19070, 2181));
Admin admin = buildAdmin(servicesMultitenantAdminOnly(), true, configServerSpecs);
- assertThat(admin.getConfigservers().size(), is(3));
- assertThat(admin.getSlobroks().size(), is(1));
+ assertEquals(3, admin.getConfigservers().size());
+ assertEquals(1, admin.getSlobroks().size());
assertNotNull(admin.hostSystem().getHostByHostname("test1"));
for (Configserver configserver : admin.getConfigservers()) {
for (Slobrok slobrok : admin.getSlobroks()) {
- assertThat(slobrok.getHostName(), is(not(configserver.getHostName())));
+ assertNotEquals(configserver.getHostName(), slobrok.getHostName());
}
}
}
@@ -138,7 +136,7 @@ public class DomAdminV2BuilderTest extends DomBuilderTest {
@Test
public void adminWithConfigserverElement() {
Admin admin = buildAdmin(servicesConfigserver());
- assertThat(admin.getConfigservers().size(), is(1));
+ assertEquals(1, admin.getConfigservers().size());
}
/**
@@ -147,15 +145,15 @@ public class DomAdminV2BuilderTest extends DomBuilderTest {
@Test
public void adminWithConfigserversElement() {
Admin admin = buildAdmin(servicesConfigservers());
- assertThat(admin.getConfigservers().size(), is(1));
+ assertEquals(1, admin.getConfigservers().size());
}
@Test
public void basicYamasNoXml() {
Admin admin = buildAdmin(servicesNoYamas());
Monitoring y = admin.getMonitoring();
- assertThat(y.getClustername(), is("vespa"));
- assertThat(y.getInterval(), is(1));
+ assertEquals("vespa", y.getClustername());
+ assertEquals(1, y.getInterval().intValue());
}
@Test
@@ -168,16 +166,16 @@ public class DomAdminV2BuilderTest extends DomBuilderTest {
public void basicYamasXml() {
Admin admin = buildAdmin(servicesYamas());
Monitoring y = admin.getMonitoring();
- assertThat(y.getClustername(), is("foo"));
- assertThat(y.getInterval(), is(1));
+ assertEquals("foo", y.getClustername());
+ assertEquals(1, y.getInterval().intValue());
}
@Test
public void yamasWithIntervalOverride() {
Admin admin = buildAdmin(servicesYamasIntervalOverride());
Monitoring y = admin.getMonitoring();
- assertThat(y.getClustername(), is("foo"));
- assertThat(y.getInterval(), is(5));
+ assertEquals("foo", y.getClustername());
+ assertEquals(5, y.getInterval().intValue());
}
/**
@@ -196,11 +194,11 @@ public class DomAdminV2BuilderTest extends DomBuilderTest {
@Test
public void configOverridesCanBeUsedInAdmin() {
Admin admin = buildAdmin(servicesOverride());
- assertThat(admin.getUserConfigs().size(), is(1));
+ assertEquals(1, admin.getUserConfigs().size());
LogdConfig.Builder logdBuilder = new LogdConfig.Builder();
admin.addUserConfig(logdBuilder);
LogdConfig config = new LogdConfig(logdBuilder);
- assertThat(config.logserver().host(), is("foobar"));
+ assertEquals("foobar", config.logserver().host());
}
private Admin buildAdmin(Element xml) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomComponentBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomComponentBuilderTest.java
index ed342d1ca87..307cbf292db 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomComponentBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomComponentBuilderTest.java
@@ -8,9 +8,8 @@ import com.yahoo.vespa.model.container.component.Component;
import org.junit.Test;
import static com.yahoo.collections.CollectionUtil.first;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
/**
* @author gjoranv
@@ -23,9 +22,9 @@ public class DomComponentBuilderTest extends DomBuilderTest {
"<handler id='theId' class='theClass' bundle='theBundle' />"));
BundleInstantiationSpecification instantiationSpecification = handler.model.bundleInstantiationSpec;
- assertThat(instantiationSpecification.id.stringValue(), is("theId"));
- assertThat(instantiationSpecification.classId.stringValue(), is("theClass"));
- assertThat(instantiationSpecification.bundle.stringValue(), is("theBundle"));
+ assertEquals("theId", instantiationSpecification.id.stringValue());
+ assertEquals("theClass", instantiationSpecification.classId.stringValue());
+ assertEquals("theBundle", instantiationSpecification.bundle.stringValue());
}
@Test
@@ -36,10 +35,10 @@ public class DomComponentBuilderTest extends DomBuilderTest {
" <component id='child' />",
"</component>"));
- assertThat(parent.getGlobalComponentId(), is(ComponentId.fromString("parent")));
+ assertEquals(ComponentId.fromString("parent"), parent.getGlobalComponentId());
Component<?, ?> child = first(parent.getChildren().values());
assertNotNull(child);
- assertThat(child.getGlobalComponentId(), is(ComponentId.fromString("child@parent")));
+ assertEquals(ComponentId.fromString("child@parent"), child.getGlobalComponentId());
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java
index 40513b019b8..91482919e11 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomConfigPayloadBuilderTest.java
@@ -23,8 +23,7 @@ import java.io.FileReader;
import java.io.Reader;
import java.io.StringReader;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
@@ -37,7 +36,7 @@ public class DomConfigPayloadBuilderTest {
@Test
public void testFunctionTest_DefaultValues() throws FileNotFoundException {
- Element configRoot = getDocument(new FileReader(new File("src/test/cfg/admin/userconfigs/functiontest-defaultvalues.xml")));
+ Element configRoot = getDocument(new FileReader("src/test/cfg/admin/userconfigs/functiontest-defaultvalues.xml"));
ConfigPayload config = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
String expected = ""
+ "{"
@@ -65,7 +64,7 @@ public class DomConfigPayloadBuilderTest {
try {
ByteArrayOutputStream a = new ByteArrayOutputStream();
new JsonFormat(true).encode(a, payload.getSlime());
- assertThat(a.toString(), is(expected));
+ assertEquals(expected, a.toString());
} catch (Exception e) {
fail("Exception thrown when encoding slime: " + e.getMessage());
}
@@ -74,7 +73,7 @@ public class DomConfigPayloadBuilderTest {
// Multi line strings are not tested in 'DefaultValues', so here it is.
@Test
public void verifyThatWhitespaceIsPreservedForStrings() throws Exception {
- Element configRoot = getDocument(new FileReader(new File("src/test/cfg/admin/userconfigs/whitespace-test.xml")));
+ Element configRoot = getDocument(new FileReader("src/test/cfg/admin/userconfigs/whitespace-test.xml"));
ConfigPayload config = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
assertPayload("{\"stringVal\":\" This is a string\\n that contains different kinds of whitespace \"}", config);
}
@@ -164,8 +163,7 @@ public class DomConfigPayloadBuilderTest {
new DomConfigPayloadBuilder(null).build(configRoot);
fail("Expected exception for wrong tag name.");
} catch (ConfigurationRuntimeException e) {
- assertThat(e.getMessage(),
- is("The root element must be 'config', but was 'configs'."));
+ assertEquals("The root element must be 'config', but was 'configs'.", e.getMessage());
}
}
@@ -177,8 +175,7 @@ public class DomConfigPayloadBuilderTest {
new DomConfigPayloadBuilder(null).build(configRoot);
fail("Expected exception for mismatch between def-name and xml name attribute.");
} catch (ConfigurationRuntimeException e) {
- assertThat(e.getMessage(),
- is("The 'config' element must have a 'name' attribute that matches the name of the config definition."));
+ assertEquals("The 'config' element must have a 'name' attribute that matches the name of the config definition.", e.getMessage());
}
}
@@ -188,8 +185,8 @@ public class DomConfigPayloadBuilderTest {
"<int_val>1</int_val> +" +
"</config>"));
ConfigDefinitionKey key = DomConfigPayloadBuilder.parseConfigName(configRoot);
- assertThat(key.getName(), is("function-test"));
- assertThat(key.getNamespace(), is("test"));
+ assertEquals("function-test", key.getName());
+ assertEquals("test", key.getNamespace());
}
@Test(expected = ConfigurationRuntimeException.class)
@@ -273,7 +270,7 @@ public class DomConfigPayloadBuilderTest {
new FileReader(new File("src/test/resources/configdefinitions/test.simpletypes.def")));
ConfigDefinition def = ConfigDefinitionBuilder.createConfigDefinition(defParser.getTree());
ConfigPayloadBuilder builder = new DomConfigPayloadBuilder(def).build(configRoot);
- //assertThat(builder.warnings().size(), is(1));
+ //assertEquals(1, builder.warnings().size());
}
private Element getDocument(Reader xmlReader) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/LegacyConfigModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/LegacyConfigModelBuilderTest.java
index 8236528f3d0..2bcb1a7459b 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/LegacyConfigModelBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/LegacyConfigModelBuilderTest.java
@@ -14,6 +14,7 @@ import org.w3c.dom.Element;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
/**
@@ -27,7 +28,7 @@ public class LegacyConfigModelBuilderTest {
ModelBuilder builder = new ModelBuilder();
Model model = builder.build(DeployState.createTestState(new MockApplicationPackage.Builder().withServices(services).build()),
null, null, new MockRoot(), XML.getDocument(services).getDocumentElement());
- assertThat(model.getContext().getParentProducer().getUserConfigs().size(), is(1));
+ assertEquals(1, model.getContext().getParentProducer().getUserConfigs().size());
}
public static class Model extends ConfigModel {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomFederationSearcherBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomFederationSearcherBuilderTest.java
index ae087f71855..d68f306c043 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomFederationSearcherBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomFederationSearcherBuilderTest.java
@@ -11,12 +11,9 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertThat;
/**
* Test of DomFederationSearcherBuilder.
@@ -46,7 +43,7 @@ public class DomFederationSearcherBuilderTest extends DomBuilderTest {
assertEquals(2, model.targets.size());
assertTrue("source-set option was ignored", model.inheritDefaultSources);
- assertThat(targetNames(model.targets), hasItems("source1", "source2"));
+ assertTrue(targetNames(model.targets).containsAll(List.of("source1", "source2")));
}
private List<String> targetNames(List<FederationSearcherModel.TargetSpec> targets) {
@@ -71,7 +68,7 @@ public class DomFederationSearcherBuilderTest extends DomBuilderTest {
FederationConfig.Builder builder = new FederationConfig.Builder();
searcher.getConfig(builder);
- assertThat(new FederationConfig(builder).targetSelector(), is(targetSelectorId));
+ assertEquals(targetSelectorId, new FederationConfig(builder).targetSelector());
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java
index 86c448c403c..d052d4dd1f2 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java
@@ -8,7 +8,11 @@ import com.yahoo.config.model.test.MockRoot;
import com.yahoo.container.core.ChainsConfig;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
import com.yahoo.vespa.model.container.component.chain.ChainedComponent;
-import com.yahoo.vespa.model.container.search.searchchain.*;
+import com.yahoo.vespa.model.container.search.searchchain.GenericTarget;
+import com.yahoo.vespa.model.container.search.searchchain.Provider;
+import com.yahoo.vespa.model.container.search.searchchain.SearchChain;
+import com.yahoo.vespa.model.container.search.searchchain.SearchChains;
+import com.yahoo.vespa.model.container.search.searchchain.Source;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@@ -23,11 +27,10 @@ import java.util.List;
import static com.yahoo.container.core.ChainsConfig.Chains;
import static com.yahoo.container.core.ChainsConfig.Components;
import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
@@ -92,7 +95,7 @@ public class DomSchemaChainsBuilderTest extends DomBuilderTest {
new DomSearchChainsBuilder().build(root.getDeployState(), root, element);
fail("Expected exception when referring to an outer 'federation' as a 'searcher'.");
} catch (RuntimeException e) {
- assertThat(e.getMessage(), containsString("Two different types declared for the component with name 'federationSearcher'"));
+ assertTrue(e.getMessage().contains("Two different types declared for the component with name 'federationSearcher'"));
}
}
@@ -163,10 +166,10 @@ public class DomSchemaChainsBuilderTest extends DomBuilderTest {
Components searcher = getSearcherConfig(config.components(), partOfSearcherName);
ComponentId searcherId = ComponentId.fromString(searcher.id());
- assertThat(searcherId.getNamespace(), is(getSearchChain(searchChainName).getComponentId()));
+ assertEquals(getSearchChain(searchChainName).getComponentId(), searcherId.getNamespace());
Chains searchChain = getSearchChainConfig(config.chains(), searchChainName);
- assertThat(ComponentId.fromString(searchChain.components(0)), is(searcherId));
+ assertEquals(searcherId, ComponentId.fromString(searchChain.components(0)));
}
private Chains getSearchChainConfig(List<Chains> searchChains,
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java
index bcd29267277..eb1cf668cc9 100755
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java
@@ -31,7 +31,6 @@ import com.yahoo.vespa.model.container.component.Component;
import com.yahoo.vespa.model.container.docproc.ContainerDocproc;
import com.yahoo.vespa.model.container.search.ContainerSearch;
import com.yahoo.vespa.model.container.search.searchchain.SearchChains;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
import java.util.ArrayList;
@@ -50,10 +49,8 @@ import static com.yahoo.config.model.api.ApplicationClusterEndpoint.Scope.applic
import static com.yahoo.config.model.api.ApplicationClusterEndpoint.Scope.global;
import static com.yahoo.config.provision.SystemName.cd;
import static com.yahoo.config.provision.SystemName.main;
-import static org.hamcrest.Matchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -482,7 +479,7 @@ public class ContainerClusterTest {
cluster.getConfig(bundleBuilder);
List<String> installedBundles = bundleBuilder.build().bundlePaths();
- expectedBundleNames.forEach(b -> assertThat(installedBundles, hasItem(CoreMatchers.endsWith(b))));
+ expectedBundleNames.forEach(b -> assertTrue(installedBundles.stream().filter(p -> p.endsWith(b)).count() > 0));
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerIncludeTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerIncludeTest.java
index 0e35b72a75b..cb1b84d272a 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerIncludeTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerIncludeTest.java
@@ -11,10 +11,9 @@ import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
@@ -28,62 +27,62 @@ public class ContainerIncludeTest {
VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude/");
VespaModel model = creator.create();
- assertThat(model.getContainerClusters().size(), is(1));
+ assertEquals(1, model.getContainerClusters().size());
ContainerCluster cluster = model.getContainerClusters().values().iterator().next();
- assertThat(cluster.getSearchChains(), notNullValue());
+ assertNotNull(cluster.getSearchChains());
Map<String, SearchChain> searchChainMap = new HashMap<>();
for (SearchChain searchChain : cluster.getSearchChains().allChains().allComponents()) {
searchChainMap.put(searchChain.getId().stringValue(), searchChain);
}
- assertThat(searchChainMap.get("searchchain1"), notNullValue());
- assertThat(searchChainMap.get("searchchain1").getInnerComponents().size(), is(1));
- assertThat(searchChainMap.get("searchchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher1"));
+ assertNotNull(searchChainMap.get("searchchain1"));
+ assertEquals(1, searchChainMap.get("searchchain1").getInnerComponents().size());
+ assertEquals("com.yahoo.Searcher1", searchChainMap.get("searchchain1").getInnerComponents().iterator().next().getComponentId().stringValue());
- assertThat(searchChainMap.get("searchchain2"), notNullValue());
- assertThat(searchChainMap.get("searchchain2").getInnerComponents().size(), is(1));
- assertThat(searchChainMap.get("searchchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher2"));
+ assertNotNull(searchChainMap.get("searchchain2"));
+ assertEquals(1, searchChainMap.get("searchchain2").getInnerComponents().size());
+ assertEquals("com.yahoo.Searcher2", searchChainMap.get("searchchain2").getInnerComponents().iterator().next().getComponentId().stringValue());
- assertThat(searchChainMap.get("searchchain3"), notNullValue());
- assertThat(searchChainMap.get("searchchain3").getInnerComponents().size(), is(1));
- assertThat(searchChainMap.get("searchchain3").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher3"));
+ assertNotNull(searchChainMap.get("searchchain3"));
+ assertEquals(1, searchChainMap.get("searchchain3").getInnerComponents().size());
+ assertEquals("com.yahoo.Searcher3", searchChainMap.get("searchchain3").getInnerComponents().iterator().next().getComponentId().stringValue());
- assertThat(searchChainMap.get("searchchain4"), notNullValue());
- assertThat(searchChainMap.get("searchchain4").getInnerComponents().size(), is(1));
- assertThat(searchChainMap.get("searchchain4").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher4"));
+ assertNotNull(searchChainMap.get("searchchain4"));
+ assertEquals(1, searchChainMap.get("searchchain4").getInnerComponents().size());
+ assertEquals("com.yahoo.Searcher4", searchChainMap.get("searchchain4").getInnerComponents().iterator().next().getComponentId().stringValue());
- assertThat(cluster.getDocprocChains(), notNullValue());
+ assertNotNull(cluster.getDocprocChains());
Map<String, DocprocChain> docprocChainMap = new HashMap<>();
for (DocprocChain docprocChain : cluster.getDocprocChains().allChains().allComponents()) {
docprocChainMap.put(docprocChain.getId().stringValue(), docprocChain);
}
- assertThat(docprocChainMap.get("docprocchain1"), notNullValue());
- assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().size(), is(1));
- assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor1"));
+ assertNotNull(docprocChainMap.get("docprocchain1"));
+ assertEquals(1, docprocChainMap.get("docprocchain1").getInnerComponents().size());
+ assertEquals("com.yahoo.DocumentProcessor1", docprocChainMap.get("docprocchain1").getInnerComponents().iterator().next().getComponentId().stringValue());
- assertThat(docprocChainMap.get("docprocchain2"), notNullValue());
- assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().size(), is(1));
- assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor2"));
+ assertNotNull(docprocChainMap.get("docprocchain2"));
+ assertEquals(1, docprocChainMap.get("docprocchain2").getInnerComponents().size());
+ assertEquals("com.yahoo.DocumentProcessor2", docprocChainMap.get("docprocchain2").getInnerComponents().iterator().next().getComponentId().stringValue());
- assertThat(cluster.getProcessingChains(), notNullValue());
+ assertNotNull(cluster.getProcessingChains());
Map<String, ProcessingChain> processingChainMap = new HashMap<>();
for (ProcessingChain processingChain : cluster.getProcessingChains().allChains().allComponents()) {
processingChainMap.put(processingChain.getId().stringValue(), processingChain);
}
- assertThat(processingChainMap.get("processingchain1"), notNullValue());
- assertThat(processingChainMap.get("processingchain1").getInnerComponents().size(), is(1));
- assertThat(processingChainMap.get("processingchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor1"));
+ assertNotNull(processingChainMap.get("processingchain1"));
+ assertEquals(1, processingChainMap.get("processingchain1").getInnerComponents().size());
+ assertEquals("com.yahoo.Processor1", processingChainMap.get("processingchain1").getInnerComponents().iterator().next().getComponentId().stringValue());
- assertThat(processingChainMap.get("processingchain2"), notNullValue());
- assertThat(processingChainMap.get("processingchain2").getInnerComponents().size(), is(1));
- assertThat(processingChainMap.get("processingchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor2"));
+ assertNotNull(processingChainMap.get("processingchain2"));
+ assertEquals(1, processingChainMap.get("processingchain2").getInnerComponents().size());
+ assertEquals("com.yahoo.Processor2", processingChainMap.get("processingchain2").getInnerComponents().iterator().next().getComponentId().stringValue());
}
@Test(expected = IllegalArgumentException.class)
@@ -123,8 +122,8 @@ public class ContainerIncludeTest {
creator.create(true);
fail("Expected exception due to xml schema violation ('zearcer')");
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage(), containsString("Invalid XML according to XML schema"));
- assertThat(e.getMessage(), containsString("zearcer"));
+ assertTrue(e.getMessage().contains("Invalid XML according to XML schema"));
+ assertTrue(e.getMessage().contains("zearcer"));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java
index 42d9ccf7089..7f49efa8770 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java
@@ -29,12 +29,8 @@ import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.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;
/**
@@ -93,30 +89,30 @@ public class ConfigserverClusterTest {
@Test
public void testStatisticsConfig() {
StatisticsConfig config = getConfig(StatisticsConfig.class);
- assertThat((int) config.collectionintervalsec(), is(60));
- assertThat((int) config.loggingintervalsec(), is(60));
+ assertEquals(60, (int) config.collectionintervalsec());
+ assertEquals(60, (int) config.loggingintervalsec());
}
@Test
public void testHealthMonitorConfig() {
HealthMonitorConfig config = getConfig(HealthMonitorConfig.class);
- assertThat(((int) config.snapshot_interval()), is(60));
+ assertEquals(60, (int) config.snapshot_interval());
}
@Test
public void testConfigserverConfig() {
ConfigserverConfig config = getConfig(ConfigserverConfig.class);
- assertThat(config.configModelPluginDir().size(), is(1));
- assertThat(config.configModelPluginDir().get(0), is(Defaults.getDefaults().underVespaHome("lib/jars/config-models")));
- assertThat(config.rpcport(), is(12345));
- assertThat(config.httpport(), is(1337));
- assertThat(config.serverId(), is(HostName.getLocalhost()));
+ assertEquals(1, config.configModelPluginDir().size());
+ assertEquals(Defaults.getDefaults().underVespaHome("lib/jars/config-models"), config.configModelPluginDir().get(0));
+ assertEquals(12345, config.rpcport());
+ assertEquals(1337, config.httpport());
+ assertEquals(HostName.getLocalhost(), config.serverId());
assertTrue(config.useVespaVersionInRequest());
- assertThat(config.numParallelTenantLoaders(), is(4));
+ assertEquals(4, config.numParallelTenantLoaders());
assertFalse(config.multitenant());
assertTrue(config.hostedVespa());
- assertThat(config.environment(), is("test"));
- assertThat(config.region(), is("bar"));
+ assertEquals("test", config.environment());
+ assertEquals("bar", config.region());
}
@Test
@@ -132,8 +128,8 @@ public class ConfigserverClusterTest {
public void model_evaluation_bundles_are_not_installed_via_config() {
// These bundles must be pre-installed because they are used by config-model.
PlatformBundlesConfig config = getConfig(PlatformBundlesConfig.class);
- assertThat(config.bundlePaths(), not(hasItem(ContainerModelEvaluation.MODEL_INTEGRATION_BUNDLE_FILE.toString())));
- assertThat(config.bundlePaths(), not(hasItem(ContainerModelEvaluation.MODEL_EVALUATION_BUNDLE_FILE.toString())));
+ assertFalse(config.bundlePaths().contains(ContainerModelEvaluation.MODEL_INTEGRATION_BUNDLE_FILE.toString()));
+ assertFalse(config.bundlePaths().contains(ContainerModelEvaluation.MODEL_EVALUATION_BUNDLE_FILE.toString()));
}
@SuppressWarnings("varargs")
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/docproc/StandaloneDocprocContainerTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/docproc/StandaloneDocprocContainerTest.java
index de37240c269..5bb93255a8f 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/docproc/StandaloneDocprocContainerTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/docproc/StandaloneDocprocContainerTest.java
@@ -14,8 +14,8 @@ import org.w3c.dom.Element;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -59,8 +59,8 @@ public class StandaloneDocprocContainerTest extends DomBuilderTest {
if (componentId.stringValue().contains("MbusClient")) foundAtLeastOneClient = true;
if (componentId.stringValue().contains("MbusServer")) foundAtLeastOneServer = true;
}
- assertThat(foundAtLeastOneClient, is(true));
- assertThat(foundAtLeastOneServer, is(true));
+ assertTrue(foundAtLeastOneClient);
+ assertTrue(foundAtLeastOneServer);
}
@@ -76,7 +76,7 @@ public class StandaloneDocprocContainerTest extends DomBuilderTest {
if (componentId.stringValue().contains("MbusClient")) foundAtLeastOneClient = true;
if (componentId.stringValue().contains("MbusServer")) foundAtLeastOneServer = true;
}
- assertThat(foundAtLeastOneClient, is(false));
- assertThat(foundAtLeastOneServer, is(false));
+ assertFalse(foundAtLeastOneClient);
+ assertFalse(foundAtLeastOneServer);
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java
index 1d774526a9b..1691868ee65 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java
@@ -5,8 +5,6 @@ package com.yahoo.vespa.model.container.http;
import com.yahoo.config.model.api.ApplicationClusterEndpoint;
import com.yahoo.config.model.api.ContainerEndpoint;
import com.yahoo.jdisc.http.filter.security.rule.RuleBasedFilterConfig;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
@@ -15,6 +13,7 @@ import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public class BlockFeedGlobalEndpointsFilterTest {
@@ -25,7 +24,7 @@ public class BlockFeedGlobalEndpointsFilterTest {
var config = getConfig(filter);
assertEquals(1, config.rule().size());
var rule = config.rule().get(0);
- assertThat(rule.hostNames(), Matchers.containsInAnyOrder("foo", "bar"));
+ assertTrue(rule.hostNames().containsAll(List.of("foo", "bar")));
assertEquals(rule.action(), RuleBasedFilterConfig.Rule.Action.Enum.BLOCK);
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterChainsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterChainsTest.java
index 97ce8030fbd..6f223afd536 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterChainsTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterChainsTest.java
@@ -10,9 +10,8 @@ import org.junit.Test;
import org.w3c.dom.Element;
import static com.yahoo.collections.CollectionUtil.first;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
/**
* @author gjoranv
@@ -55,7 +54,7 @@ public class FilterChainsTest extends DomBuilderTest {
public void filters_in_chains_are_built() {
Filter filter = first(getChain("myChain").getInnerComponents());
assertNotNull(filter);
- assertThat(filter.getComponentId().getName(), is("inner"));
+ assertEquals("inner", filter.getComponentId().getName());
}
private Chain<Filter> getChain(String chainName) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterConfigTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterConfigTest.java
index e30628eb94f..e17c5eed242 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterConfigTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/http/FilterConfigTest.java
@@ -10,11 +10,9 @@ import org.w3c.dom.Element;
import static com.yahoo.collections.CollectionUtil.first;
import static com.yahoo.vespa.model.container.http.FilterConfigProvider.configProviderId;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
/**
* @author gjoranv
@@ -59,7 +57,7 @@ public class FilterConfigTest extends DomBuilderTest {
public void filter_without_config_does_not_have_FilterConfigProvider() {
Filter noConfigFilter = getOuterFilter("no-config");
- assertThat(getProvider(noConfigFilter), nullValue());
+ assertNull(getProvider(noConfigFilter));
}
@Test
@@ -67,7 +65,7 @@ public class FilterConfigTest extends DomBuilderTest {
Filter emptyConfigFilter = getOuterFilter("empty-config");
HttpFilterConfig config = getHttpFilterConfig(emptyConfigFilter);
- assertThat(config.filterName(), is("empty-config"));
+ assertEquals("empty-config", config.filterName());
}
@Test
@@ -75,7 +73,7 @@ public class FilterConfigTest extends DomBuilderTest {
Filter emptyConfigFilter = getOuterFilter("empty-config");
HttpFilterConfig config = getHttpFilterConfig(emptyConfigFilter);
- assertThat(config.filterClass(), is("EmptyConfigFilter"));
+ assertEquals("EmptyConfigFilter", config.filterClass());
}
@Test
@@ -83,7 +81,7 @@ public class FilterConfigTest extends DomBuilderTest {
Filter emptyConfigFilter = getOuterFilter("empty-config");
HttpFilterConfig config = getHttpFilterConfig(emptyConfigFilter);
- assertThat(config.param(), is(empty()));
+ assertTrue(config.param().isEmpty());
}
@Test
@@ -91,14 +89,14 @@ public class FilterConfigTest extends DomBuilderTest {
Filter configWithParamsFilter = getOuterFilter("config-with-params");
HttpFilterConfig config = getHttpFilterConfig(configWithParamsFilter);
- assertThat(config.param(), hasSize(1));
- assertThat(config.param(0).name(), is("key1"));
- assertThat(config.param(0).value(), is("value1"));
+ assertEquals(1, config.param().size());
+ assertEquals("key1", config.param(0).name());
+ assertEquals("value1", config.param(0).value());
}
@Test
public void inner_filter_can_have_filter_config() {
- Filter innerFilter = (Filter)
+ Filter innerFilter =
first(http.getFilterChains().allChains().getComponent("myChain").getInnerComponents());
getHttpFilterConfig(innerFilter);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcherTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcherTest.java
index 2482fc131f0..3f95fb99087 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcherTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationSearcherTest.java
@@ -25,10 +25,8 @@ import static java.util.Collections.emptyList;
import static java.util.Collections.emptySet;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
-import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -99,8 +97,9 @@ public class FederationSearcherTest {
assertEquals(target.id(), "source");
assertTrue("Not used by default", target.useByDefault());
assertEquals(2, target.searchChain().size());
- assertThat(target.searchChain().stream().map(FederationConfig.Target.SearchChain::providerId).collect(toList()),
- contains("provider1", "provider2"));
+ assertTrue(target.searchChain().stream()
+ .map(FederationConfig.Target.SearchChain::providerId)
+ .collect(toList()).containsAll(List.of("provider1", "provider2")));
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationTest.java
index 39fcb9d5af2..3945a74cf15 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/FederationTest.java
@@ -7,8 +7,10 @@ import org.w3c.dom.Element;
import java.util.List;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Fail.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* Test generated config for federation.
@@ -65,7 +67,7 @@ public class FederationTest extends SchemaChainsTestBase {
}
}
- assertThat(config.target().size(), is(5));
+ assertEquals(5, config.target().size());
assertUseByDefault(config, "source1", false);
assertUseByDefault(config, "source2", false);
@@ -82,7 +84,7 @@ public class FederationTest extends SchemaChainsTestBase {
FederationConfig.Target target = getTarget(config.target(), sourceName);
FederationConfig.Target.SearchChain searchChain = getProvider(target, providerName);
- assertThat(searchChain.useByDefault(), is(expectedValue));
+ assertEquals(expectedValue, searchChain.useByDefault());
}
private FederationConfig.Target.SearchChain getProvider(FederationConfig.Target target, String providerName) {
@@ -96,8 +98,8 @@ public class FederationTest extends SchemaChainsTestBase {
private void assertUseByDefault(FederationConfig config, String chainName, boolean expectedValue) {
FederationConfig.Target target = getTarget(config.target(), chainName);
- assertThat(target.searchChain().size(), is(1));
- assertThat(target.searchChain().get(0).useByDefault(), is(expectedValue));
+ assertEquals(1, target.searchChain().size());
+ assertEquals(expectedValue, target.searchChain().get(0).useByDefault());
}
private FederationConfig.Target getTarget(List<FederationConfig.Target> targets, String chainId) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SchemaChainsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SchemaChainsTest.java
index 9ccfa768dc1..d74f271f6ef 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SchemaChainsTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SchemaChainsTest.java
@@ -5,14 +5,12 @@ import com.yahoo.component.ComponentId;
import com.yahoo.container.core.ChainsConfig;
import com.yahoo.prelude.cluster.ClusterSearcher;
import com.yahoo.search.config.ClusterConfig;
-import com.yahoo.search.federation.ProviderConfig;
import com.yahoo.vespa.defaults.Defaults;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Element;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
/**
@@ -24,7 +22,6 @@ import static org.junit.Assert.*;
public class SchemaChainsTest extends SchemaChainsTestBase {
private ChainsConfig chainsConfig;
- private ProviderConfig providerConfig;
private ClusterConfig clusterConfig;
@Before
@@ -93,7 +90,7 @@ public class SchemaChainsTest extends SchemaChainsTestBase {
@Test
public void require_that_source_chain_spec_id_is_namespaced_in_provider_id() {
Source source = (Source) getSearchChains().allChains().getComponent("source:1@provider:1");
- assertThat(source.getChainSpecification().componentId.getNamespace(), is(ComponentId.fromString("provider:1")));
+ assertEquals(ComponentId.fromString("provider:1"), source.getChainSpecification().componentId.getNamespace());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SourceGroupTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SourceGroupTest.java
index 3db112355a9..a9bab88a065 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SourceGroupTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/SourceGroupTest.java
@@ -2,19 +2,17 @@
package com.yahoo.vespa.model.container.search.searchchain;
import com.yahoo.component.ComponentId;
-import com.yahoo.component.ComponentSpecification;
-import com.yahoo.component.chain.Phase;
import com.yahoo.component.chain.model.ChainSpecification;
import com.yahoo.config.model.test.MockRoot;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
import org.junit.Before;
import org.junit.Test;
-import java.util.Collections;
+import java.util.List;
+import java.util.Set;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.hamcrest.Matchers.containsString;
/**
* @author Tony Vaagenes
@@ -41,7 +39,7 @@ public class SourceGroupTest {
searchChains.validate();
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Missing leader for the source s1."));
+ assertTrue(e.getMessage().contains("Missing leader for the source s1."));
return;
}
fail("Expected exception");
@@ -54,8 +52,8 @@ public class SourceGroupTest {
private ChainSpecification createSearchChainSpecification(String id) {
return new ChainSpecification(ComponentId.fromString(id),
new ChainSpecification.Inheritance(null, null),
- Collections.<Phase>emptyList(),
- Collections.<ComponentSpecification>emptySet());
+ List.of(),
+ Set.of());
}
private Source createSource(String sourceId, Source.GroupOption groupOption) {
@@ -82,8 +80,8 @@ public class SourceGroupTest {
searchChains.validate();
fail("Expected exception");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Same id used for a source"));
- assertThat(e.getMessage(), containsString("'sameId'"));
+ assertTrue(e.getMessage().contains("Same id used for a source"));
+ assertTrue(e.getMessage().contains("'sameId'"));
}
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java
index 18520dd2df5..909ac9edef2 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/BundleInstantiationSpecificationBuilderTest.java
@@ -15,8 +15,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author gjoranv
@@ -56,6 +55,6 @@ public class BundleInstantiationSpecificationBuilderTest {
Element component = XmlHelper.getDocumentBuilder().parse(xmlStream).getDocumentElement();
BundleInstantiationSpecification spec = BundleInstantiationSpecificationBuilder.build(component);
- assertThat(spec.bundle, is(ComponentSpecification.fromString(expectedBundle)));
+ assertEquals(ComponentSpecification.fromString(expectedBundle), spec.bundle);
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java
index ed26dafe60c..b4242336c5c 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java
@@ -17,13 +17,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.hasItem;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -36,7 +33,7 @@ public class ContainerDocumentApiBuilderTest extends ContainerModelBuilderTestBa
Map<String, Handler<?>> handlerMap = new HashMap<>();
Collection<Handler<?>> handlers = cluster.getHandlers();
for (Handler<?> handler : handlers) {
- assertThat(handlerMap.containsKey(handler.getComponentId().toString()), is(false)); //die on overwrites
+ assertFalse(handlerMap.containsKey(handler.getComponentId().toString())); //die on overwrites
handlerMap.put(handler.getComponentId().toString(), handler);
}
return handlerMap;
@@ -59,10 +56,10 @@ public class ContainerDocumentApiBuilderTest extends ContainerModelBuilderTestBa
private void verifyCustomBindings(String id) {
Handler<?> handler = getHandlers("cluster1").get(id);
- assertThat(handler.getServerBindings(), hasItem(UserBindingPattern.fromHttpPath("/document-api/reserved-for-internal-use/feedapi")));
- assertThat(handler.getServerBindings(), hasItem(UserBindingPattern.fromHttpPath("/document-api/reserved-for-internal-use/feedapi/")));
+ assertTrue(handler.getServerBindings().contains(UserBindingPattern.fromHttpPath("/document-api/reserved-for-internal-use/feedapi")));
+ assertTrue(handler.getServerBindings().contains(UserBindingPattern.fromHttpPath("/document-api/reserved-for-internal-use/feedapi/")));
- assertThat(handler.getServerBindings().size(), is(2));
+ assertEquals(2, handler.getServerBindings().size());
}
@Test
@@ -76,18 +73,16 @@ public class ContainerDocumentApiBuilderTest extends ContainerModelBuilderTestBa
Map<String, Handler<?>> handlerMap = getHandlers("cluster1");
- assertThat(handlerMap.get("com.yahoo.container.handler.VipStatusHandler"), not(nullValue()));
- assertThat(handlerMap.get("com.yahoo.container.handler.observability.ApplicationStatusHandler"), not(nullValue()));
- assertThat(handlerMap.get("com.yahoo.container.jdisc.state.StateHandler"), not(nullValue()));
-
- assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler"), not(nullValue()));
- assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings()
- .contains(SystemBindingPattern.fromHttpPath("/reserved-for-internal-use/feedapi")),
- is(true));
- assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings()
- .contains(SystemBindingPattern.fromHttpPath("/reserved-for-internal-use/feedapi")),
- is(true));
- assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings().size(), equalTo(2));
+ assertNotNull(handlerMap.get("com.yahoo.container.handler.VipStatusHandler"));
+ assertNotNull(handlerMap.get("com.yahoo.container.handler.observability.ApplicationStatusHandler"));
+ assertNotNull(handlerMap.get("com.yahoo.container.jdisc.state.StateHandler"));
+
+ assertNotNull(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler"));
+ assertTrue(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings()
+ .contains(SystemBindingPattern.fromHttpPath("/reserved-for-internal-use/feedapi")));
+ assertTrue(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings()
+ .contains(SystemBindingPattern.fromHttpPath("/reserved-for-internal-use/feedapi")));
+ assertEquals(2, handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings().size());
}
@Test
@@ -102,7 +97,7 @@ public class ContainerDocumentApiBuilderTest extends ContainerModelBuilderTestBa
Map<String, Handler<?>> handlers = getHandlers("cluster1");
Handler<?> feedApiHandler = handlers.get("com.yahoo.vespa.http.server.FeedHandler");
Set<String> injectedComponentIds = feedApiHandler.getInjectedComponentIds();
- assertThat(injectedComponentIds, hasItem("threadpool@feedapi-handler"));
+ assertTrue(injectedComponentIds.contains("threadpool@feedapi-handler"));
ContainerThreadpoolConfig config = root.getConfig(
ContainerThreadpoolConfig.class, "cluster1/component/com.yahoo.vespa.http.server.FeedHandler/threadpool@feedapi-handler");
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
index 8ceb74c3d7e..f7dbd65ab7d 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
@@ -80,19 +80,16 @@ import static com.yahoo.vespa.model.container.ContainerCluster.ROOT_HANDLER_BIND
import static com.yahoo.vespa.model.container.ContainerCluster.STATE_HANDLER_BINDING_1;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.isEmptyString;
+import static org.hamcrest.MatcherAssert.assertThat;
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.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -112,8 +109,8 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
public void model_evaluation_bundles_are_deployed() {
createBasicContainerModel();
PlatformBundlesConfig config = root.getConfig(PlatformBundlesConfig.class, "default");
- assertThat(config.bundlePaths(), hasItem(ContainerModelEvaluation.MODEL_EVALUATION_BUNDLE_FILE.toString()));
- assertThat(config.bundlePaths(), hasItem(ContainerModelEvaluation.MODEL_INTEGRATION_BUNDLE_FILE.toString()));
+ assertTrue(config.bundlePaths().contains(ContainerModelEvaluation.MODEL_EVALUATION_BUNDLE_FILE.toString()));
+ assertTrue(config.bundlePaths().contains(ContainerModelEvaluation.MODEL_INTEGRATION_BUNDLE_FILE.toString()));
}
@Test
@@ -140,7 +137,7 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
"</container>" );
createModel(root, clusterElem);
AbstractService container = (AbstractService)root.getProducer("container/container.0");
- assertThat(container.getRelativePort(0), is(getDefaults().vespaWebServicePort()));
+ assertEquals(getDefaults().vespaWebServicePort(), container.getRelativePort(0));
}
@Test
@@ -154,8 +151,8 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
"</container>" );
createModel(root, clusterElem);
AbstractService container = (AbstractService)root.getProducer("container/container.0");
- assertThat(container.getRelativePort(0), is(9000));
- assertThat(container.getRelativePort(1), is(not(9001)));
+ assertEquals(9000, container.getRelativePort(0));
+ assertNotEquals(9001, container.getRelativePort(1));
}
@Test
@@ -265,11 +262,11 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
// The handler is still set up.
ComponentsConfig.Components userRootHandler = getComponent(componentsConfig(), BindingsOverviewHandler.class.getName());
- assertThat(userRootHandler, notNullValue());
+ assertNotNull(userRootHandler);
// .. but it has no bindings
var discBindingsConfig = root.getConfig(JdiscBindingsConfig.class, "default");
- assertThat(discBindingsConfig.handlers(BindingsOverviewHandler.class.getName()), is(nullValue()));
+ assertNull(discBindingsConfig.handlers(BindingsOverviewHandler.class.getName()));
}
@Test
@@ -439,7 +436,7 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
root = ContentClusterUtils.createMockRoot(new String[]{"host1", "host2"});
createModel(root, containerElem);
ContainerCluster cluster = (ContainerCluster)root.getChildren().get("default");
- assertThat(cluster.getContainers().size(), is(2));
+ assertEquals(2, cluster.getContainers().size());
assertEquals(root.getConfig(QrMonitorConfig.class, "default/container.0").requesttimeout(), 111);
assertEquals(root.getConfig(QrMonitorConfig.class, "default/container.1").requesttimeout(), 222);
}
@@ -472,7 +469,7 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
Map<ComponentId, Component<?, ?>> componentsMap = cluster.getComponentsMap();
Component<?,?> example = componentsMap.get(
ComponentId.fromString("test.Exampledocproc"));
- assertThat(example.getComponentId().getName(), is("test.Exampledocproc"));
+ assertEquals("test.Exampledocproc", example.getComponentId().getName());
}
@Test
@@ -488,7 +485,7 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
"</container>");
createModel(root, clusterElem);
assertTrue(getContainerCluster("default").getContainers().get(0).getAffinity().isPresent());
- assertThat(getContainerCluster("default").getContainers().get(0).getAffinity().get().cpuSocket(), is(0));
+ assertEquals(0, getContainerCluster("default").getContainers().get(0).getAffinity().get().cpuSocket());
}
@Test
@@ -504,7 +501,7 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
.withServices(servicesXml)
.build();
VespaModel model = new VespaModel(applicationPackage);
- assertThat(model.hostSystem().getHosts().size(), is(1));
+ assertEquals(1, model.hostSystem().getHosts().size());
}
@Test
@@ -950,9 +947,10 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
assertEquals("KEY", connectorConfig.ssl().privateKey());
assertEquals(4443, connectorConfig.listenPort());
- assertThat("Connector must use Athenz truststore in a non-public system.",
- connectorConfig.ssl().caCertificateFile(), equalTo("/opt/yahoo/share/ssl/certs/athenz_certificate_bundle.pem"));
- assertThat(connectorConfig.ssl().caCertificate(), isEmptyString());
+ assertEquals("Connector must use Athenz truststore in a non-public system.",
+ "/opt/yahoo/share/ssl/certs/athenz_certificate_bundle.pem",
+ connectorConfig.ssl().caCertificateFile());
+ assertTrue(connectorConfig.ssl().caCertificate().isEmpty());
}
@Test
@@ -986,9 +984,10 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
assertEquals("KEY", connectorConfig.ssl().privateKey());
assertEquals(4443, connectorConfig.listenPort());
- assertThat("Connector must use Athenz truststore in a non-public system.",
- connectorConfig.ssl().caCertificateFile(), equalTo("/opt/yahoo/share/ssl/certs/athenz_certificate_bundle.pem"));
- assertThat(connectorConfig.ssl().caCertificate(), isEmptyString());
+ assertEquals("Connector must use Athenz truststore in a non-public system.",
+ "/opt/yahoo/share/ssl/certs/athenz_certificate_bundle.pem",
+ connectorConfig.ssl().caCertificateFile());
+ assertTrue(connectorConfig.ssl().caCertificate().isEmpty());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/DocprocBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/DocprocBuilderTest.java
index 5bf64338aa9..514310aa4fb 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/DocprocBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/DocprocBuilderTest.java
@@ -25,11 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -85,45 +82,45 @@ public class DocprocBuilderTest extends DomBuilderTest {
// TODO: re-enable assertions when the appropriate attributes are handled by the builder
@Test
public void testDocprocCluster() {
- assertThat(cluster.getName(), is("banan"));
- assertThat(cluster.getDocproc().isCompressDocuments(), is(true));
- //assertThat(cluster.getContainerDocproc().isPreferLocalNode(), is(true));
- //assertThat(cluster.getContainerDocproc().getNumNodesPerClient(), is(2));
+ assertEquals("banan", cluster.getName());
+ assertTrue(cluster.getDocproc().isCompressDocuments());
+ //assertTrue(cluster.getContainerDocproc().isPreferLocalNode());
+ //assertEquals(2, cluster.getContainerDocproc().getNumNodesPerClient());
List<ApplicationContainer> services = cluster.getContainers();
- assertThat(services.size(), is(1));
+ assertEquals(1, services.size());
ApplicationContainer service = services.get(0);
- assertThat(service, notNullValue());
+ assertNotNull(service);
Map<String, DocprocChain> chains = new HashMap<>();
for (DocprocChain chain : cluster.getDocprocChains().allChains().allComponents()) {
chains.put(chain.getId().stringValue(), chain);
}
- assertThat(chains.size(), is(1));
+ assertEquals(1, chains.size());
DocprocChain chain = chains.get("chein");
- assertThat(chain.getId().stringValue(), is("chein"));
- assertThat(chain.getInnerComponents().size(), is(1));
+ assertEquals("chein", chain.getId().stringValue());
+ assertEquals(1, chain.getInnerComponents().size());
DocumentProcessor processor = chain.getInnerComponents().iterator().next();
- assertThat(processor.getComponentId().stringValue(), is("docproc2"));
+ assertEquals("docproc2", processor.getComponentId().stringValue());
}
@Test
public void testDocumentManagerConfig() {
- assertThat(documentmanagerConfig.enablecompression(), is(true));
+ assertTrue(documentmanagerConfig.enablecompression());
}
@Test
public void testDocprocConfig() {
- assertThat(docprocConfig.maxqueuetimems(), is(200000));
+ assertEquals(200000, docprocConfig.maxqueuetimems());
}
@Test
public void testContainerMbusConfig() {
- assertThat(containerMbusConfig.enabled(), is(true));
+ assertTrue(containerMbusConfig.enabled());
assertTrue(containerMbusConfig.port() >= HostPorts.BASE_PORT);
- assertThat(containerMbusConfig.maxpendingcount(), is(300));
- assertThat(containerMbusConfig.maxpendingsize(), is(100));
+ assertEquals(300, containerMbusConfig.maxpendingcount());
+ assertEquals(100, containerMbusConfig.maxpendingsize());
}
@Test
@@ -135,37 +132,37 @@ public class DocprocBuilderTest extends DomBuilderTest {
}
ComponentsConfig.Components docprocHandler = components.get("com.yahoo.docproc.jdisc.DocumentProcessingHandler");
- assertThat(docprocHandler.id(), is("com.yahoo.docproc.jdisc.DocumentProcessingHandler"));
- assertThat(docprocHandler.configId(), is("banan/component/com.yahoo.docproc.jdisc.DocumentProcessingHandler"));
- assertThat(docprocHandler.classId(), is("com.yahoo.docproc.jdisc.DocumentProcessingHandler"));
- assertThat(docprocHandler.bundle(), is("container-search-and-docproc"));
+ assertEquals("com.yahoo.docproc.jdisc.DocumentProcessingHandler", docprocHandler.id());
+ assertEquals("banan/component/com.yahoo.docproc.jdisc.DocumentProcessingHandler", docprocHandler.configId());
+ assertEquals("com.yahoo.docproc.jdisc.DocumentProcessingHandler", docprocHandler.classId());
+ assertEquals("container-search-and-docproc", docprocHandler.bundle());
ComponentsConfig.Components docproc1 = components.get("docproc1");
- assertThat(docproc1.id(), is("docproc1"));
- assertThat(docproc1.configId(), is("banan/docprocchains/component/docproc1"));
- assertThat(docproc1.classId(), is("com.yahoo.Docproc1"));
- assertThat(docproc1.bundle(), is("docproc1bundle"));
+ assertEquals("docproc1", docproc1.id());
+ assertEquals("banan/docprocchains/component/docproc1", docproc1.configId());
+ assertEquals("com.yahoo.Docproc1", docproc1.classId());
+ assertEquals("docproc1bundle", docproc1.bundle());
ComponentsConfig.Components docproc2 = components.get("docproc2@chein");
- assertThat(docproc2.id(), is("docproc2@chein"));
- assertThat(docproc2.configId(), is("banan/docprocchains/chain/chein/component/docproc2"));
- assertThat(docproc2.classId(), is("docproc2"));
- assertThat(docproc2.bundle(), is("docproc2"));
+ assertEquals("docproc2@chein", docproc2.id());
+ assertEquals("banan/docprocchains/chain/chein/component/docproc2", docproc2.configId());
+ assertEquals("docproc2", docproc2.classId());
+ assertEquals("docproc2", docproc2.bundle());
/*
ComponentsConfig.Components health = components.get("com.yahoo.container.jdisc.state.StateHandler");
- assertThat(health.id(), is("com.yahoo.container.jdisc.state.StateHandler"));
- assertThat(health.classId(), is("com.yahoo.container.jdisc.state.StateHandler"));
- assertThat(health.bundle(), is("com.yahoo.container.jdisc.state.StateHandler"));
+ assertEquals("com.yahoo.container.jdisc.state.StateHandler", health.id()));
+ assertEquals("com.yahoo.container.jdisc.state.StateHandler", health.classId());
+ assertEquals("com.yahoo.container.jdisc.state.StateHandler", health.bundle()));
*/
ComponentsConfig.Components sourceClient = components.get("source@MbusClient");
assertNotNull(sourceClient);
- assertThat(sourceClient.classId(), is("com.yahoo.container.jdisc.messagebus.MbusClientProvider"));
- assertThat(sourceClient.bundle(), is("com.yahoo.container.jdisc.messagebus.MbusClientProvider"));
+ assertEquals("com.yahoo.container.jdisc.messagebus.MbusClientProvider", sourceClient.classId());
+ assertEquals("com.yahoo.container.jdisc.messagebus.MbusClientProvider", sourceClient.bundle());
ComponentsConfig.Components intermediateClient = components.get("chain.chein@MbusClient");
assertNotNull(intermediateClient);
- assertThat(intermediateClient.classId(), is("com.yahoo.container.jdisc.messagebus.MbusClientProvider"));
- assertThat(intermediateClient.bundle(), is("com.yahoo.container.jdisc.messagebus.MbusClientProvider"));
+ assertEquals("com.yahoo.container.jdisc.messagebus.MbusClientProvider", intermediateClient.classId());
+ assertEquals("com.yahoo.container.jdisc.messagebus.MbusClientProvider", intermediateClient.bundle());
}
@Test
@@ -175,32 +172,32 @@ public class DocprocBuilderTest extends DomBuilderTest {
components.put(component.id(), component);
}
- assertThat(components.size(), is(2));
+ assertEquals(2, components.size());
ChainsConfig.Components docproc1 = components.get("docproc1");
- assertThat(docproc1.id(), is("docproc1"));
- assertThat(docproc1.dependencies().provides().size(), is(0));
- assertThat(docproc1.dependencies().before().size(), is(0));
- assertThat(docproc1.dependencies().after().size(), is(0));
+ assertEquals("docproc1", docproc1.id());
+ assertTrue(docproc1.dependencies().provides().isEmpty());
+ assertTrue(docproc1.dependencies().before().isEmpty());
+ assertTrue(docproc1.dependencies().after().isEmpty());
ChainsConfig.Components docproc2 = components.get("docproc2@chein");
- assertThat(docproc2.id(), is("docproc2@chein"));
- assertThat(docproc2.dependencies().provides().size(), is(0));
- assertThat(docproc2.dependencies().before().size(), is(0));
- assertThat(docproc2.dependencies().after().size(), is(0));
+ assertEquals("docproc2@chein", docproc2.id());
+ assertTrue(docproc2.dependencies().provides().isEmpty());
+ assertTrue(docproc2.dependencies().before().isEmpty());
+ assertTrue(docproc2.dependencies().after().isEmpty());
Map<String, ChainsConfig.Chains> chainsMap = new HashMap<>();
for (ChainsConfig.Chains chain : chainsConfig.chains()) {
chainsMap.put(chain.id(), chain);
}
- assertThat(chainsMap.size(), is(1));
- assertThat(chainsMap.get("chein").id(), is("chein"));
- assertThat(chainsMap.get("chein").components().size(), is(1));
- assertThat(chainsMap.get("chein").components(0), is("docproc2@chein"));
- assertThat(chainsMap.get("chein").inherits().size(), is(0));
- assertThat(chainsMap.get("chein").excludes().size(), is(0));
- assertThat(chainsMap.get("chein").phases().size(), is(0));
+ assertEquals(1, chainsMap.size());
+ assertEquals("chein", chainsMap.get("chein").id());
+ assertEquals(1, chainsMap.get("chein").components().size());
+ assertEquals("docproc2@chein", chainsMap.get("chein").components(0));
+ assertTrue(chainsMap.get("chein").inherits().isEmpty());
+ assertTrue(chainsMap.get("chein").excludes().isEmpty());
+ assertTrue(chainsMap.get("chein").phases().isEmpty());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java
index 5fe2baaca37..ec3b9386dad 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java
@@ -12,9 +12,7 @@ import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.search.config.QrStartConfig;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.container.ContainerCluster;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
@@ -24,10 +22,10 @@ import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author baldersheim
@@ -35,8 +33,6 @@ import static org.junit.Assert.assertTrue;
*/
public class JvmOptionsTest extends ContainerModelBuilderTestBase {
- @Rule public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void verify_jvm_tag_with_attributes() throws IOException, SAXException {
String servicesXml =
@@ -178,12 +174,15 @@ public class JvmOptionsTest extends ContainerModelBuilderTestBase {
@Test
public void requireThatInvalidJvmGcOptionsFailDeployment() throws IOException, SAXException {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage(containsString("Invalid JVM GC options from services.xml: bar,foo"));
- buildModelWithJvmOptions(new TestProperties().setHostedVespa(true).failDeploymentWithInvalidJvmOptions(true),
- new TestLogger(),
- "gc-options",
- "-XX:+ParallelGCThreads=8 foo bar");
+ try {
+ buildModelWithJvmOptions(new TestProperties().setHostedVespa(true).failDeploymentWithInvalidJvmOptions(true),
+ new TestLogger(),
+ "gc-options",
+ "-XX:+ParallelGCThreads=8 foo bar");
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Invalid JVM GC options from services.xml: bar,foo"));
+ }
}
private void verifyLoggingOfJvmGcOptions(boolean isHosted, String override, String... invalidOptions) throws IOException, SAXException {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java
index e7901ebd5f0..050a2254c9b 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java
@@ -19,9 +19,7 @@ import org.w3c.dom.Element;
import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER;
import static com.yahoo.test.Matchers.hasItemWithMethod;
import static com.yahoo.vespa.model.container.search.ContainerSearch.QUERY_PROFILE_REGISTRY_CLASS;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.not;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -50,7 +48,7 @@ public class SchemaBuilderTest extends ContainerModelBuilderTestBase {
createModel(root, clusterElem);
String discBindingsConfig = root.getConfig(JdiscBindingsConfig.class, "default").toString();
- assertThat(discBindingsConfig, containsString(GUIHandler.BINDING_PATH));
+ assertTrue(discBindingsConfig.contains(GUIHandler.BINDING_PATH));
ApplicationContainerCluster cluster = (ApplicationContainerCluster)root.getChildren().get("default");
@@ -77,9 +75,9 @@ public class SchemaBuilderTest extends ContainerModelBuilderTestBase {
createModel(root, clusterElem);
String discBindingsConfig = root.getConfig(JdiscBindingsConfig.class, "default").toString();
- assertThat(discBindingsConfig, containsString(".serverBindings[0] \"http://*/binding0\""));
- assertThat(discBindingsConfig, containsString(".serverBindings[1] \"http://*/binding1\""));
- assertThat(discBindingsConfig, not(containsString("/search/*")));
+ assertTrue(discBindingsConfig.contains(".serverBindings[0] \"http://*/binding0\""));
+ assertTrue(discBindingsConfig.contains(".serverBindings[1] \"http://*/binding1\""));
+ assertFalse(discBindingsConfig.contains("/search/*"));
}
@Test
@@ -238,7 +236,7 @@ public class SchemaBuilderTest extends ContainerModelBuilderTestBase {
.findAny()
.get();
- assertThat(searchHandler.getInjectedComponentIds(), hasItem("threadpool@search-handler"));
+ assertTrue(searchHandler.getInjectedComponentIds().contains("threadpool@search-handler"));
ContainerThreadpoolConfig config = root.getConfig(
ContainerThreadpoolConfig.class, "default/component/" + SearchHandler.HANDLER_CLASS + "/threadpool@search-handler");
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ClusterResourceLimitsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ClusterResourceLimitsTest.java
index 94e9b3477a7..8cc7805fe3e 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/ClusterResourceLimitsTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ClusterResourceLimitsTest.java
@@ -5,16 +5,15 @@ import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.text.XML;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.w3c.dom.Document;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author geirst
@@ -68,9 +67,6 @@ public class ClusterResourceLimitsTest {
}
}
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void content_node_limits_are_derived_from_cluster_controller_limits_if_not_set() {
assertLimits(0.4, 0.7, 0.7, 0.85,
@@ -137,9 +133,12 @@ public class ClusterResourceLimitsTest {
@Test
public void hosted_exception_is_thrown_when_resource_limits_are_specified() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage(containsString("Element 'resource-limits' is not allowed to be set"));
- hostedBuild();
+ try {
+ hostedBuild();
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Element 'resource-limits' is not allowed to be set"));
+ }
}
@Test
@@ -158,14 +157,22 @@ public class ClusterResourceLimitsTest {
public void exception_is_thrown_when_resource_limits_are_out_of_range() {
TestProperties featureFlags = new TestProperties();
featureFlags.setResourceLimitDisk(1.1);
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage(containsString("Resource limit for disk is set to illegal value 1.1, but must be in the range [0.0, 1.0]"));
- hostedBuild(featureFlags, false);
+
+ try {
+ hostedBuild(featureFlags, false);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Resource limit for disk is set to illegal value 1.1, but must be in the range [0.0, 1.0]"));
+ }
featureFlags = new TestProperties();
featureFlags.setResourceLimitDisk(-0.1);
- expectedException.expectMessage(containsString("Resource limit for disk is set to illegal value -0.1, but must be in the range [0.0, 1.0]"));
- hostedBuild(featureFlags, false);
+ try {
+ hostedBuild(featureFlags, false);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Resource limit for disk is set to illegal value -0.1, but must be in the range [0.0, 1.0]"));
+ }
}
private ClusterResourceLimits hostedBuild() {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
index d0515ae37e8..191f7f5652a 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
@@ -38,9 +38,7 @@ import com.yahoo.vespa.model.routing.DocumentProtocol;
import com.yahoo.vespa.model.routing.Routing;
import com.yahoo.vespa.model.test.utils.ApplicationPackageUtils;
import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.util.Arrays;
import java.util.Collections;
@@ -62,9 +60,6 @@ public class ContentClusterTest extends ContentBaseTest {
private final static String HOSTS = "<admin version='2.0'><adminserver hostalias='mockhost' /></admin>";
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
ContentCluster parse(String xml) {
xml = HOSTS + xml;
TestRoot root = new TestDriver().buildModel(xml);
@@ -868,9 +863,6 @@ public class ContentClusterTest extends ContentBaseTest {
@Test
public void reserved_document_name_throws_exception() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("The following document types conflict with reserved keyword names: 'true'.");
-
String xml = "<content version=\"1.0\" id=\"storage\">" +
" <redundancy>1</redundancy>" +
" <documents>" +
@@ -882,7 +874,12 @@ public class ContentClusterTest extends ContentBaseTest {
"</content>";
List<String> sds = ApplicationPackageUtils.generateSchemas("true");
- new VespaModelCreatorWithMockPkg(null, xml, sds).create();
+ try {
+ new VespaModelCreatorWithMockPkg(null, xml, sds).create();
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("The following document types conflict with reserved keyword names: 'true'."));
+ }
}
private void assertClusterHasBucketSpaceMappings(AllClustersBucketSpacesConfig config, String clusterId,
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/GenericConfigTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/GenericConfigTest.java
index 2b484529cd3..e6e8a02e951 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/GenericConfigTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/GenericConfigTest.java
@@ -10,8 +10,7 @@ import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg;
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author gjoranv
@@ -58,7 +57,7 @@ public class GenericConfigTest {
StorageCluster cluster = model.getContentClusters().get("storage").getStorageCluster();
StorFilestorConfig config = model.getConfig(StorFilestorConfig.class, cluster.getConfigId());
- assertThat(config.num_threads(), is(7));
+ assertEquals(7, config.num_threads());
}
@Test
@@ -66,7 +65,7 @@ public class GenericConfigTest {
ContentCluster cluster = model.getContentClusters().get("storage");
StorFilestorConfig config = model.getConfig(StorFilestorConfig.class, cluster.getConfigId());
- assertThat(config.num_threads(), is(7));
+ assertEquals(7, config.num_threads());
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java
index 1143543a213..a47d25ab391 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java
@@ -3,9 +3,7 @@ package com.yahoo.vespa.model.content;
import com.yahoo.documentmodel.NewDocumentType;
import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.util.HashMap;
import java.util.HashSet;
@@ -16,15 +14,14 @@ import java.util.stream.Stream;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static java.util.stream.Collectors.toSet;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author bjorncs
*/
public class GlobalDistributionValidatorTest {
- @Rule
- public final ExpectedException exceptionRule = ExpectedException.none();
-
@Test
public void validation_succeeds_on_no_documents() {
new GlobalDistributionValidator()
@@ -44,10 +41,13 @@ public class GlobalDistributionValidatorTest {
Fixture fixture = new Fixture()
.addNonGlobalDocument(parent)
.addNonGlobalDocument(createDocumentType("child", parent));
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(
- "The following document types are referenced from other documents, but are not globally distributed: 'parent'");
- validate(fixture);
+ try {
+ validate(fixture);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("The following document types are referenced from other documents, but are not globally distributed: 'parent'",
+ e.getMessage());
+ }
}
@Test
@@ -65,18 +65,25 @@ public class GlobalDistributionValidatorTest {
NewDocumentType child = createDocumentType("child", unknown);
Fixture fixture = new Fixture()
.addNonGlobalDocument(child);
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(
- "The following document types are referenced from other documents, but are not listed in services.xml: 'unknown'");
- validate(fixture);
+
+ try {
+ validate(fixture);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("The following document types are referenced from other documents, but are not listed in services.xml: 'unknown'",
+ e.getMessage());
+ }
}
@Test
public void throws_exception_if_referenced_document_not_global_end_to_end() {
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(
- "The following document types are referenced from other documents, but are not globally distributed: 'parent'");
- new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/global_distribution_validation/").create();
+ try {
+ new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/global_distribution_validation/").create();
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("The following document types are referenced from other documents, but are not globally distributed: 'parent'",
+ e.getMessage());
+ }
}
private static NewDocumentType createDocumentType(String name, NewDocumentType... references) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java
index 125d8c7fc40..7d7ba7994aa 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java
@@ -15,11 +15,10 @@ import java.util.Optional;
import static com.yahoo.config.model.test.TestUtil.joinLines;
import static com.yahoo.vespa.model.content.utils.ContentClusterUtils.createCluster;
import static com.yahoo.vespa.model.content.utils.ContentClusterUtils.createClusterXml;
-import static org.hamcrest.Matchers.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;
/**
* Unit tests for hierarchic distribution in an indexed content cluster.
@@ -178,9 +177,9 @@ public class IndexedHierarchicDistributionTest {
public void requireThatWeMustHaveOnlyOneGroupLevel() {
try {
getIllegalMultipleGroupsLevelCluster();
- assertFalse("Did not get expected Exception", true);
+ fail("Did not get expected Exception");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("sub group 'group0' contains 2 sub groups."));
+ assertTrue(e.getMessage().contains("sub group 'group0' contains 2 sub groups."));
}
}
@@ -188,9 +187,9 @@ public class IndexedHierarchicDistributionTest {
public void requireThatLeafGroupsMustHaveEqualNumberOfNodes() {
try {
getIllegalGroupsCluster();
- assertFalse("Did not get expected Exception", true);
+ fail("Did not get expected Exception");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("leaf group 'group0' contains 1 node(s) while leaf group 'group1' contains 2 node(s)"));
+ assertTrue(e.getMessage().contains("leaf group 'group0' contains 1 node(s) while leaf group 'group1' contains 2 node(s)"));
}
}
@@ -200,7 +199,7 @@ public class IndexedHierarchicDistributionTest {
DispatchGroup dg = c.getSearch().getIndexed().getRootDispatch();
assertEquals(8, dg.getRowBits());
assertEquals(3, dg.getNumPartitions());
- assertEquals(true, dg.useFixedRowInDispatch());
+ assertTrue(dg.useFixedRowInDispatch());
ArrayList<SearchInterface> list = new ArrayList<>();
for(SearchInterface si : dg.getSearchersIterable()) {
list.add(si);
@@ -222,9 +221,9 @@ public class IndexedHierarchicDistributionTest {
public void requireThatLeafGroupsCountMustBeAFactorOfRedundancy() {
try {
getTwoGroupsCluster(3, 3, "2|*");
- assertFalse("Did not get expected Exception", true);
+ fail("Did not get expected Exception");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Expected number of leaf groups (2) to be a factor of redundancy (3)"));
+ assertTrue(e.getMessage().contains("Expected number of leaf groups (2) to be a factor of redundancy (3)"));
}
}
@@ -232,9 +231,9 @@ public class IndexedHierarchicDistributionTest {
public void requireThatRedundancyPerGroupMustBeIsEqual() {
try {
getTwoGroupsCluster(4, 4, "1|*");
- assertFalse("Did not get expected Exception", true);
+ fail("Did not get expected Exception");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Expected distribution partitions should be '2|*'"));
+ assertTrue(e.getMessage().contains("Expected distribution partitions should be '2|*'"));
}
}
@@ -242,9 +241,9 @@ public class IndexedHierarchicDistributionTest {
public void requireThatReadyCopiesMustBeEqualToRedundancy() {
try {
getTwoGroupsCluster(4, 3, "2|*");
- assertFalse("Did not get expected Exception", true);
+ fail("Did not get expected Exception");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("Expected equal amount of ready copies per group"));
+ assertTrue(e.getMessage().contains("Expected equal amount of ready copies per group"));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedTest.java
index 4522e5cfd03..d9dbd6eeca7 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedTest.java
@@ -17,14 +17,11 @@ import com.yahoo.vespa.model.test.utils.ApplicationPackageUtils;
import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg;
import org.junit.Test;
-import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.core.Is.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;
/**
* Test for using the content model to create indexed search clusters.
@@ -113,12 +110,12 @@ public class IndexedTest extends ContentBaseTest {
private VespaModelCreatorWithMockPkg getIndexedVespaModelCreator() {
List<String> sds = ApplicationPackageUtils.generateSchemas("type1", "type2", "type3");
- return new VespaModelCreatorWithMockPkg(getHosts(), createProtonIndexedVespaServices(Arrays.asList("type1", "type2", "type3")), sds);
+ return new VespaModelCreatorWithMockPkg(getHosts(), createProtonIndexedVespaServices(List.of("type1", "type2", "type3")), sds);
}
private VespaModel getStreamingVespaModel() {
List<String> sds = ApplicationPackageUtils.generateSchemas("type1");
- return new VespaModelCreatorWithMockPkg(getHosts(), createProtonStreamingVespaServices(Arrays.asList("type1")), sds).create();
+ return new VespaModelCreatorWithMockPkg(getHosts(), createProtonStreamingVespaServices(List.of("type1")), sds).create();
}
@Test
@@ -190,9 +187,9 @@ public class IndexedTest extends ContentBaseTest {
assertNotNull(s);
assertFalse(s.getSearch().hasIndexedCluster());
ClusterListConfig config = model.getConfig(ClusterListConfig.class, VespaModel.ROOT_CONFIGID);
- assertThat(config.storage().size(), is(1));
- assertThat(config.storage(0).name(), is("test"));
- assertThat(config.storage(0).configid(), is("test"));
+ assertEquals(1, config.storage().size());
+ assertEquals("test", config.storage(0).name());
+ assertEquals("test", config.storage(0).configid());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java
index d2dcc307871..cea8d724c30 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java
@@ -23,10 +23,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -247,7 +245,7 @@ public class IndexingAndDocprocRoutingTest extends ContentBaseTest {
expectedDocprocChainStrings.add(spec.name);
}
- assertThat(actualDocprocChains, hasItems(expectedDocprocChainStrings.toArray(new String[0])));
+ assertTrue(actualDocprocChains.containsAll(expectedDocprocChainStrings));
}
}
@@ -279,32 +277,32 @@ public class IndexingAndDocprocRoutingTest extends ContentBaseTest {
HopBlueprint indexingHop = table.getHop("indexing");
- assertThat(indexingHop, not(nullValue()));
+ assertNotNull(indexingHop);
- assertThat(indexingHop.getNumDirectives(), is(1));
- assertThat(indexingHop.getDirective(0), instanceOf(PolicyDirective.class));
- assertThat(indexingHop.getDirective(0).toString(), is("[DocumentRouteSelector]"));
+ assertEquals(1, indexingHop.getNumDirectives());
+ assertTrue(indexingHop.getDirective(0) instanceof PolicyDirective);
+ assertEquals("[DocumentRouteSelector]", indexingHop.getDirective(0).toString());
//assertThat(indexingHop.getNumRecipients(), is(1));
//assertThat(indexingHop.getRecipient(0).getServiceName(), is(searchClusterName));
Route route = table.getRoute(searchClusterName);
assertNotNull(route);
- assertThat(route.getNumHops(), is(1));
+ assertEquals(1, route.getNumHops());
Hop messageTypeHop = route.getHop(0);
- assertThat(messageTypeHop.getNumDirectives(), is(1));
- assertThat(messageTypeHop.getDirective(0), instanceOf(PolicyDirective.class));
- assertThat(messageTypeHop.getDirective(0).toString(), is("[MessageType:" + searchClusterName + "]"));
+ assertEquals(1, messageTypeHop.getNumDirectives());
+ assertTrue(messageTypeHop.getDirective(0) instanceof PolicyDirective);
+ assertEquals("[MessageType:" + searchClusterName + "]", messageTypeHop.getDirective(0).toString());
PolicyDirective messageTypeDirective = (PolicyDirective) messageTypeHop.getDirective(0);
- assertThat(messageTypeDirective.getName(), is("MessageType"));
- assertThat(messageTypeDirective.getParam(), is(searchClusterName));
+ assertEquals("MessageType", messageTypeDirective.getName());
+ assertEquals(searchClusterName, messageTypeDirective.getParam());
String indexingRouteName = DocumentProtocol.getIndexedRouteName(model.getContentClusters().get(searchClusterName).getConfigId());
Route indexingRoute = table.getRoute(indexingRouteName);
- assertThat(indexingRoute.getNumHops(), is(2));
- assertThat(indexingRoute.getHop(0).getServiceName(), is(indexingHopName));
- assertThat(indexingRoute.getHop(1), not(nullValue()));
+ assertEquals(2, indexingRoute.getNumHops());
+ assertEquals(indexingHopName, indexingRoute.getHop(0).getServiceName());
+ assertNotNull(indexingRoute.getHop(1));
}
private void assertFeedingRouteIndexed(VespaModel model, String searchClusterName, String indexingHopName) {
@@ -323,9 +321,9 @@ public class IndexingAndDocprocRoutingTest extends ContentBaseTest {
RoutingTable table = new RoutingTable(documentProtocol.getRoutingTableSpec());
Route indexingRoute = table.getRoute("searchcluster-index");
- assertThat(indexingRoute.getNumHops(), is(2));
- assertThat(indexingRoute.getHop(0).toString(), is(indexingHopName));
- assertThat(indexingRoute.getHop(1).toString(), is("[Content:cluster=" + searchClusterName + "]"));
+ assertEquals(2, indexingRoute.getNumHops());
+ assertEquals(indexingHopName, indexingRoute.getHop(0).toString());
+ assertEquals("[Content:cluster=" + searchClusterName + "]", indexingRoute.getHop(1).toString());
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/MonitoringConfigSnoopTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/MonitoringConfigSnoopTest.java
index ff34b6ac0d8..d1ce16bfe73 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/MonitoringConfigSnoopTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/MonitoringConfigSnoopTest.java
@@ -6,8 +6,7 @@ import com.yahoo.config.model.test.TestRoot;
import com.yahoo.metrics.MetricsmanagerConfig;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
@@ -45,11 +44,11 @@ public class MonitoringConfigSnoopTest {
}
@Test
- public void correct_config_is_snooped() throws Exception {
+ public void correct_config_is_snooped() {
initRoot(60);
- assertThat(getConfig().snapshot().periods().size(), is(2));
- assertThat(getConfig().snapshot().periods(0), is(60));
- assertThat(getConfig().snapshot().periods(1), is(300));
+ assertEquals(2, getConfig().snapshot().periods().size());
+ assertEquals(60, getConfig().snapshot().periods(0));
+ assertEquals(300, getConfig().snapshot().periods(1));
}
@Test
@@ -60,13 +59,13 @@ public class MonitoringConfigSnoopTest {
TestDriver tester = new TestDriver();
root = tester.buildModel(getAdminXmlIntervalNotSpecified + getContent());
- assertThat(getConfig().snapshot().periods().size(), is(2));
- assertThat(getConfig().snapshot().periods(0), is(60));
- assertThat(getConfig().snapshot().periods(1), is(300));
+ assertEquals(2, getConfig().snapshot().periods().size());
+ assertEquals(60, getConfig().snapshot().periods(0));
+ assertEquals(300, getConfig().snapshot().periods(1));
}
@Test(expected = Exception.class)
- public void invalid_model_1() throws Exception {
+ public void invalid_model_1() {
initRoot(120);
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java
index e73cd98f32e..684f07d99f0 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java
@@ -2,9 +2,7 @@
package com.yahoo.vespa.model.content;
import com.yahoo.documentmodel.NewDocumentType;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.util.Arrays;
import java.util.Collections;
@@ -14,10 +12,11 @@ import java.util.TreeMap;
import java.util.function.Function;
import java.util.stream.Collectors;
-public class ReservedDocumentTypeNameValidatorTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
+public class ReservedDocumentTypeNameValidatorTest {
private static Map<String, NewDocumentType> asDocTypeMapping(List<String> typeNames) {
return typeNames.stream().collect(Collectors.toMap(Function.identity(), n -> new NewDocumentType(new NewDocumentType.Name(n))));
@@ -25,16 +24,19 @@ public class ReservedDocumentTypeNameValidatorTest {
@Test
public void exception_thrown_on_reserved_names() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("The following document types conflict with reserved keyword names: " +
- "'and', 'false', 'id', 'not', 'null', 'or', 'true'. " +
- "Reserved keywords are 'and', 'false', 'id', 'not', 'null', 'or', 'true'");
-
// Ensure ordering is consistent for testing
Map<String, NewDocumentType> orderedDocTypes = new TreeMap<>(asDocTypeMapping(ReservedDocumentTypeNameValidator.ORDERED_RESERVED_NAMES));
ReservedDocumentTypeNameValidator validator = new ReservedDocumentTypeNameValidator();
- validator.validate(orderedDocTypes);
+ try {
+ validator.validate(orderedDocTypes);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("The following document types conflict with reserved keyword names: " +
+ "'and', 'false', 'id', 'not', 'null', 'or', 'true'. " +
+ "Reserved keywords are 'and', 'false', 'id', 'not', 'null', 'or', 'true'",
+ e.getMessage());
+ }
}
@Test
@@ -45,13 +47,15 @@ public class ReservedDocumentTypeNameValidatorTest {
@Test
public void validation_is_case_insensitive() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("The following document types conflict with reserved keyword names: " +
- "'NULL', 'True', 'anD'.");
-
ReservedDocumentTypeNameValidator validator = new ReservedDocumentTypeNameValidator();
Map<String, NewDocumentType> orderedDocTypes = new TreeMap<>(asDocTypeMapping(Arrays.asList("NULL", "True", "anD")));
- validator.validate(orderedDocTypes);
+ try {
+ validator.validate(orderedDocTypes);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("The following document types conflict with reserved keyword names: " +
+ "'NULL', 'True', 'anD'."));
+ }
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/generic/GenericServicesModelTest.java b/config-model/src/test/java/com/yahoo/vespa/model/generic/GenericServicesModelTest.java
index 234a313651c..7b7fc83131e 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/generic/GenericServicesModelTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/generic/GenericServicesModelTest.java
@@ -13,7 +13,7 @@ import org.xml.sax.SAXException;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author Ulf Lilleengen
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaNodeTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaNodeTest.java
index 9077fcea4d1..d000f83d6cd 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaNodeTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaNodeTest.java
@@ -13,8 +13,6 @@ import com.yahoo.vespa.model.HostResource;
import com.yahoo.vespa.model.search.NodeSpec;
import com.yahoo.vespa.model.search.SearchNode;
import com.yahoo.vespa.model.search.TransactionLogServer;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
import org.junit.Test;
import java.util.Optional;
@@ -92,8 +90,7 @@ public class SchemaNodeTest {
node.setHostResource(new HostResource(new Host(node, "mynbode2")));
node.initService(root.deployLogger());
assertTrue(node.getPreShutdownCommand().isPresent());
- Assert.assertThat(node.getPreShutdownCommand().get(),
- CoreMatchers.containsString("vespa-proton-cmd " + node.getRpcPort() + " prepareRestart"));
+ assertTrue(node.getPreShutdownCommand().get().contains("vespa-proton-cmd " + node.getRpcPort() + " prepareRestart"));
}
private MockRoot createRoot(ModelContext.Properties properties) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/storage/test/StorageModelTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/storage/test/StorageModelTestCase.java
index a2aa330efbe..72d6a80e711 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/storage/test/StorageModelTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/storage/test/StorageModelTestCase.java
@@ -8,10 +8,8 @@ import com.yahoo.vespa.model.content.cluster.ContentCluster;
import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
/**
* Tests storage model
@@ -50,7 +48,7 @@ public class StorageModelTestCase {
MetricsmanagerConfig.Builder builder = new MetricsmanagerConfig.Builder();
contentCluster.getConfig(builder);
MetricsmanagerConfig config = new MetricsmanagerConfig(builder);
- assertThat(config.snapshot().periods(0), is(60));
+ assertEquals(60, config.snapshot().periods(0));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java
index 9fe1c8c40d3..bf4d066e454 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java
@@ -39,18 +39,15 @@ import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;
-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;
/**
@@ -258,13 +255,13 @@ public class VespaModelTestCase {
"</services>")
.create();
Admin admin = model.getAdmin();
- assertThat(admin.getSlobroks().size(), is(1));
- assertThat(admin.getConfigservers().size(), is(1));
+ assertEquals(1, admin.getSlobroks().size());
+ assertEquals(1, admin.getConfigservers().size());
Set<HostInfo> hosts = model.getHosts();
- assertThat(hosts.size(), is(1));
+ assertEquals(1, hosts.size());
//logd, config proxy, sentinel, config server, slobrok, log server
HostInfo host = hosts.iterator().next();
- assertThat(host.getServices().size(), is(7));
+ assertEquals(7, host.getServices().size());
new LogdConfig((LogdConfig.Builder) model.getConfig(new LogdConfig.Builder(), "admin/model"));
}
@@ -278,7 +275,7 @@ public class VespaModelTestCase {
.applicationPackage(applicationPackage)
.modelHostProvisioner(new InMemoryProvisioner(true, false, "host1.yahoo.com"))
.properties(new TestProperties()
- .setConfigServerSpecs(Arrays.asList(new TestProperties.Spec("cfghost", 1234, 1236)))
+ .setConfigServerSpecs(List.of(new TestProperties.Spec("cfghost", 1234, 1236)))
.setMultitenant(true))
.build();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
@@ -291,8 +288,8 @@ public class VespaModelTestCase {
VespaModel model = new VespaModel(new MockApplicationPackage.Builder()
.withServices("<services version='1.0'><container version='1.0'><search /></container></services>")
.build());
- assertThat(model.hostSystem().getHosts().size(), is(1));
- assertThat(model.getContainerClusters().size(), is(1));
+ assertEquals(1, model.hostSystem().getHosts().size());
+ assertEquals(1, model.getContainerClusters().size());
}
@Test
@@ -300,9 +297,9 @@ public class VespaModelTestCase {
ApplicationPackage app = MockApplicationPackage.createEmpty();
DeployState.Builder builder = new DeployState.Builder().applicationPackage(app);
VespaModel model = new VespaModel(new NullConfigModelRegistry(), builder.build());
- assertThat(model.getContainerClusters().size(), is(0));
+ assertTrue(model.getContainerClusters().isEmpty());
model = new VespaModel(new NullConfigModelRegistry(), builder.permanentApplicationPackage(Optional.of(FilesApplicationPackage.fromFile(new File(TESTDIR, "app_permanent")))).build());
- assertThat(model.getContainerClusters().size(), is(1));
+ assertEquals(1, model.getContainerClusters().size());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
index e9527bae7a2..96815646a88 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
@@ -23,8 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author Ulf Lilleengen
@@ -89,8 +88,8 @@ public class FileSenderTest {
builder.setField("stringVal", "foo.txt");
fileRegistry.pathToRef.put("foo.txt", new FileNode("fooshash").value());
fileSender().sendUserConfiguredFiles(producer);
- assertThat(builder.getObject("fileVal").getValue(), is("fooshash"));
- assertThat(builder.getObject("stringVal").getValue(), is("foo.txt"));
+ assertEquals("fooshash", builder.getObject("fileVal").getValue());
+ assertEquals("foo.txt", builder.getObject("stringVal").getValue());
}
@Test
@@ -101,8 +100,8 @@ public class FileSenderTest {
builder.setField("stringVal", "foo.txt");
fileRegistry.pathToRef.put("foo.txt", new FileNode("fooshash").value());
fileSender().sendUserConfiguredFiles(producer);
- assertThat(builder.getObject("fileVal").getValue(), is("fooshash"));
- assertThat(builder.getObject("stringVal").getValue(), is("foo.txt"));
+ assertEquals("fooshash", builder.getObject("fileVal").getValue());
+ assertEquals("foo.txt", builder.getObject("stringVal").getValue());
}
@Test
@@ -114,8 +113,8 @@ public class FileSenderTest {
inner.setField("stringVal", "bar.txt");
fileRegistry.pathToRef.put("bar.txt", new FileNode("barhash").value());
fileSender().sendUserConfiguredFiles(producer);
- assertThat(builder.getArray("inner").get(0).getObject("fileVal").getValue(), is("barhash"));
- assertThat(builder.getArray("inner").get(0).getObject("stringVal").getValue(), is("bar.txt"));
+ assertEquals("barhash", builder.getArray("inner").get(0).getObject("fileVal").getValue());
+ assertEquals("bar.txt", builder.getArray("inner").get(0).getObject("stringVal").getValue());
}
@Test
@@ -131,10 +130,10 @@ public class FileSenderTest {
fileRegistry.pathToRef.put("bar.txt", new FileNode("barhash").value());
fileRegistry.pathToRef.put("path.txt", new FileNode("pathhash").value());
fileSender().sendUserConfiguredFiles(producer);
- assertThat(builder.getArray("fileArray").get(0).getValue(), is("foohash"));
- assertThat(builder.getArray("fileArray").get(1).getValue(), is("barhash"));
- assertThat(builder.getArray("pathArray").get(0).getValue(), is("pathhash"));
- assertThat(builder.getArray("stringArray").get(0).getValue(), is("foo.txt"));
+ assertEquals("foohash", builder.getArray("fileArray").get(0).getValue());
+ assertEquals("barhash", builder.getArray("fileArray").get(1).getValue());
+ assertEquals("pathhash", builder.getArray("pathArray").get(0).getValue());
+ assertEquals("foo.txt", builder.getArray("stringArray").get(0).getValue());
}
@Test
@@ -145,8 +144,8 @@ public class FileSenderTest {
builder.getObject("struct").setField("stringVal", "foo.txt");
fileRegistry.pathToRef.put("foo.txt", new FileNode("foohash").value());
fileSender().sendUserConfiguredFiles(producer);
- assertThat(builder.getObject("struct").getObject("fileVal").getValue(), is("foohash"));
- assertThat(builder.getObject("struct").getObject("stringVal").getValue(), is("foo.txt"));
+ assertEquals("foohash", builder.getObject("struct").getObject("fileVal").getValue());
+ assertEquals("foo.txt", builder.getObject("struct").getObject("stringVal").getValue());
}
@Test
@@ -162,10 +161,10 @@ public class FileSenderTest {
fileRegistry.pathToRef.put("bar.txt", new FileNode("barhash").value());
fileRegistry.pathToRef.put("path.txt", new FileNode("pathhash").value());
fileSender().sendUserConfiguredFiles(producer);
- assertThat(builder.getMap("fileMap").get("foo").getValue(), is("foohash"));
- assertThat(builder.getMap("fileMap").get("bar").getValue(), is("barhash"));
- assertThat(builder.getMap("pathMap").get("path").getValue(), is("pathhash"));
- assertThat(builder.getMap("stringMap").get("bar").getValue(), is("bar.txt"));
+ assertEquals("foohash", builder.getMap("fileMap").get("foo").getValue());
+ assertEquals("barhash", builder.getMap("fileMap").get("bar").getValue());
+ assertEquals("pathhash", builder.getMap("pathMap").get("path").getValue());
+ assertEquals("bar.txt", builder.getMap("stringMap").get("bar").getValue());
}
@Test
@@ -177,8 +176,8 @@ public class FileSenderTest {
inner.setField("stringVal", "bar.txt");
fileRegistry.pathToRef.put("bar.txt", new FileNode("barhash").value());
fileSender().sendUserConfiguredFiles(producer);
- assertThat(builder.getMap("inner").get("foo").getObject("fileVal").getValue(), is("barhash"));
- assertThat(builder.getMap("inner").get("foo").getObject("stringVal").getValue(), is("bar.txt"));
+ assertEquals("barhash", builder.getMap("inner").get("foo").getObject("fileVal").getValue());
+ assertEquals("bar.txt", builder.getMap("inner").get("foo").getObject("stringVal").getValue());
}
@Test(expected = IllegalArgumentException.class)
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java b/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java
index 2909031f380..fb1afb75e10 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java
@@ -12,10 +12,8 @@ import org.junit.Test;
import java.util.Set;
import static com.yahoo.vespa.model.utils.internal.ReflectionUtil.getAllConfigsProduced;
-import static org.hamcrest.Matchers.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;
/**
@@ -71,14 +69,14 @@ public class ReflectionUtilTest {
@Test
public void getAllConfigsProduced_includes_configs_produced_by_super_class() {
Set<ConfigKey<?>> configs = getAllConfigsProduced(ConcreteProducer.class, "foo");
- assertThat(configs.size(), is(1));
+ assertEquals(1, configs.size());
assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE)));
}
@Test
public void getAllConfigsProduced_includes_configs_produced_by_implemented_interface() {
Set<ConfigKey<?>> configs = getAllConfigsProduced(InterfaceImplementingProducer.class, "foo");
- assertThat(configs.size(), is(2));
+ assertEquals(2, configs.size());
assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE)));
assertTrue(configs.contains(new ConfigKey<>(ArraytypesConfig.CONFIG_DEF_NAME, "foo", ArraytypesConfig.CONFIG_DEF_NAMESPACE)));
}
@@ -86,7 +84,7 @@ public class ReflectionUtilTest {
@Test
public void getAllConfigsProduced_includes_configs_directly_implemented_by_producer() {
Set<ConfigKey<?>> configs = getAllConfigsProduced(SimpleProducer.class, "foo");
- assertThat(configs.size(), is(1));
+ assertEquals(1, configs.size());
assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE)));
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java
index ffbc1896aab..68cadb33ecd 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java
@@ -7,8 +7,7 @@ import org.junit.Test;
import java.io.File;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -28,15 +27,15 @@ public class ConfigGetterTest {
ConfigGetter<AppConfig> getter = new ConfigGetter<>(AppConfig.class);
AppConfig config = getter.getConfig(configId);
- assertThat(config.times(), is(times));
- assertThat(config.message(), is(message));
- assertThat(config.a().size(), is(1));
- assertThat(config.a(0).name(), is(a0));
+ assertEquals(times, config.times());
+ assertEquals(message, config.message());
+ assertEquals(1, config.a().size());
+ assertEquals(a0, config.a(0).name());
AppService service = new AppService(configId, sourceSet);
AppConfig serviceConfig = service.getConfig();
assertTrue(service.isConfigured());
- assertThat(config, is(serviceConfig));
+ assertEquals(config, serviceConfig);
service.cancelSubscription();
}
@@ -45,16 +44,16 @@ public class ConfigGetterTest {
public void testGetFromRawSource() {
ConfigGetter<AppConfig> getter = new ConfigGetter<>(new RawSource("message \"one\""), AppConfig.class);
AppConfig config = getter.getConfig("test");
- assertThat(config.message(), is("one"));
+ assertEquals("one", config.message());
}
@Test
public void testGetTwice() {
ConfigGetter<AppConfig> getter = new ConfigGetter<>(AppConfig.class);
AppConfig config = getter.getConfig("raw:message \"one\"");
- assertThat(config.message(), is("one"));
+ assertEquals("one", config.message());
config = getter.getConfig("raw:message \"two\"");
- assertThat(config.message(), is("two"));
+ assertEquals("two", config.message());
}
@Test
@@ -85,11 +84,11 @@ public class ConfigGetterTest {
}
private void verifyFooValues(AppConfig config) {
- assertThat(config.message(), is("msg1"));
- assertThat(config.times(), is(3));
- assertThat(config.a(0).name(), is("a0"));
- assertThat(config.a(1).name(), is("a1"));
- assertThat(config.a(2).name(), is("a2"));
+ assertEquals("msg1", config.message());
+ assertEquals(3, config.times());
+ assertEquals("a0", config.a(0).name());
+ assertEquals("a1", config.a(1).name());
+ assertEquals("a2", config.a(2).name());
}
@Test
@@ -100,15 +99,15 @@ public class ConfigGetterTest {
String configId = "raw:times " + times + "\nmessage " + message + "\na[1]\na[0].name " + a0;
AppConfig config = ConfigGetter.getConfig(AppConfig.class, configId);
- assertThat(config.times(), is(times));
- assertThat(config.message(), is(message));
- assertThat(config.a().size(), is(1));
- assertThat(config.a(0).name(), is(a0));
+ assertEquals(times, config.times());
+ assertEquals(message, config.message());
+ assertEquals(1, config.a().size());
+ assertEquals(a0, config.a(0).name());
AppService service = new AppService(configId, sourceSet);
AppConfig serviceConfig = service.getConfig();
assertTrue(service.isConfigured());
- assertThat(config, is(serviceConfig));
+ assertEquals(config, serviceConfig);
service.cancelSubscription();
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java
index 3dc0f7188e3..c656bfe1a60 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java
@@ -15,9 +15,8 @@ import java.util.Arrays;
import java.util.List;
import static com.yahoo.foo.FunctionTestConfig.*;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
@@ -131,8 +130,8 @@ public class ConfigInstancePayloadTest {
try {
System.out.println(payload.toString(false));
FunctionTestConfig config2 = new FunctionTestConfig((FunctionTestConfig.Builder)new ConfigTransformer<>(FunctionTestConfig.class).toConfigBuilder(payload));
- assertThat(config2, is(expected));
- assertThat(ConfigInstance.serialize(config2), is(ConfigInstance.serialize(expected)));
+ assertEquals(expected, config2);
+ assertEquals(ConfigInstance.serialize(expected), ConfigInstance.serialize(config2));
} catch (Exception e) {
e.printStackTrace();
fail();
@@ -156,14 +155,14 @@ public class ConfigInstancePayloadTest {
System.out.println(payload.toString());
MaptypesConfig config = ConfigInstanceUtil.getNewInstance(MaptypesConfig.class, "foo", payload);
System.out.println(config);
- assertThat(config.intmap().size(), is(1));
- assertThat(config.intmap("foo"), is(1337));
+ assertEquals(1, config.intmap().size());
+ assertEquals(1337, config.intmap("foo"));
assertNotNull(config.innermap("bar"));
- assertThat(config.innermap("bar").foo(), is(93));
- assertThat(config.nestedmap().size(), is(1));
+ assertEquals(93, config.innermap("bar").foo());
+ assertEquals(1, config.nestedmap().size());
assertNotNull(config.nestedmap("baz"));
- assertThat(config.nestedmap("baz").inner("foo"), is(1));
- assertThat(config.nestedmap("baz").inner("bar"), is(2));
+ assertEquals(1, config.nestedmap("baz").inner("foo"));
+ assertEquals(2, config.nestedmap("baz").inner("bar"));
}
private MaptypesConfig createMapTypesConfig() {
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java
index 57ceee9b1bb..831e645c763 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java
@@ -8,8 +8,7 @@ import org.junit.Test;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author gjoranv
@@ -27,8 +26,8 @@ public class ConfigInstanceSerializationTest {
ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(lines);
FunctionTestConfig config2 = ConfigInstanceUtil.getNewInstance(FunctionTestConfig.class, ":parent:", payload);
- assertThat(config, is(config2));
- assertThat(ConfigInstance.serialize(config), is(ConfigInstance.serialize(config2)));
+ assertEquals(config, config2);
+ assertEquals(ConfigInstance.serialize(config), ConfigInstance.serialize(config2));
}
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java
index aaf6782a6ff..091494955fb 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java
@@ -13,11 +13,9 @@ import org.junit.Test;
import java.io.File;
import java.util.Arrays;
-import static org.hamcrest.CoreMatchers.is;
-
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static com.yahoo.foo.FunctionTestConfig.*;
+import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
@@ -43,26 +41,26 @@ public class ConfigInstanceUtilTest {
ConfigInstanceUtil.setValues(destination, source);
FunctionTestConfig result = new FunctionTestConfig(destination);
- assertThat(result.int_val(), is(-1));
- assertThat(result.string_val(), is("foo"));
- assertThat(result.intarr().size(), is(1));
- assertThat(result.intarr(0), is(0));
- assertThat(result.longarr().size(), is(2));
- assertThat(result.doublearr().size(), is(3));
+ assertEquals(-1, result.int_val());
+ assertEquals("foo", result.string_val());
+ assertEquals(1, result.intarr().size());
+ assertEquals(0, result.intarr(0));
+ assertEquals(2, result.longarr().size());
+ assertEquals(3, result.doublearr().size());
assertEquals(2344.0, result.doublearr(0), 0.01);
assertEquals(123.0, result.doublearr(1), 0.01);
assertEquals(0.0, result.doublearr(2), 0.01);
- assertThat(result.basicStruct().bar(), is(-1));
- assertThat(result.basicStruct().foo(), is("basicFoo"));
- assertThat(result.basicStruct().intArr().size(), is(3));
- assertThat(result.basicStruct().intArr(0), is(310));
- assertThat(result.basicStruct().intArr(1), is(311));
- assertThat(result.basicStruct().intArr(2), is(0));
- assertThat(result.myarray().size(), is(3));
- assertThat(result.myarray(2).intval(), is(-1));
- assertThat(result.myarray(2).refval(), is(""));
- assertThat(result.myarray(2).fileVal().value(), is(""));
- assertThat(result.myarray(2).myStruct().a(), is(0));
+ assertEquals(-1, result.basicStruct().bar());
+ assertEquals("basicFoo", result.basicStruct().foo());
+ assertEquals(3, result.basicStruct().intArr().size());
+ assertEquals(310, result.basicStruct().intArr(0));
+ assertEquals(311, result.basicStruct().intArr(1));
+ assertEquals(0, result.basicStruct().intArr(2));
+ assertEquals(3, result.myarray().size());
+ assertEquals(-1, result.myarray(2).intval());
+ assertTrue(result.myarray(2).refval().isEmpty());
+ assertTrue(result.myarray(2).fileVal().value().isEmpty());
+ assertEquals(0, result.myarray(2).myStruct().a());
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java
index dbc47b7e24d..3f050c449c7 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java
@@ -3,8 +3,7 @@ package com.yahoo.config.subscription;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author Ulf Lilleengen
@@ -14,6 +13,6 @@ public class ConfigInterruptedExceptionTest {
@Test
public void require_that_throwable_is_preserved() {
ConfigInterruptedException e = new ConfigInterruptedException(new RuntimeException("foo"));
- assertThat(e.getCause().getMessage(), is("foo"));
+ assertEquals("foo", e.getCause().getMessage());
}
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java
index 452b51bf408..2e46623ef9a 100755
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java
@@ -6,8 +6,9 @@ import org.junit.After;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author <a href="gv@yahoo-inc.com">G. Voldengen</a>
@@ -54,7 +55,7 @@ public class ConfigSourceSetTest {
// TODO: Unable to set environment, so only able to test property usage for now
System.setProperty("configsources", "foo:123,bar:345,tcp/baz:333,quux");
ConfigSourceSet set = ConfigSourceSet.createDefault();
- assertThat(set.getSources().size(), is(4));
+ assertEquals(4, set.getSources().size());
assertTrue(set.getSources().contains("tcp/foo:123"));
assertTrue(set.getSources().contains("tcp/bar:345"));
assertTrue(set.getSources().contains("tcp/baz:333"));
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java
index 3c2750c55cb..5c6c09b8b18 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java
@@ -6,8 +6,7 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -18,7 +17,7 @@ public class ConfigURITest {
@Test
public void testDefaultUri() {
ConfigURI uri = ConfigURI.createFromId("foo");
- assertThat(uri.getConfigId(), is("foo"));
+ assertEquals("foo", uri.getConfigId());
assertTrue(uri.getSource() instanceof ConfigSourceSet);
}
@@ -26,21 +25,21 @@ public class ConfigURITest {
public void testFileUri() throws IOException {
File file = File.createTempFile("foo", ".cfg");
ConfigURI uri = ConfigURI.createFromId("file:" + file.getAbsolutePath());
- assertThat(uri.getConfigId(), is(""));
+ assertTrue(uri.getConfigId().isEmpty());
assertTrue(uri.getSource() instanceof FileSource);
}
@Test
public void testDirUri() throws IOException {
ConfigURI uri = ConfigURI.createFromId("dir:.");
- assertThat(uri.getConfigId(), is(""));
+ assertTrue(uri.getConfigId().isEmpty());
assertTrue(uri.getSource() instanceof DirSource);
}
@Test
public void testCustomUri() {
ConfigURI uri = ConfigURI.createFromIdAndSource("foo", new ConfigSet());
- assertThat(uri.getConfigId(), is("foo"));
+ assertEquals("foo", uri.getConfigId());
assertTrue(uri.getSource() instanceof ConfigSet);
}
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java b/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java
index 97a682d3b9a..42c2c599899 100644
--- a/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java
@@ -214,7 +214,7 @@ public class FunctionTest {
assertEquals(0, config.intarr().size());
assertEquals(2, config.longarr().size());
assertEquals(Long.MAX_VALUE, config.longarr(0));
- assertThat(config.longarr().get(1), is(Long.MIN_VALUE));
+ assertEquals(Long.MIN_VALUE, config.longarr().get(1).longValue());
assertEquals(2, config.doublearr().size());
assertEquals(1, config.stringarr().size());
assertEquals(1, config.enumarr().size());
@@ -231,8 +231,8 @@ public class FunctionTest {
assertEquals("basicFoo", config.basicStruct().foo());
assertEquals(3, config.basicStruct().bar()); // new List api
assertEquals(2, config.basicStruct().intArr().size());
- assertThat(config.basicStruct().intArr().get(0), is(310)); // new List api
- assertThat(config.basicStruct().intArr().get(1), is(311)); // new List api
+ assertEquals(310, config.basicStruct().intArr().get(0).intValue()); // new List api
+ assertEquals(311, config.basicStruct().intArr().get(1).intValue()); // new List api
assertEquals(310, config.basicStruct().intArr(0)); // short-hand
assertEquals("inner0", config.rootStruct().inner0().name()); // new List api
assertEquals(11, config.rootStruct().inner0().index());
diff --git a/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java b/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java
index 4edf931a7c6..963f3de5e43 100644
--- a/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java
@@ -4,8 +4,7 @@ package com.yahoo.config.subscription;
import com.yahoo.myproject.config.NamespaceConfig;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author gjoranv
@@ -15,6 +14,6 @@ public class NamespaceTest {
@Test
public void verifyConfigClassWithExplicitNamespace() {
NamespaceConfig config = new ConfigGetter<>(NamespaceConfig.class).getConfig("raw: a 0\n");
- assertThat(config.a(), is(0));
+ assertEquals(0, config.a());
}
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java
index 74af35e39dc..e37a5d7b36b 100644
--- a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java
@@ -14,11 +14,10 @@ import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -45,11 +44,11 @@ public class FileConfigSubscriptionTest {
new ConfigKey<>(SimpletypesConfig.class, ""),
TEST_TYPES_FILE);
assertTrue(sub.nextConfig(1000));
- assertThat(sub.getConfigState().getConfig().intval(), is(23));
+ assertEquals(23, sub.getConfigState().getConfig().intval());
Thread.sleep(1000);
writeConfig("intval", "33");
assertTrue(sub.nextConfig(1000));
- assertThat(sub.getConfigState().getConfig().intval(), is(33));
+ assertEquals(33, sub.getConfigState().getConfig().intval());
}
@Test
@@ -59,12 +58,12 @@ public class FileConfigSubscriptionTest {
new ConfigKey<>(SimpletypesConfig.class, ""),
TEST_TYPES_FILE);
assertTrue(sub.nextConfig(1000));
- assertThat(sub.getConfigState().getConfig().intval(), is(23));
+ assertEquals(23, sub.getConfigState().getConfig().intval());
writeConfig("intval", "33");
sub.reload(1);
assertTrue(sub.nextConfig(1000));
ConfigSubscription.ConfigState<SimpletypesConfig> configState = sub.getConfigState();
- assertThat(configState.getConfig().intval(), is(33));
+ assertEquals(33, configState.getConfig().intval());
assertTrue(configState.isConfigChanged());
assertTrue(configState.isGenerationChanged());
@@ -81,7 +80,7 @@ public class FileConfigSubscriptionTest {
sub.reload(2);
assertTrue(sub.nextConfig(1000));
configState = sub.getConfigState();
- assertThat(configState.getConfig().intval(), is(33));
+ assertEquals(33, configState.getConfig().intval());
assertFalse(configState.isConfigChanged());
assertTrue(configState.isGenerationChanged());
@@ -102,7 +101,7 @@ public class FileConfigSubscriptionTest {
new DirSource(new File(cfgDir)),
new TimingValues());
assertTrue(sub.nextConfig(1000));
- assertThat(sub.getConfigState().getConfig().configId(), is(cfgId));
+ assertEquals(cfgId, sub.getConfigState().getConfig().configId());
}
@Test(expected = IllegalArgumentException.class)
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java
index 4800a05b114..93139d2c92e 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java
@@ -12,7 +12,7 @@ import java.util.Arrays;
import static com.yahoo.foo.MaptypesConfig.Innermap;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* SEO keywords: test override() on builders. overrideTest, testOverride
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java
index 6788a2f9c36..7d6174c2fbc 100755
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java
@@ -3,9 +3,8 @@ package com.yahoo.vespa.config;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
/**
*
@@ -30,10 +29,10 @@ public class ConfigCacheKeyTest {
assertEquals(k1, k2);
assertNotEquals(k3, k2);
assertNotEquals(k4, k1);
- assertThat(k1.hashCode(), is(k2.hashCode()));
- assertThat(k1.getDefMd5(), is(defMd5));
- assertThat(k1.toString(), is(configKey.toString() + "," + defMd5));
- assertThat(k5.hashCode(), is(not(k1.hashCode())));
+ assertEquals(k2.hashCode(), k1.hashCode());
+ assertEquals(defMd5, k1.getDefMd5());
+ assertEquals(configKey + "," + defMd5, k1.toString());
+ assertNotEquals(k1.hashCode(), k5.hashCode());
}
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java
index 68b25266de8..a9f09951d7e 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java
@@ -10,7 +10,11 @@ import java.io.FileReader;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
/**
* Unit tests for ConfigDefinitionBuilder.
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java
index db12145776b..fa85f582e99 100755
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java
@@ -11,8 +11,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
/**
* Unit tests for ConfigDefinition.
@@ -56,14 +56,14 @@ public class ConfigDefinitionTest {
def.addIntDef("xyzzy", 2, 0, null);
assertNull(def.getIntDefs().get("foo").getDefVal());
- assertThat(def.getIntDefs().get("foo").getMin(), is(ConfigDefinition.INT_MIN));
- assertThat(def.getIntDefs().get("foo").getMax(), is(ConfigDefinition.INT_MAX));
- assertThat(def.getIntDefs().get("bar").getDefVal(), is(0));
- assertThat(def.getIntDefs().get("baz").getDefVal(), is(1));
-
- assertThat(def.getIntDefs().get("xyzzy").getDefVal(), is(2));
- assertThat(def.getIntDefs().get("xyzzy").getMin(), is(0));
- assertThat(def.getIntDefs().get("xyzzy").getMax(), is(ConfigDefinition.INT_MAX));
+ assertEquals(ConfigDefinition.INT_MIN, def.getIntDefs().get("foo").getMin());
+ assertEquals(ConfigDefinition.INT_MAX, def.getIntDefs().get("foo").getMax());
+ assertEquals(0, def.getIntDefs().get("bar").getDefVal().longValue());
+ assertEquals(1, def.getIntDefs().get("baz").getDefVal().longValue());
+
+ assertEquals(2, def.getIntDefs().get("xyzzy").getDefVal().longValue());
+ assertEquals(0, def.getIntDefs().get("xyzzy").getMin().longValue());
+ assertEquals(ConfigDefinition.INT_MAX, def.getIntDefs().get("xyzzy").getMax());
}
@Test
@@ -75,17 +75,16 @@ public class ConfigDefinitionTest {
def.addLongDef("xyzzy", 2L, 0L, null);
assertNull(def.getLongDefs().get("foo").getDefVal());
- assertThat(def.getLongDefs().get("foo").getMin(), is(ConfigDefinition.LONG_MIN));
- assertThat(def.getLongDefs().get("foo").getMax(), is(ConfigDefinition.LONG_MAX));
- assertThat(def.getLongDefs().get("bar").getDefVal(), is(1234567890123L));
+ assertEquals(ConfigDefinition.LONG_MIN, def.getLongDefs().get("foo").getMin());
+ assertEquals(ConfigDefinition.LONG_MAX, def.getLongDefs().get("foo").getMax());
+ assertEquals(1234567890123L, def.getLongDefs().get("bar").getDefVal().longValue());
- assertThat(def.getLongDefs().get("xyzzy").getDefVal(), is(2L));
- assertThat(def.getLongDefs().get("xyzzy").getMin(), is(0L));
- assertThat(def.getLongDefs().get("xyzzy").getMax(), is(ConfigDefinition.LONG_MAX));
+ assertEquals(2L, def.getLongDefs().get("xyzzy").getDefVal().longValue());
+ assertEquals(0L, def.getLongDefs().get("xyzzy").getMin().longValue());
+ assertEquals(ConfigDefinition.LONG_MAX, def.getLongDefs().get("xyzzy").getMax());
}
@Test
- @SuppressWarnings("serial")
public void testDefaultsPayloadMap() {
ConfigDefinition def = new ConfigDefinition("foo", "namespace1");
def.addStringDef("mystring");
@@ -122,7 +121,7 @@ public class ConfigDefinitionTest {
def.addIntDef("intval");
def.addLongDef("longval");
def.addDoubleDef("doubleval");
- def.addEnumDef("enumval", new EnumDef(Arrays.asList("FOO"), "FOO"));
+ def.addEnumDef("enumval", new EnumDef(List.of("FOO"), "FOO"));
def.addReferenceDef("refval");
def.addFileDef("fileval");
def.addInnerArrayDef("innerarr");
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java
index c86d54d7471..ab07b669bd0 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java
@@ -19,15 +19,15 @@ import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
*/
public class ConfigFileFormatterTest {
- private String expected_simpletypes = "stringval \"foo\"\n" +
+ private final String expected_simpletypes = "stringval \"foo\"\n" +
"intval 324234\n" +
"longval 324\n" +
"doubleval 3.455\n" +
@@ -66,7 +66,7 @@ public class ConfigFileFormatterTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is(expected_simpletypes));
+ assertEquals(expected_simpletypes, baos.toString());
}
@Test
@@ -77,7 +77,7 @@ public class ConfigFileFormatterTest {
InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is(""));
+ assertTrue(baos.toString().isEmpty());
}
// TODO: Reenable this when we can reenable typechecking.
@@ -121,7 +121,7 @@ public class ConfigFileFormatterTest {
InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is("boolval false\n"));
+ assertEquals("boolval false\n", baos.toString());
}
// TODO: Remove this when we can reenable typechecking.
@@ -137,7 +137,8 @@ public class ConfigFileFormatterTest {
InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(StandardCharsets.UTF_8), is("enumval null\nintval null\nlongval null\nboolval false\ndoubleval null\n"));
+ assertEquals("enumval null\nintval null\nlongval null\nboolval false\ndoubleval null\n",
+ baos.toString(StandardCharsets.UTF_8));
}
// TODO: Reenable this when we can reenable typechecking.
@@ -160,7 +161,7 @@ public class ConfigFileFormatterTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(StandardCharsets.UTF_8), is("stringval \"" + value + "\"\n"));
+ assertEquals("stringval \"" + value + "\"\n", baos.toString(StandardCharsets.UTF_8));
}
@Test
@@ -189,7 +190,7 @@ public class ConfigFileFormatterTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InnerCNode def = new DefParser("arraytypes", new StringReader(StringUtilities.implode(ArraytypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is(
+ assertEquals(
"boolarr[0] true\n" +
"boolarr[1] false\n" +
"doublearr[0] 3.14\n" +
@@ -201,7 +202,8 @@ public class ConfigFileFormatterTest {
"longarr[0] 55\n" +
"longarr[1] 66\n" +
"stringarr[0] \"foo\"\n" +
- "stringarr[1] \"bar\"\n"));
+ "stringarr[1] \"bar\"\n",
+ baos.toString());
}
@Test
@@ -221,7 +223,7 @@ public class ConfigFileFormatterTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InnerCNode def = new DefParser("maptypes", new StringReader(StringUtilities.implode(MaptypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is(
+ assertEquals(
"boolmap{\"foo\"} true\n" +
"boolmap{\"bar\"} false\n" +
"intmap{\"foo\"} 1234\n" +
@@ -229,7 +231,8 @@ public class ConfigFileFormatterTest {
"doublemap{\"foo\"} 3.14\n" +
"stringmap{\"foo\"} \"bar\"\n" +
"innermap{\"bar\"}.foo 1234\n" +
- "nestedmap{\"baz\"}.inner{\"foo\"} 1234\n"));
+ "nestedmap{\"baz\"}.inner{\"foo\"} 1234\n",
+ baos.toString());
}
@Test
@@ -246,12 +249,12 @@ public class ConfigFileFormatterTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InnerCNode def = new DefParser("structtypes", new StringReader(StringUtilities.implode(StructtypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is(
+ assertEquals(
"simple.name \"myname\"\n" +
"simple.gender FEMALE\n" +
"simple.emails[0] \"foo@bar.com\"\n" +
- "simple.emails[1] \"bar@baz.net\"\n"
- ));
+ "simple.emails[1] \"bar@baz.net\"\n",
+ baos.toString());
}
@Test
@@ -286,8 +289,7 @@ public class ConfigFileFormatterTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InnerCNode def = new DefParser("structtypes", new StringReader(StringUtilities.implode(StructtypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is(
- "nested.inner.name \"baz\"\n" +
+ assertEquals("nested.inner.name \"baz\"\n" +
"nested.inner.gender FEMALE\n" +
"nested.inner.emails[0] \"foo\"\n" +
"nested.inner.emails[1] \"bar\"\n" +
@@ -296,8 +298,8 @@ public class ConfigFileFormatterTest {
"nestedarr[0].inner.emails[0] \"foo@bar\"\n" +
"nestedarr[0].inner.emails[1] \"bar@foo\"\n" +
"complexarr[0].innerarr[0].name \"bar\"\n" +
- "complexarr[0].innerarr[0].gender MALE\n"
- ));
+ "complexarr[0].innerarr[0].gender MALE\n",
+ baos.toString());
}
@Test
@@ -308,7 +310,7 @@ public class ConfigFileFormatterTest {
InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ConfigFileFormat(def).encode(baos, slime);
- assertThat(baos.toString(), is("stringval \"some\\\"quotes\\\\\\\"instring\"\n"));
+ assertEquals("stringval \"some\\\"quotes\\\\\\\"instring\"\n", baos.toString());
}
@Test
@@ -323,7 +325,7 @@ public class ConfigFileFormatterTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ConfigFileFormat(def).encode(baos, slime);
System.out.println(bytesToHexString(baos.toByteArray()));
- assertThat(Utf8.toString(baos.toByteArray()), is("stringval \"" + input + "\"\n"));
+ assertEquals(Utf8.toString(baos.toByteArray()), "stringval \"" + input + "\"\n");
}
private static String bytesToHexString(byte[] bytes){
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java
index 3e5cf22ef37..cc5ec7de1ad 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java
@@ -10,10 +10,8 @@ import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
@@ -89,12 +87,12 @@ public class ConfigPayloadBuilderTest {
map.put("barkey", "barvalue");
map.put("bazkey", "bazvalue");
map.put("fookey", "lolvalue");
- assertThat(map.getElements().size(), is(3));
+ assertEquals(3, map.getElements().size());
Cursor root = createSlime(builder);
Cursor a = root.field("foo");
- assertThat(a.field("barkey").asString(), is("barvalue"));
- assertThat(a.field("bazkey").asString(), is("bazvalue"));
- assertThat(a.field("fookey").asString(), is("lolvalue"));
+ assertEquals("barvalue", a.field("barkey").asString());
+ assertEquals("bazvalue", a.field("bazkey").asString());
+ assertEquals("lolvalue", a.field("fookey").asString());
}
@Test
@@ -111,7 +109,7 @@ public class ConfigPayloadBuilderTest {
array.append("bar");
array.append("baz");
array.append("bim");
- assertThat(array.getElements().size(), is(3));
+ assertEquals(3, array.getElements().size());
Cursor root = createSlime(builder);
Cursor a = root.field("foo");
assertEquals("bar", a.entry(0).asString());
@@ -174,16 +172,16 @@ public class ConfigPayloadBuilderTest {
ConfigPayloadBuilder b2 = array.get(1);
ConfigPayloadBuilder b3 = array.get(0);
ConfigPayloadBuilder b4 = array.get(1);
- assertThat(b1, is(b3));
- assertThat(b2, is(b4));
+ assertEquals(b1, b3);
+ assertEquals(b2, b4);
ConfigPayloadBuilder.Array array_indexed = builder.getArray("bar");
ConfigPayloadBuilder bi3 = array_indexed.set(3);
ConfigPayloadBuilder bi1 = array_indexed.set(1);
ConfigPayloadBuilder bi32 = array_indexed.get(3);
ConfigPayloadBuilder bi12 = array_indexed.get(1);
- assertThat(bi12, is(bi1));
- assertThat(bi32, is(bi3));
+ assertEquals(bi12, bi1);
+ assertEquals(bi32, bi3);
}
@Test
@@ -204,30 +202,30 @@ public class ConfigPayloadBuilderTest {
b3.getArray("eee").append("lll");
b3.setField("uuu", "vvv");
- assertThat(b1.override(b2), is(b1));
- assertThat(b1.override(b3), is(b1));
+ assertEquals(b1, b1.override(b2));
+ assertEquals(b1, b1.override(b3));
Cursor b1root = createSlime(b1);
Cursor b2root = createSlime(b2);
Cursor b3root = createSlime(b3);
- assertThat(b3root.field("aaa").asString(), is("c"));
- assertThat(b3root.field("bbb").field("ccc").asString(), is("fff"));
- assertThat(b3root.field("eee").children(), is(1));
- assertThat(b3root.field("eee").entry(0).asString(), is("lll"));
- assertThat(b3root.field("uuu").asString(), is("vvv"));
-
- assertThat(b2root.field("aaa").asString(), is("b"));
- assertThat(b2root.field("bbb").field("ccc").asString(), is("eee"));
- assertThat(b2root.field("eee").children(), is(1));
- assertThat(b2root.field("eee").entry(0).asString(), is("kkk"));
- assertThat(b2root.field("uuu").asString(), is("ttt"));
-
- assertThat(b1root.field("aaa").asString(), is("c"));
- assertThat(b1root.field("bbb").field("ccc").asString(), is("fff"));
- assertThat(b1root.field("eee").children(), is(2));
- assertThat(b1root.field("eee").entry(0).asString(), is("kkk"));
- assertThat(b1root.field("eee").entry(1).asString(), is("lll"));
- assertThat(b1root.field("uuu").asString(), is("vvv"));
+ assertEquals("c", b3root.field("aaa").asString());
+ assertEquals("fff", b3root.field("bbb").field("ccc").asString());
+ assertEquals(1, b3root.field("eee").children());
+ assertEquals("lll", b3root.field("eee").entry(0).asString());
+ assertEquals("vvv", b3root.field("uuu").asString());
+
+ assertEquals("b", b2root.field("aaa").asString());
+ assertEquals("eee", b2root.field("bbb").field("ccc").asString());
+ assertEquals(1, b2root.field("eee").children());
+ assertEquals("kkk", b2root.field("eee").entry(0).asString());
+ assertEquals("ttt", b2root.field("uuu").asString());
+
+ assertEquals("c", b1root.field("aaa").asString());
+ assertEquals("fff", b1root.field("bbb").field("ccc").asString());
+ assertEquals(2, b1root.field("eee").children());
+ assertEquals("kkk", b1root.field("eee").entry(0).asString());
+ assertEquals("lll", b1root.field("eee").entry(1).asString());
+ assertEquals("vvv", b1root.field("uuu").asString());
}
@Test(expected=IllegalStateException.class)
@@ -266,7 +264,8 @@ public class ConfigPayloadBuilderTest {
ConfigPayloadBuilder builder = new ConfigPayloadBuilder(new ConfigPayload(slime));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ConfigPayload.fromBuilder(builder).serialize(baos, new JsonFormat(true));
- assertThat(baos.toString(), is("{\"foo\":\"bar\",\"foorio\":{\"bar\":\"bam\",\"bario\":{\"bim\":\"bul\"},\"blim\":[{\"fim\":\"fam\"},{\"blim\":\"blam\"}]},\"arrio\":[\"himbio\"]}"));
+ assertEquals("{\"foo\":\"bar\",\"foorio\":{\"bar\":\"bam\",\"bario\":{\"bim\":\"bul\"},\"blim\":[{\"fim\":\"fam\"},{\"blim\":\"blam\"}]},\"arrio\":[\"himbio\"]}",
+ baos.toString());
}
@Test(expected=IllegalArgumentException.class)
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java
index 50f4233e13a..46b710cdcf9 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java
@@ -17,10 +17,10 @@ import org.junit.Test;
import java.io.StringReader;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
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;
/**
diff --git a/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java b/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java
index 0acefe5cd18..199d5f14b9f 100644
--- a/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java
@@ -10,8 +10,7 @@ import org.junit.Test;
import java.io.StringReader;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -43,9 +42,9 @@ public class DefaultValueApplierTest {
public void require_that_simple_defaults_are_applied() {
Slime slime = apply("strdef string default=\"foo\"");
assertTrue(slime.get().field("str").valid());
- assertThat(slime.get().field("str").asString(), is("myvalue"));
+ assertEquals("myvalue", slime.get().field("str").asString());
assertTrue(slime.get().field("strdef").valid());
- assertThat(slime.get().field("strdef").asString(), is("foo"));
+ assertEquals("foo", slime.get().field("strdef").asString());
}
@@ -54,7 +53,7 @@ public class DefaultValueApplierTest {
Slime slime = apply("nested.str string default=\"bar\"");
assertTrue(slime.get().field("nested").valid());
assertTrue(slime.get().field("nested").field("str").valid());
- assertThat(slime.get().field("nested").field("str").asString(), is("bar"));
+ assertEquals("bar", slime.get().field("nested").field("str").asString());
}
@Test
@@ -65,11 +64,11 @@ public class DefaultValueApplierTest {
Slime slime = apply(payload, "nestedarr[].foo string", "nestedarr[].bar string default=\"bim\"");
assertTrue(slime.get().field("nestedarr").valid());
- assertThat(slime.get().field("nestedarr").entries(), is(1));
+ assertEquals(1, slime.get().field("nestedarr").entries());
assertTrue(slime.get().field("nestedarr").entry(0).field("foo").valid());
- assertThat(slime.get().field("nestedarr").entry(0).field("foo").asString(), is("myfoo"));
+ assertEquals("myfoo", slime.get().field("nestedarr").entry(0).field("foo").asString());
assertTrue(slime.get().field("nestedarr").entry(0).field("bar").valid());
- assertThat(slime.get().field("nestedarr").entry(0).field("bar").asString(), is("bim"));
+ assertEquals("bim", slime.get().field("nestedarr").entry(0).field("bar").asString());
}
@Test
@@ -79,8 +78,8 @@ public class DefaultValueApplierTest {
Slime slime = apply(payload, "nestedarr[].foo string", "nestedarr[].bar string default=\"bim\"");
assertTrue(slime.get().field("nestedarr").valid());
- assertThat(slime.get().field("nestedarr").entries(), is(0));
- assertThat(slime.get().field("nestedarr").type(), is(Type.ARRAY));
+ assertEquals(0, slime.get().field("nestedarr").entries());
+ assertEquals(Type.ARRAY, slime.get().field("nestedarr").type());
}
@Test
@@ -91,10 +90,10 @@ public class DefaultValueApplierTest {
Slime slime = apply(payload, "nestedmap{}.foo string", "nestedmap{}.bar string default=\"bim\"");
assertTrue(slime.get().field("nestedmap").valid());
- assertThat(slime.get().field("nestedmap").fields(), is(1));
+ assertEquals(1, slime.get().field("nestedmap").fields());
assertTrue(slime.get().field("nestedmap").field("mykey").field("foo").valid());
- assertThat(slime.get().field("nestedmap").field("mykey").field("foo").asString(), is("myfoo"));
+ assertEquals("myfoo", slime.get().field("nestedmap").field("mykey").field("foo").asString());
assertTrue(slime.get().field("nestedmap").field("mykey").field("bar").valid());
- assertThat(slime.get().field("nestedmap").field("mykey").field("bar").asString(), is("bim"));
+ assertEquals("bim", slime.get().field("nestedmap").field("mykey").field("bar").asString());
}
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java b/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java
index 4ae8bc676d7..3bbdd6f0aa2 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java
@@ -4,8 +4,7 @@ package com.yahoo.vespa.config;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author hmusum
*/
diff --git a/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java
index bb612bb3245..ff801e5cf12 100644
--- a/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java
@@ -9,8 +9,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author Ulf Lilleengen
*/
diff --git a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
index 43f9a87454d..8186347f998 100644
--- a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
@@ -11,12 +11,9 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -100,7 +97,7 @@ public class JRTConnectionPoolTest {
// Update to the same set, should be equal
sourcePool.updateSources(twoSources);
- assertThat(sourcesBefore, is(sourcePool.getSourceSet()));
+ assertEquals(sourcePool.getSourceSet(), sourcesBefore);
// Update to new set
List<String> newSources = new ArrayList<>();
@@ -109,8 +106,8 @@ public class JRTConnectionPoolTest {
sourcePool.updateSources(newSources);
ConfigSourceSet newSourceSet = sourcePool.getSourceSet();
assertNotNull(newSourceSet);
- assertThat(newSourceSet.getSources().size(), is(2));
- assertThat(newSourceSet, is(not(sourcesBefore)));
+ assertEquals(2, newSourceSet.getSources().size());
+ assertNotEquals(sourcesBefore, newSourceSet);
assertTrue(newSourceSet.getSources().contains("host2"));
assertTrue(newSourceSet.getSources().contains("host3"));
@@ -120,8 +117,8 @@ public class JRTConnectionPoolTest {
sourcePool.updateSources(newSources2);
ConfigSourceSet newSourceSet2 = sourcePool.getSourceSet();
assertNotNull(newSourceSet2);
- assertThat(newSourceSet2.getSources().size(), is(1));
- assertThat(newSourceSet2, is(not(newSourceSet)));
+ assertEquals(1, newSourceSet2.getSources().size());
+ assertNotEquals(newSourceSet, newSourceSet2);
assertTrue(newSourceSet2.getSources().contains("host4"));
sourcePool.close();
diff --git a/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java b/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java
index 56bcdda20a0..c35dd016b39 100644
--- a/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java
@@ -4,8 +4,7 @@ package com.yahoo.vespa.config;
import com.yahoo.text.Utf8;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertArrayEquals;
/**
* @author Ulf Lilleengen
@@ -24,6 +23,6 @@ public class LZ4PayloadCompressorTest {
byte[] data = Utf8.toBytes(input);
byte[] compressed = compressor.compress(data);
byte[] output = compressor.decompress(compressed, data.length);
- assertThat(data, is(output));
+ assertArrayEquals(output, data);
}
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java b/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java
index 12c1d2f8069..7d49d15dc47 100644
--- a/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java
@@ -16,11 +16,11 @@ import static com.yahoo.vespa.config.PayloadChecksum.Type.MD5;
import static com.yahoo.vespa.config.PayloadChecksum.Type.XXHASH64;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
/**
* @author hmusum
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java
index dabd87e1eec..8d160076db9 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java
@@ -28,10 +28,10 @@ import java.util.Optional;
import static com.yahoo.vespa.config.PayloadChecksum.Type.MD5;
import static com.yahoo.vespa.config.PayloadChecksum.Type.XXHASH64;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
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;
/**
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java
index 8d895d0e2b8..af6aefb26e1 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java
@@ -10,8 +10,7 @@ import org.junit.Test;
import java.nio.charset.StandardCharsets;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author Ulf Lilleengen
@@ -23,13 +22,13 @@ public class PayloadTest {
String json = "{\"foo\":13}";
ConfigPayload configPayload = ConfigPayload.fromString(json);
Payload payload = Payload.from(configPayload);
- assertThat(payload.getData().toString(), is(json));
+ assertEquals(json, payload.getData().toString());
payload = Payload.from(payload.getData(), CompressionInfo.create(CompressionType.UNCOMPRESSED, 0));
Payload compressed = payload.withCompression(CompressionType.LZ4);
Payload uncompressed = compressed.withCompression(CompressionType.UNCOMPRESSED);
- assertThat(uncompressed.getData().toString(), is(json));
- assertThat(compressed.toString(), is(json));
- assertThat(uncompressed.toString(), is(json));
+ assertEquals(json, uncompressed.getData().toString());
+ assertEquals(json, compressed.toString());
+ assertEquals(json, uncompressed.toString());
}
@Test
@@ -52,10 +51,7 @@ public class PayloadTest {
slime.setString("foo 2");
Payload f = Payload.from(new ConfigPayload(slime));
- Payload g = null;
- Payload h = null;
- Payload i = null;
- Payload j = null;
+ Payload g, h, i, j;
g = Payload.from(new Utf8Array(foo1.getBytes(StandardCharsets.UTF_8)), CompressionInfo.uncompressed());
h = Payload.from(new Utf8Array(foo1.getBytes(StandardCharsets.UTF_8)), CompressionInfo.uncompressed());
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java
index 3525809a447..8b1de561a1e 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java
@@ -15,8 +15,8 @@ import java.util.Iterator;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
diff --git a/container-core/src/test/java/com/yahoo/container/di/ConfigRetrieverTest.java b/container-core/src/test/java/com/yahoo/container/di/ConfigRetrieverTest.java
index 99ea6a4ee58..695efbf7c17 100644
--- a/container-core/src/test/java/com/yahoo/container/di/ConfigRetrieverTest.java
+++ b/container-core/src/test/java/com/yahoo/container/di/ConfigRetrieverTest.java
@@ -9,21 +9,17 @@ import com.yahoo.container.di.ConfigRetriever.BootstrapConfigs;
import com.yahoo.container.di.ConfigRetriever.ComponentsConfigs;
import com.yahoo.container.di.ConfigRetriever.ConfigSnapshot;
import com.yahoo.vespa.config.ConfigKey;
-import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
@@ -52,7 +48,7 @@ public class ConfigRetrieverTest {
ConfigRetriever retriever = createConfigRetriever();
ConfigSnapshot bootstrapConfigs = retriever.getConfigs(Collections.emptySet(), 0, true);
- assertThat(bootstrapConfigs, Matchers.instanceOf(BootstrapConfigs.class));
+ assertTrue(bootstrapConfigs instanceof BootstrapConfigs);
}
@Test
@@ -66,19 +62,15 @@ public class ConfigRetrieverTest {
ConfigSnapshot componentsConfigs = retriever.getConfigs(Collections.singleton(testConfigKey), 0, true);
if (componentsConfigs instanceof ComponentsConfigs) {
- assertThat(componentsConfigs.size(), is(3));
+ assertEquals(3, componentsConfigs.size());
} else {
fail("ComponentsConfigs has unexpected type: " + componentsConfigs);
}
}
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Ignore
@SuppressWarnings("unused")
public void require_exception_upon_modified_components_keys_without_bootstrap() {
- expectedException.expect(IllegalArgumentException.class);
writeConfigs();
ConfigRetriever retriever = createConfigRetriever();
@@ -88,15 +80,20 @@ public class ConfigRetrieverTest {
Set<ConfigKey<? extends ConfigInstance>> keys = new HashSet<>();
keys.add(testConfigKey);
keys.add(new ConfigKey<>(TestConfig.class, ""));
- retriever.getConfigs(keys, 0, true);
+ try {
+ retriever.getConfigs(keys, 0, true);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("", e.getMessage());
+ }
}
@Test
public void require_that_empty_components_keys_after_bootstrap_returns_components_configs() {
writeConfigs();
ConfigRetriever retriever = createConfigRetriever();
- assertThat(retriever.getConfigs(Collections.emptySet(), 0, true), instanceOf(BootstrapConfigs.class));
- assertThat(retriever.getConfigs(Collections.emptySet(), 0, true), instanceOf(ComponentsConfigs.class));
+ assertTrue(retriever.getConfigs(Collections.emptySet(), 0, true) instanceof BootstrapConfigs);
+ assertTrue(retriever.getConfigs(Collections.emptySet(), 0, true) instanceof ComponentsConfigs);
}
public void writeConfigs() {
diff --git a/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ComponentGraphTest.java b/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ComponentGraphTest.java
index 1ded443a3eb..4d44281658c 100644
--- a/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ComponentGraphTest.java
+++ b/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ComponentGraphTest.java
@@ -30,16 +30,11 @@ import java.util.concurrent.Executors;
import java.util.function.Supplier;
import static com.yahoo.container.di.componentgraph.core.ComponentGraph.isBindingAnnotation;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.sameInstance;
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.assertNotSame;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -80,7 +75,7 @@ public class ComponentGraphTest {
ComponentTakingConfig instance = componentGraph.getInstance(ComponentTakingConfig.class);
assertNotNull(instance);
- assertThat(instance.config.stringVal(), is("test-value"));
+ assertEquals("test-value", instance.config.stringVal());
}
@Test
@@ -154,7 +149,7 @@ public class ComponentGraphTest {
componentGraph.complete();
ComponentTakingAllSimpleComponents instance = componentGraph.getInstance(ComponentTakingAllSimpleComponents.class);
- assertThat(instance.simpleComponents.allComponents().size(), is(3));
+ assertEquals(3, instance.simpleComponents.allComponents().size());
}
@Test
@@ -164,7 +159,7 @@ public class ComponentGraphTest {
componentGraph.complete();
ComponentTakingAllSimpleComponents instance = componentGraph.getInstance(ComponentTakingAllSimpleComponents.class);
- assertThat(instance.simpleComponents.allComponents().size(), is(0));
+ assertTrue(instance.simpleComponents.allComponents().isEmpty());
}
@Test
@@ -177,7 +172,7 @@ public class ComponentGraphTest {
ComponentTakingAllSimpleComponentsUpperBound instance = componentGraph
.getInstance(ComponentTakingAllSimpleComponentsUpperBound.class);
- assertThat(instance.simpleComponents.allComponents().size(), is(2));
+ assertEquals(2, instance.simpleComponents.allComponents().size());
}
@Test(expected = RuntimeException.class)
@@ -202,7 +197,7 @@ public class ComponentGraphTest {
SimpleComponent instance1 = componentGraph.getInstance(SimpleComponent.class);
SimpleComponent instance2 = componentGraph.getInstance(SimpleComponent.class);
- assertThat(instance1, sameInstance(instance2));
+ assertSame(instance1, instance2);
}
@Test
@@ -218,7 +213,7 @@ public class ComponentGraphTest {
ComponentTakingComponent instance = componentGraph.getInstance(ComponentTakingComponent.class);
ComponentTakingConfig injected = (ComponentTakingConfig) instance.injectedComponent;
- assertThat(injected.config.stringVal(), is("test-value"));
+ assertEquals("test-value", injected.config.stringVal());
}
@Test(expected = RuntimeException.class)
@@ -248,11 +243,11 @@ public class ComponentGraphTest {
componentGraph.complete();
Set<ConfigKey<? extends ConfigInstance>> configKeys = componentGraph.configKeys();
- assertThat(configKeys.size(), is(2));
+ assertEquals(2, configKeys.size());
configKeys.forEach(key -> {
- assertThat(key.getConfigClass(), equalTo(TestConfig.class));
- assertThat(key.getConfigId(), containsString("component"));
+ assertEquals(key.getConfigClass(), TestConfig.class);
+ assertTrue(key.getConfigId().contains("component"));
});
}
@@ -362,8 +357,8 @@ public class ComponentGraphTest {
componentGraph.complete();
fail("Cycle exception expected.");
} catch (Throwable e) {
- assertThat(e.getMessage(), containsString("cycle"));
- assertThat(e.getMessage(), containsString("ComponentCausingCycle"));
+ assertTrue(e.getMessage().contains("cycle"));
+ assertTrue(e.getMessage().contains("ComponentCausingCycle"));
}
}
@@ -411,8 +406,8 @@ public class ComponentGraphTest {
Executor executorA = graph.getSecond().getFirst();
Executor executorB = graph.getSecond().getSecond();
- assertThat(graphSize, is(4));
- assertThat(executorA, not(sameInstance(executorB)));
+ assertEquals(4, graphSize);
+ assertNotSame(executorA, executorB);
}
@Test
@@ -423,8 +418,8 @@ public class ComponentGraphTest {
Executor executorA = graph.getSecond().getFirst();
Executor executorB = graph.getSecond().getSecond();
- assertThat(graphSize, is(3));
- assertThat(executorA, sameInstance(executorB));
+ assertEquals(3, graphSize);
+ assertSame(executorA, executorB);
}
private Pair<Integer, Pair<Executor, Executor>> buildGraphWithChildInjector(Supplier<Executor> executorProvider) {
@@ -459,7 +454,7 @@ public class ComponentGraphTest {
newGraph.reuseNodes(oldGraph);
Executor newExecutor = newGraph.getInstance(Executor.class);
- assertThat(executor, sameInstance(newExecutor));
+ assertSame(executor, newExecutor);
}
private ComponentGraph createReusingGraph() {
@@ -478,7 +473,7 @@ public class ComponentGraphTest {
componentGraph.add(mockComponentNodeWithId(ComponentTakingComponentId.class, componentId));
componentGraph.complete();
- assertThat(componentGraph.getInstance(ComponentTakingComponentId.class).componentId, is(ComponentId.fromString(componentId)));
+ assertEquals(ComponentId.fromString(componentId), componentGraph.getInstance(ComponentTakingComponentId.class).componentId);
}
@@ -512,7 +507,7 @@ public class ComponentGraphTest {
private final TestConfig config;
public ComponentTakingConfig(TestConfig config) {
- assertThat(config, notNullValue());
+ assertNotNull(config);
this.config = config;
}
}
@@ -521,7 +516,7 @@ public class ComponentGraphTest {
private final SimpleComponent injectedComponent;
public ComponentTakingComponent(SimpleComponent injectedComponent) {
- assertThat(injectedComponent, notNullValue());
+ assertNotNull(injectedComponent);
this.injectedComponent = injectedComponent;
}
}
@@ -530,7 +525,7 @@ public class ComponentGraphTest {
private final ComponentTakingComponent injectedComponent;
public ComponentTakingComponentTakingComponent(ComponentTakingComponent injectedComponent) {
- assertThat(injectedComponent, notNullValue());
+ assertNotNull(injectedComponent);
this.injectedComponent = injectedComponent;
}
}
@@ -541,8 +536,8 @@ public class ComponentGraphTest {
private final SimpleComponent simpleComponent;
public ComponentTakingConfigAndComponent(TestConfig config, SimpleComponent injectedComponent) {
- assertThat(config, notNullValue());
- assertThat(injectedComponent, notNullValue());
+ assertNotNull(config);
+ assertNotNull(injectedComponent);
this.config = config;
this.simpleComponent = injectedComponent;
}
@@ -552,7 +547,7 @@ public class ComponentGraphTest {
public final ComponentRegistry<SimpleComponent> simpleComponents;
public ComponentTakingAllSimpleComponents(ComponentRegistry<SimpleComponent> simpleComponents) {
- assertThat(simpleComponents, notNullValue());
+ assertNotNull(simpleComponents);
this.simpleComponents = simpleComponents;
}
}
@@ -561,20 +556,20 @@ public class ComponentGraphTest {
private final ComponentRegistry<? extends SimpleComponent> simpleComponents;
public ComponentTakingAllSimpleComponentsUpperBound(ComponentRegistry<? extends SimpleComponent> simpleComponents) {
- assertThat(simpleComponents, notNullValue());
+ assertNotNull(simpleComponents);
this.simpleComponents = simpleComponents;
}
}
public static class ComponentTakingAllComponentsWithTypeVariable<COMPONENT extends AbstractComponent> extends AbstractComponent {
public ComponentTakingAllComponentsWithTypeVariable(ComponentRegistry<COMPONENT> simpleComponents) {
- assertThat(simpleComponents, notNullValue());
+ assertNotNull(simpleComponents);
}
}
public static class ComponentTakingNamedComponent extends AbstractComponent {
public ComponentTakingNamedComponent(@Named("named-test") SimpleComponent injectedComponent) {
- assertThat(injectedComponent, notNullValue());
+ assertNotNull(injectedComponent);
}
}
@@ -633,7 +628,7 @@ public class ComponentGraphTest {
private final Executor executor;
public ComponentTakingExecutor(Executor executor) {
- assertThat(executor, notNullValue());
+ assertNotNull(executor);
this.executor = executor;
}
}
diff --git a/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/FallbackToGuiceInjectorTest.java b/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/FallbackToGuiceInjectorTest.java
index 188e04d8497..1e3d67ed463 100644
--- a/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/FallbackToGuiceInjectorTest.java
+++ b/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/FallbackToGuiceInjectorTest.java
@@ -10,23 +10,19 @@ import com.google.inject.name.Names;
import com.yahoo.component.AbstractComponent;
import com.yahoo.component.ComponentId;
import com.yahoo.config.ConfigInstance;
-import com.yahoo.container.di.componentgraph.core.ComponentGraph;
-import com.yahoo.container.di.componentgraph.core.ComponentNode;
-import com.yahoo.container.di.componentgraph.core.Node;
import com.yahoo.vespa.config.ConfigKey;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author Tony Vaagenes
@@ -37,11 +33,8 @@ public class FallbackToGuiceInjectorTest {
private ComponentGraph componentGraph;
private Injector injector;
- private Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configs =
- new HashMap<>();
+ private final Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configs = new HashMap<>();
- @Rule
- public final ExpectedException exception = ExpectedException.none();
@Before
public void createGraph() {
@@ -91,7 +84,7 @@ public class FallbackToGuiceInjectorTest {
complete();
MyComponent component = getInstance(MyComponent.class);
- assertThat(component.url, is("http://yahoo.com"));
+ assertEquals("http://yahoo.com", component.url);
assertNotNull(component.executor);
}
@@ -102,17 +95,19 @@ public class FallbackToGuiceInjectorTest {
complete();
ComponentTakingDefaultString component = getInstance(ComponentTakingDefaultString.class);
- assertThat(component.injectedString, is(""));
+ assertTrue(component.injectedString.isEmpty());
}
@Test
public void guice_injector_fails_when_no_explicit_binding_exists_and_class_has_no_default_ctor() {
setInjector(emptyGuiceInjector());
register(ComponentThatCannotBeConstructed.class);
-
- exception.expect(RuntimeException.class);
- exception.expectMessage("When resolving dependencies of 'com.yahoo.container.di.componentgraph.core.FallbackToGuiceInjectorTest$ComponentThatCannotBeConstructed'");
- complete();
+ try {
+ complete();
+ fail();
+ } catch (RuntimeException e) {
+ assertEquals("When resolving dependencies of 'com.yahoo.container.di.componentgraph.core.FallbackToGuiceInjectorTest$ComponentThatCannotBeConstructed'", e.getMessage());
+ }
}
public void register(Class<?> componentClass) {
@@ -123,9 +118,8 @@ public class FallbackToGuiceInjectorTest {
return ComponentId.fromString(componentClass.getName());
}
- @SuppressWarnings("unchecked")
private Node mockComponentNode(Class<?> componentClass) {
- return new ComponentNode(toId(componentClass), toId(componentClass).toString(), (Class<Object>)componentClass, null);
+ return new ComponentNode(toId(componentClass), toId(componentClass).toString(), componentClass, null);
}
public <T> T getInstance(Class<T> componentClass) {
diff --git a/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ReuseComponentsTest.java b/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ReuseComponentsTest.java
index 537140d6f3f..29452f7babe 100644
--- a/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ReuseComponentsTest.java
+++ b/container-core/src/test/java/com/yahoo/container/di/componentgraph/core/ReuseComponentsTest.java
@@ -21,11 +21,9 @@ import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.function.Supplier;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.sameInstance;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
/**
* @author gjoranv
@@ -47,7 +45,7 @@ public class ReuseComponentsTest {
newGraph.reuseNodes(graph);
T instance2 = getComponent(newGraph, classToLookup);
- assertThat(instance2, sameInstance(instance));
+ assertSame(instance2, instance);
}
@Test(expected = IllegalStateException.class)
@@ -59,7 +57,7 @@ public class ReuseComponentsTest {
newGraph.reuseNodes(graph);
SimpleComponent2 instance2 = getComponent(newGraph, SimpleComponent2.class);
- assertThat(instance2.getId(), is(instance.getId()));
+ assertEquals(instance2.getId(),instance.getId());
@SuppressWarnings("unused")
SimpleComponent throwsException = getComponent(newGraph, SimpleComponent.class);
}
@@ -79,7 +77,7 @@ public class ReuseComponentsTest {
newGraph.reuseNodes(graph);
ComponentTakingConfig instance2 = getComponent(newGraph, componentClass);
- assertThat(instance2, not(sameInstance(instance)));
+ assertNotSame(instance2, instance);
}
@Test
@@ -111,7 +109,7 @@ public class ReuseComponentsTest {
newGraph.reuseNodes(oldGraph);
ComponentTakingComponent newInstance = getComponent(newGraph, ComponentTakingComponent.class);
- assertThat(newInstance, not(sameInstance(oldInstance)));
+ assertNotSame(newInstance, oldInstance);
}
@Test
@@ -143,7 +141,7 @@ public class ReuseComponentsTest {
newGraph.reuseNodes(oldGraph);
ComponentRegistry<SimpleComponent> newSimpleComponentRegistry = getComponent(newGraph, ComponentTakingAllSimpleComponents.class).simpleComponents;
- assertThat(newSimpleComponentRegistry, not(sameInstance(oldSimpleComponentRegistry)));
+ assertNotSame(newSimpleComponentRegistry, oldSimpleComponentRegistry);
}
@Test
@@ -177,8 +175,8 @@ public class ReuseComponentsTest {
SimpleComponent newInjectedComponent = getComponent(newGraph, SimpleComponent.class);
ComponentTakingConfigAndComponent newDependentComponent = getComponent(newGraph, ComponentTakingConfigAndComponent.class);
- assertThat(newDependentComponent, not(sameInstance(oldDependentComponent)));
- assertThat(newInjectedComponent, sameInstance(oldInjectedComponent));
+ assertNotSame(newDependentComponent, oldDependentComponent);
+ assertSame(newInjectedComponent, oldInjectedComponent);
}
@Test
@@ -197,7 +195,7 @@ public class ReuseComponentsTest {
componentRetriever.apply(oldGraph); // Ensure creation of GuiceNode
ComponentGraph newGraph = makeGraph.get();
newGraph.reuseNodes(oldGraph);
- assertThat(componentRetriever.apply(oldGraph), sameInstance(componentRetriever.apply(newGraph)));
+ assertSame(componentRetriever.apply(oldGraph), componentRetriever.apply(newGraph));
}
@Test
@@ -218,7 +216,7 @@ public class ReuseComponentsTest {
Node targetNode1 = createNodeWithInjectedNodeWithInjectedNode.apply("indirectlyInjected_1");
Node targetNode2 = createNodeWithInjectedNodeWithInjectedNode.apply("indirectlyInjected_2");
- assertThat(targetNode1, equalTo(targetNode2));
+ assertEquals(targetNode1, targetNode2);
}
private void completeNode(ComponentNode node) {
diff --git a/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/CycleFinderTest.java b/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/CycleFinderTest.java
index d1d3914a5ff..65fbdc578aa 100644
--- a/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/CycleFinderTest.java
+++ b/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/CycleFinderTest.java
@@ -4,13 +4,13 @@ package com.yahoo.container.di.componentgraph.cycle;
import org.junit.Test;
+import java.util.List;
+
import static com.yahoo.container.di.componentgraph.cycle.CycleFinderTest.Vertices.A;
import static com.yahoo.container.di.componentgraph.cycle.CycleFinderTest.Vertices.B;
import static com.yahoo.container.di.componentgraph.cycle.CycleFinderTest.Vertices.C;
import static com.yahoo.container.di.componentgraph.cycle.CycleFinderTest.Vertices.D;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.empty;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* @author gjoranv
@@ -28,7 +28,7 @@ public class CycleFinderTest {
graph.edge(D, A);
var cycleFinder = new CycleFinder<>(graph);
- assertThat(cycleFinder.findCycle(), empty());
+ assertTrue(cycleFinder.findCycle().isEmpty());
}
@Test
@@ -39,7 +39,7 @@ public class CycleFinderTest {
graph.edge(C, A);
var cycleFinder = new CycleFinder<>(graph);
- assertThat(cycleFinder.findCycle(), contains(A, B, C, A));
+ assertTrue(cycleFinder.findCycle().containsAll(List.of(A, B, C, A)));
}
@Test
@@ -48,7 +48,7 @@ public class CycleFinderTest {
graph.edge(A, A);
var cycleFinder = new CycleFinder<>(graph);
- assertThat(cycleFinder.findCycle(), contains(A, A));
+ assertTrue(cycleFinder.findCycle().containsAll(List.of(A, A)));
}
@Test
@@ -59,7 +59,7 @@ public class CycleFinderTest {
graph.edge(C, B);
var cycleFinder = new CycleFinder<>(graph);
- assertThat(cycleFinder.findCycle(), contains(B, C, B));
+ assertTrue(cycleFinder.findCycle().containsAll(List.of(B, C, B)));
}
@Test
@@ -68,8 +68,8 @@ public class CycleFinderTest {
graph.edge(A, A);
var cycleFinder = new CycleFinder<>(graph);
- assertThat(cycleFinder.findCycle(), contains(A, A));
- assertThat(cycleFinder.findCycle(), contains(A, A));
+ assertTrue(cycleFinder.findCycle().containsAll(List.of(A, A)));
+ assertTrue(cycleFinder.findCycle().containsAll(List.of(A, A)));
}
@Test
@@ -78,8 +78,8 @@ public class CycleFinderTest {
graph.edge(A, B);
var cycleFinder = new CycleFinder<>(graph);
- assertThat(cycleFinder.findCycle(), empty());
- assertThat(cycleFinder.findCycle(), empty());
+ assertTrue(cycleFinder.findCycle().isEmpty());
+ assertTrue(cycleFinder.findCycle().isEmpty());
}
}
diff --git a/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/GraphTest.java b/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/GraphTest.java
index c5c6e97180c..526e683ad46 100644
--- a/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/GraphTest.java
+++ b/container-core/src/test/java/com/yahoo/container/di/componentgraph/cycle/GraphTest.java
@@ -2,18 +2,16 @@
package com.yahoo.container.di.componentgraph.cycle;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
+
+import java.util.List;
import static com.yahoo.container.di.componentgraph.cycle.GraphTest.Vertices.A;
import static com.yahoo.container.di.componentgraph.cycle.GraphTest.Vertices.B;
import static com.yahoo.container.di.componentgraph.cycle.GraphTest.Vertices.C;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.empty;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author gjoranv
@@ -22,9 +20,6 @@ public class GraphTest {
enum Vertices {A, B, C}
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void vertices_and_edges_are_added_and_can_be_retrieved() {
var graph = new Graph<Vertices>();
@@ -32,19 +27,22 @@ public class GraphTest {
graph.edge(B, C);
graph.edge(A, C);
- assertThat(graph.getVertices().size(), is(3));
- assertThat(graph.getAdjacent(A), containsInAnyOrder(B, C));
- assertThat(graph.getAdjacent(B), containsInAnyOrder(C));
- assertThat(graph.getAdjacent(C), empty());
+ assertEquals(3, graph.getVertices().size());
+ assertTrue(graph.getAdjacent(A).containsAll(List.of(B, C)));
+ assertTrue(graph.getAdjacent(B).contains(C));
+ assertTrue(graph.getAdjacent(C).isEmpty());
}
@Test
public void null_vertices_are_not_allowed() {
var graph = new Graph<Vertices>();
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Null vertices are not allowed");
- graph.edge(A, null);
+ try {
+ graph.edge(A, null);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Null vertices are not allowed, edge: A->null", e.getMessage());
+ }
}
@Test
@@ -53,7 +51,7 @@ public class GraphTest {
graph.edge(A, B);
graph.edge(A, B);
- assertThat(graph.getAdjacent(A).size(), is(1));
+ assertEquals(1, graph.getAdjacent(A).size());
}
@Test
@@ -61,7 +59,7 @@ public class GraphTest {
var graph = new Graph<Vertices>();
graph.edge(A, A);
- assertThat(graph.getAdjacent(A), contains(A));
+ assertTrue(graph.getAdjacent(A).contains(A));
}
}
diff --git a/container-core/src/test/java/com/yahoo/container/handler/AccessLogRequestHandlerTest.java b/container-core/src/test/java/com/yahoo/container/handler/AccessLogRequestHandlerTest.java
index aad064bc82e..2eba4144b45 100644
--- a/container-core/src/test/java/com/yahoo/container/handler/AccessLogRequestHandlerTest.java
+++ b/container-core/src/test/java/com/yahoo/container/handler/AccessLogRequestHandlerTest.java
@@ -9,8 +9,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.Executor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
public class AccessLogRequestHandlerTest {
@@ -25,14 +24,14 @@ public class AccessLogRequestHandlerTest {
keeper.addUri("foo");
HttpResponse response = handler.handle(null);
response.render(out);
- assertThat(out.toString(), is("{\"entries\":[{\"url\":\"foo\"}]}"));
+ assertEquals("{\"entries\":[{\"url\":\"foo\"}]}", out.toString());
}
@Test
public void testEmpty() throws IOException {
HttpResponse response = handler.handle(null);
response.render(out);
- assertThat(out.toString(), is("{\"entries\":[]}"));
+ assertEquals("{\"entries\":[]}", out.toString());
}
@Test
@@ -41,7 +40,7 @@ public class AccessLogRequestHandlerTest {
keeper.addUri("foo");
HttpResponse response = handler.handle(null);
response.render(out);
- assertThat(out.toString(), is("{\"entries\":[{\"url\":\"foo\"},{\"url\":\"foo\"}]}"));
+ assertEquals("{\"entries\":[{\"url\":\"foo\"},{\"url\":\"foo\"}]}", out.toString());
}
}
diff --git a/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java b/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java
index 604fe9494d7..2efa717800d 100644
--- a/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java
+++ b/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java
@@ -12,8 +12,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.Executor;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author Ulf Lilleengen
@@ -37,7 +36,7 @@ public class MockServiceTest {
@Test
public void testNoHandlerFound() throws InterruptedException, IOException {
HttpResponse response = runHandler(com.yahoo.jdisc.http.HttpRequest.Method.DELETE, "/foo/bar");
- assertThat(response.getStatus(), is(404));
+ assertEquals(404, response.getStatus());
assertResponseContents(response, "DELETE:/foo/bar was not found");
}
@@ -52,19 +51,14 @@ public class MockServiceTest {
}
private void assertResponse(HttpResponse response, int expectedCode, String expectedMessage) throws IOException {
- assertThat(response.getStatus(), is(expectedCode));
+ assertEquals(expectedCode, response.getStatus());
assertResponseContents(response, expectedMessage);
}
private void assertResponseContents(HttpResponse response, String expected) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.render(baos);
- assertThat(baos.toString(), is(expected));
- }
-
- private void assertResponseOk(HttpResponse response) {
- assertThat(response.getStatus(), is(200));
- assertThat(response.getContentType(), is("text/plain"));
+ assertEquals(expected, baos.toString());
}
private HttpResponse runHandler(com.yahoo.jdisc.http.HttpRequest.Method method, String path) throws InterruptedException, IOException {
diff --git a/container-core/src/test/java/com/yahoo/container/logging/CircularArrayAccessLogKeeperTest.java b/container-core/src/test/java/com/yahoo/container/logging/CircularArrayAccessLogKeeperTest.java
index c69e293750c..451e6dc42bb 100644
--- a/container-core/src/test/java/com/yahoo/container/logging/CircularArrayAccessLogKeeperTest.java
+++ b/container-core/src/test/java/com/yahoo/container/logging/CircularArrayAccessLogKeeperTest.java
@@ -8,7 +8,7 @@ import static org.hamcrest.Matchers.contains;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class CircularArrayAccessLogKeeperTest {
private CircularArrayAccessLogKeeper circularArrayAccessLogKeeper = new CircularArrayAccessLogKeeper();
diff --git a/container-core/src/test/java/com/yahoo/osgi/provider/model/ComponentModelTest.java b/container-core/src/test/java/com/yahoo/osgi/provider/model/ComponentModelTest.java
index 2b1a8a42149..4433b78c807 100644
--- a/container-core/src/test/java/com/yahoo/osgi/provider/model/ComponentModelTest.java
+++ b/container-core/src/test/java/com/yahoo/osgi/provider/model/ComponentModelTest.java
@@ -4,8 +4,7 @@ package com.yahoo.osgi.provider.model;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author gjoranv
@@ -13,7 +12,7 @@ import static org.junit.Assert.assertThat;
public class ComponentModelTest {
@Test
- public void create_from_instantiation_spec() throws Exception {
+ public void create_from_instantiation_spec() {
ComponentModel model = new ComponentModel(
BundleInstantiationSpecification.getFromStrings("id", "class", "bundle"));
verifyBundleSpec(model);
@@ -29,19 +28,19 @@ public class ComponentModelTest {
ComponentModel model = new ComponentModel(
BundleInstantiationSpecification.getFromStrings("id", "class", "bundle"), "configId");
verifyBundleSpec(model);
- assertThat(model.configId, is("configId"));
+ assertEquals("configId", model.configId);
}
@Test
public void create_from_strings() throws Exception {
ComponentModel model = new ComponentModel("id", "class", "bundle", "configId");
verifyBundleSpec(model);
- assertThat(model.configId, is("configId"));
+ assertEquals("configId", model.configId);
}
private void verifyBundleSpec(ComponentModel model) {
- assertThat(model.getComponentId().stringValue(), is("id"));
- assertThat(model.getClassId().stringValue(), is("class"));
- assertThat(model.bundleInstantiationSpec.bundle.stringValue(), is("bundle"));
+ assertEquals("id", model.getComponentId().stringValue());
+ assertEquals("class", model.getClassId().stringValue());
+ assertEquals("bundle", model.bundleInstantiationSpec.bundle.stringValue());
}
}
diff --git a/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java b/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
index eddaf91986d..3ff3f6e2d27 100644
--- a/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
+++ b/container-core/src/test/java/com/yahoo/processing/handler/ProcessingHandlerTestCase.java
@@ -30,7 +30,6 @@ import java.io.InputStream;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
@@ -40,13 +39,11 @@ import java.util.concurrent.ExecutionException;
import static com.yahoo.jdisc.http.server.jetty.AccessLoggingRequestHandler.CONTEXT_KEY_ACCESS_LOG_ENTRY;
import static com.yahoo.processing.test.ProcessorLibrary.MapData;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
@@ -64,17 +61,17 @@ public class ProcessingHandlerTestCase {
private ProcessingTestDriver driver;
private final Chain<Processor> defaultChain =
- new Chain<Processor>("default",
+ new Chain<>("default",
new ProcessorLibrary.StringDataListAdder("Item1", "Item2"),
new ProcessorLibrary.Trace("TraceMessage", 1),
new ProcessorLibrary.StringDataAdder("StringData.toString()"));
private final Chain<Processor> simpleChain =
- new Chain<Processor>("simple",
+ new Chain<>("simple",
new ProcessorLibrary.StringDataAdder("StringData.toString()"));
private final Chain<Processor> logValueChain =
- new Chain<Processor>("log-value",
+ new Chain<>("log-value",
new ProcessorLibrary.LogValueAdder(LOG_KEY, LOG_VALUE));
@After
@@ -94,11 +91,11 @@ public class ProcessingHandlerTestCase {
requestContent.close(null);
request.release();
responseHandler.readAll();
- assertThat(entry.getKeyValues().get(LOG_KEY), is(List.of(LOG_VALUE)));
+ assertEquals(List.of(LOG_VALUE), entry.getKeyValues().get(LOG_KEY));
}
@Test
- public void testProcessingHandlerResolvesChains() throws Exception {
+ public void testProcessingHandlerResolvesChains() {
List<Chain<Processor>> chains = new ArrayList<>();
chains.add(defaultChain);
chains.add(simpleChain);
@@ -109,16 +106,16 @@ public class ProcessingHandlerTestCase {
}
@Test
- public void testProcessingHandlerPropagatesRequestParametersAndContext() throws InterruptedException {
+ public void testProcessingHandlerPropagatesRequestParametersAndContext() {
List<Chain<Processor>> chains = new ArrayList<>();
- chains.add(new Chain<Processor>("default", new RequestPropertyTracer()));
+ chains.add(new Chain<>("default", new RequestPropertyTracer()));
driver = new ProcessingTestDriver(chains);
assertTrue("JDisc request context is propagated to properties()",
driver.sendRequest("http://localhost/?chain=default&tracelevel=4").readAll().contains("context.contextVariable: '37'"));
}
@Test
- public void testProcessingHandlerOutputsTrace() throws Exception {
+ public void testProcessingHandlerOutputsTrace() {
List<Chain<Processor>> chains = new ArrayList<>();
chains.add(defaultChain);
driver = new ProcessingTestDriver(chains);
@@ -131,28 +128,28 @@ public class ProcessingHandlerTestCase {
}
@Test
- public void testProcessingHandlerTransfersErrorsToHttpStatusCodesNoData() throws Exception {
+ public void testProcessingHandlerTransfersErrorsToHttpStatusCodesNoData() {
List<Chain<Processor>> chains = new ArrayList<>();
chains.add(simpleChain);
- chains.add(new Chain<Processor>("moved_permanently", new ProcessorLibrary.ErrorAdder(new ErrorMessage(301,"Message"))));
- chains.add(new Chain<Processor>("unauthorized", new ProcessorLibrary.ErrorAdder(new ErrorMessage(401,"Message"))));
- chains.add(new Chain<Processor>("unauthorized_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.UNAUTHORIZED.code,"Message"))));
- chains.add(new Chain<Processor>("forbidden", new ProcessorLibrary.ErrorAdder(new ErrorMessage(403,"Message"))));
- chains.add(new Chain<Processor>("forbidden_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.FORBIDDEN.code,"Message"))));
- chains.add(new Chain<Processor>("not_found", new ProcessorLibrary.ErrorAdder(new ErrorMessage(404,"Message"))));
- chains.add(new Chain<Processor>("not_found_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NOT_FOUND.code,"Message"))));
- chains.add(new Chain<Processor>("too_many_requests", new ProcessorLibrary.ErrorAdder(new ErrorMessage(429,"Message"))));
- chains.add(new Chain<Processor>("bad_request", new ProcessorLibrary.ErrorAdder(new ErrorMessage(400,"Message"))));
- chains.add(new Chain<Processor>("bad_request_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BAD_REQUEST.code,"Message"))));
- chains.add(new Chain<Processor>("internal_server_error", new ProcessorLibrary.ErrorAdder(new ErrorMessage(500,"Message"))));
- chains.add(new Chain<Processor>("internal_server_error_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.INTERNAL_SERVER_ERROR.code,"Message"))));
- chains.add(new Chain<Processor>("service_unavailable", new ProcessorLibrary.ErrorAdder(new ErrorMessage(503,"Message"))));
- chains.add(new Chain<Processor>("service_unavailable_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NO_BACKENDS_IN_SERVICE.code,"Message"))));
- chains.add(new Chain<Processor>("gateway_timeout", new ProcessorLibrary.ErrorAdder(new ErrorMessage(504,"Message"))));
- chains.add(new Chain<Processor>("gateway_timeout_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.TIMEOUT.code,"Message"))));
- chains.add(new Chain<Processor>("bad_gateway", new ProcessorLibrary.ErrorAdder(new ErrorMessage(502,"Message"))));
- chains.add(new Chain<Processor>("bad_gateway_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BACKEND_COMMUNICATION_ERROR.code,"Message"))));
- chains.add(new Chain<Processor>("unknown_code", new ProcessorLibrary.ErrorAdder(new ErrorMessage(1234567,"Message"))));
+ chains.add(new Chain<>("moved_permanently", new ProcessorLibrary.ErrorAdder(new ErrorMessage(301,"Message"))));
+ chains.add(new Chain<>("unauthorized", new ProcessorLibrary.ErrorAdder(new ErrorMessage(401,"Message"))));
+ chains.add(new Chain<>("unauthorized_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.UNAUTHORIZED.code,"Message"))));
+ chains.add(new Chain<>("forbidden", new ProcessorLibrary.ErrorAdder(new ErrorMessage(403,"Message"))));
+ chains.add(new Chain<>("forbidden_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.FORBIDDEN.code,"Message"))));
+ chains.add(new Chain<>("not_found", new ProcessorLibrary.ErrorAdder(new ErrorMessage(404,"Message"))));
+ chains.add(new Chain<>("not_found_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NOT_FOUND.code,"Message"))));
+ chains.add(new Chain<>("too_many_requests", new ProcessorLibrary.ErrorAdder(new ErrorMessage(429,"Message"))));
+ chains.add(new Chain<>("bad_request", new ProcessorLibrary.ErrorAdder(new ErrorMessage(400,"Message"))));
+ chains.add(new Chain<>("bad_request_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BAD_REQUEST.code,"Message"))));
+ chains.add(new Chain<>("internal_server_error", new ProcessorLibrary.ErrorAdder(new ErrorMessage(500,"Message"))));
+ chains.add(new Chain<>("internal_server_error_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.INTERNAL_SERVER_ERROR.code,"Message"))));
+ chains.add(new Chain<>("service_unavailable", new ProcessorLibrary.ErrorAdder(new ErrorMessage(503,"Message"))));
+ chains.add(new Chain<>("service_unavailable_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NO_BACKENDS_IN_SERVICE.code,"Message"))));
+ chains.add(new Chain<>("gateway_timeout", new ProcessorLibrary.ErrorAdder(new ErrorMessage(504,"Message"))));
+ chains.add(new Chain<>("gateway_timeout_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.TIMEOUT.code,"Message"))));
+ chains.add(new Chain<>("bad_gateway", new ProcessorLibrary.ErrorAdder(new ErrorMessage(502,"Message"))));
+ chains.add(new Chain<>("bad_gateway_mapped", new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BACKEND_COMMUNICATION_ERROR.code,"Message"))));
+ chains.add(new Chain<>("unknown_code", new ProcessorLibrary.ErrorAdder(new ErrorMessage(1234567,"Message"))));
driver = new ProcessingTestDriver(chains);
assertEqualStatus(200, "http://localhost/?chain=simple");
assertEqualStatus(301, "http://localhost/?chain=moved_permanently");
@@ -177,28 +174,28 @@ public class ProcessingHandlerTestCase {
}
@Test
- public void testProcessingHandlerTransfersErrorsToHttpStatusCodesWithData() throws Exception {
+ public void testProcessingHandlerTransfersErrorsToHttpStatusCodesWithData() {
List<Chain<Processor>> chains = new ArrayList<>();
chains.add(simpleChain);
- chains.add(new Chain<Processor>("moved_permanently", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(301,"Message"))));
- chains.add(new Chain<Processor>("unauthorized", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(401,"Message"))));
- chains.add(new Chain<Processor>("unauthorized_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.UNAUTHORIZED.code,"Message"))));
- chains.add(new Chain<Processor>("forbidden", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(403,"Message"))));
- chains.add(new Chain<Processor>("forbidden_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.FORBIDDEN.code,"Message"))));
- chains.add(new Chain<Processor>("not_found", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(404,"Message"))));
- chains.add(new Chain<Processor>("not_found_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NOT_FOUND.code,"Message"))));
- chains.add(new Chain<Processor>("too_many_requests", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(429,"Message"))));
- chains.add(new Chain<Processor>("bad_request", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(400,"Message"))));
- chains.add(new Chain<Processor>("bad_request_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BAD_REQUEST.code,"Message"))));
- chains.add(new Chain<Processor>("internal_server_error", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(500,"Message"))));
- chains.add(new Chain<Processor>("internal_server_error_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.INTERNAL_SERVER_ERROR.code,"Message"))));
- chains.add(new Chain<Processor>("service_unavailable", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(503,"Message"))));
- chains.add(new Chain<Processor>("service_unavailable_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NO_BACKENDS_IN_SERVICE.code,"Message"))));
- chains.add(new Chain<Processor>("gateway_timeout", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(504,"Message"))));
- chains.add(new Chain<Processor>("gateway_timeout_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.TIMEOUT.code,"Message"))));
- chains.add(new Chain<Processor>("bad_gateway", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(502,"Message"))));
- chains.add(new Chain<Processor>("bad_gateway_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BACKEND_COMMUNICATION_ERROR.code,"Message"))));
- chains.add(new Chain<Processor>("unknown_code", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(1234567,"Message"))));
+ chains.add(new Chain<>("moved_permanently", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(301,"Message"))));
+ chains.add(new Chain<>("unauthorized", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(401,"Message"))));
+ chains.add(new Chain<>("unauthorized_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.UNAUTHORIZED.code,"Message"))));
+ chains.add(new Chain<>("forbidden", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(403,"Message"))));
+ chains.add(new Chain<>("forbidden_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.FORBIDDEN.code,"Message"))));
+ chains.add(new Chain<>("not_found", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(404,"Message"))));
+ chains.add(new Chain<>("not_found_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NOT_FOUND.code,"Message"))));
+ chains.add(new Chain<>("too_many_requests", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(429,"Message"))));
+ chains.add(new Chain<>("bad_request", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(400,"Message"))));
+ chains.add(new Chain<>("bad_request_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BAD_REQUEST.code,"Message"))));
+ chains.add(new Chain<>("internal_server_error", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(500,"Message"))));
+ chains.add(new Chain<>("internal_server_error_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.INTERNAL_SERVER_ERROR.code,"Message"))));
+ chains.add(new Chain<>("service_unavailable", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(503,"Message"))));
+ chains.add(new Chain<>("service_unavailable_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.NO_BACKENDS_IN_SERVICE.code,"Message"))));
+ chains.add(new Chain<>("gateway_timeout", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(504,"Message"))));
+ chains.add(new Chain<>("gateway_timeout_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.TIMEOUT.code,"Message"))));
+ chains.add(new Chain<>("bad_gateway", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(502,"Message"))));
+ chains.add(new Chain<>("bad_gateway_mapped", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.BACKEND_COMMUNICATION_ERROR.code,"Message"))));
+ chains.add(new Chain<>("unknown_code", new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(1234567,"Message"))));
driver = new ProcessingTestDriver(chains);
assertEqualStatus(200, "http://localhost/?chain=simple");
assertEqualStatus(301, "http://localhost/?chain=moved_permanently");
@@ -227,15 +224,15 @@ public class ProcessingHandlerTestCase {
ProcessingTestDriver.MockResponseHandler responseHandler = null;
try {
Map<String,List<String>> responseHeaders = new HashMap<>();
- responseHeaders.put("foo", Collections.singletonList("fooValue"));
- responseHeaders.put("bar", Arrays.asList(new String[] { "barValue", "bazValue"}));
+ responseHeaders.put("foo", List.of("fooValue"));
+ responseHeaders.put("bar", List.of("barValue", "bazValue"));
Map<String,List<String>> otherResponseHeaders = new HashMap<>();
- otherResponseHeaders.put("foo", Collections.singletonList("fooValue2"));
- otherResponseHeaders.put("bax", Collections.singletonList("baxValue"));
+ otherResponseHeaders.put("foo", List.of("fooValue2"));
+ otherResponseHeaders.put("bax", List.of("baxValue"));
List<Chain<Processor>> chains = new ArrayList<>();
- chains.add(new Chain<Processor>("default",new ResponseHeaderSetter(responseHeaders),
+ chains.add(new Chain<>("default",new ResponseHeaderSetter(responseHeaders),
new ResponseHeaderSetter(otherResponseHeaders)));
driver = new ProcessingTestDriver(chains);
responseHandler = driver.sendRequest("http://localhost/?chain=default").awaitResponse();
@@ -256,7 +253,7 @@ public class ProcessingHandlerTestCase {
ProcessingTestDriver.MockResponseHandler responseHandler = null;
try {
List<Chain<Processor>> chains = new ArrayList<>();
- chains.add(new Chain<Processor>("default", new ResponseStatusSetter(429)));
+ chains.add(new Chain<>("default", new ResponseStatusSetter(429)));
driver = new ProcessingTestDriver(chains);
responseHandler = driver.sendRequest("http://localhost/?chain=default").awaitResponse();
Response response = responseHandler.getResponse();
@@ -275,7 +272,7 @@ public class ProcessingHandlerTestCase {
ProcessingTestDriver.MockResponseHandler responseHandler = null;
try {
List<Chain<Processor>> chains = new ArrayList<>();
- chains.add(new Chain<Processor>("default", new ResponseStatusSetter(200),
+ chains.add(new Chain<>("default", new ResponseStatusSetter(200),
new ProcessorLibrary.StringDataAdder("Hello"),
new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.FORBIDDEN.code,"Message"))));
driver = new ProcessingTestDriver(chains);
@@ -307,14 +304,14 @@ public class ProcessingHandlerTestCase {
@SuppressWarnings("unchecked")
@Test
- public void testProcessingHandlerSupportsAsyncRendering() throws Exception {
+ public void testProcessingHandlerSupportsAsyncRendering() {
// Set up
ProcessorLibrary.FutureDataSource futureDataSource = new ProcessorLibrary.FutureDataSource();
- Chain<Processor> asyncCompletionChain = new Chain<Processor>("asyncCompletion", new ProcessorLibrary.DataCounter("async"));
+ Chain<Processor> asyncCompletionChain = new Chain<>("asyncCompletion", new ProcessorLibrary.DataCounter("async"));
Chain<Processor> chain =
- new Chain<Processor>("federation", new ProcessorLibrary.DataCounter("sync"),
+ new Chain<>("federation", new ProcessorLibrary.DataCounter("sync"),
new ProcessorLibrary.Federator(new Chain<Processor>(new ProcessorLibrary.DataSource()),
- new Chain<Processor>(new ProcessorLibrary.AsyncDataProcessingInitiator(asyncCompletionChain),futureDataSource)));
+ new Chain<>(new ProcessorLibrary.AsyncDataProcessingInitiator(asyncCompletionChain),futureDataSource)));
List<Chain<Processor>> chains = new ArrayList<>();
chains.add(chain);
driver = new ProcessingTestDriver(chains);
@@ -350,17 +347,17 @@ public class ProcessingHandlerTestCase {
assertEquals(",{\"data\":\"[sync] Data count: 3\"}" + // Async items not counted as they arrive after chain completion
"]}",
responseHandler.read());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
@SuppressWarnings("unchecked")
@Test
- public void testProcessingHandlerSupportsAsyncUnorderedRendering() throws Exception {
+ public void testProcessingHandlerSupportsAsyncUnorderedRendering() {
// Set up
ProcessorLibrary.FutureDataSource futureDataSource1 = new ProcessorLibrary.FutureDataSource();
ProcessorLibrary.FutureDataSource futureDataSource2 = new ProcessorLibrary.FutureDataSource();
Chain<Processor> chain =
- new Chain<Processor>("federation",
+ new Chain<>("federation",
new ProcessorLibrary.Federator(false,new Chain<Processor>(futureDataSource1),
new Chain<Processor>(futureDataSource2)));
List<Chain<Processor>> chains = new ArrayList<>();
@@ -393,7 +390,7 @@ public class ProcessingHandlerTestCase {
"]}",
responseHandler.read());
- assertTrue("Transmission completed", responseHandler.read()==null);
+ assertNull("Transmission completed", responseHandler.read());
}
@SuppressWarnings("unchecked")
@@ -401,7 +398,7 @@ public class ProcessingHandlerTestCase {
public void testAsyncOnlyRendering() throws Exception {
// Set up
ProcessorLibrary.ListenableFutureDataSource futureDataSource = new ProcessorLibrary.ListenableFutureDataSource();
- Chain<Processor> chain = new Chain<>("main", Collections.<Processor>singletonList(futureDataSource));
+ Chain<Processor> chain = new Chain<>("main", List.of(futureDataSource));
driver = new ProcessingTestDriver(chain);
ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=main");
@@ -421,7 +418,7 @@ public class ProcessingHandlerTestCase {
responseHandler.read());
assertEquals(200, responseHandler.getStatus());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
@SuppressWarnings("unchecked")
@@ -429,7 +426,7 @@ public class ProcessingHandlerTestCase {
public void testAsyncRenderingWithClientClose() throws Exception {
// Set up
ProcessorLibrary.ListenableFutureDataSource futureDataSource = new ProcessorLibrary.ListenableFutureDataSource();
- Chain<Processor> chain = new Chain<>("main", Collections.<Processor>singletonList(futureDataSource));
+ Chain<Processor> chain = new Chain<>("main", List.of(futureDataSource));
driver = new ProcessingTestDriver(chain);
ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=main");
@@ -446,7 +443,7 @@ public class ProcessingHandlerTestCase {
assertNull(responseHandler.read());
assertEquals(200, responseHandler.getStatus());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
@SuppressWarnings("unchecked")
@@ -482,7 +479,7 @@ public class ProcessingHandlerTestCase {
assertEquals("Data is completed, so post data is read", "Hello, world!", postReader.bodyDataFuture.get().trim());
assertEquals(200, responseHandler.getStatus());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
private static class PostReader extends Processor {
@@ -511,12 +508,12 @@ public class ProcessingHandlerTestCase {
@Test
public void testStatusAndHeadersCanBeSetAsynchronously() throws Exception {
Map<String,List<String>> responseHeaders = new HashMap<>();
- responseHeaders.put("foo", Collections.singletonList("fooValue"));
- responseHeaders.put("bar", Arrays.asList(new String[] { "barValue", "bazValue"}));
+ responseHeaders.put("foo", List.of("fooValue"));
+ responseHeaders.put("bar", List.of("barValue", "bazValue"));
// Set up
ProcessorLibrary.ListenableFutureDataSource futureDataSource = new ProcessorLibrary.ListenableFutureDataSource(true, false);
- Chain<Processor> chain = new Chain<Processor>("main", new ProcessorLibrary.AsyncDataProcessingInitiator(new Chain<Processor>("async", new ProcessorLibrary.StatusSetter(500), new ResponseHeaderSetter(responseHeaders))), futureDataSource);
+ Chain<Processor> chain = new Chain<>("main", new ProcessorLibrary.AsyncDataProcessingInitiator(new Chain<>("async", new ProcessorLibrary.StatusSetter(500), new ResponseHeaderSetter(responseHeaders))), futureDataSource);
driver = new ProcessingTestDriver(chain);
ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=main");
@@ -530,18 +527,18 @@ public class ProcessingHandlerTestCase {
assertEquals(500, responseHandler.getStatus());
assertEquals("[fooValue]", responseHandler.getResponse().headers().get("foo").toString());
assertEquals("[barValue, bazValue]", responseHandler.getResponse().headers().get("bar").toString());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
@SuppressWarnings("unchecked")
@Test
- public void testAsyncRenderingDoesNotHoldThreads() throws Exception {
+ public void testAsyncRenderingDoesNotHoldThreads() {
// Set up
ProcessorLibrary.FutureDataSource futureDataSource = new ProcessorLibrary.FutureDataSource();
// Add some sync data as well to cause rendering to start before async data is added.
// This allows us to wait on return data rather than having to wait for the 100 requests
// to be done, which is cumbersome.
- Chain<Processor> chain = new Chain<Processor>("main", new ProcessorLibrary.Federator(new Chain<Processor>(new ProcessorLibrary.DataSource()), new Chain<Processor>(futureDataSource)));
+ Chain<Processor> chain = new Chain<>("main", new ProcessorLibrary.Federator(new Chain<Processor>(new ProcessorLibrary.DataSource()), new Chain<Processor>(futureDataSource)));
driver = new ProcessingTestDriver(chain);
int requestCount = 1000;
@@ -561,7 +558,7 @@ public class ProcessingHandlerTestCase {
futureDataSource.incomingData.get(i).addLast(new ProcessorLibrary.StringData(null, "d2"));
assertEquals(",{\"data\":\"d2\"}]}", responseHandler[i].read());
assertEquals("]}", responseHandler[i].read());
- assertTrue("Transmission completed", null == responseHandler[i].read());
+ assertNull("Transmission completed", responseHandler[i].read());
}
}
@@ -569,10 +566,10 @@ public class ProcessingHandlerTestCase {
@Test
public void testStreamedRendering() throws Exception {
// Set up
- Chain<Processor> streamChain = new Chain<Processor>(new StreamProcessor());
+ Chain<Processor> streamChain = new Chain<>(new StreamProcessor());
ProcessorLibrary.ListenableFutureDataSource futureDataSource = new ProcessorLibrary.ListenableFutureDataSource();
- Chain<Processor> mainChain = new Chain<Processor>("main", new ProcessorLibrary.StreamProcessingInitiator(streamChain), futureDataSource);
+ Chain<Processor> mainChain = new Chain<>("main", new ProcessorLibrary.StreamProcessingInitiator(streamChain), futureDataSource);
driver = new ProcessingTestDriver(mainChain);
ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=main");
@@ -596,14 +593,13 @@ public class ProcessingHandlerTestCase {
",{\"data\":\"map data: {streamProcessed=true}\"}]}",
responseHandler.read());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
- @SuppressWarnings("unchecked")
@Test
- public void testEagerStreamedRenderingOnFreeze() throws Exception {
+ public void testEagerStreamedRenderingOnFreeze() {
FreezingDataSource source = new FreezingDataSource();
- Chain<Processor> mainChain = new Chain<Processor>("main", source);
+ Chain<Processor> mainChain = new Chain<>("main", source);
driver = new ProcessingTestDriver(mainChain);
ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=main");
assertEquals("No data is available at this point", 0, responseHandler.available());
@@ -611,18 +607,17 @@ public class ProcessingHandlerTestCase {
assertEquals("{\"datalist\":[{\"data\":\"d1\"}", responseHandler.read());
source.addLastData.set(true); // signal completion
assertEquals(",{\"data\":\"d2\"}]}", responseHandler.read());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
- @SuppressWarnings("unchecked")
@Test
@Ignore // TODO
- public void testNestedEagerStreamedRenderingOnFreeze() throws Exception {
+ public void testNestedEagerStreamedRenderingOnFreeze() {
try {
FreezingDataSource source1 = new FreezingDataSource("s1");
FreezingDataSource source2 = new FreezingDataSource("s2");
FreezingDataSource source3 = new FreezingDataSource("s3");
- Chain<Processor> mainChain = new Chain<Processor>("main",
+ Chain<Processor> mainChain = new Chain<>("main",
new ProcessorLibrary.StringDataAdder("main-data"),
new ProcessorLibrary.EagerReturnFederator(true,
new Chain<Processor>(source1),
@@ -639,7 +634,7 @@ public class ProcessingHandlerTestCase {
assertEquals("{\"datalist\":[{\"data\":\"s1d1\"}", responseHandler.read());
source1.addLastData.set(true); // Make source 1 and 2 available
assertEquals(",{\"data\":\"d2\"}]}", responseHandler.read());
- assertTrue("Transmission completed", null == responseHandler.read());
+ assertNull("Transmission completed", responseHandler.read());
}
catch (Throwable t) {
t.printStackTrace();
@@ -648,31 +643,31 @@ public class ProcessingHandlerTestCase {
}
@Test(expected = IllegalArgumentException.class)
- public void testRetrievingNonExistingRendererThrows() throws Exception {
- driver = new ProcessingTestDriver(Collections.<Chain<Processor>>emptyList());
+ public void testRetrievingNonExistingRendererThrows() {
+ driver = new ProcessingTestDriver(List.of());
driver.processingHandler().getRendererCopy(ComponentSpecification.fromString("non-existent"));
}
@Test
- public void testDefaultRendererIsAddedToRegistryWhenNoneIsGivenByUser() throws Exception {
+ public void testDefaultRendererIsAddedToRegistryWhenNoneIsGivenByUser() {
String defaultId = AbstractProcessingHandler.DEFAULT_RENDERER_ID;
- driver = new ProcessingTestDriver(Collections.<Chain<Processor>>emptyList());
+ driver = new ProcessingTestDriver(List.of());
Renderer defaultRenderer = driver.processingHandler().getRenderers().getComponent(defaultId);
- assertThat(defaultRenderer, notNullValue());
+ assertNotNull(defaultRenderer);
}
@Test
- public void testUserSpecifiedDefaultRendererIsNotReplacedInRegistry() throws Exception {
+ public void testUserSpecifiedDefaultRendererIsNotReplacedInRegistry() {
String defaultId = AbstractProcessingHandler.DEFAULT_RENDERER_ID;
Renderer myDefaultRenderer = new ProcessingRenderer();
ComponentRegistry<Renderer> renderers = new ComponentRegistry<>();
renderers.register(ComponentId.fromString(defaultId), myDefaultRenderer);
- driver = new ProcessingTestDriver(Collections.<Chain<Processor>>emptyList(), renderers);
+ driver = new ProcessingTestDriver(List.of(), renderers);
Renderer defaultRenderer = driver.processingHandler().getRenderers().getComponent(defaultId);
- assertThat(defaultRenderer, sameInstance(myDefaultRenderer));
+ assertSame(defaultRenderer, myDefaultRenderer);
}
@@ -727,7 +722,7 @@ public class ProcessingHandlerTestCase {
}
- private String defaultChainResponse =
+ private final String defaultChainResponse =
"{\"datalist\":[" +
"{\"data\":\"StringData.toString()\"}," +
"{\"datalist\":[" +
@@ -736,17 +731,17 @@ public class ProcessingHandlerTestCase {
"}]" +
"}";
- private String simpleChainResponse =
+ private final String simpleChainResponse =
"{\"datalist\":[" +
"{\"data\":\"StringData.toString()\"}]" +
"}";
- private String trace1 =
+ private final String trace1 =
"{\"trace\":[" +
"\"TraceMessage\"" +
"],";
- private String trace1WithFullResult =
+ private final String trace1WithFullResult =
"{\"trace\":[" +
"\"TraceMessage\"" +
"]," +
@@ -758,7 +753,7 @@ public class ProcessingHandlerTestCase {
"]}" +
"]}";
- private String trace4 =
+ private final String trace4 =
"{\"trace\":[" +
"\"Invoke '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$StringDataListAdder'\"," +
"\"Invoke '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$Trace'\"," +
@@ -769,7 +764,7 @@ public class ProcessingHandlerTestCase {
"\"Return '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$StringDataListAdder'\"" +
"],";
- private String trace5 =
+ private final String trace5 =
"{\"trace\":[" +
"\"Invoke '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$StringDataListAdder'\"," +
"\"Invoke '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$Trace'\"," +
@@ -780,7 +775,7 @@ public class ProcessingHandlerTestCase {
"\"Return '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$StringDataListAdder'\"" +
"],";
- private String trace6 =
+ private final String trace6 =
"{\"trace\":[" +
"{\"timestamp\":ddddddddddddd,\"message\":\"Invoke '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$StringDataListAdder'\"}," +
"{\"timestamp\":ddddddddddddd,\"message\":\"Invoke '(anonymous)' of class 'com.yahoo.processing.test.ProcessorLibrary$Trace'\"}," +
diff --git a/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java b/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java
index 627081e0d3b..0ea8a157410 100644
--- a/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java
+++ b/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java
@@ -23,15 +23,12 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
/**
* @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
@@ -45,7 +42,7 @@ public class AsynchronousSectionedRendererTest {
TestRenderer rendererPrototype = new TestRenderer();
TestRenderer rendererCopy1 = (TestRenderer)rendererPrototype.clone();
rendererCopy1.init();
- assertTrue(rendererPrototype.getRenderingExecutor() == rendererCopy1.getRenderingExecutor());
+ assertSame(rendererPrototype.getRenderingExecutor(), rendererCopy1.getRenderingExecutor());
}
@Test
@@ -57,7 +54,7 @@ public class AsynchronousSectionedRendererTest {
TestRenderer rendererPrototype2 = new TestRenderer();
TestRenderer rendererCopy2 = (TestRenderer)rendererPrototype2.clone();
rendererCopy2.init();
- assertTrue(rendererPrototype1.getRenderingExecutor() != rendererCopy2.getRenderingExecutor());
+ assertNotSame(rendererPrototype1.getRenderingExecutor(), rendererCopy2.getRenderingExecutor());
}
@Test
@@ -69,9 +66,9 @@ public class AsynchronousSectionedRendererTest {
String str = render(renderer, dataList);
- assertThat(str,
- equalTo(" beginResponse beginList[f\\o\"o, [b/a\br, f\f\no\ro\tbar\u0005]] dataf\\o\"o beginList[b/a\br, " +
- "f\f\no\ro\tbar\u0005] datab/a\br dataf\f\no\ro\tbar\u0005 endList[b/a\br, f\f\no\ro\tbar\u0005] endList[f\\o\"o, [b/a\br, f\f\no\ro\tbar\u0005]] endResponse"));
+ assertEquals(" beginResponse beginList[f\\o\"o, [b/a\br, f\f\no\ro\tbar\u0005]] dataf\\o\"o beginList[b/a\br, " +
+ "f\f\no\ro\tbar\u0005] datab/a\br dataf\f\no\ro\tbar\u0005 endList[b/a\br, f\f\no\ro\tbar\u0005] endList[f\\o\"o, [b/a\br, f\f\no\ro\tbar\u0005]] endResponse",
+ str);
}
@Test
@@ -79,23 +76,21 @@ public class AsynchronousSectionedRendererTest {
Request request = new Request();
DataList dataList = ArrayDataList.create(request);
- assertThat(render(dataList),
- equalTo("{\"datalist\":[" +
- "]}"));
+ assertEquals("{\"datalist\":[]}", render(dataList));
}
@Test
public void testProcessingRendering() throws IOException, InterruptedException {
StringDataList dataList = createDataListWithStrangeStrings();
- assertThat(render(dataList),
- equalTo("{\"datalist\":[" +
+ assertEquals("{\"datalist\":[" +
"{\"data\":\"f\\\\o\\\"o\"}," +
"{\"datalist\":[" +
"{\"data\":\"b/a\\br\"}," +
"{\"data\":\"f\\f\\no\\ro\\tbar\\u0005\"}" +
"]}" +
- "]}"));
+ "]}",
+ render(dataList));
}
@Test
@@ -106,8 +101,7 @@ public class AsynchronousSectionedRendererTest {
dataList.request().errors().add(new ErrorMessage("m1","d1"));
dataList.request().errors().add(new ErrorMessage("m2","d2"));
- assertThat(render(dataList),
- equalTo("{\"errors\":[" +
+ assertEquals("{\"errors\":[" +
"\"m1: d1\"," +
"\"m2: d2\"" +
"]," +
@@ -117,12 +111,13 @@ public class AsynchronousSectionedRendererTest {
"{\"data\":\"l11\"}," +
"{\"data\":\"l12\"}" +
"]}" +
- "]}"));
+ "]}",
+ render(dataList));
}
@Test
public void testProcessingRenderingWithStackTraces() throws IOException, InterruptedException {
- Exception exception=null;
+ Exception exception;
// Create thrown exception
try {
throw new RuntimeException("Thrown");
@@ -155,8 +150,7 @@ public class AsynchronousSectionedRendererTest {
dataList.add(new StringDataList(dataList.request().clone())); // Cloning a request which contains errors
// ... should not cause repetition of those errors
- assertThat(render(dataList),
- equalTo("{\"errors\":[" +
+ assertEquals("{\"errors\":[" +
"\"m1: d1\"," +
"\"m2: d2\"" +
"]," +
@@ -167,7 +161,8 @@ public class AsynchronousSectionedRendererTest {
"{\"data\":\"l12\"}" +
"]}," +
"{\"datalist\":[]}" +
- "]}"));
+ "]}",
+ render(dataList));
}
@Test
@@ -181,8 +176,7 @@ public class AsynchronousSectionedRendererTest {
// and adding new errors to it
dataList.asList().get(2).request().errors().add(new ErrorMessage("m3","d3"));
- assertThat(render(dataList),
- equalTo("{\"errors\":[" +
+ assertEquals("{\"errors\":[" +
"\"m1: d1\"," +
"\"m2: d2\"" +
"]," +
@@ -196,7 +190,8 @@ public class AsynchronousSectionedRendererTest {
"\"m3: d3\"" +
"]," +
"\"datalist\":[]}" +
- "]}"));
+ "]}",
+ render(dataList));
}
public StringDataList createDataList() {
@@ -334,7 +329,7 @@ public class AsynchronousSectionedRendererTest {
}
}
- private abstract class StringData extends ListenableFreezableClass implements Data {
+ private static abstract class StringData extends ListenableFreezableClass implements Data {
private final Request request;
private StringData(Request request) {
@@ -410,7 +405,7 @@ public class AsynchronousSectionedRendererTest {
@Override
@SuppressWarnings("removal")
public ListenableFuture<DataList<StringData>> complete() {
- return new ListenableFuture<DataList<StringData>>() {
+ return new ListenableFuture<>() {
@Override
public void addListener(Runnable runnable, Executor executor) {
}
@@ -431,13 +426,12 @@ public class AsynchronousSectionedRendererTest {
}
@Override
- public DataList<StringData> get() throws InterruptedException, ExecutionException {
+ public DataList<StringData> get() {
return StringDataList.this;
}
@Override
- public DataList<StringData> get(long l, TimeUnit timeUnit)
- throws InterruptedException, ExecutionException, TimeoutException {
+ public DataList<StringData> get(long l, TimeUnit timeUnit) {
return StringDataList.this;
}
};
diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java
index 9115a000e20..757356e3096 100644
--- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java
+++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java
@@ -58,7 +58,6 @@ import com.yahoo.document.update.RemoveValueUpdate;
import com.yahoo.document.update.ValueUpdate;
import com.yahoo.document.WeightedSetDataType;
import com.yahoo.io.GrowableByteBuffer;
-import com.yahoo.tensor.serialization.TypedBinaryFormat;
import com.yahoo.text.Utf8;
import com.yahoo.text.Utf8Array;
import com.yahoo.text.Utf8String;
diff --git a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
index bee5f78ae83..63a0f8d25ed 100644
--- a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
@@ -5,9 +5,7 @@ import com.yahoo.document.idstring.IdIdString;
import com.yahoo.document.idstring.IdString;
import com.yahoo.vespa.objects.BufferSerializer;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.io.BufferedReader;
@@ -17,8 +15,10 @@ import java.io.UnsupportedEncodingException;
import java.util.regex.Pattern;
import java.util.Arrays;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -26,9 +26,6 @@ public class DocumentIdTestCase {
DocumentTypeManager manager = new DocumentTypeManager();
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Before
public void setUp() {
DocumentType testDocType = new DocumentType("testdoc");
@@ -87,16 +84,22 @@ public class DocumentIdTestCase {
@Test
public void empty_user_location_value_throws_exception() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("ID location value for 'n=' key is empty");
- new DocumentId("id:namespace:type:n=:foo");
+ try {
+ new DocumentId("id:namespace:type:n=:foo");
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("ID location value for 'n=' key is empty", e.getMessage());
+ }
}
@Test
public void empty_group_location_value_throws_exception() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("ID location value for 'g=' key is empty");
- new DocumentId("id:namespace:type:g=:foo");
+ try {
+ new DocumentId("id:namespace:type:g=:foo");
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("ID location value for 'g=' key is empty", e.getMessage());
+ }
}
//Compares globalId with C++ implementation located in
@@ -198,14 +201,10 @@ public class DocumentIdTestCase {
DocumentId docId0Copy = new DocumentId("id:blabla:type::0");
byte[] docId0CopyGid = docId0Copy.getGlobalId();
-
- //GIDs should be the same
- for (int i = 0; i < docId0Gid.length; i++) {
- assertEquals(docId0Gid[i], docId0CopyGid[i]);
- }
+ assertArrayEquals(docId0Gid, docId0CopyGid);
//straight hashCode() of byte arrays won't be the same
- assertFalse(docId0Gid.hashCode() == docId0CopyGid.hashCode());
+ assertNotEquals(docId0Gid.hashCode(), docId0CopyGid.hashCode());
//Arrays.hashCode() works better...
assertEquals(Arrays.hashCode(docId0Gid), Arrays.hashCode(docId0CopyGid));
@@ -231,7 +230,7 @@ public class DocumentIdTestCase {
}
@Test
- public void testSerializedDocumentIdCanContainNonTextCharacter() throws UnsupportedEncodingException {
+ public void testSerializedDocumentIdCanContainNonTextCharacter() {
String strId = new String(new byte[]{105, 100, 58, 97, 58, 98, 58, 58, 7, 99}); // "id:a:b::0x7c"
DocumentId docId = DocumentId.createFromSerialized(strId);
{
@@ -247,7 +246,7 @@ public class DocumentIdTestCase {
}
@Test
- public void testSerializedDocumentIdCannotContainZeroByte() throws UnsupportedEncodingException {
+ public void testSerializedDocumentIdCannotContainZeroByte() {
String strId = new String(new byte[]{105, 100, 58, 97, 58, 98, 58, 58, 0, 99}); // "id:a:b::0x0c"
try {
DocumentId.createFromSerialized(strId);
diff --git a/document/src/test/java/com/yahoo/document/datatypes/ReferenceFieldValueTestCase.java b/document/src/test/java/com/yahoo/document/datatypes/ReferenceFieldValueTestCase.java
index a537f5f5108..9ff15339ab4 100644
--- a/document/src/test/java/com/yahoo/document/datatypes/ReferenceFieldValueTestCase.java
+++ b/document/src/test/java/com/yahoo/document/datatypes/ReferenceFieldValueTestCase.java
@@ -6,15 +6,14 @@ import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentType;
import com.yahoo.document.Field;
import com.yahoo.document.ReferenceDataType;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author vekterli
@@ -22,9 +21,6 @@ import static org.junit.Assert.assertTrue;
*/
public class ReferenceFieldValueTestCase {
- @Rule
- public final ExpectedException exceptionRule = ExpectedException.none();
-
private static DocumentType createDocumentType(String name) {
DocumentType type = new DocumentType(name);
type.addField(new Field("foo", DataType.STRING));
@@ -126,10 +122,13 @@ public class ReferenceFieldValueTestCase {
public void assigning_reference_field_with_different_type_to_existing_reference_throws_exception() {
ReferenceFieldValue existing = new ReferenceFieldValue(referenceTypeFoo());
ReferenceFieldValue newValue = new ReferenceFieldValue(referenceTypeBar());
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("Can't assign reference of type Reference<bar> " +
- "to reference of type Reference<foo>");
- existing.assign(newValue);
+ try {
+ existing.assign(newValue);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Can't assign reference of type Reference<bar> to reference of type Reference<foo>",
+ e.getMessage());
+ }
}
@Test
diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
index a1c1669ffa1..66ff7a7d4cd 100644
--- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
@@ -56,9 +56,7 @@ import com.yahoo.text.Utf8;
import com.yahoo.yolean.Exceptions;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -96,9 +94,6 @@ public class JsonReaderTestCase {
private DocumentTypeManager types;
private JsonFactory parserFactory;
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
@Before
public void setUp() throws Exception {
parserFactory = new JsonFactory();
@@ -202,7 +197,6 @@ public class JsonReaderTestCase {
public void tearDown() throws Exception {
types = null;
parserFactory = null;
- exception = ExpectedException.none();
}
private JsonReader createReader(String jsonInput) {
@@ -963,9 +957,12 @@ public class JsonReaderTestCase {
DocumentParseInfo parseInfo = r.parseDocument().get();
DocumentType docType = r.readDocumentType(parseInfo.documentId);
DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("No field 'smething' in the structure of type 'smoke'");
- new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
+ try {
+ new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("No field 'smething' in the structure of type 'smoke'"));
+ }
}
@Test
@@ -975,9 +972,12 @@ public class JsonReaderTestCase {
" { 'put': 'id:test:smoke::1', 'fields': { 'something': 'foo' } },",
" { 'put': 'id:test:smoke::2', 'fields': { 'something': 'foo' } },",
"]"));
- exception.expect(RuntimeException.class);
- exception.expectMessage("JsonParseException");
- while (r.next() != null);
+ try {
+ while (r.next() != null) ;
+ fail();
+ } catch (RuntimeException e) {
+ assertTrue(e.getMessage().contains("JsonParseException"));
+ }
}
@Test
@@ -1869,9 +1869,6 @@ public class JsonReaderTestCase {
@Test
public void requireThatUnknownDocTypeThrowsIllegalArgumentException() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Document type walrus does not exist");
-
final String jsonData = inputJson(
"[",
" {",
@@ -1881,8 +1878,12 @@ public class JsonReaderTestCase {
" }",
" }",
"]");
-
- new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
+ try {
+ new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Document type walrus does not exist", e.getMessage());
+ }
}
private static final String TENSOR_DOC_ID = "id:unittest:testtensor::0";
@@ -2051,10 +2052,13 @@ public class JsonReaderTestCase {
// NOTE: Do not call this method multiple times from a test method as it's using the ExpectedException rule
private void assertParserErrorMatches(String expectedError, String... json) {
- exception.expect(JsonReaderException.class);
- exception.expectMessage(expectedError);
String jsonData = inputJson(json);
- new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
+ try {
+ new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
+ fail();
+ } catch (JsonReaderException e) {
+ assertEquals(expectedError, e.getMessage());
+ }
}
private void assertCreatePutFails(String tensor, String name, String msg) {
diff --git a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
index 5a75110ca74..0a23c14cf16 100644
--- a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
+++ b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
@@ -28,9 +28,7 @@ import com.yahoo.document.select.parser.ParseException;
import com.yahoo.document.select.parser.TokenMgrException;
import com.yahoo.yolean.Exceptions;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -49,9 +47,6 @@ import static org.junit.Assert.fail;
*/
public class DocumentSelectorTestCase {
- @Rule
- public final ExpectedException exceptionRule = ExpectedException.none();
-
private static final DocumentTypeManager manager = new DocumentTypeManager();
@Before
@@ -786,13 +781,15 @@ public class DocumentSelectorTestCase {
@Test
public void imported_fields_only_supported_for_simple_expressions() throws ParseException {
- exceptionRule.expect(IllegalArgumentException.class);
// TODO we should probably handle this case specially and give a better exception message
- exceptionRule.expectMessage("Field 'my_imported_field' not found in type datatype test");
-
var documents = createDocs();
- // Nested field access is NOT considered a simple expression.
- evaluate("test.my_imported_field.foo", documents.get(0));
+ try {
+ // Nested field access is NOT considered a simple expression.
+ evaluate("test.my_imported_field.foo", documents.get(0));
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("Field 'my_imported_field' not found in type datatype test"));
+ }
}
@Test
diff --git a/document/src/test/java/com/yahoo/document/update/TensorModifyUpdateTest.java b/document/src/test/java/com/yahoo/document/update/TensorModifyUpdateTest.java
index 5b7e9ad89d5..60dd5ad1d0d 100644
--- a/document/src/test/java/com/yahoo/document/update/TensorModifyUpdateTest.java
+++ b/document/src/test/java/com/yahoo/document/update/TensorModifyUpdateTest.java
@@ -5,17 +5,13 @@ import com.yahoo.document.datatypes.TensorFieldValue;
import com.yahoo.document.update.TensorModifyUpdate.Operation;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
public class TensorModifyUpdateTest {
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
@Test
public void convert_to_compatible_type_with_only_mapped_dimensions() {
assertConvertToCompatible("tensor(x{})", "tensor(x[])");
@@ -31,10 +27,14 @@ public class TensorModifyUpdateTest {
@Test
public void use_of_incompatible_tensor_type_throws() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Tensor type 'tensor(x[3])' is not compatible as it has no mapped dimensions");
- new TensorModifyUpdate(TensorModifyUpdate.Operation.REPLACE,
- new TensorFieldValue(Tensor.from("tensor(x[3])", "{{x:1}:3}")));
+ try {
+ new TensorModifyUpdate(TensorModifyUpdate.Operation.REPLACE,
+ new TensorFieldValue(Tensor.from("tensor(x[3])", "{{x:1}:3}")));
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Tensor type 'tensor(x[3])' is not compatible as it has no mapped dimensions",
+ e.getMessage());
+ }
}
@Test
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyRepositoryTest.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyRepositoryTest.java
index 2bd7c965fdc..43687254498 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyRepositoryTest.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyRepositoryTest.java
@@ -1,19 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class RoutingPolicyRepositoryTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void policy_creation_does_not_swallow_exception() {
final RoutingPolicyRepository repo = new RoutingPolicyRepository();
@@ -22,10 +19,12 @@ public class RoutingPolicyRepositoryTest {
when(factory.createPolicy(anyString())).thenThrow(new IllegalArgumentException("oh no!"));
repo.putFactory("foo", factory);
- expectedException.expectMessage("oh no!");
- expectedException.expect(IllegalArgumentException.class);
-
- repo.createPolicy("foo", "bar");
+ try {
+ repo.createPolicy("foo", "bar");
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("oh no!", e.getMessage());
+ }
}
}
diff --git a/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzAuthorizationFilterTest.java b/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzAuthorizationFilterTest.java
index 8be552c1da0..63223f3c221 100644
--- a/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzAuthorizationFilterTest.java
+++ b/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzAuthorizationFilterTest.java
@@ -39,14 +39,10 @@ import static com.yahoo.jdisc.http.filter.security.athenz.AthenzAuthorizationFil
import static com.yahoo.security.SignatureAlgorithm.SHA256_WITH_ECDSA;
import static com.yahoo.security.SubjectAlternativeName.Type.RFC822_NAME;
import static com.yahoo.vespa.athenz.zpe.AuthorizationResult.Type;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -240,13 +236,13 @@ public class AthenzAuthorizationFilterTest {
}
private void assertMetrics(MetricMock metric, String metricName, Map<String, String> dimensions) {
- assertThat(metric.addInvocations.keySet(), hasItem(metricName));
+ assertTrue(metric.addInvocations.keySet().contains(metricName));
SimpleMetricContext metricContext = metric.addInvocations.get(metricName);
assertNotNull("Metric not found " + metricName, metricName);
for (Map.Entry<String, String> entry : dimensions.entrySet()) {
String dimensionName = entry.getKey();
String expected = entry.getValue();
- assertThat(metricContext.dimensions.keySet(), hasItem(dimensionName));
+ assertTrue(metricContext.dimensions.keySet().contains(dimensionName));
assertEquals(expected, metricContext.dimensions.get(dimensionName));
}
}
@@ -307,8 +303,8 @@ public class AthenzAuthorizationFilterTest {
private static void assertStatusCode(MockResponseHandler responseHandler, int statusCode) {
Response response = responseHandler.getResponse();
- assertThat(response, notNullValue());
- assertThat(response.getStatus(), equalTo(statusCode));
+ assertNotNull(response);
+ assertEquals(statusCode, response.getStatus());
}
private static void assertMatchedCredentialType(DiscFilterRequest request, EnabledCredentials.Enum expectedType) {
@@ -316,7 +312,7 @@ public class AthenzAuthorizationFilterTest {
}
private static void assertRequestNotFiltered(MockResponseHandler responseHandler) {
- assertThat(responseHandler.getResponse(), nullValue());
+ assertNull(responseHandler.getResponse());
}
private static void assertMatchedRole(DiscFilterRequest request, AthenzRole role) {
@@ -325,9 +321,9 @@ public class AthenzAuthorizationFilterTest {
private static void assertErrorMessage(MockResponseHandler responseHandler, String errorMessage) {
Response response = responseHandler.getResponse();
- assertThat(response, notNullValue());
+ assertNotNull(response);
String content = responseHandler.readAll();
- assertThat(content, containsString(errorMessage));
+ assertTrue(content.contains(errorMessage));
}
private static class AllowingZpe implements Zpe {
diff --git a/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzPrincipalFilterTest.java b/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzPrincipalFilterTest.java
index 23b1b7c569e..d670c969e5c 100644
--- a/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzPrincipalFilterTest.java
+++ b/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/athenz/AthenzPrincipalFilterTest.java
@@ -31,11 +31,10 @@ import static com.yahoo.security.SignatureAlgorithm.SHA256_WITH_ECDSA;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.joining;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -91,7 +90,7 @@ public class AthenzPrincipalFilterTest {
AthenzPrincipalFilter filter = createFilter(true);
filter.filter(request, responseHandler);
- assertThat(responseHandler.response, nullValue());
+ assertNull(responseHandler.response);
}
private DiscFilterRequest createRequestMock() {
@@ -103,9 +102,9 @@ public class AthenzPrincipalFilterTest {
}
private static void assertUnauthorized(DiscFilterRequest request, ResponseHandlerMock responseHandler, String expectedMessageSubstring) {
- assertThat(responseHandler.response, notNullValue());
- assertThat(responseHandler.response.getStatus(), equalTo(UNAUTHORIZED));
- assertThat(responseHandler.getResponseContent(), containsString(expectedMessageSubstring));
+ assertNotNull(responseHandler.response);
+ assertEquals(UNAUTHORIZED, responseHandler.response.getStatus());
+ assertTrue(responseHandler.getResponseContent().contains(expectedMessageSubstring));
verify(request).setAttribute(AthenzPrincipalFilter.RESULT_ERROR_CODE_ATTRIBUTE, UNAUTHORIZED);
}
diff --git a/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/base/JsonSecurityRequestFilterBaseTest.java b/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/base/JsonSecurityRequestFilterBaseTest.java
index a2746e84e1c..0f5512a6ec5 100644
--- a/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/base/JsonSecurityRequestFilterBaseTest.java
+++ b/jdisc-security-filters/src/test/java/com/yahoo/jdisc/http/filter/security/base/JsonSecurityRequestFilterBaseTest.java
@@ -11,9 +11,8 @@ import org.junit.Test;
import java.io.IOException;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
/**
@@ -34,12 +33,12 @@ public class JsonSecurityRequestFilterBaseTest {
filter.filter(request, responseHandler);
Response response = responseHandler.getResponse();
- assertThat(response, notNullValue());
- assertThat(response.getStatus(), equalTo(statusCode));
+ assertNotNull(response);
+ assertEquals(statusCode, response.getStatus());
JsonNode jsonNode = mapper.readTree(responseHandler.readAll());
- assertThat(jsonNode.get("message").asText(), equalTo(message));
- assertThat(jsonNode.get("code").asInt(), equalTo(statusCode));
+ assertEquals(message, jsonNode.get("message").asText());
+ assertEquals(statusCode, jsonNode.get("code").asInt());
}
private static class SimpleSecurityRequestFilter extends JsonSecurityRequestFilterBase {
diff --git a/vespajlib/src/main/java/com/yahoo/io/TeeInputStream.java b/vespajlib/src/main/java/com/yahoo/io/TeeInputStream.java
deleted file mode 100644
index c199fedf395..00000000000
--- a/vespajlib/src/main/java/com/yahoo/io/TeeInputStream.java
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.io;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * Forwards input from a source InputStream while making a copy of it into an outputstream.
- * Note that it also does read-ahead and copies up to 64K of data more than was used.
- *
- * @author arnej
- */
-class TeeInputStream extends InputStream {
- final InputStream src;
- final OutputStream dst;
-
- static final int CAPACITY = 65536;
-
- byte[] buf = new byte[CAPACITY];
- int readPos = 0;
- int writePos = 0;
-
- private int inBuf() { return writePos - readPos; }
-
- private void fillBuf() throws IOException {
- if (readPos == writePos) {
- readPos = 0;
- writePos = 0;
- }
- if (readPos * 3 > CAPACITY) {
- int had = inBuf();
- System.arraycopy(buf, readPos, buf, 0, had);
- readPos = 0;
- writePos = had;
- }
- int wantToRead = CAPACITY - writePos;
- if (inBuf() > 0) {
- // if we have data already, do not block, read only what is available
- wantToRead = Math.min(wantToRead, src.available());
- }
- if (wantToRead > 0) {
- int got = src.read(buf, writePos, wantToRead);
- if (got > 0) {
- dst.write(buf, writePos, got);
- writePos += got;
- }
- }
- }
-
- /** Construct a Tee */
- public TeeInputStream(InputStream from, OutputStream to) {
- super();
- this.src = from;
- this.dst = to;
- }
-
- @Override
- public int available() throws IOException {
- return inBuf() + src.available();
- }
-
- @Override
- public void close() throws IOException {
- src.close();
- dst.close();
- }
-
- @Override
- public int read() throws IOException {
- fillBuf();
- if (inBuf() > 0) {
- int r = buf[readPos++];
- return r & 0xff;
- }
- return -1;
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- if (len <= 0) {
- return 0;
- }
- fillBuf();
- int had = inBuf();
- if (had > 0) {
- len = Math.min(len, had);
- System.arraycopy(buf, readPos, b, off, len);
- readPos += len;
- return len;
- }
- return -1;
- }
-
-}
diff --git a/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java
index 59f0583cbd4..ddee8147acd 100644
--- a/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java
@@ -3,7 +3,6 @@ package com.yahoo.collections;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
public class HashletTestCase {
@@ -12,14 +11,14 @@ public class HashletTestCase {
public void testCopyEmptyHashlet() {
Hashlet<String, Integer> hash = new Hashlet<>();
Hashlet<String, Integer> hash2 = new Hashlet<>(hash);
- assertThat(hash.size(), is(0));
- assertThat(hash2.size(), is(0));
+ assertEquals(0, hash.size());
+ assertEquals(0, hash2.size());
hash.put("foo", 5);
hash2.put("bar", 7);
- assertThat(hash.get("foo"), is(5));
- assertThat(hash.get("bar"), nullValue());
- assertThat(hash2.get("foo"), nullValue());
- assertThat(hash2.get("bar"), is(7));
+ assertEquals(5, hash.get("foo").intValue());
+ assertNull(hash.get("bar"));
+ assertNull(hash2.get("foo"));
+ assertEquals(7, hash2.get("bar").intValue());
}
private void verifyEquals(Object a, Object b) {
@@ -112,17 +111,17 @@ public class HashletTestCase {
hash.put("foo", 5);
hash.put("bar", 7);
Hashlet<String, Integer> hash2 = new Hashlet<>(hash);
- assertThat(hash2.size(), is(2));
- assertThat(hash2.get("foo"), is(5));
- assertThat(hash2.get("bar"), is(7));
- assertThat(hash2.key(0), is("foo"));
- assertThat(hash2.key(1), is("bar"));
- assertThat(hash2.value(0), is(5));
- assertThat(hash2.value(1), is(7));
- assertThat(hash2.key(0), sameInstance(hash.key(0)));
- assertThat(hash2.key(1), sameInstance(hash.key(1)));
- assertThat(hash2.value(0), sameInstance(hash.value(0)));
- assertThat(hash2.value(1), sameInstance(hash.value(1)));
+ assertEquals(2, hash2.size());
+ assertEquals(5, hash2.get("foo").intValue());
+ assertEquals(7, hash2.get("bar").intValue());
+ assertEquals("foo", hash2.key(0));
+ assertEquals("bar", hash2.key(1));
+ assertEquals(5, hash2.value(0).intValue());
+ assertEquals(7, hash2.value(1).intValue());
+ assertSame(hash2.key(0), hash.key(0));
+ assertSame(hash2.key(1), hash.key(1));
+ assertSame(hash2.value(0), hash.value(0));
+ assertSame(hash2.value(1), hash.value(1));
}
@Test
@@ -130,21 +129,21 @@ public class HashletTestCase {
Hashlet<String, Integer> hash = new Hashlet<>();
hash.put("foo", 5);
hash.put("bar", 7);
- assertThat(hash.size(), is(2));
- assertThat(hash.get("foo"), is(5));
- assertThat(hash.get("bar"), is(7));
- assertThat(hash.key(0), is("foo"));
- assertThat(hash.key(1), is("bar"));
- assertThat(hash.value(0), is(5));
- assertThat(hash.value(1), is(7));
+ assertEquals(2, hash.size());
+ assertEquals(5, hash.get("foo").intValue());
+ assertEquals(7, hash.get("bar").intValue());
+ assertEquals("foo", hash.key(0));
+ assertEquals("bar", hash.key(1));
+ assertEquals(5, hash.value(0).intValue());
+ assertEquals(7, hash.value(1).intValue());
hash.put("foo", null);
- assertThat(hash.size(), is(2));
- assertThat(hash.get("foo"), nullValue());
- assertThat(hash.get("bar"), is(7));
- assertThat(hash.key(0), is("foo"));
- assertThat(hash.key(1), is("bar"));
- assertThat(hash.value(0), nullValue());
- assertThat(hash.value(1), is(7));
+ assertEquals(2, hash.size());
+ assertNull(hash.get("foo"));
+ assertEquals(7, hash.get("bar").intValue());
+ assertEquals("foo", hash.key(0));
+ assertEquals("bar", hash.key(1));
+ assertNull(hash.value(0));
+ assertEquals(7, hash.value(1).intValue());
}
@Test
@@ -155,11 +154,11 @@ public class HashletTestCase {
String str = ("" + i + "_str_" + i);
hash.put(str, i);
}
- assertThat(hash.size(), is(n));
+ assertEquals(n, hash.size());
for (int i = 0; i < n; i++) {
String str = ("" + i + "_str_" + i);
- assertThat(hash.key(i), is(str));
- assertThat(hash.value(i), is(i));
+ assertEquals(str, hash.key(i));
+ assertEquals(i, hash.value(i).intValue());
}
}
@@ -169,17 +168,17 @@ public class HashletTestCase {
Hashlet<String, Integer> hash = new Hashlet<>();
for (int i = 0; i < n; i++) {
String str = ("" + i + "_str_" + i);
- assertThat(hash.get(str), nullValue());
+ assertNull(hash.get(str));
switch (i % 2) {
- case 1: assertThat(hash.put(str, i), nullValue());
+ case 1: assertNull(hash.put(str, i));
}
}
- assertThat(hash.size(), is(n / 2));
+ assertEquals(n / 2, hash.size());
for (int i = 0; i < n; i++) {
String str = ("" + i + "_str_" + i);
switch (i % 2) {
- case 0: assertThat(hash.get(str), nullValue()); break;
- case 1: assertThat(hash.get(str), is(i)); break;
+ case 0: assertNull(hash.get(str)); break;
+ case 1: assertEquals(i, hash.get(str).intValue()); break;
}
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/io/TeeInputStreamTest.java b/vespajlib/src/test/java/com/yahoo/io/TeeInputStreamTest.java
deleted file mode 100644
index 7b944e92d48..00000000000
--- a/vespajlib/src/test/java/com/yahoo/io/TeeInputStreamTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.io;
-
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-
-import org.junit.Test;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
-/**
- * @author arnej
- */
-public class TeeInputStreamTest {
-
- @Test
- public void testSimpleInput() throws IOException {
- byte[] input = "very simple input".getBytes(StandardCharsets.UTF_8);
- ByteArrayInputStream in = new ByteArrayInputStream(input);
- ByteArrayOutputStream gotten = new ByteArrayOutputStream();
- ByteArrayOutputStream output = new ByteArrayOutputStream();
-
- TeeInputStream tee = new TeeInputStream(in, gotten);
- int b = tee.read();
- assertThat(b, is((int)'v'));
- output.write(b);
- assertThat(gotten.toString(), is("very simple input"));
- for (int i = 0; i < 16; i++) {
- b = tee.read();
- // System.out.println("got["+i+"]: "+(char)b);
- assertThat(b, is(greaterThan(0)));
- output.write(b);
- }
- assertThat(tee.read(), is(-1));
- assertThat(gotten.toString(), is("very simple input"));
- assertThat(output.toString(), is("very simple input"));
- }
-
- private class Generator implements Runnable {
- private OutputStream dst;
- public Generator(OutputStream dst) { this.dst = dst; }
- @Override
- public void run() {
- for (int i = 0; i < 123456789; i++) {
- int b = i & 0x7f;
- if (b < 32) continue;
- if (b > 126) b = '\n';
- try {
- dst.write(b);
- } catch (IOException e) {
- return;
- }
- }
- }
- }
-
- @Test
- public void testPipedInput() throws IOException {
- PipedOutputStream input = new PipedOutputStream();
- PipedInputStream in = new PipedInputStream(input);
- ByteArrayOutputStream gotten = new ByteArrayOutputStream();
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- TeeInputStream tee = new TeeInputStream(in, gotten);
- input.write("first input".getBytes(StandardCharsets.UTF_8));
- int b = tee.read();
- assertThat(b, is((int)'f'));
- output.write(b);
- assertThat(gotten.toString(), is("first input"));
- input.write(" second input".getBytes(StandardCharsets.UTF_8));
- b = tee.read();
- assertThat(b, is((int)'i'));
- output.write(b);
- assertThat(gotten.toString(), is("first input second input"));
- new Thread(new Generator(input)).start();
- b = tee.read();
- assertThat(b, is((int)'r'));
- output.write(b);
- byte[] ba = new byte[9];
- for (int i = 0; i < 12345; i++) {
- b = tee.read();
- // System.out.println("got["+i+"]: "+(char)b);
- assertThat(b, is(greaterThan(0)));
- output.write(b);
- int l = tee.read(ba);
- assertThat(l, is(greaterThan(0)));
- output.write(ba, 0, l);
- l = tee.read(ba, 3, 3);
- assertThat(l, is(greaterThan(0)));
- output.write(ba, 3, l);
- }
- tee.close();
- String got = gotten.toString();
- // System.out.println("got length: "+got.length());
- // System.out.println("output length: "+output.toString().length());
- // System.out.println("got: "+got);
- assertThat(got.length(), is(greaterThan(34567)));
- assertTrue(got.startsWith(output.toString()));
- }
-
-}
diff --git a/vespajlib/src/test/java/com/yahoo/path/PathTest.java b/vespajlib/src/test/java/com/yahoo/path/PathTest.java
index aa09c491586..ae4581f1e9d 100644
--- a/vespajlib/src/test/java/com/yahoo/path/PathTest.java
+++ b/vespajlib/src/test/java/com/yahoo/path/PathTest.java
@@ -3,9 +3,8 @@ package com.yahoo.path;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -15,85 +14,85 @@ import static org.junit.Assert.assertTrue;
public class PathTest {
@Test
public void testGetName() {
- assertThat(getAbsolutePath().getName(), is("baz"));
- assertThat(getRelativePath().getName(), is("baz"));
- assertThat(getWithSlashes().getName(), is("baz"));
- assertThat(getAppended().getName(), is("baz"));
- assertThat(getOne().getName(), is("foo"));
+ assertEquals("baz", getAbsolutePath().getName());
+ assertEquals("baz", getRelativePath().getName());
+ assertEquals("baz", getWithSlashes().getName());
+ assertEquals("baz", getAppended().getName());
+ assertEquals("foo", getOne().getName());
}
@Test
public void testEquals() {
- assertTrue(getAbsolutePath().equals(getAbsolutePath()));
- assertTrue(getAbsolutePath().equals(getRelativePath()));
- assertTrue(getAbsolutePath().equals(getWithSlashes()));
- assertTrue(getAbsolutePath().equals(getAppended()));
- assertFalse(getAbsolutePath().equals(getOne()));
-
- assertTrue(getRelativePath().equals(getAbsolutePath()));
- assertTrue(getRelativePath().equals(getRelativePath()));
- assertTrue(getRelativePath().equals(getWithSlashes()));
- assertTrue(getRelativePath().equals(getAppended()));
- assertFalse(getRelativePath().equals(getOne()));
-
- assertTrue(getWithSlashes().equals(getAbsolutePath()));
- assertTrue(getWithSlashes().equals(getRelativePath()));
- assertTrue(getWithSlashes().equals(getWithSlashes()));
- assertTrue(getWithSlashes().equals(getAppended()));
- assertFalse(getWithSlashes().equals(getOne()));
-
- assertTrue(getAppended().equals(getAbsolutePath()));
- assertTrue(getAppended().equals(getRelativePath()));
- assertTrue(getAppended().equals(getWithSlashes()));
- assertTrue(getAppended().equals(getAppended()));
- assertFalse(getAppended().equals(getOne()));
-
- assertFalse(getOne().equals(getAbsolutePath()));
- assertFalse(getOne().equals(getRelativePath()));
- assertFalse(getOne().equals(getWithSlashes()));
- assertFalse(getOne().equals(getAppended()));
- assertTrue(getOne().equals(getOne()));
+ assertEquals(getAbsolutePath(), getAbsolutePath());
+ assertEquals(getAbsolutePath(), getRelativePath());
+ assertEquals(getAbsolutePath(), getWithSlashes());
+ assertEquals(getAbsolutePath(), getAppended());
+ assertNotEquals(getAbsolutePath(), getOne());
+
+ assertEquals(getRelativePath(), getAbsolutePath());
+ assertEquals(getRelativePath(), getRelativePath());
+ assertEquals(getRelativePath(), getWithSlashes());
+ assertEquals(getRelativePath(), getAppended());
+ assertNotEquals(getRelativePath(), getOne());
+
+ assertEquals(getWithSlashes(), getAbsolutePath());
+ assertEquals(getWithSlashes(), getRelativePath());
+ assertEquals(getWithSlashes(), getWithSlashes());
+ assertEquals(getWithSlashes(), getAppended());
+ assertNotEquals(getWithSlashes(), getOne());
+
+ assertEquals(getAppended(), getAbsolutePath());
+ assertEquals(getAppended(), getRelativePath());
+ assertEquals(getAppended(), getWithSlashes());
+ assertEquals(getAppended(), getAppended());
+ assertNotEquals(getAppended(), getOne());
+
+ assertNotEquals(getOne(), getAbsolutePath());
+ assertNotEquals(getOne(), getRelativePath());
+ assertNotEquals(getOne(), getWithSlashes());
+ assertNotEquals(getOne(), getAppended());
+ assertEquals(getOne(), getOne());
}
@Test
public void testGetPath() {
- assertThat(getAbsolutePath().getRelative(), is("foo/bar/baz"));
- assertThat(getRelativePath().getRelative(), is("foo/bar/baz"));
- assertThat(getWithSlashes().getRelative(), is("foo/bar/baz"));
- assertThat(getAppended().getRelative(), is("foo/bar/baz"));
- assertThat(getOne().getRelative(), is("foo"));
+ assertEquals("foo/bar/baz", getAbsolutePath().getRelative());
+ assertEquals("foo/bar/baz", getRelativePath().getRelative());
+ assertEquals("foo/bar/baz", getWithSlashes().getRelative());
+ assertEquals("foo/bar/baz", getAppended().getRelative());
+ assertEquals("foo", getOne().getRelative());
}
@Test
public void testGetParentPath() {
- assertThat(getAbsolutePath().getParentPath().getRelative(), is("foo/bar"));
- assertThat(getRelativePath().getParentPath().getRelative(), is("foo/bar"));
- assertThat(getWithSlashes().getParentPath().getRelative(), is("foo/bar"));
- assertThat(getAppended().getParentPath().getRelative(), is("foo/bar"));
- assertThat(getOne().getParentPath().getRelative(), is(""));
+ assertEquals("foo/bar", getAbsolutePath().getParentPath().getRelative());
+ assertEquals("foo/bar", getRelativePath().getParentPath().getRelative());
+ assertEquals("foo/bar", getWithSlashes().getParentPath().getRelative());
+ assertEquals("foo/bar", getAppended().getParentPath().getRelative());
+ assertTrue(getOne().getParentPath().getRelative().isEmpty());
}
@Test
public void testGetAbsolutePath() {
- assertThat(getAbsolutePath().getAbsolute(), is("/foo/bar/baz"));
- assertThat(getAbsolutePath().getParentPath().getAbsolute(), is("/foo/bar"));
+ assertEquals("/foo/bar/baz", getAbsolutePath().getAbsolute());
+ assertEquals("/foo/bar", getAbsolutePath().getParentPath().getAbsolute());
}
@Test
public void testEmptyPath() {
- assertThat(Path.createRoot().getName(), is(""));
- assertThat(Path.createRoot().getRelative(), is(""));
- assertThat(Path.createRoot().getParentPath().getRelative(), is(""));
+ assertTrue(Path.createRoot().getName().isEmpty());
+ assertTrue(Path.createRoot().getRelative().isEmpty());
+ assertTrue(Path.createRoot().getParentPath().getRelative().isEmpty());
assertTrue(Path.createRoot().isRoot());
}
@Test
public void testDelimiters() {
- assertThat(Path.fromString("foo/bar", ",").getName(), is("foo/bar"));
- assertThat(Path.fromString("foo/bar", "/").getName(), is("bar"));
- assertThat(Path.fromString("foo,bar", "/").getName(), is("foo,bar"));
- assertThat(Path.fromString("foo,bar", ",").getName(), is("bar"));
- assertThat(Path.createRoot(",").append("foo").append("bar").getRelative(), is("foo,bar"));
+ assertEquals("foo/bar", Path.fromString("foo/bar", ",").getName());
+ assertEquals("bar", Path.fromString("foo/bar", "/").getName());
+ assertEquals("foo,bar", Path.fromString("foo,bar", "/").getName());
+ assertEquals("bar", Path.fromString("foo,bar", ",").getName());
+ assertEquals("foo,bar", Path.createRoot(",").append("foo").append("bar").getRelative());
}
@Test
@@ -101,9 +100,9 @@ public class PathTest {
Path p1 = getAbsolutePath();
Path p2 = getAbsolutePath();
Path p3 = p1.append(p2);
- assertThat(p1.getAbsolute(), is("/foo/bar/baz"));
- assertThat(p2.getAbsolute(), is("/foo/bar/baz"));
- assertThat(p3.getAbsolute(), is("/foo/bar/baz/foo/bar/baz"));
+ assertEquals("/foo/bar/baz", p1.getAbsolute());
+ assertEquals("/foo/bar/baz", p2.getAbsolute());
+ assertEquals("/foo/bar/baz/foo/bar/baz", p3.getAbsolute());
}
private Path getRelativePath() {
diff --git a/vespajlib/src/test/java/com/yahoo/reflection/CastingTest.java b/vespajlib/src/test/java/com/yahoo/reflection/CastingTest.java
index f2fa14e8958..1b781c265f4 100644
--- a/vespajlib/src/test/java/com/yahoo/reflection/CastingTest.java
+++ b/vespajlib/src/test/java/com/yahoo/reflection/CastingTest.java
@@ -6,9 +6,9 @@ import org.junit.Test;
import java.util.Optional;
import static com.yahoo.text.StringUtilities.quote;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
import static com.yahoo.reflection.Casting.cast;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
public class CastingTest {
@Test
@@ -16,7 +16,7 @@ public class CastingTest {
Object objectToCast = 12;
Optional<Integer> value = cast(Integer.class, objectToCast);
assertTrue("Value is not present", value.isPresent());
- assertThat(value.get(), is(objectToCast));
+ assertSame(objectToCast, value.get());
}
@Test
diff --git a/vespajlib/src/test/java/com/yahoo/slime/BinaryFormatTestCase.java b/vespajlib/src/test/java/com/yahoo/slime/BinaryFormatTestCase.java
index 19ded5c8db1..5c3126ce3cf 100644
--- a/vespajlib/src/test/java/com/yahoo/slime/BinaryFormatTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/slime/BinaryFormatTestCase.java
@@ -13,8 +13,7 @@ import static com.yahoo.slime.BinaryFormat.encode_double;
import static com.yahoo.slime.BinaryFormat.encode_type_and_meta;
import static com.yahoo.slime.BinaryFormat.encode_zigzag;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class BinaryFormatTestCase {
diff --git a/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java b/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java
index 67a11f8be5a..763f8cb221c 100644
--- a/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java
@@ -2,15 +2,12 @@
package com.yahoo.slime;
import com.yahoo.text.Utf8;
-import org.junit.Ignore;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -108,7 +105,7 @@ public class JsonFormatTestCase {
Slime slime = new Slime();
String str = null;
slime.setString(str);
- assertThat(slime.get().type(), is(Type.NIX));
+ assertEquals(Type.NIX, slime.get().type());
verifyEncoding(slime, "null");
}
@@ -117,7 +114,7 @@ public class JsonFormatTestCase {
Slime slime = new Slime();
byte[] utf8 = null;
slime.setString(utf8);
- assertThat(slime.get().type(), is(Type.NIX));
+ assertEquals(Type.NIX, slime.get().type());
verifyEncoding(slime, "null");
}
@@ -125,7 +122,7 @@ public class JsonFormatTestCase {
public void testNullDataNixFallback() {
Slime slime = new Slime();
slime.setData(null);
- assertThat(slime.get().type(), is(Type.NIX));
+ assertEquals(Type.NIX, slime.get().type());
verifyEncoding(slime, "null");
}
@@ -203,7 +200,7 @@ public class JsonFormatTestCase {
Slime slime = new Slime();
new JsonDecoder().decode(slime, Utf8.toBytesStd(json));
Cursor a = slime.get().field("body");
- assertThat(a.asString(), is("some text&more text"));
+ assertEquals("some text&more text", a.asString());
}
@Test
@@ -226,11 +223,11 @@ public class JsonFormatTestCase {
Slime slime = new Slime();
slime = new JsonDecoder().decode(slime, Utf8.toBytesStd(json));
Cursor a = slime.get().field("rules");
- assertThat(a.asString(), is(str));
+ assertEquals(str, a.asString());
}
@Test(expected = UnsupportedOperationException.class)
- public void testThatDecodeIsNotImplemented() throws IOException {
+ public void testThatDecodeIsNotImplemented() {
new JsonFormat(true).decode(null, null);
}
@@ -244,7 +241,7 @@ public class JsonFormatTestCase {
slime.setString("M\u00E6L");
ByteArrayOutputStream a = new ByteArrayOutputStream();
new JsonFormat(true).encode(a, slime);
- String val = new String(a.toByteArray(), "UTF-8");
+ String val = a.toString(StandardCharsets.UTF_8);
assertEquals("\"M\u00E6L\"", val);
}
@@ -252,7 +249,7 @@ public class JsonFormatTestCase {
try {
ByteArrayOutputStream a = new ByteArrayOutputStream();
new JsonFormat(compact).encode(a, slime);
- assertEquals(expected, new String(a.toByteArray(), StandardCharsets.UTF_8));
+ assertEquals(expected, a.toString(StandardCharsets.UTF_8));
} catch (Exception e) {
fail("Exception thrown when encoding slime: " + e.getMessage());
}
@@ -276,7 +273,7 @@ public class JsonFormatTestCase {
slime.setDouble(value);
ByteArrayOutputStream a = new ByteArrayOutputStream();
new JsonFormat(true).encode(a, slime);
- return new String(a.toByteArray(), StandardCharsets.UTF_8);
+ return a.toString(StandardCharsets.UTF_8);
} catch (Exception e) {
return "";
}
diff --git a/vespajlib/src/test/java/com/yahoo/slime/SlimeTestCase.java b/vespajlib/src/test/java/com/yahoo/slime/SlimeTestCase.java
index 33abfe39345..6ee8fb6c7e2 100644
--- a/vespajlib/src/test/java/com/yahoo/slime/SlimeTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/slime/SlimeTestCase.java
@@ -3,8 +3,9 @@ package com.yahoo.slime;
import org.junit.Test;
-import static org.junit.Assert.assertThat;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.sameInstance;
public class SlimeTestCase {
diff --git a/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java b/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java
index 6a0e6366775..a5b2accec48 100644
--- a/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java
+++ b/vespajlib/src/test/java/com/yahoo/stream/CustomCollectorsTest.java
@@ -3,9 +3,7 @@ package com.yahoo.stream;
import com.google.common.collect.Lists;
import com.yahoo.stream.CustomCollectors.DuplicateKeyException;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.util.HashMap;
import java.util.List;
@@ -16,15 +14,13 @@ import static com.yahoo.stream.CustomCollectors.toCustomMap;
import static com.yahoo.stream.CustomCollectors.toLinkedMap;
import static java.util.function.Function.identity;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author gjoranv
*/
public class CustomCollectorsTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void linked_map_collector_returns_map_with_insertion_order() {
List<String> stringList = numberList();
@@ -48,8 +44,12 @@ public class CustomCollectorsTest {
public void custom_map_collector_throws_exception_upon_duplicate_keys() {
List<String> duplicates = Lists.newArrayList("same", "same");
- thrown.expect(DuplicateKeyException.class);
- duplicates.stream().collect(toCustomMap(Function.identity(), Function.identity(), HashMap::new));
+ try {
+ duplicates.stream().collect(toCustomMap(Function.identity(), Function.identity(), HashMap::new));
+ fail();
+ } catch (DuplicateKeyException e) {
+
+ }
}
private static List<String> numberList() {
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorTypeTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorTypeTestCase.java
index c5009fa3ab2..738697d4521 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/TensorTypeTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorTypeTestCase.java
@@ -3,10 +3,8 @@ package com.yahoo.tensor;
import org.junit.Test;
-import static org.hamcrest.Matchers.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;
@@ -117,7 +115,7 @@ public class TensorTypeTestCase {
TensorType.fromSpec(typeSpec);
fail("Expected exception to be thrown with message: '" + messageSubstring + "'");
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage(), containsString(messageSubstring));
+ assertTrue(e.getMessage().contains(messageSubstring));
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TypeResolverTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/TypeResolverTestCase.java
index 055603c5f59..82b7e73fb20 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/TypeResolverTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/TypeResolverTestCase.java
@@ -9,10 +9,7 @@ import java.util.List;
import org.junit.Test;
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;
/**
* @author arnej
diff --git a/vespajlib/src/test/java/com/yahoo/text/LowercaseTestCase.java b/vespajlib/src/test/java/com/yahoo/text/LowercaseTestCase.java
index 70374adbb16..ca3b316c11b 100644
--- a/vespajlib/src/test/java/com/yahoo/text/LowercaseTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/text/LowercaseTestCase.java
@@ -6,9 +6,7 @@ import org.junit.Test;
import java.util.Locale;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
/**
* @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
@@ -20,32 +18,32 @@ public class LowercaseTestCase {
public void testAZ() {
{
String lowercase = Lowercase.toLowerCase("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
- assertThat(lowercase, equalTo("abcdefghijklmnopqrstuvwxyz"));
+ assertEquals("abcdefghijklmnopqrstuvwxyz", lowercase);
}
{
String lowercase = Lowercase.toLowerCase("abcdefghijklmnopqrstuvwxyz");
- assertThat(lowercase, equalTo("abcdefghijklmnopqrstuvwxyz"));
+ assertEquals("abcdefghijklmnopqrstuvwxyz", lowercase);
}
{
String lowercase = Lowercase.toLowerCase("AbCDEfGHIJklmnoPQRStuvwXyz");
- assertThat(lowercase, equalTo("abcdefghijklmnopqrstuvwxyz"));
+ assertEquals("abcdefghijklmnopqrstuvwxyz", lowercase);
}
{
String lowercase = Lowercase.toLowerCase("@+#");
- assertThat(lowercase, equalTo("@+#"));
+ assertEquals("@+#", lowercase);
}
{
String lowercase = Lowercase.toLowerCase("[]");
- assertThat(lowercase, equalTo("[]"));
+ assertEquals("[]", lowercase);
}
{
String lowercase = Lowercase.toLowerCase("{}");
- assertThat(lowercase, equalTo("{}"));
+ assertEquals("{}", lowercase);
}
{
String lowercase = Lowercase.toLowerCase("\u00cd\u00f4");
- assertThat(lowercase, equalTo("\u00ed\u00f4"));
+ assertEquals("\u00ed\u00f4", lowercase);
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/text/StringUtilitiesTest.java b/vespajlib/src/test/java/com/yahoo/text/StringUtilitiesTest.java
index b1ec37cb7d7..b68cca6e54f 100644
--- a/vespajlib/src/test/java/com/yahoo/text/StringUtilitiesTest.java
+++ b/vespajlib/src/test/java/com/yahoo/text/StringUtilitiesTest.java
@@ -1,12 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;
-import java.util.Arrays;
+import java.util.List;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class StringUtilitiesTest {
@@ -40,7 +43,7 @@ public class StringUtilitiesTest {
@Test
public void testImplode() {
- assertEquals(StringUtilities.implode(null, null), null);
+ assertNull(StringUtilities.implode(null, null));
assertEquals(StringUtilities.implode(new String[0], null), "");
assertEquals(StringUtilities.implode(new String[] {"foo"}, null), "foo");
assertEquals(StringUtilities.implode(new String[] {"foo"}, "asdfsdfsadfsadfasdfs"), "foo");
@@ -55,17 +58,17 @@ public class StringUtilitiesTest {
@Test
public void testImplodeMultiline() {
- assertEquals(StringUtilities.implodeMultiline(Arrays.asList("foo", "bar")), "foo\nbar");
- assertEquals(StringUtilities.implodeMultiline(Arrays.asList("")), "");
- assertEquals(StringUtilities.implodeMultiline(null), null);
- assertEquals(StringUtilities.implodeMultiline(Arrays.asList("\n")), "\n");
+ assertEquals(StringUtilities.implodeMultiline(List.of("foo", "bar")), "foo\nbar");
+ assertEquals(StringUtilities.implodeMultiline(List.of("")), "");
+ assertNull(StringUtilities.implodeMultiline(null));
+ assertEquals(StringUtilities.implodeMultiline(List.of("\n")), "\n");
}
@Test
public void testTruncation() {
String a = "abbc";
- assertTrue(a == StringUtilities.truncateSequencesIfNecessary(a, 2));
- assertTrue(a != StringUtilities.truncateSequencesIfNecessary(a, 1));
+ assertSame(a, StringUtilities.truncateSequencesIfNecessary(a, 2));
+ assertNotSame(a, StringUtilities.truncateSequencesIfNecessary(a, 1));
assertEquals("abc", StringUtilities.truncateSequencesIfNecessary(a, 1));
assertEquals("abc", StringUtilities.truncateSequencesIfNecessary("aabbccc", 1));
assertEquals("abc", StringUtilities.truncateSequencesIfNecessary("abcc", 1));
@@ -77,9 +80,9 @@ public class StringUtilitiesTest {
@Test
public void testStripSuffix() {
- assertThat(StringUtilities.stripSuffix("abc.def", ".def"), is("abc"));
- assertThat(StringUtilities.stripSuffix("abc.def", ""), is("abc.def"));
- assertThat(StringUtilities.stripSuffix("", ".def"), is(""));
- assertThat(StringUtilities.stripSuffix("", ""), is(""));
+ assertEquals("abc", StringUtilities.stripSuffix("abc.def", ".def"));
+ assertEquals("abc.def", StringUtilities.stripSuffix("abc.def", ""));
+ assertTrue(StringUtilities.stripSuffix("", ".def").isEmpty());
+ assertTrue(StringUtilities.stripSuffix("", "").isEmpty());
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
index 9e43cb3c6ea..926d19f433f 100644
--- a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
@@ -18,9 +18,9 @@ import static com.yahoo.text.Utf8.calculateBytePositions;
import static com.yahoo.text.Utf8.calculateStringPositions;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
diff --git a/vespajlib/src/test/java/com/yahoo/vespa/objects/FieldBaseTestCase.java b/vespajlib/src/test/java/com/yahoo/vespa/objects/FieldBaseTestCase.java
index 40792ac05c1..32b87a4b373 100644
--- a/vespajlib/src/test/java/com/yahoo/vespa/objects/FieldBaseTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/vespa/objects/FieldBaseTestCase.java
@@ -6,9 +6,7 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author arnej27959
diff --git a/vespajlib/src/test/java/com/yahoo/vespa/objects/ObjectDumperTestCase.java b/vespajlib/src/test/java/com/yahoo/vespa/objects/ObjectDumperTestCase.java
index 7694548344c..ab0da1b7d33 100644
--- a/vespajlib/src/test/java/com/yahoo/vespa/objects/ObjectDumperTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/vespa/objects/ObjectDumperTestCase.java
@@ -3,13 +3,9 @@ package com.yahoo.vespa.objects;
import org.junit.Test;
-import java.nio.ByteBuffer;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
/**
* @author arnej27959
@@ -37,7 +33,7 @@ public class ObjectDumperTestCase {
oneOD.visit("biggie", b);
- assertThat(oneOD.toString(), equalTo(
+ assertEquals(
"biggie: BigIdClass {\n"+
" classId: 42\n"+
" : <NULL>\n"+
@@ -69,11 +65,11 @@ public class ObjectDumperTestCase {
" [3]: 4\n"+
" [4]: 5\n"+
" }\n"+
-"}\n"));
+"}\n", oneOD.toString());
ObjectDumper defOD = new ObjectDumper();
defOD.visit("", b);
- assertThat(b.toString(), equalTo(b.toString()));
+ assertEquals(b.toString(), b.toString());
}
@Test
@@ -100,7 +96,7 @@ public class ObjectDumperTestCase {
defOD.visit("s5", s5);
oneOD.visit("s6", s5);
- assertThat(defOD.toString(), is("s5: FooBarIdClass {\n"+
+ assertEquals("s5: FooBarIdClass {\n"+
" classId: 17\n"+
" foo: 'def-foo'\n"+
" bar: 42\n"+
@@ -109,8 +105,8 @@ public class ObjectDumperTestCase {
" [1]: 42\n"+
" [2]: 666\n"+
" }\n"+
- "}\n"));
- assertThat(oneOD.toString(), is("s6: FooBarIdClass {\n"+
+ "}\n", defOD.toString());
+ assertEquals("s6: FooBarIdClass {\n"+
" classId: 17\n"+
" foo: 'def-foo'\n"+
" bar: 42\n"+
@@ -119,31 +115,29 @@ public class ObjectDumperTestCase {
" [1]: 42\n"+
" [2]: 666\n"+
" }\n"+
- "}\n"));
+ "}\n", oneOD.toString());
}
@Test
public void testRegistry() {
- assertThat(FooBarIdClass.classId, is(17));
+ assertEquals(17, FooBarIdClass.classId);
int x = Identifiable.registerClass(17, FooBarIdClass.class);
- assertThat(x, is(17));
- boolean caught = false;
+ assertEquals(17, x);
try {
- x = Identifiable.registerClass(17, SomeIdClass.class);
+ x = Identifiable.registerClass(17, SomeIdClass.class);
+ fail();
} catch (IllegalArgumentException e) {
- caught = true;
- assertThat(e.getMessage(), is(
+ assertEquals(e.getMessage(),
"Can not register class 'class com.yahoo.vespa.objects.SomeIdClass' with id 17,"+
-" because it already maps to class 'class com.yahoo.vespa.objects.FooBarIdClass'."));
+" because it already maps to class 'class com.yahoo.vespa.objects.FooBarIdClass'.");
}
- assertThat(x, is(17));
- assertThat(caught, is(true));
+ assertEquals(17, x);
Identifiable s7 = Identifiable.createFromId(17);
ObjectDumper defOD = new ObjectDumper();
defOD.visit("s7", s7);
- assertThat(defOD.toString(), is("s7: FooBarIdClass {\n"+
+ assertEquals("s7: FooBarIdClass {\n"+
" classId: 17\n"+
" foo: 'def-foo'\n"+
" bar: 42\n"+
@@ -152,10 +146,9 @@ public class ObjectDumperTestCase {
" [1]: 42\n"+
" [2]: 666\n"+
" }\n"+
- "}\n"));
+ "}\n", defOD.toString());
- Identifiable nsi = Identifiable.createFromId(717273);
- assertThat(nsi, is((Identifiable)null));
+ assertNull(Identifiable.createFromId(717273));
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/vespa/objects/SerializeTestCase.java b/vespajlib/src/test/java/com/yahoo/vespa/objects/SerializeTestCase.java
index ce4f6846248..31c43f6008d 100644
--- a/vespajlib/src/test/java/com/yahoo/vespa/objects/SerializeTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/vespa/objects/SerializeTestCase.java
@@ -8,7 +8,7 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author arnej27959