summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/pom.xml16
-rw-r--r--application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java4
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java26
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java16
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java9
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java9
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerTest.java30
-rw-r--r--application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java30
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java1
-rw-r--r--cloud-tenant-base-dependencies-enforcer/pom.xml7
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java7
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java2
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java4
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java34
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java61
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java8
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java55
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java1
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java4
-rw-r--r--config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java67
-rw-r--r--config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java68
-rw-r--r--config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java6
-rw-r--r--config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java12
-rw-r--r--config-lib/src/test/java/com/yahoo/config/FileNodeTest.java12
-rw-r--r--config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java5
-rw-r--r--config-lib/src/test/java/com/yahoo/config/LongNodeTest.java5
-rw-r--r--config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java19
-rw-r--r--config-lib/src/test/java/com/yahoo/config/PathNodeTest.java7
-rw-r--r--config-lib/src/test/java/com/yahoo/config/StringNodeTest.java21
-rw-r--r--config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java9
-rw-r--r--config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java9
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java3
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java14
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java1
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java21
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java50
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java7
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java10
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java19
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/ConfigModelContextTest.java23
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/ConfigModelUtilsTest.java19
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/QrserverAndGatewayPortAllocationTest.java7
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java3
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/builder/xml/ConfigModelIdTest.java38
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java18
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java19
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/graph/ModelGraphTest.java27
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/producer/AbstractConfigProducerTest.java11
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java311
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java45
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java8
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java18
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java4
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java6
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java1
-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/AccessControlFilterValidatorTest.java16
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlValidatorTestBase.java31
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java18
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java1
-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/ConstantTensorJsonValidatorTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/EndpointCertificateSecretsValidatorTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidatorTest.java21
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/SecretStoreValidatorTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java1
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/UriBindingsValidatorTest.java1
-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
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/UserConfigBuilderTest.java23
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java65
-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.java23
-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/AccessControlTest.java48
-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/JettyContainerModelBuilderTest.java76
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java89
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/SchemaBuilderTest.java16
-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.java37
-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/NodeResourcesTuningTest.java60
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaNodeTest.java9
-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-proxy/pom.xml5
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java98
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java23
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java13
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java11
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java35
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java28
-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--configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java14
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java17
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java24
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java39
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java18
-rw-r--r--configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java26
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java10
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java28
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerDBTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java9
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java13
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java25
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java29
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/TimeoutBudgetTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java15
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStreamTest.java29
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java22
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsFormatterTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java22
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java25
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java17
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java14
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java7
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java8
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java7
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java14
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java7
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java12
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java24
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java10
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java40
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java39
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java19
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java14
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/PrepareParamsTest.java31
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java12
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java25
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java11
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java17
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java5
-rw-r--r--container-core/src/main/java/com/yahoo/language/provider/DefaultLinguisticsProvider.java6
-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.java208
-rw-r--r--container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java56
-rw-r--r--container-dev/pom.xml4
-rwxr-xr-xcontainer-disc/src/main/sh/vespa-start-container-daemon.sh1
-rw-r--r--container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4134
-rw-r--r--container-search/src/main/java/com/yahoo/search/result/FieldComparator.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/ExpressionOperator.java3
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java131
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java97
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java58
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java76
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java118
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java3
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java453
-rw-r--r--container-search/src/test/java/com/yahoo/select/SelectTestCase.java2
-rw-r--r--controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java1
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/TenantRoleMaintainerTest.java5
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/proxy/ProxyRequestTest.java5
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java1
-rw-r--r--document/src/test/java/com/yahoo/document/DataTypeTestCase.java7
-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/abi-spec.json32
-rw-r--r--documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java96
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/RoutingPolicyRepositoryTest.java17
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java44
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java30
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java2
-rw-r--r--eval/CMakeLists.txt1
-rw-r--r--eval/src/tests/instruction/sparse_112_dot_product/CMakeLists.txt9
-rw-r--r--eval/src/tests/instruction/sparse_112_dot_product/sparse_112_dot_product_test.cpp88
-rw-r--r--eval/src/vespa/eval/eval/fast_value.hpp21
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.h5
-rw-r--r--eval/src/vespa/eval/eval/optimize_tensor_function.cpp2
-rw-r--r--eval/src/vespa/eval/instruction/CMakeLists.txt1
-rw-r--r--eval/src/vespa/eval/instruction/generic_create.cpp90
-rw-r--r--eval/src/vespa/eval/instruction/sparse_112_dot_product.cpp236
-rw-r--r--eval/src/vespa/eval/instruction/sparse_112_dot_product.h31
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/Flags.java83
-rw-r--r--indexinglanguage/pom.xml5
-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--linguistics/pom.xml5
-rw-r--r--linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java32
-rw-r--r--linguistics/src/main/java/com/yahoo/language/opennlp/LanguageDetectorFactory.java28
-rw-r--r--linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java92
-rw-r--r--linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java25
-rw-r--r--linguistics/src/main/java/com/yahoo/language/opennlp/OptimaizeDetector.java107
-rw-r--r--linguistics/src/main/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizer.java31
-rw-r--r--linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java6
-rw-r--r--linguistics/src/main/java/com/yahoo/language/simple/SimpleLinguistics.java4
-rw-r--r--linguistics/src/main/resources/configdefinitions/language.opennlp.opennlp-linguistics.def6
-rw-r--r--linguistics/src/main/resources/models/langdetect-183.binbin0 -> 10568240 bytes
-rw-r--r--linguistics/src/test/java/com/yahoo/language/opennlp/OpenNlpDetectorTestCase.java87
-rw-r--r--linguistics/src/test/java/com/yahoo/language/opennlp/OptimaizeDetectorTestCase.java35
-rw-r--r--linguistics/src/test/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizerTest.java20
-rw-r--r--logd/src/logd/watcher.cpp2
-rw-r--r--messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java135
-rw-r--r--orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java46
-rw-r--r--orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java15
-rw-r--r--orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java17
-rw-r--r--orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusServiceTest.java50
-rw-r--r--parent/pom.xml11
-rwxr-xr-xscrewdriver/release-java-artifacts.sh8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/changevector.h15
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumattribute.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumattribute.hpp9
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp8
-rw-r--r--security-utils/pom.xml5
-rw-r--r--security-utils/src/test/java/com/yahoo/security/KeyUtilsTest.java15
-rw-r--r--security-utils/src/test/java/com/yahoo/security/Pkcs10CsrUtilsTest.java7
-rw-r--r--security-utils/src/test/java/com/yahoo/security/X509CertificateUtilsTest.java13
-rw-r--r--storage/src/tests/storageserver/communicationmanagertest.cpp8
-rw-r--r--storage/src/vespa/storage/common/storagelink.cpp45
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.cpp5
-rw-r--r--vespa-feed-client-api/abi-spec.json15
-rw-r--r--vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClient.java19
-rw-r--r--vespa-feed-client-api/src/main/java/ai/vespa/feed/client/Helper.java42
-rw-r--r--vespa-feed-client-api/src/main/java/ai/vespa/feed/client/MultiFeedException.java38
-rw-r--r--vespa-feed-client-api/src/test/java/ai/vespa/feed/client/FeedClientTest.java105
-rw-r--r--vespa-hadoop/pom.xml43
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java41
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/documentapi/metrics/DocumentOperationStatus.java9
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java20
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java1
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java31
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java1
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java1
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java1
-rw-r--r--vespajlib/src/main/java/com/yahoo/io/TeeInputStream.java100
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorType.java5
-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
-rw-r--r--zookeeper-client-common/pom.xml10
-rw-r--r--zookeeper-command-line-client/pom.xml24
-rw-r--r--zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/FourLetterWordMain.java5
-rw-r--r--zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/Main.java6
356 files changed, 4684 insertions, 3968 deletions
diff --git a/application/pom.xml b/application/pom.xml
index 61cea1a1826..2496b8becc5 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -74,11 +74,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -97,17 +92,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>com.optimaize.languagedetector</groupId>
- <artifactId>language-detector</artifactId>
- <exclusions>
- <exclusion>
- <!-- We want to get this via jdisc-core -->
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
</dependency>
diff --git a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
index 215b0961509..800c30ac8b8 100644
--- a/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
+++ b/application/src/test/java/com/yahoo/application/ApplicationBuilderTest.java
@@ -8,7 +8,6 @@ import org.junit.rules.ExpectedException;
import java.nio.file.Files;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertTrue;
/**
@@ -49,6 +48,7 @@ public class ApplicationBuilderTest {
});
}
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -56,7 +56,7 @@ public class ApplicationBuilderTest {
@SuppressWarnings("try") // application unreferenced inside try
public void builder_cannot_be_reused() throws Exception {
expectedException.expect(RuntimeException.class);
- expectedException.expectMessage(containsString("build method"));
+ expectedException.expectMessage("build method");
ApplicationBuilder builder = new ApplicationBuilder();
builder.servicesXml("<container version=\"1.0\" />");
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java b/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
index 855a56293d0..7c786d35fab 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
@@ -16,10 +16,8 @@ import com.yahoo.processing.execution.chain.ChainRegistry;
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.sameInstance;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
@@ -75,13 +73,13 @@ public class ContainerDocprocTest {
processing = com.yahoo.docproc.Processing.of(put);
progress = docProc.process(ComponentSpecification.fromString(CHAIN_NAME), processing);
- assertThat(progress, sameInstance(DocumentProcessor.Progress.DONE));
- assertThat(doc.getFieldValue("title").toString(), equalTo("Terng Nyohz!"));
+ assertSame(progress, DocumentProcessor.Progress.DONE);
+ assertEquals("Terng Nyohz!", doc.getFieldValue("title").toString());
processing = com.yahoo.docproc.Processing.of(put);
progress = docProc.process(ComponentSpecification.fromString(CHAIN_NAME), processing);
- assertThat(progress, sameInstance(DocumentProcessor.Progress.DONE));
- assertThat(doc.getFieldValue("title").toString(), equalTo("Great Album!"));
+ assertSame(progress, DocumentProcessor.Progress.DONE);
+ assertEquals("Great Album!", doc.getFieldValue("title").toString());
}
}
@@ -107,16 +105,16 @@ public class ContainerDocprocTest {
processing = com.yahoo.docproc.Processing.of(put);
progress = docProc.processOnce(ComponentSpecification.fromString(CHAIN_NAME), processing);
- assertThat(progress, instanceOf(DocumentProcessor.LaterProgress.class));
- assertThat(doc.getFieldValue("title").toString(), equalTo("Great Album!"));
+ assertTrue(progress instanceof DocumentProcessor.LaterProgress);
+ assertEquals("Great Album!", doc.getFieldValue("title").toString());
progress = docProc.processOnce(ComponentSpecification.fromString(CHAIN_NAME), processing);
- assertThat(progress, instanceOf(DocumentProcessor.LaterProgress.class));
- assertThat(doc.getFieldValue("title").toString(), equalTo("Great Album!"));
+ assertTrue(progress instanceof DocumentProcessor.LaterProgress);
+ assertEquals("Great Album!", doc.getFieldValue("title").toString());
progress = docProc.processOnce(ComponentSpecification.fromString(CHAIN_NAME), processing);
- assertThat(progress, sameInstance(DocumentProcessor.Progress.DONE));
- assertThat(doc.getFieldValue("title").toString(), equalTo("Terng Nyohz!"));
+ assertSame(progress, DocumentProcessor.Progress.DONE);
+ assertEquals("Terng Nyohz!", doc.getFieldValue("title").toString());
}
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
index e0385543022..e5019d6b54f 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
@@ -10,10 +10,10 @@ import com.yahoo.processing.Response;
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -50,7 +50,7 @@ public class ContainerProcessingTest {
req.properties().set("title", "Good day!");
Response response = processing.process(ComponentSpecification.fromString("foo"), req);
- assertThat(response.data().get(0).toString(), equalTo("Tbbq qnl!"));
+ assertEquals("Tbbq qnl!", response.data().get(0).toString());
}
}
@@ -69,7 +69,7 @@ public class ContainerProcessingTest {
container.handleRequest(
new com.yahoo.application.container.handler.Request("http://foo/processing/?chain=foo&title=" + foo.toString()));
- assertThat(response.getBody().length, is(SIZE+26));
+ assertEquals(SIZE+26, response.getBody().length);
}
}
}
@@ -84,9 +84,9 @@ public class ContainerProcessingTest {
byte[] rendered = processing.processAndRender(ComponentSpecification.fromString("foo"),
ComponentSpecification.fromString("default"), req);
- String renderedAsString = new String(rendered, "utf-8");
+ String renderedAsString = new String(rendered, StandardCharsets.UTF_8);
- assertThat(renderedAsString, containsString("Tbbq qnl!"));
+ assertTrue(renderedAsString.contains("Tbbq qnl!"));
}
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java b/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
index 98f35d5ed6c..911d57a7d6e 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
@@ -15,9 +15,8 @@ import org.junit.Test;
import java.nio.charset.CharacterCodingException;
-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;
/**
* @author Einar M R Rosenvinge
@@ -44,7 +43,7 @@ public class ContainerRequestTest {
try (JDisc container = JDisc.fromServicesXml(getXML(EchoRequestHandler.class.getCanonicalName(), "http://*/echo"), Networking.disable)) {
Response response = container.handleRequest(req);
- assertThat(response.getBodyAsString(), equalTo(DATA));
+ assertEquals(DATA, response.getBodyAsString());
req.toString();
response.toString();
}
@@ -57,7 +56,7 @@ public class ContainerRequestTest {
try (JDisc container = JDisc.fromServicesXml(getXML(HeaderEchoRequestHandler.class.getCanonicalName(), "http://*/echo"), Networking.disable)) {
Response response = container.handleRequest(req);
- assertThat(response.getHeaders().contains("X-Foo", "Bar"), is(true));
+ assertTrue(response.getHeaders().contains("X-Foo", "Bar"));
req.toString();
response.toString();
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java b/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
index 40bdf023c63..e1e520bccc9 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
@@ -10,9 +10,8 @@ import org.junit.Test;
import java.nio.charset.StandardCharsets;
-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;
/**
* @author gjoranv
@@ -28,7 +27,7 @@ public class ContainerSchemaTest {
byte[] rendered = container.search().processAndRender(ComponentSpecification.fromString("mychain"),
ComponentSpecification.fromString("XmlRenderer"), new Query(""));
String renderedAsString = new String(rendered, StandardCharsets.UTF_8);
- assertThat(renderedAsString, containsString(searcherId));
+ assertTrue(renderedAsString.contains(searcherId));
}
}
@@ -40,7 +39,7 @@ public class ContainerSchemaTest {
Search searching = container.search();
Result result = searching.process(ComponentSpecification.fromString("mychain"), new Query(""));
String hitTitle = result.hits().get(0).getField("title").toString();
- assertThat(hitTitle, is(searcherId));
+ assertEquals(searcherId, hitTitle);
}
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerTest.java b/application/src/test/java/com/yahoo/application/container/ContainerTest.java
index a46ae6e1ef5..f36237066b5 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerTest.java
@@ -8,9 +8,6 @@ import com.yahoo.application.container.handler.Request;
import com.yahoo.application.container.handler.Response;
import com.yahoo.application.container.handlers.TestHandler;
import com.yahoo.component.ComponentSpecification;
-import com.yahoo.container.Container;
-import com.yahoo.jdisc.http.server.jetty.JettyHttpServer;
-import com.yahoo.jdisc.service.ServerProvider;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import org.junit.Ignore;
@@ -20,11 +17,9 @@ import java.nio.charset.CharacterCodingException;
import java.nio.file.FileSystems;
import static com.yahoo.application.container.JDisc.fromServicesXml;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.hasItem;
-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;
import static org.junit.Assert.fail;
/**
@@ -73,7 +68,7 @@ public class ContainerTest {
"</services>", Networking.disable)) {
fail("expected exception");
} catch (Exception e) {
- assertThat(e.getMessage(), containsString("container id='id1', container id='', jdisc id=''"));
+ assertTrue(e.getMessage().contains("container id='id1', container id='', jdisc id=''"));
}
}
@@ -87,7 +82,7 @@ public class ContainerTest {
"</container>", Networking.disable)) {
Response response = container.handleRequest(new Request("http://foo/TestHandler"));
try {
- assertThat(response.getBodyAsString(), is(TestHandler.RESPONSE));
+ assertEquals(TestHandler.RESPONSE, response.getBodyAsString());
} catch (CharacterCodingException e) {
throw new RuntimeException(e);
}
@@ -100,7 +95,7 @@ public class ContainerTest {
Networking.disable)) {
Result result = container.search().process(ComponentSpecification.fromString("default"),
new Query("?query=ignored"));
- assertThat(result.hits().get(0).getField("title").toString(), is("Heal the World!"));
+ assertEquals("Heal the World!", result.hits().get(0).getField("title").toString());
}
}
@@ -110,7 +105,7 @@ public class ContainerTest {
.servicesXml(CONTAINER_WITH_DOCUMENT_PROCESSING).build()) {
JDisc container = application.getJDisc("container");
DocumentProcessing processing = container.documentProcessing();
- assertThat(processing.getDocumentTypes().keySet(), hasItem("example"));
+ assertTrue(processing.getDocumentTypes().containsKey("example"));
}
}
@@ -123,7 +118,7 @@ public class ContainerTest {
servicesXml(CONTAINER_WITH_DOCUMENT_PROCESSING).build()) {
JDisc container = application.getJDisc("container");
DocumentProcessing processing = container.documentProcessing();
- assertThat(processing.getAnnotationTypes().keySet(), hasItem("exampleAnnotation"));
+ assertTrue(processing.getAnnotationTypes().containsKey("exampleAnnotation"));
}
}
@@ -138,7 +133,7 @@ public class ContainerTest {
private void sendRequest(JDisc jdisc) throws CharacterCodingException {
Response response = jdisc.handleRequest(new Request("http://foo/TestHandler"));
- assertThat(response.getBodyAsString(), is(TestHandler.RESPONSE));
+ assertEquals(TestHandler.RESPONSE, response.getBodyAsString());
}
public static final String CONTAINER_WITH_DOCUMENT_PROCESSING = //
@@ -169,13 +164,4 @@ public class ContainerTest {
return JDisc.fromServicesXml(xml, Networking.disable);
}
- public static int getListenPort() {
- for (ServerProvider server : Container.get().getServerProviderRegistry().allComponents()) {
- if (null != server && server instanceof JettyHttpServer) {
- return ((JettyHttpServer) server).getListenPort();
- }
- }
- throw new RuntimeException("No http server found");
- }
-
}
diff --git a/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java b/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
index 315ccb9d708..edd2acb630d 100644
--- a/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
+++ b/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
@@ -3,10 +3,8 @@ package com.yahoo.application.container.handler;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.equalTo;
-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;
/**
* @author Einar M R Rosenvinge
@@ -15,16 +13,16 @@ public class ResponseTestCase {
@Test
public void requireThatCharsetParsingWorks() {
- assertThat(Response.charset("text/foobar").toString().toLowerCase(), equalTo("utf-8"));
- assertThat(Response.charset("adsf").toString().toLowerCase(), equalTo("utf-8"));
- assertThat(Response.charset("").toString().toLowerCase(), equalTo("utf-8"));
- assertThat(Response.charset(null).toString().toLowerCase(), equalTo("utf-8"));
+ assertEquals("utf-8", Response.charset("text/foobar").toString().toLowerCase());
+ assertEquals("utf-8", Response.charset("adsf").toString().toLowerCase());
+ assertEquals("utf-8", Response.charset("").toString().toLowerCase());
+ assertEquals("utf-8", Response.charset(null).toString().toLowerCase());
- assertThat(Response.charset("something; charset=US-ASCII").toString().toLowerCase(), equalTo("us-ascii"));
- assertThat(Response.charset("something; charset=iso-8859-1").toString().toLowerCase(), equalTo("iso-8859-1"));
+ assertEquals("us-ascii", Response.charset("something; charset=US-ASCII").toString().toLowerCase());
+ assertEquals("iso-8859-1", Response.charset("something; charset=iso-8859-1").toString().toLowerCase());
- assertThat(Response.charset("something; charset=").toString().toLowerCase(), equalTo("utf-8"));
- assertThat(Response.charset("something; charset=bananarama").toString().toLowerCase(), equalTo("utf-8"));
+ assertEquals("utf-8", Response.charset("something; charset=").toString().toLowerCase());
+ assertEquals("utf-8", Response.charset("something; charset=bananarama").toString().toLowerCase());
}
@Test
@@ -32,9 +30,9 @@ public class ResponseTestCase {
Response res1 = new Response();
Response res2 = new Response(new byte[0]);
- assertThat(res1.getBody(), notNullValue());
- assertThat(res1.getBody().length, is(0));
- assertThat(res2.getBody(), notNullValue());
- assertThat(res2.getBody().length, is(0));
+ assertNotNull(res1.getBody());
+ assertEquals(0, res1.getBody().length);
+ assertNotNull(res2.getBody());
+ assertEquals(0, res2.getBody().length);
}
}
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
index ee7b6c9c2f1..29f2be838a1 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
@@ -76,6 +76,7 @@ public class ImportPackageTest {
assertTrue(new Import("foo", Optional.empty()).importVersionRange().isEmpty());
}
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/cloud-tenant-base-dependencies-enforcer/pom.xml b/cloud-tenant-base-dependencies-enforcer/pom.xml
index fa1b8555c69..2025431d86c 100644
--- a/cloud-tenant-base-dependencies-enforcer/pom.xml
+++ b/cloud-tenant-base-dependencies-enforcer/pom.xml
@@ -219,7 +219,6 @@
<include>com.ibm.icu:icu4j:57.1:jar:test</include>
<include>com.intellij:annotations:12.0:jar:test</include>
<include>com.microsoft.onnxruntime:onnxruntime:[${onnxruntime.version}]:jar:test</include>
- <include>com.optimaize.languagedetector:language-detector:0.6:jar:test</include>
<include>com.thaiopensource:jing:20091111:jar:test</include>
<include>com.yahoo.athenz:athenz-auth-core:[${athenz.version}]:jar:test</include>
<include>com.yahoo.athenz:athenz-client-common:[${athenz.version}]:jar:test</include>
@@ -236,7 +235,7 @@
<include>io.prometheus:simpleclient:0.6.0:jar:test</include>
<include>io.prometheus:simpleclient_common:0.6.0:jar:test</include>
<include>joda-time:joda-time:2.8.1:jar:test</include>
- <include>junit:junit:4.13:jar:test</include>
+ <include>junit:junit:4.13.2:jar:test</include>
<include>net.arnx:jsonic:1.2.11:jar:test</include>
<include>net.java.dev.jna:jna:4.5.2:jar:test</include>
<include>org.abego.treelayout:org.abego.treelayout.core:1.0.1:jar:test</include>
@@ -249,7 +248,7 @@
<include>org.apache.httpcomponents.core5:httpcore5-h2:${httpclient5.version}:jar:test</include>
<include>org.apache.httpcomponents:httpclient:4.5.12:jar:test</include>
<include>org.apache.httpcomponents:httpcore:4.4.13:jar:test</include>
- <include>org.apache.opennlp:opennlp-tools:1.8.4:jar:test</include>
+ <include>org.apache.opennlp:opennlp-tools:1.9.3:jar:test</include>
<include>org.apiguardian:apiguardian-api:1.1.0:jar:test</include>
<include>org.codehaus.woodstox:stax2-api:3.1.4:jar:test</include>
<include>org.eclipse.jetty.alpn:alpn-api:[${jetty-alpn.version}]:jar:test</include>
@@ -275,7 +274,7 @@
<include>org.kohsuke:libpam4j:1.11:jar:test</include>
<include>org.opentest4j:opentest4j:1.2.0:jar:test</include>
<include>software.amazon.ion:ion-java:1.0.2:jar:test</include>
- <include>xerces:xercesImpl:2.12.0:jar:test</include>
+ <include>xerces:xercesImpl:2.12.1:jar:test</include>
</includes>
</bannedDependencies>
</rules>
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java
index 15b59e4e8e4..f857bfcee89 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateGeneratorTest.java
@@ -17,7 +17,7 @@ import static com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForN
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class ClusterStateGeneratorTest {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java
index 8e00593587a..ff1c5b0bb17 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ContentClusterHtmlRendererTest.java
@@ -16,7 +16,7 @@ import java.util.Collections;
import java.util.TreeMap;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
public class ContentClusterHtmlRendererTest {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java
index 35431703824..a621b0f565a 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java
@@ -8,8 +8,7 @@ import com.yahoo.vespa.clustercontroller.core.listeners.NodeAddedOrRemovedListen
import com.yahoo.vespa.clustercontroller.core.listeners.NodeStateOrHostInfoChangeHandler;
import org.junit.Test;
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -90,7 +89,7 @@ public class DatabaseHandlerTest {
when(f.mockDatabase.retrieveLastPublishedStateBundle()).thenReturn(f.dummyBundle);
ClusterStateBundle retrievedBundle = handler.getLatestClusterStateBundle();
- assertThat(retrievedBundle, equalTo(f.dummyBundle));
+ assertEquals(f.dummyBundle, retrievedBundle);
}
// FIXME I don't like the semantics of this, but it mirrors the legacy behavior for the
@@ -102,7 +101,7 @@ public class DatabaseHandlerTest {
// Note: no DB setup step
ClusterStateBundle retrievedBundle = handler.getLatestClusterStateBundle();
- assertThat(retrievedBundle, equalTo(ClusterStateBundle.empty()));
+ assertEquals(ClusterStateBundle.empty(), retrievedBundle);
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java
index a616f823ad0..48d6ccbf655 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/EventDiffCalculatorTest.java
@@ -12,7 +12,7 @@ import static com.yahoo.vespa.clustercontroller.core.matchers.EventTypeIs.eventT
import static com.yahoo.vespa.clustercontroller.core.matchers.EventTimeIs.eventTimeIs;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.hasItem;
import static com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
index a3bc39bde39..254f863e9ea 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAutoTakedownTest.java
@@ -20,7 +20,7 @@ import java.util.Set;
import static org.hamcrest.core.AllOf.allOf;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
index a533cd35f94..a5357e0a639 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/GroupAvailabilityCalculatorTest.java
@@ -11,7 +11,7 @@ import java.util.List;
import java.util.Set;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class GroupAvailabilityCalculatorTest {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
index cfcaf1ce0c5..418400b3fff 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/LeafGroupsTest.java
@@ -7,7 +7,7 @@ import org.junit.Test;
import java.util.List;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class LeafGroupsTest {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
index 4ddf6453981..2f79ad3fa95 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MaintenanceWhenPendingGlobalMergesTest.java
@@ -10,7 +10,7 @@ import java.util.Arrays;
import static com.yahoo.vespa.clustercontroller.core.NodeStateReason.MAY_HAVE_MERGES_PENDING;
import static com.yahoo.vespa.clustercontroller.core.NodeStateReason.NODE_TOO_UNSTABLE;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java
index bf3efb17ddf..ab638a1da7d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java
@@ -25,10 +25,8 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
-import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class MasterElectionTest extends FleetControllerTest {
@@ -504,7 +502,7 @@ public class MasterElectionTest extends FleetControllerTest {
final long postElectionVersionNumber = fleetControllers.get(1).getSystemState().getVersion();
- assertThat(postElectionVersionNumber, greaterThan(preElectionVersionNumber));
+ assertTrue(postElectionVersionNumber > preElectionVersionNumber);
}
@Test
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
index 3a301c52b42..87e102c67c1 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
@@ -20,12 +20,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -130,7 +127,7 @@ public class NodeStateChangeCheckerTest {
UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("Master cluster controller is bootstrapping and in moratorium"));
+ assertEquals("Master cluster controller is bootstrapping and in moratorium", result.getReason());
}
@Test
@@ -143,7 +140,7 @@ public class NodeStateChangeCheckerTest {
UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("Unknown node storage.10"));
+ assertEquals("Unknown node storage.10", result.getReason());
}
@Test
@@ -162,8 +159,8 @@ public class NodeStateChangeCheckerTest {
SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("At most one node can have a wanted state when #groups = 1: " +
- "Other storage node 0 has wanted state Maintenance"));
+ assertEquals("At most one node can have a wanted state when #groups = 1: Other storage node 0 has wanted state Maintenance",
+ result.getReason());
}
@Test
@@ -183,8 +180,8 @@ public class NodeStateChangeCheckerTest {
SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("At most one node can have a wanted state when #groups = 1: " +
- "Other distributor 0 has wanted state Down"));
+ assertEquals("At most one node can have a wanted state when #groups = 1: Other distributor 0 has wanted state Down",
+ result.getReason());
}
@Test
@@ -208,8 +205,7 @@ public class NodeStateChangeCheckerTest {
SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("At most one group can have wanted state: " +
- "Other distributor 0 in group 0 has wanted state Down"));
+ assertEquals("At most one group can have wanted state: Other distributor 0 in group 0 has wanted state Down", result.getReason());
}
{
@@ -243,8 +239,8 @@ public class NodeStateChangeCheckerTest {
SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("At most one group can have wanted state: " +
- "Other storage node 0 in group 0 has wanted state Maintenance"));
+ assertEquals("At most one group can have wanted state: Other storage node 0 in group 0 has wanted state Maintenance",
+ result.getReason());
}
{
@@ -306,7 +302,7 @@ public class NodeStateChangeCheckerTest {
UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), containsString("Safe-set of node state is only supported for storage nodes"));
+ assertTrue(result.getReason().contains("Safe-set of node state is only supported for storage nodes"));
}
@Test
@@ -327,7 +323,7 @@ public class NodeStateChangeCheckerTest {
UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("Another storage node has state DOWN: 3"));
+ assertEquals("Another storage node has state DOWN: 3", result.getReason());
}
@Test
@@ -394,8 +390,8 @@ public class NodeStateChangeCheckerTest {
UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("Distributor 0 says storage node 1 " +
- "has buckets with redundancy as low as 3, but we require at least 4"));
+ assertEquals("Distributor 0 says storage node 1 has buckets with redundancy as low as 3, but we require at least 4",
+ result.getReason());
}
@Test
@@ -445,7 +441,7 @@ public class NodeStateChangeCheckerTest {
nodeStorage, defaultAllUpClusterState(), SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), is("Distributor node 0 has not reported any cluster state version yet."));
+ assertEquals("Distributor node 0 has not reported any cluster state version yet.", result.getReason());
}
private NodeStateChangeChecker.Result transitionToSameState(State state, String oldDescription, String newDescription) {
@@ -559,7 +555,7 @@ public class NodeStateChangeCheckerTest {
NodeStateChangeChecker.Result result = transitionToMaintenanceWithOneStorageNodeDown(otherIndex);
assertFalse(result.settingWantedStateIsAllowed());
assertFalse(result.wantedStateAlreadySet());
- assertThat(result.getReason(), containsString("Another storage node has state DOWN: 2"));
+ assertTrue(result.getReason().contains("Another storage node has state DOWN: 2"));
}
@Test
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
index e98cea72d08..2361a5cefd8 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateVersionTrackerTest.java
@@ -9,12 +9,10 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo;
import org.junit.Test;
-import java.util.Arrays;
+import java.util.List;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -46,34 +44,34 @@ public class StateVersionTrackerTest {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(100);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2"), 123);
- assertThat(versionTracker.getCurrentVersion(), equalTo(101));
- assertThat(versionTracker.getVersionedClusterState().toString(), equalTo("version:101 distributor:2 storage:2"));
+ assertEquals(101, versionTracker.getCurrentVersion());
+ assertEquals("version:101 distributor:2 storage:2", versionTracker.getVersionedClusterState().toString());
}
@Test
public void version_is_1_upon_construction() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
- assertThat(versionTracker.getCurrentVersion(), equalTo(1));
+ assertEquals(1, versionTracker.getCurrentVersion());
}
@Test
public void set_current_version_caps_lowest_version_to_1() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(0);
- assertThat(versionTracker.getCurrentVersion(), equalTo(1));
+ assertEquals(1, versionTracker.getCurrentVersion());
}
@Test
public void new_version_from_zk_predicate_initially_false() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
- assertThat(versionTracker.hasReceivedNewVersionFromZooKeeper(), is(false));
+ assertFalse(versionTracker.hasReceivedNewVersionFromZooKeeper());
}
@Test
public void new_version_from_zk_predicate_true_after_setting_zk_version() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(5);
- assertThat(versionTracker.hasReceivedNewVersionFromZooKeeper(), is(true));
+ assertTrue(versionTracker.hasReceivedNewVersionFromZooKeeper());
}
@Test
@@ -81,14 +79,14 @@ public class StateVersionTrackerTest {
final StateVersionTracker versionTracker = createWithMockedMetrics();
versionTracker.setVersionRetrievedFromZooKeeper(5);
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:2 storage:2"), 123);
- assertThat(versionTracker.hasReceivedNewVersionFromZooKeeper(), is(false));
+ assertFalse(versionTracker.hasReceivedNewVersionFromZooKeeper());
}
@Test
public void exposed_states_are_empty_upon_construction() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
- assertThat(versionTracker.getVersionedClusterState().toString(), equalTo(""));
- assertThat(versionTracker.getAnnotatedVersionedClusterState().getClusterState().toString(), equalTo(""));
+ assertTrue(versionTracker.getVersionedClusterState().toString().isEmpty());
+ assertTrue(versionTracker.getAnnotatedVersionedClusterState().getClusterState().toString().isEmpty());
}
@Test
@@ -143,20 +141,20 @@ public class StateVersionTrackerTest {
@Test
public void lowest_observed_distribution_bit_is_initially_16() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
- assertThat(versionTracker.getLowestObservedDistributionBits(), equalTo(16));
+ assertEquals(16, versionTracker.getLowestObservedDistributionBits());
}
@Test
public void lowest_observed_distribution_bit_is_tracked_across_states() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
updateAndPromote(versionTracker, stateWithoutAnnotations("bits:15 distributor:2 storage:2"), 100);
- assertThat(versionTracker.getLowestObservedDistributionBits(), equalTo(15));
+ assertEquals(15, versionTracker.getLowestObservedDistributionBits());
updateAndPromote(versionTracker, stateWithoutAnnotations("bits:17 distributor:2 storage:2"), 200);
- assertThat(versionTracker.getLowestObservedDistributionBits(), equalTo(15));
+ assertEquals(15, versionTracker.getLowestObservedDistributionBits());
updateAndPromote(versionTracker, stateWithoutAnnotations("bits:14 distributor:2 storage:2"), 300);
- assertThat(versionTracker.getLowestObservedDistributionBits(), equalTo(14));
+ assertEquals(14, versionTracker.getLowestObservedDistributionBits());
}
// For similarity purposes, only the cluster-wide bits matter, not the individual node state
@@ -201,11 +199,8 @@ public class StateVersionTrackerTest {
String s2 = "version:2 distributor:2 storage:2";
// Note: newest entry first
- assertThat(versionTracker.getClusterStateHistory(),
- equalTo(Arrays.asList(
- historyEntry(s4, s3, 300),
- historyEntry(s3, s2, 200),
- historyEntry(s2, 100))));
+ assertEquals(List.of(historyEntry(s4, s3, 300), historyEntry(s3, s2, 200), historyEntry(s2, 100)),
+ versionTracker.getClusterStateHistory());
}
@Test
@@ -222,17 +217,13 @@ public class StateVersionTrackerTest {
String s3 = "version:3 distributor:3 storage:3";
String s2 = "version:2 distributor:2 storage:2";
- assertThat(versionTracker.getClusterStateHistory(),
- equalTo(Arrays.asList(
- historyEntry(s4, s3, 300),
- historyEntry(s3, s2, 200))));
+ assertEquals(List.of(historyEntry(s4, s3, 300), historyEntry(s3, s2, 200)),
+ versionTracker.getClusterStateHistory());
updateAndPromote(versionTracker, stateWithoutAnnotations("distributor:5 storage:5"), 400);
- assertThat(versionTracker.getClusterStateHistory(),
- equalTo(Arrays.asList(
- historyEntry(s5, s4, 400),
- historyEntry(s4, s3, 300))));
+ assertEquals(List.of(historyEntry(s5, s4, 400), historyEntry(s4, s3, 300)),
+ versionTracker.getClusterStateHistory());
}
@Test
@@ -241,11 +232,11 @@ public class StateVersionTrackerTest {
AnnotatedClusterState candidate = stateWithoutAnnotations("distributor:2 storage:2");
versionTracker.updateLatestCandidateStateBundle(ClusterStateBundle.ofBaselineOnly(candidate));
- assertThat(versionTracker.getLatestCandidateState(), equalTo(candidate));
+ assertEquals(candidate, versionTracker.getLatestCandidateState());
candidate = stateWithoutAnnotations("distributor:3 storage:3");
versionTracker.updateLatestCandidateStateBundle(ClusterStateBundle.ofBaselineOnly(candidate));
- assertThat(versionTracker.getLatestCandidateState(), equalTo(candidate));
+ assertEquals(candidate, versionTracker.getLatestCandidateState());
}
private static ClusterState stateOf(String state) {
@@ -327,9 +318,9 @@ public class StateVersionTrackerTest {
versionTracker.setVersionRetrievedFromZooKeeper(200);
versionTracker.setClusterStateBundleRetrievedFromZooKeeper(zkBundle);
- assertThat(versionTracker.getLatestCandidateState(), equalTo(AnnotatedClusterState.emptyState()));
- assertThat(versionTracker.getVersionedClusterStateBundle(), equalTo(zkBundle));
- assertThat(versionTracker.getCurrentVersion(), equalTo(200)); // Not from bundle, but from explicitly stored version
+ assertEquals(AnnotatedClusterState.emptyState(), versionTracker.getLatestCandidateState());
+ assertEquals(zkBundle, versionTracker.getVersionedClusterStateBundle());
+ assertEquals(200, versionTracker.getCurrentVersion()); // Not from bundle, but from explicitly stored version
}
private HostInfo createHostInfo(long bucketsPending) {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
index a71665fb364..7d64a8f8878 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperDatabaseTest.java
@@ -11,12 +11,12 @@ import org.junit.rules.ExpectedException;
import java.io.IOException;
import java.time.Duration;
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
public class ZooKeeperDatabaseTest {
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -66,7 +66,7 @@ public class ZooKeeperDatabaseTest {
f.db().storeLastPublishedStateBundle(bundleToStore);
ClusterStateBundle bundleReceived = f.db().retrieveLastPublishedStateBundle();
- assertThat(bundleReceived, equalTo(bundleToStore));
+ assertEquals(bundleToStore, bundleReceived);
}
}
@@ -102,7 +102,7 @@ public class ZooKeeperDatabaseTest {
f.createDatabase();
ClusterStateBundle bundleReceived = f.db().retrieveLastPublishedStateBundle();
- assertThat(bundleReceived, equalTo(ClusterStateBundle.empty()));
+ assertEquals(ClusterStateBundle.empty(), bundleReceived);
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
index 98fc879adbc..b5ad82b6b0c 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/hostinfo/HostInfoTest.java
@@ -13,13 +13,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.core.Is.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;
public class HostInfoTest {
@@ -35,41 +31,40 @@ public class HostInfoTest {
@Test
public void testEmptyJson() {
HostInfo hostInfo = HostInfo.createHostInfo("{}");
- assertThat(hostInfo.getVtag().getVersionOrNull(), is(nullValue()));
- assertThat(hostInfo.getDistributor().getStorageNodes().size(), is(0));
- assertThat(hostInfo.getContentNode().getResourceUsage().size(), is(0));
- assertThat(hostInfo.getMetrics().getMetrics().size(), is(0));
- assertThat(hostInfo.getClusterStateVersionOrNull(), is(nullValue()));
+ assertNull(hostInfo.getVtag().getVersionOrNull());
+ assertTrue(hostInfo.getDistributor().getStorageNodes().isEmpty());
+ assertTrue(hostInfo.getContentNode().getResourceUsage().isEmpty());
+ assertTrue(hostInfo.getMetrics().getMetrics().isEmpty());
+ assertNull(hostInfo.getClusterStateVersionOrNull());
}
@Test
public void testExtendedJson() throws IOException {
HostInfo hostInfo = HostInfo.createHostInfo(readDataFile("host_info.json"));
- assertThat(hostInfo.getVtag().getVersionOrNull(), is("5.32.76"));
+ assertEquals("5.32.76", hostInfo.getVtag().getVersionOrNull());
}
@Test
public void testFullSet() throws IOException {
HostInfo hostInfo = HostInfo.createHostInfo(readDataFile("host_info.json"));
List<StorageNode> storageNodeList = hostInfo.getDistributor().getStorageNodes();
- assertThat(storageNodeList.size(), is(2));
- assertThat(storageNodeList.get(0).getIndex(), is(0));
+ assertEquals(2, storageNodeList.size());
+ assertEquals(0, storageNodeList.get(0).getIndex().intValue());
List<Metrics.Metric> metrics = hostInfo.getMetrics().getMetrics();
- assertThat(metrics.size(), is(4));
- assertThat(metrics.get(0).getValue().getLast(), is(5095L));
- assertThat(metrics.get(0).getName(), equalTo("vds.datastored.alldisks.buckets"));
- assertThat(metrics.get(3).getValue().getLast(), is(129L));
- assertThat(metrics.get(3).getName(), equalTo("vds.datastored.bucket_space.buckets_total"));
- assertThat(hostInfo.getClusterStateVersionOrNull(), is(123));
-
- assertThat(hostInfo.getMetrics()
+ assertEquals(4, metrics.size());
+ assertEquals(5095L, metrics.get(0).getValue().getLast().longValue());
+ assertEquals("vds.datastored.alldisks.buckets", metrics.get(0).getName());
+ assertEquals(129L, metrics.get(3).getValue().getLast().longValue());
+ assertEquals("vds.datastored.bucket_space.buckets_total", metrics.get(3).getName());
+ assertEquals(123, hostInfo.getClusterStateVersionOrNull().intValue());
+
+ assertEquals(Optional.of(129L), hostInfo.getMetrics()
.getValueAt("vds.datastored.bucket_space.buckets_total", Map.of("bucketSpace", "default"))
- .map(Metrics.Value::getLast),
- equalTo(Optional.of(129L)));
- assertThat(hostInfo.getMetrics()
+ .map(Metrics.Value::getLast));
+ assertEquals(Optional.of(0L),
+ hostInfo.getMetrics()
.getValueAt("vds.datastored.bucket_space.buckets_total", Map.of("bucketSpace", "global"))
- .map(Metrics.Value::getLast),
- equalTo(Optional.of(0L)));
+ .map(Metrics.Value::getLast));
var resourceUsage = hostInfo.getContentNode().getResourceUsage();
assertEquals(resourceUsage.size(), 2);
@@ -102,7 +97,7 @@ public class HostInfoTest {
HostInfo hostInfo = HostInfo.createHostInfo(json);
List<StorageNode> storageNodeList = hostInfo.getDistributor().getStorageNodes();
- assertThat(storageNodeList.size(), is(2));
+ assertEquals(2, storageNodeList.size());
Map<Integer, StorageNode> storageNodeByIndex = new TreeMap<>();
for (StorageNode node : storageNodeList) {
Integer index = node.getIndex();
@@ -111,11 +106,11 @@ public class HostInfoTest {
}
assertTrue(storageNodeByIndex.containsKey(0));
- assertThat(storageNodeByIndex.get(0).getIndex(), is(0));
- assertThat(storageNodeByIndex.get(0).getMinCurrentReplicationFactorOrNull(), is(2));
+ assertEquals(0, storageNodeByIndex.get(0).getIndex().intValue());
+ assertEquals(2, storageNodeByIndex.get(0).getMinCurrentReplicationFactorOrNull().intValue());
assertTrue(storageNodeByIndex.containsKey(5));
- assertThat(storageNodeByIndex.get(5).getIndex(), is(5));
- assertThat(storageNodeByIndex.get(5).getMinCurrentReplicationFactorOrNull(), is(9));
+ assertEquals(5, storageNodeByIndex.get(5).getIndex().intValue());
+ assertEquals(9, storageNodeByIndex.get(5).getMinCurrentReplicationFactorOrNull().intValue());
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
index 086098514e2..685ad3f0b43 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
@@ -44,6 +44,7 @@ import static org.mockito.Mockito.when;
public class SetNodeStateTest extends StateRestApiTest {
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java
index 8fc5e8ac208..3d3347acb2d 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java
@@ -8,7 +8,7 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class SlimeClusterStateBundleCodecTest {
@@ -45,7 +45,7 @@ public class SlimeClusterStateBundleCodecTest {
}
// Exact same state set string repeated twice; perfect compression fodder.
return ClusterStateBundleUtil.makeBundle(String.format("distributor:100%s storage:100%s",
- allDownStates.toString(), allDownStates.toString()));
+ allDownStates, allDownStates));
}
@Test
diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
index 7b2c2757b56..613cfe1cced 100644
--- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java
@@ -26,14 +26,10 @@ import static com.yahoo.test.FunctionTestConfig.RootStruct;
import static com.yahoo.test.FunctionTestConfig.MyStructMap;
import static com.yahoo.foo.MaptypesConfig.Innermap;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.startsWith;
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.assertTrue;
/**
@@ -51,8 +47,8 @@ public class ConfigInstanceBuilderTest
.gender(FEMALE);
StructtypesConfig config = builder.build();
- assertThat(config.simple().name(), is("myname"));
- assertThat(config.simple().gender(), is(FEMALE));
+ assertEquals("myname", config.simple().name());
+ assertEquals(FEMALE, config.simple().gender());
}
@Test
@@ -65,8 +61,8 @@ public class ConfigInstanceBuilderTest
builder.intmap(newMap);
MaptypesConfig config = new MaptypesConfig(builder);
- assertThat(config.intmap("one"), is(1));
- assertThat(config.intmap("two"), is(2));
+ assertEquals(1, config.intmap("one"));
+ assertEquals(2, config.intmap("two"));
}
@Test
@@ -80,8 +76,8 @@ public class ConfigInstanceBuilderTest
builder.innermap(newMap);
MaptypesConfig config = new MaptypesConfig(builder);
- assertThat(config.innermap("one").foo(), is(1));
- assertThat(config.innermap("two").foo(), is(2));
+ assertEquals(1, config.innermap("one").foo());
+ assertEquals(2, config.innermap("two").foo());
}
@Test
@@ -262,12 +258,12 @@ public class ConfigInstanceBuilderTest
assertEquals("etc", config.fileVal().value());
assertEquals(1, config.boolarr().size());
assertEquals(1, config.boolarr().size()); // new api with accessor for a List of the original Java type
- assertEquals(false, config.boolarr().get(0)); // new List api
- assertEquals(false, config.boolarr(0)); // short-hand
+ assertFalse(config.boolarr().get(0)); // new List api
+ assertFalse(config.boolarr(0)); // short-hand
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());
@@ -279,25 +275,25 @@ public class ConfigInstanceBuilderTest
assertEquals("parent:", config.refarr(2));
assertEquals("bin", config.fileArr(0).value());
- assertThat(config.intMap("one"), is(1));
- assertThat(config.intMap("two"), is(2));
- assertThat(config.stringMap("one"), is("first"));
- assertThat(config.filemap("f1").value(), is("/var"));
- assertThat(config.filemap("f2").value(), is("/store"));
+ assertEquals(1, config.intMap("one"));
+ assertEquals(2, config.intMap("two"));
+ assertEquals("first", config.stringMap("one"));
+ assertEquals("/var", config.filemap("f1").value());
+ assertEquals("/store", config.filemap("f2").value());
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());
assertEquals("inner1", config.rootStruct().inner1().name());
assertEquals(12, config.rootStruct().inner1().index());
assertEquals(2, config.rootStruct().innerArr().size());
- assertEquals(true, config.rootStruct().innerArr(0).boolVal());
+ assertTrue(config.rootStruct().innerArr(0).boolVal());
assertEquals("deep", config.rootStruct().innerArr(0).stringVal());
- assertEquals(false, config.rootStruct().innerArr(1).boolVal());
+ assertFalse(config.rootStruct().innerArr(1).boolVal());
assertEquals("blue a=\"escaped\"", config.rootStruct().innerArr(1).stringVal());
assertEquals(2, config.myarray().size()); // new List api
@@ -311,12 +307,12 @@ public class ConfigInstanceBuilderTest
assertEquals(-1, config.myarray(1).myStruct().a());
assertEquals(-2, config.myarray(1).myStruct().b());
- assertThat(config.myStructMap("one").myInt(), is(1));
- assertThat(config.myStructMap("one").myString(), is("bull"));
- assertThat(config.myStructMap("one").myIntDef(), is(2));
- assertThat(config.myStructMap("one").myStringDef(), is("bear"));
- assertThat(config.myStructMap("one").anotherMap("anotherOne").anInt(), is(3));
- assertThat(config.myStructMap("one").anotherMap("anotherOne").anIntDef(), is(4));
+ assertEquals(1, config.myStructMap("one").myInt());
+ assertEquals("bull", config.myStructMap("one").myString());
+ assertEquals(2, config.myStructMap("one").myIntDef());
+ assertEquals("bear", config.myStructMap("one").myStringDef());
+ assertEquals(3, config.myStructMap("one").anotherMap("anotherOne").anInt());
+ assertEquals(4, config.myStructMap("one").anotherMap("anotherOne").anIntDef());
}
private boolean callContainsFieldsFlaggedWithRestart(Class<?> configClass)
@@ -372,9 +368,8 @@ public class ConfigInstanceBuilderTest
report = callGetChangesRequiringRestart(function1, function2);
assertTrue(report.needsRestart());
assertEquals("function-test", report.getName());
- assertThat(
- report.toString(),
- startsWith(
+ assertTrue(
+ report.toString().startsWith(
"# An int value\n" +
"# Also test that multiline comments\n" +
"# work.\n" +
@@ -398,9 +393,8 @@ public class ConfigInstanceBuilderTest
)
);
- assertThat(
- report.toString(),
- containsString(
+ assertTrue(
+ report.toString().contains(
"function-test.myStructMap{one}.myInt has changed from 1 to 42\n" +
"function-test.myStructMap{new} was added with value \n"
)
@@ -410,9 +404,8 @@ public class ConfigInstanceBuilderTest
FunctionTestConfig function3 = new FunctionTestConfig(funcBuilder);
report = callGetChangesRequiringRestart(function2, function3);
assertEquals(1, report.getReportLines().size());
- assertThat(
- report.toString(),
- containsString("function-test.myStructMap{one} with value \n")
+ assertTrue(
+ report.toString().contains("function-test.myStructMap{one} with value \n")
);
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
index 1ca33b8628a..536c18786da 100644
--- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java
@@ -14,10 +14,8 @@ import static com.yahoo.test.FunctionTestConfig.Enum_val;
import static com.yahoo.test.FunctionTestConfig.Enumarr;
import static com.yahoo.test.FunctionTestConfig.Myarray;
import static com.yahoo.test.FunctionTestConfig.RootStruct;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
public class ConfigInstanceEqualsTest {
FunctionTestConfig config1;
@@ -33,90 +31,90 @@ public class ConfigInstanceEqualsTest {
@Test
public void require_same_hashCode_for_equal_instances() {
- assertThat(config1.hashCode(), is(config2.hashCode()));
+ assertEquals(config1.hashCode(), config2.hashCode());
}
@Test
public void require_true_for_equal_instances() {
- assertThat(config1, is(config2));
+ assertEquals(config1, config2);
}
@Test
public void require_false_for_null() {
- assertThat(config1, not((FunctionTestConfig) null));
+ assertNotEquals(null, config1);
}
@Test
public void require_false_for_different_subclass() {
- assertFalse(config1.equals(new AppConfig(new AppConfig.Builder())));
+ assertNotEquals(config1, new AppConfig(new AppConfig.Builder()));
}
@Test
public void require_false_for_different_scalars_at_root_node() {
- assertThat(config1, not(new FunctionTestConfig(newBuilder().bool_val(true))));
- assertThat(config1, not(new FunctionTestConfig(newBuilder().int_val(0))));
- assertThat(config1, not(new FunctionTestConfig(newBuilder().long_val(0L))));
- assertThat(config1, not(new FunctionTestConfig(newBuilder().double_val(0.0))));
- assertThat(config1, not(new FunctionTestConfig(newBuilder().string_val(""))));
- assertThat(config1, not(new FunctionTestConfig(newBuilder().enum_val(Enum_val.FOO))));
- assertThat(config1, not(new FunctionTestConfig(newBuilder().refval(""))));
- assertThat(config1, not(new FunctionTestConfig(newBuilder().fileVal(""))));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().bool_val(true)));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().int_val(0)));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().long_val(0L)));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().double_val(0.0)));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().string_val("")));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().enum_val(Enum_val.FOO)));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().refval("")));
+ assertNotEquals(config1, new FunctionTestConfig(newBuilder().fileVal("")));
}
@Test
public void require_false_for_different_leaf_array_at_root_node() {
builder2.longarr.set(0, 0L);
- assertThat(config1, not(new FunctionTestConfig(builder2)));
+ assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
public void require_false_for_different_scalar_in_struct() {
builder2.basicStruct(new BasicStruct.Builder(config1.basicStruct()).bar(0));
- assertThat(config1, not(new FunctionTestConfig(builder2)));
+ assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
public void require_false_for_different_scalar_in_inner_array() {
builder2.myarray.get(0).intval(0);
- assertThat(config1, not(new FunctionTestConfig(builder2)));
+ assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
public void require_false_for_different_leaf_array_in_inner_array() {
builder2.myarray.get(0).stringval.set(0, "");
- assertThat(config1, not(new FunctionTestConfig(builder2)));
+ assertNotEquals(config1, new FunctionTestConfig(builder2));
}
@Test
public void require_equal_structs_for_equal_configs() {
- assertThat(config1.basicStruct(), is(config2.basicStruct()));
- assertThat(config1.rootStruct(), is(config2.rootStruct()));
- assertThat(config1.rootStruct().inner0(), is(config2.rootStruct().inner0()));
+ assertEquals(config1.basicStruct(), config2.basicStruct());
+ assertEquals(config1.rootStruct(), config2.rootStruct());
+ assertEquals(config1.rootStruct().inner0(), config2.rootStruct().inner0());
}
@Test
public void require_equal_inner_arrays_for_equal_configs() {
- assertThat(config1.myarray(), is(config2.myarray()));
- assertThat(config1.myarray(0).anotherarray(), is(config2.myarray(0).anotherarray()));
+ assertEquals(config1.myarray(), config2.myarray());
+ assertEquals(config1.myarray(0).anotherarray(), config2.myarray(0).anotherarray());
}
@Test
public void require_equal_inner_array_elements_for_equal_configs() {
- assertThat(config1.myarray(0), is(config2.myarray(0)));
- assertThat(config1.myarray(0).anotherarray(0), is(config2.myarray(0).anotherarray(0)));
+ assertEquals(config1.myarray(0), config2.myarray(0));
+ assertEquals(config1.myarray(0).anotherarray(0), config2.myarray(0).anotherarray(0));
}
@Test
public void require_equal_leaf_arrays_for_equal_configs() {
- assertThat(config1.intarr(), is(config2.intarr()));
- assertThat(config1.boolarr(), is(config2.boolarr()));
- assertThat(config1.longarr(), is(config2.longarr()));
- assertThat(config1.doublearr(), is(config2.doublearr()));
- assertThat(config1.stringarr(), is(config2.stringarr()));
- assertThat(config1.enumarr(), is(config2.enumarr()));
- assertThat(config1.refarr(), is(config2.refarr()));
- assertThat(config1.fileArr(), is(config2.fileArr()));
+ assertEquals(config1.intarr(), config2.intarr());
+ assertEquals(config1.boolarr(), config2.boolarr());
+ assertEquals(config1.longarr(), config2.longarr());
+ assertEquals(config1.doublearr(), config2.doublearr());
+ assertEquals(config1.stringarr(), config2.stringarr());
+ assertEquals(config1.enumarr(), config2.enumarr());
+ assertEquals(config1.refarr(), config2.refarr());
+ assertEquals(config1.fileArr(), config2.fileArr());
}
private static FunctionTestConfig.Builder newBuilder() {
diff --git a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java
index 42819957a1d..1192cc6673e 100644
--- a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java
@@ -3,8 +3,10 @@ package com.yahoo.config;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* @author Ulf Lilleengen
diff --git a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
index b9ebaf1f4dd..fac765f40aa 100644
--- a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java
@@ -3,8 +3,10 @@ package com.yahoo.config;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
@@ -31,10 +33,10 @@ public class EnumNodeTest {
public void testEnumNode() {
MyNode n = new MyNode();
assertNull(n.getValue());
- assertThat(n.toString(), is("(null)"));
+ assertEquals("(null)", n.toString());
assertTrue(n.doSetValue("ONE"));
- assertThat(n.getValue(), is("ONE"));
- assertThat(n.toString(), is("ONE"));
+ assertEquals("ONE", n.getValue());
+ assertEquals("ONE", n.toString());
assertFalse(n.doSetValue("THREE"));
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java
index 67edf5e9631..56dd7dd116d 100644
--- a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java
@@ -3,9 +3,7 @@ package com.yahoo.config;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -16,11 +14,11 @@ public class FileNodeTest {
@Test
public void testSetValue() {
FileNode n = new FileNode();
- assertThat(n.toString(), is("(null)"));
+ assertEquals("(null)", n.toString());
assertTrue(n.doSetValue("foo.txt"));
- assertThat(n.value().value(), is("foo.txt"));
+ assertEquals("foo.txt", n.value().value());
assertTrue(n.doSetValue("\"foo.txt\""));
- assertThat(n.value().value(), is("foo.txt"));
- assertThat(n.toString(), is("\"foo.txt\""));
+ assertEquals("foo.txt", n.value().value());
+ assertEquals("\"foo.txt\"", n.toString());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java
index c8404b8791e..899e34edce4 100644
--- a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java
@@ -3,9 +3,8 @@ package com.yahoo.config;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -18,6 +17,6 @@ public class IntegerNodeTest {
IntegerNode n = new IntegerNode();
assertFalse(n.setValue("invalid"));
assertTrue(n.setValue("10"));
- assertThat(n.value(), is(10));
+ assertEquals(10, n.value().intValue());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java
index c3f9ff9ae8f..fc603ba65ac 100644
--- a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java
@@ -3,9 +3,8 @@ package com.yahoo.config;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -18,6 +17,6 @@ public class LongNodeTest {
LongNode n = new LongNode();
assertFalse(n.setValue("invalid"));
assertTrue(n.setValue("10"));
- assertThat(n.value(), is(10l));
+ assertEquals(10L, n.value().longValue());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
index cb9bd65c406..9637ab25278 100644
--- a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java
@@ -5,9 +5,8 @@ import org.junit.Test;
import java.util.Arrays;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -61,10 +60,10 @@ public class NodeVectorTest {
StringNode val = new StringNode("foo");
TestNodeVector v = new TestNodeVector(val.getValue());
assertFalse(v.isEmpty());
- assertThat(v.indexOf(val), is(0));
- assertThat(v.indexOf(barNode()), is(-1));
- assertThat(v.lastIndexOf(val), is(0));
- assertThat(v.lastIndexOf(barNode()), is(-1));
+ assertEquals(0, v.indexOf(val));
+ assertEquals(-1, v.indexOf(barNode()));
+ assertEquals(0, v.lastIndexOf(val));
+ assertEquals(-1, v.lastIndexOf(barNode()));
}
@Test
@@ -82,11 +81,11 @@ public class NodeVectorTest {
public void require_that_sublisting_works() {
String val = "foo";
TestNodeVector v = new TestNodeVector(val, val, val);
- assertThat(v.subList(0, 1).size(), is(1));
- assertThat(v.subList(0, 2).size(), is(2));
- assertThat(v.subList(0, 3).size(), is(3));
+ assertEquals(1, v.subList(0, 1).size());
+ assertEquals(2, v.subList(0, 2).size());
+ assertEquals(3, v.subList(0, 3).size());
StringNode[] vals = v.toArray(new StringNode[0]);
- assertThat(vals.length, is(3));
+ assertEquals(3, vals.length);
}
private StringNode barNode() { return new StringNode("bar");}
diff --git a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java
index 7bb465f203b..37313bbcdf3 100644
--- a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java
@@ -5,8 +5,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;
/**
* @author gjoranv
@@ -17,10 +16,10 @@ public class PathNodeTest {
@Test
public void testSetValue() {
PathNode n = new PathNode();
- assertThat(n.toString(), is("(null)"));
+ assertEquals("(null)", n.toString());
n = new PathNode(new FileReference("foo.txt"));
- assertThat(n.value(), is(new File("foo.txt").toPath()));
+ assertEquals(new File("foo.txt").toPath(), n.value());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
index 05b9361865c..5d606e12454 100644
--- a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java
@@ -3,8 +3,7 @@ package com.yahoo.config;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author hmusum
@@ -15,11 +14,11 @@ public class StringNodeTest {
@Test
public void testUnescapeQuotedString() {
String a = "\"Hei\"";
- assertThat(StringNode.unescapeQuotedString(a), is("Hei"));
- assertThat(StringNode.unescapeQuotedString("foo\"bar\""), is("foo\"bar\""));
- assertThat(StringNode.unescapeQuotedString("foo\\\"bar\\\""), is("foo\"bar\""));
- assertThat(StringNode.unescapeQuotedString("a\\rb\\tc\\fd"), is("a\rb\tc\fd"));
- assertThat(StringNode.unescapeQuotedString("\\x55"), is("U"));
+ assertEquals("Hei", StringNode.unescapeQuotedString(a));
+ assertEquals("foo\"bar\"", StringNode.unescapeQuotedString("foo\"bar\""));
+ assertEquals("foo\"bar\"", StringNode.unescapeQuotedString("foo\\\"bar\\\""));
+ assertEquals("a\rb\tc\fd", StringNode.unescapeQuotedString("a\\rb\\tc\\fd"));
+ assertEquals("U", StringNode.unescapeQuotedString("\\x55"));
}
@Test(expected = IllegalArgumentException.class)
@@ -30,17 +29,17 @@ public class StringNodeTest {
@Test
public void testToString() {
StringNode n = new StringNode();
- assertThat(n.toString(), is("(null)"));
+ assertEquals("(null)", n.toString());
n.setValue("foo");
- assertThat(n.toString(), is("\"foo\""));
+ assertEquals("\"foo\"", n.toString());
}
@Test
public void testSetValue() {
StringNode n = new StringNode();
n.setValue("\"foo\"");
- assertThat(n.getValue(), is("foo"));
+ assertEquals("foo", n.getValue());
n.setValue("foo");
- assertThat(n.getValue(), is("foo"));
+ assertEquals("foo", n.getValue());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java b/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java
index 040e3304a66..abf04c34bb8 100644
--- a/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java
@@ -3,8 +3,7 @@ package com.yahoo.config;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author lesters
@@ -14,13 +13,13 @@ public class UrlNodeTest {
@Test
public void testSetValue() {
UrlNode url = new UrlNode();
- assertThat(url.toString(), is("(null)"));
+ assertEquals("(null)", url.toString());
url = new UrlNode(new UrlReference("https://docs.vespa.ai/"));
- assertThat(url.getUrlReference().value(), is("https://docs.vespa.ai/"));
+ assertEquals("https://docs.vespa.ai/", url.getUrlReference().value());
url = new UrlNode(new UrlReference("pom.xml"));
- assertThat(url.getValue(), is("pom.xml"));
+ assertEquals("pom.xml", url.getValue());
}
}
diff --git a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
index 066b5383621..54e2271f7dc 100644
--- a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
+++ b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java
@@ -6,8 +6,7 @@ import com.github.myproject.PackageConfig;
import com.yahoo.my.namespace.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
@@ -18,17 +17,17 @@ public class NamespaceAndPackageTest {
@Test
public void namespace_is_set_from_def_file() {
- assertThat(NamespaceConfig.CONFIG_DEF_NAMESPACE, is(NAMESPACE));
+ assertEquals(NAMESPACE, NamespaceConfig.CONFIG_DEF_NAMESPACE);
}
@Test
public void package_is_used_as_namespace_when_namespace_is_not_set_explicitly() {
- assertThat(PackageConfig.CONFIG_DEF_NAMESPACE, is(PACKAGE));
+ assertEquals(PACKAGE, PackageConfig.CONFIG_DEF_NAMESPACE);
}
@Test
public void package_does_not_override_namespace() {
- assertThat(NamespaceAndPackageConfig.CONFIG_DEF_NAMESPACE, is(NAMESPACE));
+ assertEquals(NAMESPACE, NamespaceAndPackageConfig.CONFIG_DEF_NAMESPACE);
}
}
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
index 1f78ad20e40..9fef9b4615d 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
@@ -111,6 +111,9 @@ public interface ModelContext {
@ModelFeatureFlag(owners = {"arnej"}) default boolean useV8GeoPositions() { return false; }
@ModelFeatureFlag(owners = {"arnej", "baldersheim"}) default boolean useV8DocManagerCfg() { return false; }
@ModelFeatureFlag(owners = {"baldersheim", "geirst", "toregge"}) default int maxCompactBuffers() { return 1; }
+ @ModelFeatureFlag(owners = {"hmusum"}) default boolean failDeploymentWithInvalidJvmOptions() { return false; }
+ @ModelFeatureFlag(owners = {"baldersheim"}) default double tlsSizeFraction() { throw new UnsupportedOperationException("TODO specify default value"); }
+ @ModelFeatureFlag(owners = {"bjorncs"}) default boolean enableServerOcspStapling() { return false; }
}
/** Warning: As elsewhere in this package, do not make backwards incompatible changes that will break old config models! */
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
index cf649162c08..e645fec5520 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
@@ -76,6 +76,8 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
private boolean unorderedMergeChaining = false;
private List<String> zoneDnsSuffixes = List.of();
private int maxCompactBuffers = 1;
+ private boolean failDeploymentWithInvalidJvmOptions = false;
+ private double tlsSizeFraction = 0.07;
@Override public ModelContext.FeatureFlags featureFlags() { return this; }
@Override public boolean multitenant() { return multitenant; }
@@ -132,6 +134,8 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
@Override public boolean unorderedMergeChaining() { return unorderedMergeChaining; }
@Override public List<String> zoneDnsSuffixes() { return zoneDnsSuffixes; }
@Override public int maxCompactBuffers() { return maxCompactBuffers; }
+ @Override public boolean failDeploymentWithInvalidJvmOptions() { return failDeploymentWithInvalidJvmOptions; }
+ @Override public double tlsSizeFraction() { return tlsSizeFraction; }
public TestProperties maxUnCommittedMemory(int maxUnCommittedMemory) {
this.maxUnCommittedMemory = maxUnCommittedMemory;
@@ -347,6 +351,16 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
return this;
}
+ public TestProperties failDeploymentWithInvalidJvmOptions(boolean fail) {
+ failDeploymentWithInvalidJvmOptions = fail;
+ return this;
+ }
+
+ public TestProperties tlsSizeFraction(double tlsSizeFraction) {
+ this.tlsSizeFraction = tlsSizeFraction;
+ return this;
+ }
+
public static class Spec implements ConfigServerSpec {
private final String hostName;
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java
index be67cbb9dd6..d2294402cd2 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java
@@ -167,6 +167,7 @@ public class VespaMetricSet {
metrics.add(new Metric("httpapi_failed.rate"));
metrics.add(new Metric("httpapi_parse_error.rate"));
addMetric(metrics, "httpapi_condition_not_met", List.of("rate"));
+ addMetric(metrics, "httpapi_not_found", List.of("rate"));
metrics.add(new Metric("mem.heap.total.average"));
metrics.add(new Metric("mem.heap.free.average"));
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java
index 9ad257fad04..7c386875d02 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java
@@ -23,6 +23,7 @@ public final class ApplicationContainer extends Container implements
private static final String defaultHostedJVMArgs = "-XX:+SuppressFatalErrorMessage";
private final boolean isHostedVespa;
+ private final boolean enableServerOcspStapling;
public ApplicationContainer(AbstractConfigProducer<?> parent, String name, int index, DeployState deployState) {
this(parent, name, false, index, deployState);
@@ -31,6 +32,7 @@ public final class ApplicationContainer extends Container implements
public ApplicationContainer(AbstractConfigProducer<?> parent, String name, boolean retired, int index, DeployState deployState) {
super(parent, name, retired, index, deployState);
this.isHostedVespa = deployState.isHosted();
+ this.enableServerOcspStapling = deployState.featureFlags().enableServerOcspStapling();
addComponent(new SimpleComponent("com.yahoo.container.jdisc.messagebus.NetworkMultiplexerHolder"));
addComponent(new SimpleComponent("com.yahoo.container.jdisc.messagebus.NetworkMultiplexerProvider"));
@@ -64,10 +66,23 @@ public final class ApplicationContainer extends Container implements
/** Returns the jvm arguments this should start with */
@Override
public String getJvmOptions() {
+ StringBuilder b = new StringBuilder();
+ if (isHostedVespa) {
+ if (hasDocproc()) {
+ b.append(ApplicationContainer.defaultHostedJVMArgs).append(' ');
+ }
+ if (enableServerOcspStapling) {
+ b.append("-Djdk.tls.server.enableStatusRequestExtension=true ")
+ .append("-Djdk.tls.stapling.responseTimeout=2000 ")
+ .append("-Djdk.tls.stapling.cacheSize=256 ")
+ .append("-Djdk.tls.stapling.cacheLifetime=3600 ");
+ }
+ }
String jvmArgs = super.getJvmOptions();
- return isHostedVespa && hasDocproc()
- ? ("".equals(jvmArgs) ? defaultHostedJVMArgs : defaultHostedJVMArgs + " " + jvmArgs)
- : jvmArgs;
+ if (!jvmArgs.isBlank()) {
+ b.append(jvmArgs.trim());
+ }
+ return b.toString().trim();
}
private boolean hasDocproc() {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
index d7691f4c486..2da68262fe7 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
@@ -101,7 +101,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
-import java.util.logging.Level;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -1071,18 +1070,20 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
private static class JvmOptions {
+ private static final Pattern validPattern = Pattern.compile("-[a-zA-z0-9=:.]+");
+
private final ContainerCluster<?> cluster;
private final Element nodesElement;
private final DeployLogger logger;
- private final boolean isHosted;
private final boolean legacyOptions;
+ private final boolean failDeploymentWithInvalidJvmOptions;
public JvmOptions(ContainerCluster<?> cluster, Element nodesElement, DeployState deployState, boolean legacyOptions) {
this.cluster = cluster;
this.nodesElement = nodesElement;
this.logger = deployState.getDeployLogger();
- this.isHosted = deployState.isHosted();
this.legacyOptions = legacyOptions;
+ this.failDeploymentWithInvalidJvmOptions = deployState.featureFlags().failDeploymentWithInvalidJvmOptions();
}
String build() {
@@ -1093,7 +1094,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
if (jvmElement == null) return "";
String jvmOptions = jvmElement.getAttribute(VespaDomBuilder.OPTIONS);
if (jvmOptions == null) return "";
- log(jvmOptions);
+ validateJvmOptions(jvmOptions);
return jvmOptions;
}
@@ -1101,7 +1102,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
String jvmOptions;
if (nodesElement.hasAttribute(VespaDomBuilder.JVM_OPTIONS)) {
jvmOptions = nodesElement.getAttribute(VespaDomBuilder.JVM_OPTIONS);
- log(jvmOptions);
+ validateJvmOptions(jvmOptions);
if (nodesElement.hasAttribute(VespaDomBuilder.JVMARGS_ATTRIB_NAME)) {
String jvmArgs = nodesElement.getAttribute(VespaDomBuilder.JVMARGS_ATTRIB_NAME);
throw new IllegalArgumentException("You have specified both jvm-options='" + jvmOptions + "'" +
@@ -1111,7 +1112,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
}
} else {
jvmOptions = nodesElement.getAttribute(VespaDomBuilder.JVMARGS_ATTRIB_NAME);
- log(jvmOptions);
+ validateJvmOptions(jvmOptions);
if (incompatibleGCOptions(jvmOptions)) {
logger.logApplicationPackage(WARNING, "You need to move your GC-related options from deprecated 'jvmargs' to 'gc-options' in 'jvm' element." +
" See https://docs.vespa.ai/en/reference/services-container.html#jvm");
@@ -1121,9 +1122,23 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
return jvmOptions;
}
- private void log(String jvmOptions) {
- if (isHosted && jvmOptions != null && !jvmOptions.isEmpty())
- logger.logApplicationPackage(Level.INFO, "JVM options from services.xml: " + jvmOptions);
+ private void validateJvmOptions(String jvmOptions) {
+ if (jvmOptions == null || jvmOptions.isEmpty()) return;
+
+ String[] optionList = jvmOptions.split(" ");
+ List<String> invalidOptions = Arrays.stream(optionList)
+ .filter(option -> !option.isEmpty())
+ .filter(option -> !Pattern.matches(validPattern.pattern(), option))
+ .sorted()
+ .collect(Collectors.toList());
+
+ if (invalidOptions.isEmpty()) return;
+
+ String message = "Invalid JVM options in services.xml: " + String.join(",", invalidOptions);
+ if (failDeploymentWithInvalidJvmOptions)
+ throw new IllegalArgumentException(message);
+ else
+ logger.logApplicationPackage(WARNING, message);
}
}
@@ -1133,19 +1148,21 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
*/
private static class JvmGcOptions {
- private static final Pattern validPattern = Pattern.compile("-XX:[+-][a-zA-z0-9=]+");
+ private static final Pattern validPattern = Pattern.compile("-XX:[+-]*[a-zA-z0-9=]+");
private static final Pattern invalidCMSPattern = Pattern.compile("-XX:[+-]\\w*CMS[a-zA-z0-9=]+");
private final DeployState deployState;
private final String jvmGcOptions;
private final DeployLogger logger;
private final boolean isHosted;
+ private final boolean failDeploymentWithInvalidJvmOptions;
public JvmGcOptions(DeployState deployState, String jvmGcOptions) {
this.deployState = deployState;
this.jvmGcOptions = jvmGcOptions;
this.logger = deployState.getDeployLogger();
this.isHosted = deployState.isHosted();
+ this.failDeploymentWithInvalidJvmOptions = deployState.featureFlags().failDeploymentWithInvalidJvmOptions();
}
private String build() {
@@ -1162,13 +1179,12 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
// CMS GC options cannot be used in hosted, CMS is unsupported in JDK 17
invalidOptions.addAll(Arrays.stream(optionList)
.filter(option -> !option.isEmpty())
- .filter(option -> Pattern
- .matches(invalidCMSPattern.pattern(), option) ||
+ .filter(option -> Pattern.matches(invalidCMSPattern.pattern(), option) ||
option.equals("-XX:+UseConcMarkSweepGC"))
.collect(Collectors.toList()));
}
- logInvalidOptions(invalidOptions);
+ logOrFailInvalidOptions(invalidOptions);
}
if (options == null || options.isEmpty())
@@ -1177,11 +1193,15 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
return options;
}
- private void logInvalidOptions(List<String> options) {
+ private void logOrFailInvalidOptions(List<String> options) {
if (options.isEmpty()) return;
Collections.sort(options);
- logger.logApplicationPackage(WARNING, "Invalid JVM GC options from services.xml: " + String.join(",", options));
+ String message = "Invalid JVM GC options in services.xml: " + String.join(",", options);
+ if (failDeploymentWithInvalidJvmOptions)
+ throw new IllegalArgumentException(message);
+ else
+ logger.logApplicationPackage(WARNING, message);
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java
index fb6e2dc0bd8..54d09bacfa9 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java
@@ -290,7 +290,8 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster>
Optional<Tuning> tuning = Optional.ofNullable(this.tuning);
if (element == null) {
searchNode = SearchNode.create(parent, "" + node.getDistributionKey(), node.getDistributionKey(), spec,
- clusterName, node, flushOnShutdown, tuning, resourceLimits, parentGroup.isHosted(), fractionOfMemoryReserved);
+ clusterName, node, flushOnShutdown, tuning, resourceLimits, parentGroup.isHosted(),
+ fractionOfMemoryReserved, deployState.featureFlags().tlsSizeFraction());
searchNode.setHostResource(node.getHostResource());
searchNode.initService(deployState.getDeployLogger());
@@ -298,7 +299,9 @@ public class ContentSearchCluster extends AbstractConfigProducer<SearchCluster>
tls.setHostResource(searchNode.getHostResource());
tls.initService(deployState.getDeployLogger());
} else {
- searchNode = new SearchNode.Builder(""+node.getDistributionKey(), spec, clusterName, node, flushOnShutdown, tuning, resourceLimits, fractionOfMemoryReserved).build(deployState, parent, element.getXml());
+ searchNode = new SearchNode.Builder(""+node.getDistributionKey(), spec, clusterName, node, flushOnShutdown,
+ tuning, resourceLimits, fractionOfMemoryReserved)
+ .build(deployState, parent, element.getXml());
tls = new TransactionLogServer.Builder(clusterName, syncTransactionLog).build(deployState, searchNode, element.getXml());
}
searchNode.setTls(tls);
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
index 9ab684c3f9d..628cf6bb4c7 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
@@ -240,7 +240,7 @@ public class ContentCluster extends AbstractConfigProducer<AbstractConfigProduce
}
}
- /** Returns whether this hosts one of the given container clusters */
+ /** Returns of memory reserved on a host. Memory is reserved for the jvm if th ecluster is combined */
private double fractionOfMemoryReserved(String clusterId, Collection<ContainerModel> containers) {
for (ContainerModel containerModel : containers) {
Optional<String> hostClusterId = containerModel.getCluster().getHostClusterId();
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java b/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java
index 652029dfef3..3af0b49de82 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java
@@ -5,6 +5,7 @@ import com.yahoo.config.provision.NodeResources;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import static java.lang.Long.min;
+import static java.lang.Long.max;
/**
* Tuning of proton config for a search node based on the resources on the node.
@@ -20,16 +21,19 @@ public class NodeResourcesTuning implements ProtonConfig.Producer {
private final NodeResources resources;
private final int threadsPerSearch;
private final double fractionOfMemoryReserved;
+ private final double tlsSizeFraction;
// "Reserve" 0.5GB of memory for other processes running on the content node (config-proxy, metrics-proxy).
public static final double reservedMemoryGb = 0.5;
public NodeResourcesTuning(NodeResources resources,
int threadsPerSearch,
- double fractionOfMemoryReserved) {
+ double fractionOfMemoryReserved,
+ double tlsSizeFraction) {
this.resources = resources;
this.threadsPerSearch = threadsPerSearch;
this.fractionOfMemoryReserved = fractionOfMemoryReserved;
+ this.tlsSizeFraction = tlsSizeFraction;
}
@Override
@@ -94,8 +98,8 @@ public class NodeResourcesTuning implements ProtonConfig.Producer {
}
private void tuneFlushStrategyTlsSize(ProtonConfig.Flush.Memory.Builder builder) {
- long tlsSizeBytes = (long) ((resources.diskGb() * 0.07) * GB);
- tlsSizeBytes = min(tlsSizeBytes, 100 * GB);
+ long tlsSizeBytes = (long) ((resources.diskGb() * tlsSizeFraction) * GB);
+ tlsSizeBytes = max(2*GB, min(tlsSizeBytes, 100 * GB));
builder.maxtlssize(tlsSizeBytes);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
index 6a4be692b0c..31513a273b2 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
@@ -68,6 +68,7 @@ public class SearchNode extends AbstractService implements
private final Optional<Tuning> tuning;
private final Optional<ResourceLimits> resourceLimits;
private final double fractionOfMemoryReserved;
+ private final double tlsSizeFraction;
public static class Builder extends VespaDomBuilder.DomConfigProducerBuilder<SearchNode> {
@@ -96,7 +97,8 @@ public class SearchNode extends AbstractService implements
@Override
protected SearchNode doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element producerSpec) {
return new SearchNode(ancestor, name, contentNode.getDistributionKey(), nodeSpec, clusterName, contentNode,
- flushOnShutdown, tuning, resourceLimits, deployState.isHosted(), fractionOfMemoryReserved);
+ flushOnShutdown, tuning, resourceLimits, deployState.isHosted(), fractionOfMemoryReserved,
+ deployState.featureFlags().tlsSizeFraction());
}
}
@@ -104,16 +106,16 @@ public class SearchNode extends AbstractService implements
public static SearchNode create(AbstractConfigProducer parent, String name, int distributionKey, NodeSpec nodeSpec,
String clusterName, AbstractService serviceLayerService, boolean flushOnShutdown,
Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits, boolean isHostedVespa,
- double fractionOfMemoryReserved) {
- return new SearchNode(parent, name, distributionKey, nodeSpec, clusterName, serviceLayerService,
- flushOnShutdown, tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved);
+ double fractionOfMemoryReserved, double tlsSizeFraction) {
+ return new SearchNode(parent, name, distributionKey, nodeSpec, clusterName, serviceLayerService, flushOnShutdown,
+ tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved, tlsSizeFraction);
}
private SearchNode(AbstractConfigProducer parent, String name, int distributionKey, NodeSpec nodeSpec,
String clusterName, AbstractService serviceLayerService, boolean flushOnShutdown,
Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits, boolean isHostedVespa,
- double fractionOfMemoryReserved) {
- this(parent, name, nodeSpec, clusterName, flushOnShutdown, tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved);
+ double fractionOfMemoryReserved, double tlsSizeFraction) {
+ this(parent, name, nodeSpec, clusterName, flushOnShutdown, tuning, resourceLimits, isHostedVespa, fractionOfMemoryReserved, tlsSizeFraction);
this.distributionKey = distributionKey;
this.serviceLayerService = serviceLayerService;
setPropertiesElastic(clusterName, distributionKey);
@@ -121,11 +123,12 @@ public class SearchNode extends AbstractService implements
private SearchNode(AbstractConfigProducer parent, String name, NodeSpec nodeSpec, String clusterName,
boolean flushOnShutdown, Optional<Tuning> tuning, Optional<ResourceLimits> resourceLimits, boolean isHostedVespa,
- double fractionOfMemoryReserved) {
+ double fractionOfMemoryReserved, double tlsSizeFraction) {
super(parent, name);
setOmpNumThreads(1);
this.isHostedVespa = isHostedVespa;
this.fractionOfMemoryReserved = fractionOfMemoryReserved;
+ this.tlsSizeFraction = tlsSizeFraction;
this.nodeSpec = nodeSpec;
this.clusterName = clusterName;
this.flushOnShutdown = flushOnShutdown;
@@ -279,7 +282,7 @@ public class SearchNode extends AbstractService implements
if (nodeResources.isPresent()) {
var nodeResourcesTuning = new NodeResourcesTuning(nodeResources.get(),
tuning.map(Tuning::threadsPerSearch).orElse(1),
- fractionOfMemoryReserved);
+ fractionOfMemoryReserved, tlsSizeFraction);
nodeResourcesTuning.getConfig(builder);
tuning.ifPresent(t -> t.getConfig(builder));
diff --git a/config-model/src/test/java/com/yahoo/config/model/ConfigModelContextTest.java b/config-model/src/test/java/com/yahoo/config/model/ConfigModelContextTest.java
index efa1ca5949a..532c446ec6f 100644
--- a/config-model/src/test/java/com/yahoo/config/model/ConfigModelContextTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/ConfigModelContextTest.java
@@ -9,9 +9,8 @@ import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.model.test.MockRoot;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
/**
* @author Ulf Lilleengen
@@ -28,18 +27,18 @@ public class ConfigModelContextTest {
DeployState deployState = DeployState.createTestState(pkg);
DeployLogger logger = deployState.getDeployLogger();
ConfigModelContext ctx = ConfigModelContext.create(deployState, null, null, root, id);
- assertThat(ctx.getApplicationPackage(), is(pkg));
- assertThat(ctx.getProducerId(), is(id));
- assertThat(ctx.getParentProducer(), is(root));
- assertThat(ctx.getDeployLogger(), is(logger));
+ assertEquals(pkg, ctx.getApplicationPackage());
+ assertEquals(id, ctx.getProducerId());
+ assertEquals(root, ctx.getParentProducer());
+ assertEquals(logger, ctx.getDeployLogger());
ctx = ConfigModelContext.create(root.getDeployState(), null, null, root, id);
- assertThat(ctx.getProducerId(), is(id));
- assertThat(ctx.getParentProducer(), is(root));
+ assertEquals(id, ctx.getProducerId());
+ assertEquals(root, ctx.getParentProducer());
AbstractConfigProducer newRoot = new MockRoot("bar");
ctx = ctx.withParent(newRoot);
- assertThat(ctx.getProducerId(), is(id));
- assertThat(ctx.getParentProducer(), is(not(root)));
- assertThat(ctx.getParentProducer(), is(newRoot));
+ assertEquals(id, ctx.getProducerId());
+ assertNotEquals(root, ctx.getParentProducer());
+ assertEquals(newRoot, ctx.getParentProducer());
}
}
diff --git a/config-model/src/test/java/com/yahoo/config/model/ConfigModelUtilsTest.java b/config-model/src/test/java/com/yahoo/config/model/ConfigModelUtilsTest.java
index 0127129ba0b..325361e0127 100644
--- a/config-model/src/test/java/com/yahoo/config/model/ConfigModelUtilsTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/ConfigModelUtilsTest.java
@@ -7,8 +7,7 @@ import org.junit.Test;
import java.io.File;
import java.util.List;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
@@ -22,38 +21,38 @@ public class ConfigModelUtilsTest {
@Test
public void all_def_files_in_correct_directory_are_handled_and_files_outside_are_ignored() {
List<Bundle> bundles = Bundle.getBundles(new File(VALID_TEST_BUNDLE));
- assertThat(bundles.size(), is(1));
- assertThat(bundles.get(0).getDefEntries().size(), is(5));
+ assertEquals(1, bundles.size());
+ assertEquals(5, bundles.get(0).getDefEntries().size());
}
@Test
public void def_file_with_namespace_is_handled() {
Bundle.DefEntry defEntry = getDefEntry("test-namespace");
- assertThat(defEntry.defNamespace, is("config"));
+ assertEquals("config", defEntry.defNamespace);
}
@Test
public void def_file_with_namespace_and_namespace_in_filename_is_handled() {
Bundle.DefEntry defEntry = getDefEntry("namespace-in-filename");
- assertThat(defEntry.defNamespace, is("a.b"));
+ assertEquals("a.b", defEntry.defNamespace);
}
@Test
public void def_file_with_package_is_handled() {
Bundle.DefEntry defEntry = getDefEntry("test-package");
- assertThat(defEntry.defNamespace, is("com.mydomain.mypackage"));
+ assertEquals("com.mydomain.mypackage", defEntry.defNamespace);
}
@Test
public void def_file_with_package_and_pacakage_in_filename_is_handled() {
Bundle.DefEntry defEntry = getDefEntry("package-in-filename");
- assertThat(defEntry.defNamespace, is("com.mydomain.mypackage"));
+ assertEquals("com.mydomain.mypackage", defEntry.defNamespace);
}
@Test
public void def_file_with_both_package_and_namespace_gets_package_as_namespace() {
Bundle.DefEntry defEntry = getDefEntry("namespace-and-package");
- assertThat(defEntry.defNamespace, is("com.mydomain.mypackage"));
+ assertEquals("com.mydomain.mypackage", defEntry.defNamespace);
}
private static Bundle.DefEntry getDefEntry(String defName) {
@@ -72,7 +71,7 @@ public class ConfigModelUtilsTest {
Bundle.getBundles(new File(INVALID_TEST_BUNDLE));
fail();
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage(), is("Error opening jar file 'invalid.jar'. Please check that this is a valid jar file"));
+ assertEquals("Error opening jar file 'invalid.jar'. Please check that this is a valid jar file", e.getMessage());
}
}
diff --git a/config-model/src/test/java/com/yahoo/config/model/QrserverAndGatewayPortAllocationTest.java b/config-model/src/test/java/com/yahoo/config/model/QrserverAndGatewayPortAllocationTest.java
index 06cce8f0be9..a06da645e17 100644
--- a/config-model/src/test/java/com/yahoo/config/model/QrserverAndGatewayPortAllocationTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/QrserverAndGatewayPortAllocationTest.java
@@ -9,8 +9,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;
/**
* Tests that qrserver is assigned port Defaults.getDefaults().vespaWebServicePort() even if there is a HTTP gateway configured earlier in
@@ -26,8 +25,8 @@ public class QrserverAndGatewayPortAllocationTest {
VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg(appDir);
VespaModel vespaModel = creator.create();
List<ApplicationContainer> qrservers = vespaModel.getContainerClusters().get("container").getContainers();
- assertThat(qrservers.size(), is(1));
- assertThat(qrservers.get(0).getSearchPort(), is(Container.BASEPORT));
+ assertEquals(1, qrservers.size());
+ assertEquals(Container.BASEPORT, qrservers.get(0).getSearchPort());
}
}
diff --git a/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java b/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java
index f0425d20af5..1bf8c834586 100644
--- a/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/application/provider/SchemaValidatorTest.java
@@ -2,12 +2,10 @@
package com.yahoo.config.model.application.provider;
import com.yahoo.component.Version;
-import com.yahoo.io.IOUtils;
import com.yahoo.vespa.config.VespaVersion;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.xml.sax.InputSource;
import java.io.File;
import java.io.IOException;
@@ -43,6 +41,7 @@ public class SchemaValidatorTest {
" </admin>\n" +
"</services>\n";
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/config/model/builder/xml/ConfigModelIdTest.java b/config-model/src/test/java/com/yahoo/config/model/builder/xml/ConfigModelIdTest.java
index 9874c249175..931768b6fd9 100644
--- a/config-model/src/test/java/com/yahoo/config/model/builder/xml/ConfigModelIdTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/builder/xml/ConfigModelIdTest.java
@@ -4,8 +4,10 @@ package com.yahoo.config.model.builder.xml;
import com.yahoo.component.Version;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
@@ -16,21 +18,21 @@ public class ConfigModelIdTest {
@Test
public void require_that_element_gets_correct_name() {
ConfigModelId id = ConfigModelId.fromName("foo");
- assertThat(id.getName(), is("foo"));
- assertThat(id.getVersion(), is(Version.fromString("1")));
+ assertEquals("foo", id.getName());
+ assertEquals(Version.fromString("1"), id.getVersion());
id = ConfigModelId.fromNameAndVersion("bar", "2.2");
- assertThat(id.getName(), is("bar"));
- assertThat(id.getVersion(), is(Version.fromString("2.2")));
+ assertEquals("bar", id.getName());
+ assertEquals(Version.fromString("2.2"), id.getVersion());
}
@Test
public void test_toString() {
ConfigModelId id = ConfigModelId.fromNameAndVersion("bar", "1.0");
- assertThat(id.toString(), is("bar.1"));
+ assertEquals("bar.1", id.toString());
id = ConfigModelId.fromNameAndVersion("foo", "1.1.3");
- assertThat(id.toString(), is("foo.1.1.3"));
+ assertEquals("foo.1.1.3", id.toString());
id = ConfigModelId.fromNameAndVersion("bar", "1");
- assertThat(id.toString(), is("bar.1"));
+ assertEquals("bar.1", id.toString());
}
@Test
@@ -38,15 +40,15 @@ public class ConfigModelIdTest {
ConfigModelId a1 = ConfigModelId.fromName("a");
ConfigModelId a2 = ConfigModelId.fromName("a");
ConfigModelId b = ConfigModelId.fromName("b");
- assertTrue(a1.equals(a2));
- assertTrue(a2.equals(a1));
- assertFalse(a1.equals(b));
- assertFalse(a2.equals(b));
- assertFalse(b.equals(a1));
- assertFalse(b.equals(a2));
- assertTrue(a1.equals(a1));
- assertTrue(a2.equals(a2));
- assertTrue(b.equals(b));
+ assertEquals(a1, a2);
+ assertEquals(a2, a1);
+ assertNotEquals(a1, b);
+ assertNotEquals(a2, b);
+ assertNotEquals(b, a1);
+ assertNotEquals(b, a2);
+ assertEquals(a1, a1);
+ assertEquals(a2, a2);
+ assertEquals(b, b);
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java b/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java
index 031f25306d5..64870ff8e49 100644
--- a/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java
@@ -25,10 +25,8 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
-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;
/**
@@ -42,7 +40,7 @@ public class DeployStateTest {
HostProvisioner provisioner = new InMemoryProvisioner(true, false, "foo.yahoo.com");
builder.modelHostProvisioner(provisioner);
DeployState state = builder.build();
- assertThat(state.getProvisioner(), is(provisioner));
+ assertEquals(provisioner, state.getProvisioner());
}
@Test
@@ -51,28 +49,28 @@ public class DeployStateTest {
ApplicationPackage app = MockApplicationPackage.createEmpty();
builder.permanentApplicationPackage(Optional.of(app));
DeployState state = builder.build();
- assertThat(state.getPermanentApplicationPackage().get(), is(app));
+ assertEquals(app, state.getPermanentApplicationPackage().get());
}
@Test
public void testPreviousModelIsProvided() throws IOException, SAXException {
VespaModel prevModel = new VespaModel(MockApplicationPackage.createEmpty());
DeployState.Builder builder = new DeployState.Builder();
- assertThat(builder.previousModel(prevModel).build().getPreviousModel().get(), is(prevModel));
+ assertEquals(prevModel, builder.previousModel(prevModel).build().getPreviousModel().get());
}
@Test
public void testProperties() {
DeployState.Builder builder = new DeployState.Builder();
DeployState state = builder.build();
- assertThat(state.getProperties().applicationId(), is(ApplicationId.defaultId()));
+ assertEquals(ApplicationId.defaultId(), state.getProperties().applicationId());
ApplicationId customId = new ApplicationId.Builder()
.tenant("bar")
.applicationName("foo").instanceName("quux").build();
ModelContext.Properties properties = new TestProperties().setApplicationId(customId);
builder.properties(properties);
state = builder.build();
- assertThat(state.getProperties().applicationId(), is(customId));
+ assertEquals(customId, state.getProperties().applicationId());
}
@Test
@@ -89,7 +87,7 @@ public class DeployStateTest {
assertNotNull(overridden);
Double defaultValue = overridden.getDoubleDefs().get("doubleVal").getDefVal();
assertNotNull(defaultValue);
- assertThat(defaultValue.intValue(), is(0));
+ assertEquals(0, defaultValue.intValue());
}
@Test
@@ -105,8 +103,8 @@ public class DeployStateTest {
ConfigDefinition test1 = state.getConfigDefinition(new ConfigDefinitionKey("test2", "a.b")).get();
assertNotNull(test1);
- assertThat(test1.getName(), is("test2"));
- assertThat(test1.getNamespace(), is("a.b"));
+ assertEquals("test2", test1.getName());
+ assertEquals("a.b", test1.getNamespace());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java b/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java
index 8736f85e41b..66cbfbd537f 100644
--- a/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java
+++ b/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java
@@ -8,7 +8,10 @@ import com.yahoo.config.model.ConfigModelRegistry;
import com.yahoo.config.model.MapConfigModelRegistry;
import com.yahoo.config.model.ApplicationConfigProducerRoot;
import com.yahoo.net.HostName;
-import com.yahoo.vespa.model.*;
+import com.yahoo.vespa.model.ConfigProducer;
+import com.yahoo.vespa.model.HostResource;
+import com.yahoo.vespa.model.HostSystem;
+import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.test.ApiConfigModel;
import com.yahoo.vespa.model.test.SimpleConfigModel;
import com.yahoo.vespa.model.test.SimpleService;
@@ -19,8 +22,10 @@ import java.util.Iterator;
import java.util.Map;
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.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author bratseth
@@ -52,7 +57,7 @@ public class SystemModelTestCase {
VespaModel vespaModel = getVespaModelDoNotValidateXml(TESTDIR + "metricsconfig");
SimpleService service0 = (SimpleService)vespaModel.getConfigProducer("simple/simpleservice.0").get();
vespaModel.getConfigProducer("simple/simpleservice.1");
- assertThat(service0.getDefaultMetricDimensions().get("clustername"), is("testClusterName"));
+ assertEquals("testClusterName", service0.getDefaultMetricDimensions().get("clustername"));
}
@Test
@@ -144,8 +149,8 @@ public class SystemModelTestCase {
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertEquals(5, vespaModel.configModelRepo().asMap().size());
- assertTrue(vespaModel.configModelRepo().asMap().keySet().contains("simple"));
- assertTrue(vespaModel.configModelRepo().asMap().keySet().contains("api"));
+ assertTrue(vespaModel.configModelRepo().asMap().containsKey("simple"));
+ assertTrue(vespaModel.configModelRepo().asMap().containsKey("api"));
assertTrue(root.getConfigIds().contains("simple/simpleservice.0"));
assertTrue(root.getConfigIds().contains("simple/simpleservice.1"));
assertTrue(root.getConfigIds().contains("api/apiservice.0"));
@@ -176,7 +181,7 @@ public class SystemModelTestCase {
getVespaModelDoNotValidateXml(TESTDIR + "doubleconfig");
fail("No exception upon two plugins with the same name");
} catch (RuntimeException expected) {
- assertThat(expected.getMessage(), is("Could not resolve tag <simpleplugin version=\"1.0\"> to a config model component"));
+ assertEquals("Could not resolve tag <simpleplugin version=\"1.0\"> to a config model component", expected.getMessage());
}
}
diff --git a/config-model/src/test/java/com/yahoo/config/model/graph/ModelGraphTest.java b/config-model/src/test/java/com/yahoo/config/model/graph/ModelGraphTest.java
index 1d078c132fc..da8ce7fd425 100644
--- a/config-model/src/test/java/com/yahoo/config/model/graph/ModelGraphTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/graph/ModelGraphTest.java
@@ -9,8 +9,10 @@ import org.junit.rules.ExpectedException;
import java.util.List;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
/**
* @author Ulf Lilleengen
@@ -24,7 +26,7 @@ public class ModelGraphTest {
for (ModelNode<?> node : sortedEntries) {
sb.append(node.builder.getModelClass().getSimpleName());
}
- assertThat(sb.toString(), is(expectedOrdering));
+ assertEquals(expectedOrdering, sb.toString());
}
@Test
@@ -33,7 +35,7 @@ public class ModelGraphTest {
builder.addBuilder(new GraphMock.BC()).addBuilder(new GraphMock.BB()).addBuilder(new GraphMock.BA());
ModelGraph graph = builder.build();
List<ModelNode> nodes = graph.getNodes();
- assertThat(graph.getNodes().size(), is(3));
+ assertEquals(3, graph.getNodes().size());
assertTrue(nodes.get(0).hasDependencies());
assertTrue(nodes.get(1).hasDependencies());
assertFalse(nodes.get(2).hasDependencies());
@@ -51,7 +53,7 @@ public class ModelGraphTest {
@Test(expected = IllegalArgumentException.class)
public void require_that_cycles_are_detected() {
ModelGraph graph = new ModelGraphBuilder().addBuilder(new GraphMock.BD()).addBuilder(new GraphMock.BE()).build();
- assertThat(graph.getNodes().size(), is(2));
+ assertEquals(2, graph.getNodes().size());
assertTrue(graph.getNodes().get(0).dependsOn(graph.getNodes().get(1)));
assertTrue(graph.getNodes().get(1).dependsOn(graph.getNodes().get(0)));
graph.topologicalSort();
@@ -70,17 +72,18 @@ public class ModelGraphTest {
assertNotNull(b);
assertNotNull(b2);
assertNotNull(c);
- assertThat(a.getId(), is("first"));
- assertThat(b.getId(), is("second"));
- assertThat(b2.getId(), is("second2"));
- assertThat(c.getId(), is("third"));
- assertThat(b.a, is(a));
+ assertEquals("first", a.getId());
+ assertEquals("second", b.getId());
+ assertEquals("second2", b2.getId());
+ assertEquals("third", c.getId());
+ assertEquals(a, b.a);
assertNotNull(c.b);
- assertThat(c.b.size(), is(2));
+ assertEquals(2, c.b.size());
assertTrue(c.b.contains(b));
assertTrue(c.b.contains(b2));
}
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedEx = ExpectedException.none();
@@ -109,7 +112,7 @@ public class ModelGraphTest {
MockRoot root = new MockRoot();
GraphMock.A a = (GraphMock.A) nodes.get(0).createModel(ConfigModelContext.create(root.getDeployState(), null, null, root, "first"));
GraphMock.C c = (GraphMock.C) nodes.get(1).createModel(ConfigModelContext.create(root.getDeployState(), null, null, root, "second"));
- assertThat(c.a, is(a));
+ assertEquals(a, c.a);
assertTrue(c.b.isEmpty());
}
diff --git a/config-model/src/test/java/com/yahoo/config/model/producer/AbstractConfigProducerTest.java b/config-model/src/test/java/com/yahoo/config/model/producer/AbstractConfigProducerTest.java
index 68868ae1a06..5d62abcc4df 100644
--- a/config-model/src/test/java/com/yahoo/config/model/producer/AbstractConfigProducerTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/producer/AbstractConfigProducerTest.java
@@ -4,9 +4,8 @@ package com.yahoo.config.model.producer;
import com.yahoo.cloud.config.log.LogdConfig;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* Verifies some of the logic in the abstract config producer that is not tested in other classes.
@@ -25,8 +24,8 @@ public class AbstractConfigProducerTest {
LogdConfig.Builder builder = (LogdConfig.Builder) clazz.getDeclaredConstructor().newInstance();
producer.getConfig(builder);
LogdConfig config = new LogdConfig(builder);
- assertThat(config.logserver().host(), is("bar"));
- assertThat(config.logserver().port(), is(1338));
+ assertEquals("bar", config.logserver().host());
+ assertEquals(1338, config.logserver().port());
}
@Test
@@ -38,8 +37,8 @@ public class AbstractConfigProducerTest {
LogdConfig.Builder builder = (LogdConfig.Builder) clazz.getDeclaredConstructor().newInstance();
producer.getConfig(builder);
LogdConfig config = new LogdConfig(builder);
- assertThat(config.logserver().host(), is("foo"));
- assertThat(config.logserver().port(), is(1337));
+ assertEquals("foo", config.logserver().host());
+ assertEquals(1337, config.logserver().port());
}
private static class MockLogdProducer extends AbstractConfigProducer implements LogdConfig.Producer {
diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
index 912161019fe..5fdd2974643 100644
--- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
@@ -29,6 +29,7 @@ import com.yahoo.vespa.model.container.ApplicationContainerCluster;
import com.yahoo.vespa.model.container.Container;
import com.yahoo.vespa.model.container.ContainerCluster;
import com.yahoo.vespa.model.content.ContentSearchCluster;
+import com.yahoo.vespa.model.content.StorageGroup;
import com.yahoo.vespa.model.content.StorageNode;
import com.yahoo.vespa.model.content.cluster.ContentCluster;
import com.yahoo.vespa.model.content.storagecluster.StorageCluster;
@@ -51,12 +52,10 @@ import static com.yahoo.vespa.defaults.Defaults.getDefaults;
import static com.yahoo.vespa.model.search.NodeResourcesTuning.GB;
import static com.yahoo.vespa.model.search.NodeResourcesTuning.reservedMemoryGb;
import static com.yahoo.vespa.model.test.utils.ApplicationPackageUtils.generateSchemas;
-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.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -540,58 +539,60 @@ public class ModelProvisioningTest {
// Check content clusters
ContentCluster cluster = model.getContentClusters().get("bar");
+ List<StorageGroup> subGroups = cluster.getRootGroup().getSubgroups();
assertEquals(0, cluster.getRootGroup().getNodes().size());
- assertEquals(9, cluster.getRootGroup().getSubgroups().size());
- assertEquals("0", cluster.getRootGroup().getSubgroups().get(0).getIndex());
- assertEquals(3, cluster.getRootGroup().getSubgroups().get(0).getNodes().size());
- assertEquals(0, cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey());
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("bar/storage/0"));
- assertEquals("node-1-3-10-57", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getDistributionKey(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getConfigId(), is("bar/storage/1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getDistributionKey(), is(2));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getConfigId(), is("bar/storage/2"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(3));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(3));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("bar/storage/3"));
- assertEquals("node-1-3-10-54", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getDistributionKey(), is(4));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getConfigId(), is("bar/storage/4"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getDistributionKey(), is(5));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getConfigId(), is("bar/storage/5"));
+ assertEquals(9, subGroups.size());
+ assertEquals("0", subGroups.get(0).getIndex());
+ assertEquals(3, subGroups.get(0).getNodes().size());
+ assertEquals(0, subGroups.get(0).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/0", subGroups.get(0).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-57", subGroups.get(0).getNodes().get(0).getHostName());
+ assertEquals(1, subGroups.get(0).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/1", subGroups.get(0).getNodes().get(1).getConfigId());
+ assertEquals(2, subGroups.get(0).getNodes().get(2).getDistributionKey());
+ assertEquals("bar/storage/2", subGroups.get(0).getNodes().get(2).getConfigId());
+ assertEquals("1", subGroups.get(1).getIndex());
+ assertEquals(3, subGroups.get(1).getNodes().size());
+ assertEquals(3, subGroups.get(1).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/3", subGroups.get(1).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-54", subGroups.get(1).getNodes().get(0).getHostName());
+ assertEquals(4, subGroups.get(1).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/4", subGroups.get(1).getNodes().get(1).getConfigId());
+ assertEquals(5, subGroups.get(1).getNodes().get(2).getDistributionKey());
+ assertEquals("bar/storage/5", subGroups.get(1).getNodes().get(2).getConfigId());
// ...
- assertEquals("node-1-3-10-51", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
+ assertEquals("node-1-3-10-51", subGroups.get(2).getNodes().get(0).getHostName());
// ...
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getIndex(), is("8"));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().size(), is(3));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getDistributionKey(), is(24));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getConfigId(), is("bar/storage/24"));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getDistributionKey(), is(25));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getConfigId(), is("bar/storage/25"));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getDistributionKey(), is(26));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getConfigId(), is("bar/storage/26"));
+ assertEquals("8", subGroups.get(8).getIndex());
+ assertEquals(3, subGroups.get(8).getNodes().size());
+ assertEquals(24, subGroups.get(8).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/24", subGroups.get(8).getNodes().get(0).getConfigId());
+ assertEquals(25, subGroups.get(8).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/25", subGroups.get(8).getNodes().get(1).getConfigId());
+ assertEquals(26, subGroups.get(8).getNodes().get(2).getDistributionKey());
+ assertEquals("bar/storage/26", subGroups.get(8).getNodes().get(2).getConfigId());
cluster = model.getContentClusters().get("baz");
+ subGroups = cluster.getRootGroup().getSubgroups();
assertEquals(0, cluster.getRootGroup().getNodes().size());
- assertEquals(27, cluster.getRootGroup().getSubgroups().size());
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey(), is(0));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("baz/storage/0"));
- assertEquals("node-1-3-10-27", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("baz/storage/1"));
- assertEquals("node-1-3-10-26", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
+ assertEquals(27, subGroups.size());
+ assertEquals("0", subGroups.get(0).getIndex());
+ assertEquals(1, subGroups.get(0).getNodes().size());
+ assertEquals(0, subGroups.get(0).getNodes().get(0).getDistributionKey());
+ assertEquals("baz/storage/0", subGroups.get(0).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-27", subGroups.get(0).getNodes().get(0).getHostName());
+ assertEquals("1", subGroups.get(1).getIndex());
+ assertEquals(1, subGroups.get(1).getNodes().size());
+ assertEquals(1, subGroups.get(1).getNodes().get(0).getDistributionKey());
+ assertEquals("baz/storage/1", subGroups.get(1).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-26", subGroups.get(1).getNodes().get(0).getHostName());
// ...
- assertEquals("node-1-3-10-25", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
+ assertEquals("node-1-3-10-25", subGroups.get(2).getNodes().get(0).getHostName());
// ...
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getIndex(), is("26"));
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getDistributionKey(), is(26));
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getConfigId(), is("baz/storage/26"));
+ assertEquals("26", subGroups.get(26).getIndex());
+ assertEquals(1, subGroups.get(26).getNodes().size());
+ assertEquals(26, subGroups.get(26).getNodes().get(0).getDistributionKey());
+ assertEquals("baz/storage/26", subGroups.get(26).getNodes().get(0).getConfigId());
}
@Test
@@ -679,58 +680,60 @@ public class ModelProvisioningTest {
// Check content clusters
ContentCluster cluster = model.getContentClusters().get("bar");
+ List<StorageGroup> subGroups = cluster.getRootGroup().getSubgroups();
assertEquals(0, cluster.getRootGroup().getNodes().size());
- assertEquals(9, cluster.getRootGroup().getSubgroups().size());
- assertEquals("0", cluster.getRootGroup().getSubgroups().get(0).getIndex());
- assertEquals(3, cluster.getRootGroup().getSubgroups().get(0).getNodes().size());
- assertEquals(0, cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey());
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("bar/storage/0"));
- assertEquals("node-1-3-10-57", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getDistributionKey(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getConfigId(), is("bar/storage/1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getDistributionKey(), is(2));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getConfigId(), is("bar/storage/2"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(3));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(3));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("bar/storage/3"));
- assertEquals("node-1-3-10-54", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getDistributionKey(), is(4));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getConfigId(), is("bar/storage/4"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getDistributionKey(), is(5));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getConfigId(), is("bar/storage/5"));
+ assertEquals(9, subGroups.size());
+ assertEquals("0", subGroups.get(0).getIndex());
+ assertEquals(3, subGroups.get(0).getNodes().size());
+ assertEquals(0, subGroups.get(0).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/0", subGroups.get(0).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-57", subGroups.get(0).getNodes().get(0).getHostName());
+ assertEquals(1, subGroups.get(0).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/1", subGroups.get(0).getNodes().get(1).getConfigId());
+ assertEquals(2, subGroups.get(0).getNodes().get(2).getDistributionKey());
+ assertEquals("bar/storage/2", subGroups.get(0).getNodes().get(2).getConfigId());
+ assertEquals("1", subGroups.get(1).getIndex());
+ assertEquals(3, subGroups.get(1).getNodes().size());
+ assertEquals(3, subGroups.get(1).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/3", subGroups.get(1).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-54", subGroups.get(1).getNodes().get(0).getHostName());
+ assertEquals(4, subGroups.get(1).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/4", subGroups.get(1).getNodes().get(1).getConfigId());
+ assertEquals(5, subGroups.get(1).getNodes().get(2).getDistributionKey());
+ assertEquals("bar/storage/5", subGroups.get(1).getNodes().get(2).getConfigId());
// ...
- assertEquals("node-1-3-10-51", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
+ assertEquals("node-1-3-10-51", subGroups.get(2).getNodes().get(0).getHostName());
// ...
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getIndex(), is("8"));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().size(), is(3));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getDistributionKey(), is(24));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getConfigId(), is("bar/storage/24"));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getDistributionKey(), is(25));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getConfigId(), is("bar/storage/25"));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getDistributionKey(), is(26));
- assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getConfigId(), is("bar/storage/26"));
+ assertEquals("8", subGroups.get(8).getIndex());
+ assertEquals(3, subGroups.get(8).getNodes().size());
+ assertEquals(24, subGroups.get(8).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/24", subGroups.get(8).getNodes().get(0).getConfigId());
+ assertEquals(25, subGroups.get(8).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/25", subGroups.get(8).getNodes().get(1).getConfigId());
+ assertEquals(26, subGroups.get(8).getNodes().get(2).getDistributionKey());
+ assertEquals("bar/storage/26", subGroups.get(8).getNodes().get(2).getConfigId());
cluster = model.getContentClusters().get("baz");
+ subGroups = cluster.getRootGroup().getSubgroups();
assertEquals(0, cluster.getRootGroup().getNodes().size());
- assertEquals(27, cluster.getRootGroup().getSubgroups().size());
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey(), is(0));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("baz/storage/0"));
- assertEquals("node-1-3-10-27", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("baz/storage/1"));
- assertEquals("node-1-3-10-26", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
+ assertEquals(27, subGroups.size());
+ assertEquals("0", subGroups.get(0).getIndex());
+ assertEquals(1, subGroups.get(0).getNodes().size());
+ assertEquals(0, subGroups.get(0).getNodes().get(0).getDistributionKey());
+ assertEquals("baz/storage/0", subGroups.get(0).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-27", subGroups.get(0).getNodes().get(0).getHostName());
+ assertEquals("1", subGroups.get(1).getIndex());
+ assertEquals(1, subGroups.get(1).getNodes().size());
+ assertEquals(1, subGroups.get(1).getNodes().get(0).getDistributionKey());
+ assertEquals("baz/storage/1", subGroups.get(1).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-26", subGroups.get(1).getNodes().get(0).getHostName());
// ...
- assertEquals("node-1-3-10-25", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
+ assertEquals("node-1-3-10-25", subGroups.get(2).getNodes().get(0).getHostName());
// ...
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getIndex(), is("26"));
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getDistributionKey(), is(26));
- assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getConfigId(), is("baz/storage/26"));
+ assertEquals("26", subGroups.get(26).getIndex());
+ assertEquals(1, subGroups.get(26).getNodes().size());
+ assertEquals(26, subGroups.get(26).getNodes().get(0).getDistributionKey());
+ assertEquals("baz/storage/26", subGroups.get(26).getNodes().get(0).getConfigId());
}
@Test
@@ -755,7 +758,7 @@ public class ModelProvisioningTest {
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(services, true);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
ClusterControllerContainerCluster clusterControllers = model.getAdmin().getClusterControllers();
assertEquals(3, clusterControllers.getContainers().size());
@@ -766,27 +769,28 @@ public class ModelProvisioningTest {
// Check content cluster
ContentCluster cluster = model.getContentClusters().get("bar");
+ List<StorageGroup> subGroups = cluster.getRootGroup().getSubgroups();
assertEquals(0, cluster.getRootGroup().getNodes().size());
- assertEquals(8, cluster.getRootGroup().getSubgroups().size());
+ assertEquals(8, subGroups.size());
assertEquals(8, cluster.distributionBits());
// first group
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey(), is(0));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("bar/storage/0"));
- assertEquals("node-1-3-10-11", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
+ assertEquals("0", subGroups.get(0).getIndex());
+ assertEquals(1, subGroups.get(0).getNodes().size());
+ assertEquals(0, subGroups.get(0).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/0", subGroups.get(0).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-11", subGroups.get(0).getNodes().get(0).getHostName());
// second group
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("bar/storage/1"));
- assertEquals("node-1-3-10-10", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
+ assertEquals("1", subGroups.get(1).getIndex());
+ assertEquals(1, subGroups.get(1).getNodes().size());
+ assertEquals(1, subGroups.get(1).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/1", subGroups.get(1).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-10", subGroups.get(1).getNodes().get(0).getHostName());
// ... last group
- assertThat(cluster.getRootGroup().getSubgroups().get(7).getIndex(), is("7"));
- assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getDistributionKey(), is(7));
- assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getConfigId(), is("bar/storage/7"));
- assertEquals("node-1-3-10-04", cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getHostName());
+ assertEquals("7", subGroups.get(7).getIndex());
+ assertEquals(1, subGroups.get(7).getNodes().size());
+ assertEquals(7, subGroups.get(7).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/7", subGroups.get(7).getNodes().get(0).getConfigId());
+ assertEquals("node-1-3-10-04", subGroups.get(7).getNodes().get(0).getHostName());
}
@Test
@@ -804,7 +808,7 @@ public class ModelProvisioningTest {
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(services, true, "node-1-3-10-09");
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
// Check slobroks clusters
assertEquals("Includes retired node", 1+3, model.getAdmin().getSlobroks().size());
@@ -858,7 +862,7 @@ public class ModelProvisioningTest {
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(services, true, "node-1-3-10-15", "node-1-3-10-05", "node-1-3-10-04");
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
// Check slobroks clusters
// ... from cluster default
@@ -950,7 +954,7 @@ public class ModelProvisioningTest {
tester.addHosts(numberOfHosts+1);
VespaModel model = tester.createModel(Zone.defaultZone(), services, true);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
Admin admin = model.getAdmin();
Logserver logserver = admin.getLogserver();
@@ -961,7 +965,7 @@ public class ModelProvisioningTest {
assertNull(hostResource.getService("logforwarder"));
var clist = model.getContainerClusters().get("foo").getContainers();
- assertThat(clist.size(), is(1));
+ assertEquals(1, clist.size());
hostResource = clist.get(0).getHostResource();
assertNull(hostResource.getService("logserver"));
assertNotNull(hostResource.getService("container"));
@@ -969,7 +973,7 @@ public class ModelProvisioningTest {
var lfs = hostResource.getService("logforwarder");
String shutdown = lfs.getPreShutdownCommand().orElse("<none>");
- assertThat(shutdown, is("/usr/bin/env SPLUNK_HOME=/opt/splunkforwarder /opt/splunkforwarder/bin/splunk stop"));
+ assertEquals("/usr/bin/env SPLUNK_HOME=/opt/splunkforwarder /opt/splunkforwarder/bin/splunk stop", shutdown);
}
@@ -996,7 +1000,7 @@ public class ModelProvisioningTest {
tester.addHosts(numberOfHosts+1);
VespaModel model = tester.createModel(Zone.defaultZone(), services, true);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
Admin admin = model.getAdmin();
Logserver logserver = admin.getLogserver();
@@ -1007,7 +1011,7 @@ public class ModelProvisioningTest {
assertNotNull(hostResource.getService("logforwarder"));
var clist = model.getContainerClusters().get("foo").getContainers();
- assertThat(clist.size(), is(1));
+ assertEquals(1, clist.size());
hostResource = clist.get(0).getHostResource();
assertNull(hostResource.getService("logserver"));
assertNotNull(hostResource.getService("container"));
@@ -1052,30 +1056,31 @@ public class ModelProvisioningTest {
assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
ContentCluster cluster = model.getContentClusters().get("bar");
+ List<StorageGroup> subGroups = cluster.getRootGroup().getSubgroups();
assertEquals(2*3, cluster.redundancy().effectiveInitialRedundancy()); // Reduced from 3*3
assertEquals(2*3, cluster.redundancy().effectiveFinalRedundancy()); // Reduced from 3*4
assertEquals(2*3, cluster.redundancy().effectiveReadyCopies()); // Reduced from 3*3
assertEquals("2|2|*", cluster.getRootGroup().getPartitions().get()); // Reduced from 4|4|*
assertEquals(0, cluster.getRootGroup().getNodes().size());
- assertEquals(3, cluster.getRootGroup().getSubgroups().size());
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(2));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey(), is(0));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("bar/storage/0"));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getDistributionKey(), is(1));
- assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getConfigId(), is("bar/storage/1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(2));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(2));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("bar/storage/2"));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getDistributionKey(), is(3));
- assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getConfigId(), is("bar/storage/3"));
- assertThat(cluster.getRootGroup().getSubgroups().get(2).getIndex(), is("2"));
- assertThat(cluster.getRootGroup().getSubgroups().get(2).getNodes().size(), is(2));
- assertThat(cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getDistributionKey(), is(4));
- assertThat(cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getConfigId(), is("bar/storage/4"));
- assertThat(cluster.getRootGroup().getSubgroups().get(2).getNodes().get(1).getDistributionKey(), is(5));
- assertThat(cluster.getRootGroup().getSubgroups().get(2).getNodes().get(1).getConfigId(), is("bar/storage/5"));
+ assertEquals(3, subGroups.size());
+ assertEquals("0", subGroups.get(0).getIndex());
+ assertEquals(2, subGroups.get(0).getNodes().size());
+ assertEquals(0, subGroups.get(0).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/0", subGroups.get(0).getNodes().get(0).getConfigId());
+ assertEquals(1, subGroups.get(0).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/1", subGroups.get(0).getNodes().get(1).getConfigId());
+ assertEquals("1", subGroups.get(1).getIndex());
+ assertEquals(2, subGroups.get(1).getNodes().size());
+ assertEquals(2, subGroups.get(1).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/2", subGroups.get(1).getNodes().get(0).getConfigId());
+ assertEquals(3, subGroups.get(1).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/3", subGroups.get(1).getNodes().get(1).getConfigId());
+ assertEquals("2", subGroups.get(2).getIndex());
+ assertEquals(2, subGroups.get(2).getNodes().size());
+ assertEquals(4, subGroups.get(2).getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/4", subGroups.get(2).getNodes().get(0).getConfigId());
+ assertEquals(5, subGroups.get(2).getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/5", subGroups.get(2).getNodes().get(1).getConfigId());
}
@Test
@@ -1192,7 +1197,7 @@ public class ModelProvisioningTest {
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(services, false);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
ContentCluster cluster = model.getContentClusters().get("bar");
assertEquals(4, cluster.redundancy().effectiveInitialRedundancy());
@@ -1203,15 +1208,15 @@ public class ModelProvisioningTest {
assertFalse(cluster.getRootGroup().getPartitions().isPresent());
assertEquals(4, cluster.getRootGroup().getNodes().size());
assertEquals(0, cluster.getRootGroup().getSubgroups().size());
- assertThat(cluster.getRootGroup().getNodes().size(), is(4));
- assertThat(cluster.getRootGroup().getNodes().get(0).getDistributionKey(), is(0));
- assertThat(cluster.getRootGroup().getNodes().get(0).getConfigId(), is("bar/storage/0"));
- assertThat(cluster.getRootGroup().getNodes().get(1).getDistributionKey(), is(1));
- assertThat(cluster.getRootGroup().getNodes().get(1).getConfigId(), is("bar/storage/1"));
- assertThat(cluster.getRootGroup().getNodes().get(2).getDistributionKey(), is(2));
- assertThat(cluster.getRootGroup().getNodes().get(2).getConfigId(), is("bar/storage/2"));
- assertThat(cluster.getRootGroup().getNodes().get(3).getDistributionKey(), is(3));
- assertThat(cluster.getRootGroup().getNodes().get(3).getConfigId(), is("bar/storage/3"));
+ assertEquals(4, cluster.getRootGroup().getNodes().size());
+ assertEquals(0, cluster.getRootGroup().getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/0", cluster.getRootGroup().getNodes().get(0).getConfigId());
+ assertEquals(1, cluster.getRootGroup().getNodes().get(1).getDistributionKey());
+ assertEquals("bar/storage/1", cluster.getRootGroup().getNodes().get(1).getConfigId());
+ assertEquals(2, cluster.getRootGroup().getNodes().get(2).getDistributionKey());
+ assertEquals("bar/storage/2", cluster.getRootGroup().getNodes().get(2).getConfigId());
+ assertEquals(3, cluster.getRootGroup().getNodes().get(3).getDistributionKey());
+ assertEquals("bar/storage/3", cluster.getRootGroup().getNodes().get(3).getConfigId());
}
@Test
@@ -1236,7 +1241,7 @@ public class ModelProvisioningTest {
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(services, false);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
ContentCluster cluster = model.getContentClusters().get("bar");
assertEquals(1, cluster.redundancy().effectiveInitialRedundancy()); // Reduced from 3*3
@@ -1245,9 +1250,9 @@ public class ModelProvisioningTest {
assertFalse(cluster.getRootGroup().getPartitions().isPresent()); // 1 group - > flattened -> no distribution
assertEquals(1, cluster.getRootGroup().getNodes().size());
assertEquals(0, cluster.getRootGroup().getSubgroups().size());
- assertThat(cluster.getRootGroup().getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getNodes().get(0).getDistributionKey(), is(0));
- assertThat(cluster.getRootGroup().getNodes().get(0).getConfigId(), is("bar/storage/0"));
+ assertEquals(1, cluster.getRootGroup().getNodes().size());
+ assertEquals(0, cluster.getRootGroup().getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/0", cluster.getRootGroup().getNodes().get(0).getConfigId());
}
@Test(expected = IllegalArgumentException.class)
@@ -1337,7 +1342,7 @@ public class ModelProvisioningTest {
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(services, false);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
ContentCluster cluster = model.getContentClusters().get("bar");
assertEquals(1, cluster.redundancy().effectiveInitialRedundancy());
@@ -1348,9 +1353,9 @@ public class ModelProvisioningTest {
assertFalse(cluster.getRootGroup().getPartitions().isPresent());
assertEquals(1, cluster.getRootGroup().getNodes().size());
assertEquals(0, cluster.getRootGroup().getSubgroups().size());
- assertThat(cluster.getRootGroup().getNodes().size(), is(1));
- assertThat(cluster.getRootGroup().getNodes().get(0).getDistributionKey(), is(0));
- assertThat(cluster.getRootGroup().getNodes().get(0).getConfigId(), is("bar/storage/0"));
+ assertEquals(1, cluster.getRootGroup().getNodes().size());
+ assertEquals(0, cluster.getRootGroup().getNodes().get(0).getDistributionKey());
+ assertEquals("bar/storage/0", cluster.getRootGroup().getNodes().get(0).getConfigId());
}
@Test
@@ -1850,7 +1855,7 @@ public class ModelProvisioningTest {
"</services>";
VespaModel model = createNonProvisionedMultitenantModel(services);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(1));
+ assertEquals(1, model.getRoot().hostSystem().getHosts().size());
ContentCluster content = model.getContentClusters().get("storage");
assertEquals(1, content.getRootGroup().getNodes().size());
ContainerCluster<?> controller = model.getAdmin().getClusterControllers();
@@ -2178,7 +2183,7 @@ public class ModelProvisioningTest {
tester.addHosts(numberOfHosts);
VespaModel model = tester.createModel(Zone.defaultZone(), services, true);
- assertThat(model.getRoot().hostSystem().getHosts().size(), is(numberOfHosts));
+ assertEquals(numberOfHosts, model.getRoot().hostSystem().getHosts().size());
Admin admin = model.getAdmin();
Logserver logserver = admin.getLogserver();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java
index 8656e740333..e4de0aef622 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java
@@ -10,15 +10,16 @@ import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.tensor.TensorType;
import com.yahoo.vespa.config.search.AttributesConfig;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import java.io.IOException;
import java.util.Optional;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Attribute settings
@@ -27,9 +28,6 @@ import static org.junit.Assert.*;
*/
public class AttributeSettingsTestCase extends AbstractSchemaTestCase {
- @Rule
- public final ExpectedException exceptionRule = ExpectedException.none();
-
@Test
public void testAttributeSettings() throws IOException, ParseException {
Schema schema = SchemaBuilder.buildFromFile("src/test/examples/attributesettings.sd");
@@ -37,8 +35,8 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase {
SDField f1=(SDField) schema.getDocument().getField("f1");
assertEquals(1, f1.getAttributes().size());
Attribute a1 = f1.getAttributes().get(f1.getName());
- assertThat(a1.getType(), is(Attribute.Type.LONG));
- assertThat(a1.getCollectionType(), is(Attribute.CollectionType.SINGLE));
+ assertEquals(Attribute.Type.LONG, a1.getType());
+ assertEquals(Attribute.CollectionType.SINGLE, a1.getCollectionType());
assertTrue(a1.isHuge());
assertFalse(a1.isFastSearch());
assertFalse(a1.isFastAccess());
@@ -48,21 +46,21 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase {
SDField f2=(SDField) schema.getDocument().getField("f2");
assertEquals(1, f2.getAttributes().size());
Attribute a2 = f2.getAttributes().get(f2.getName());
- assertThat(a2.getType(), is(Attribute.Type.LONG));
- assertThat(a2.getCollectionType(), is(Attribute.CollectionType.SINGLE));
+ assertEquals(Attribute.Type.LONG, a2.getType());
+ assertEquals(Attribute.CollectionType.SINGLE, a2.getCollectionType());
assertFalse(a2.isHuge());
assertTrue(a2.isFastSearch());
assertFalse(a2.isFastAccess());
assertFalse(a2.isRemoveIfZero());
assertFalse(a2.isCreateIfNonExistent());
- assertThat(f2.getAliasToName().get("f2alias"), is("f2"));
+ assertEquals("f2", f2.getAliasToName().get("f2alias"));
SDField f3=(SDField) schema.getDocument().getField("f3");
assertEquals(1, f3.getAttributes().size());
- assertThat(f3.getAliasToName().get("f3alias"), is("f3"));
+ assertEquals("f3", f3.getAliasToName().get("f3alias"));
Attribute a3 = f3.getAttributes().get(f3.getName());
- assertThat(a3.getType(), is(Attribute.Type.LONG));
- assertThat(a3.getCollectionType(), is(Attribute.CollectionType.SINGLE));
+ assertEquals(Attribute.Type.LONG, a3.getType());
+ assertEquals(Attribute.CollectionType.SINGLE, a3.getCollectionType());
assertFalse(a3.isHuge());
assertFalse(a3.isFastSearch());
assertFalse(a3.isFastAccess());
@@ -82,13 +80,13 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase {
SDField f4 = (SDField) schema.getDocument().getField(name);
assertEquals(1, f4.getAttributes().size());
Attribute a4 = f4.getAttributes().get(f4.getName());
- assertThat(a4.getType(), is(Attribute.Type.STRING));
- assertThat(a4.getCollectionType(), is(Attribute.CollectionType.WEIGHTEDSET));
+ assertEquals(Attribute.Type.STRING, a4.getType());
+ assertEquals(Attribute.CollectionType.WEIGHTEDSET, a4.getCollectionType());
assertFalse(a4.isHuge());
assertFalse(a4.isFastSearch());
assertFalse(a4.isFastAccess());
- assertThat(removeIfZero, is(a4.isRemoveIfZero()));
- assertThat(createIfNonExistent, is(a4.isCreateIfNonExistent()));
+ assertEquals(a4.isRemoveIfZero(), removeIfZero);
+ assertEquals(a4.isCreateIfNonExistent(), createIfNonExistent);
}
@Test
@@ -154,9 +152,8 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase {
@Test
public void requireThatMutableCanNotbeSetInDocument() throws ParseException {
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("Field 'f' in 'test' can not be marked mutable as it is inside the document clause.");
- getSearch("search test {\n" +
+ try {
+ getSearch("search test {\n" +
" document test {\n" +
" field f type int {\n" +
" indexing: attribute\n" +
@@ -164,6 +161,10 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase {
" }\n" +
" }\n" +
"}\n");
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Field 'f' in 'test' can not be marked mutable as it is inside the document clause.", e.getMessage());
+ }
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java
index 30cda8b5f42..fb552f5cfb0 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.fail;
*/
public class DocumentGraphValidatorTest {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java
index 19964700dd0..cc45a2aaec0 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java
@@ -25,6 +25,7 @@ public class DocumentReferenceResolverTest {
private static final String BAR = "bar";
private static final String FOO = "foo";
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java
index a3dd45a629f..456a236f293 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java
@@ -1,8 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
-import static org.junit.Assert.*;
-
import com.yahoo.searchdefinition.document.ImmutableSDField;
import org.junit.Rule;
import org.junit.Test;
@@ -11,6 +9,11 @@ import org.junit.rules.ExpectedException;
import com.yahoo.document.DataType;
import com.yahoo.searchdefinition.parser.ParseException;
+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 Lester Solbakken
*/
@@ -49,6 +52,7 @@ public class PredicateDataTypeTestCase {
return "upper-bound: " + bound + "\n";
}
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException exception = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java
index 7951962a8bd..1925b7e77b9 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java
@@ -18,6 +18,7 @@ import static org.junit.Assert.fail;
*/
public class RankingConstantTest {
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException thrown = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java
index 19bd8305fa5..b2c2a54ce5e 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructInheritanceTestCase.java
@@ -1,29 +1,18 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;
-import com.yahoo.document.DataType;
-import com.yahoo.document.config.DocumentmanagerConfig;
-import com.yahoo.searchdefinition.Index;
-import com.yahoo.searchdefinition.Schema;
+
import com.yahoo.searchdefinition.SchemaBuilder;
-import com.yahoo.searchdefinition.document.SDDocumentType;
-import com.yahoo.searchdefinition.document.SDField;
+
import com.yahoo.searchdefinition.parser.ParseException;
-import com.yahoo.vespa.configmodel.producers.DocumentManager;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import java.io.File;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import org.junit.rules.TemporaryFolder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import org.junit.rules.TemporaryFolder;
/**
* Tests struct inheritance
@@ -35,6 +24,7 @@ public class StructInheritanceTestCase extends AbstractExportingTestCase {
@Rule
public TemporaryFolder tmpDir = new TemporaryFolder();
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java
index 7b46e9899e2..d6ff8fa1067 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java
@@ -6,9 +6,7 @@ import java.util.Optional;
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.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
public class HnswIndexParamsTestCase {
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java
index 3b5add5b3d8..5d2590a420d 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java
@@ -86,6 +86,7 @@ public class AdjustPositionSummaryFieldsTestCase {
model.assertSummaryField("pos.distance", DataType.INT, SummaryTransform.DISTANCE, "pos_zcurve");
}
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
index 00f67c80084..dd958fb34cd 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
@@ -14,6 +14,7 @@ import org.junit.rules.ExpectedException;
*/
public class FastAccessValidatorTest {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java
index 522d4dc2b15..324010f9e83 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertSame;
*/
public class ImportedFieldsResolverTestCase {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
index 0ece6d57fe1..6eab1dddc79 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
@@ -38,6 +38,7 @@ public class ImportedFieldsTestCase {
assertSearchContainsImportedField("my_name", "person_ref", "person", "name", schema);
}
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException exception = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
index 4fb1bd50e3f..7eea2fca0e6 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals;
*/
public class MatchedElementsOnlyResolverTestCase {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java
index e8564d0875d..c9437761e0d 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java
@@ -13,16 +13,16 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* @author bjorncs
*/
public class ReferenceFieldTestCase {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
@@ -83,7 +83,7 @@ public class ReferenceFieldTestCase {
Field field = documentType.getDocumentType().getField(expectedFieldname);
assertNotNull("Field does not exist in document type: " + expectedFieldname, field);
DataType dataType = field.getDataType();
- assertThat(dataType, instanceOf(ReferenceDataType.class));
+ assertTrue(dataType instanceof ReferenceDataType);
ReferenceDataType refField = (ReferenceDataType) dataType;
assertEquals(referencedDocType, refField.getTargetType().getName());
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
index 08c123b5578..fe9d19310a9 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
@@ -31,6 +31,7 @@ public class ValidateFieldTypesTest {
private static final String IMPORTED_FIELD_NAME = "imported_myfield";
private static final String DOCUMENT_NAME = "my_doc";
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
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/AccessControlFilterValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlFilterValidatorTest.java
index 09e9ec9904b..86d4c527670 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlFilterValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlFilterValidatorTest.java
@@ -7,13 +7,14 @@ import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.model.test.ModelBuilderAddingAccessControlFilter;
import com.yahoo.vespa.model.VespaModel;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.xml.sax.SAXException;
import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
/**
* @author bjorncs
*/
@@ -31,17 +32,18 @@ public class AccessControlFilterValidatorTest {
" </container>",
"</services>");
- @Rule
- public ExpectedException exceptionRule = ExpectedException.none();
@Test
public void validator_fails_with_empty_access_control_filter_chain() throws IOException, SAXException {
DeployState deployState = createDeployState();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("The 'access-control' feature is not available in open-source Vespa.");
- new AccessControlFilterValidator().validate(model, deployState);
+ try {
+ new AccessControlFilterValidator().validate(model, deployState);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("The 'access-control' feature is not available in open-source Vespa.", e.getMessage());
+ }
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlValidatorTestBase.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlValidatorTestBase.java
index 5cdddcfba31..107ee8aef72 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlValidatorTestBase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/AccessControlValidatorTestBase.java
@@ -8,9 +8,7 @@ import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.model.VespaModel;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.xml.sax.SAXException;
import java.io.IOException;
@@ -21,9 +19,9 @@ import java.time.format.DateTimeFormatter;
import static com.yahoo.config.model.test.TestUtil.joinLines;
import static com.yahoo.config.provision.Environment.prod;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author gjoranv
@@ -33,9 +31,6 @@ public abstract class AccessControlValidatorTestBase {
protected Validator validator;
protected Zone zone;
- @Rule
- public final ExpectedException exceptionRule = ExpectedException.none();
-
private static String servicesXml(boolean addHandler, boolean protection) {
return joinLines("<services version='1.0'>",
" <container id='default' version='1.0'>",
@@ -83,22 +78,20 @@ public abstract class AccessControlValidatorTestBase {
@Test
public void cluster_with_handler_fails_validation_without_protection() throws IOException, SAXException{
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(containsString("Access-control must be enabled"));
- exceptionRule.expectMessage(containsString("production zones: [default]"));
-
DeployState deployState = deployState(servicesXml(true, false));
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
- validator.validate(model, deployState);
+ try {
+ validator.validate(model, deployState);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Access-control must be enabled"));
+ assertTrue(e.getMessage().contains("production zones: [default]"));
+ }
}
@Test
public void no_http_element_has_same_effect_as_no_write_protection() throws IOException, SAXException{
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(containsString("Access-control must be enabled"));
- exceptionRule.expectMessage(containsString("production zones: [default]"));
-
String servicesXml = joinLines("<services version='1.0'>",
" <container id='default' version='1.0'>",
httpHandlerXml,
@@ -107,7 +100,13 @@ public abstract class AccessControlValidatorTestBase {
DeployState deployState = deployState(servicesXml);
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
- validator.validate(model, deployState);
+ try {
+ validator.validate(model, deployState);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Access-control must be enabled"));
+ assertTrue(e.getMessage().contains("production zones: [default]"));
+ }
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java
index 2fb2ed15521..92aa3151d91 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java
@@ -11,9 +11,7 @@ import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.model.VespaModel;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.xml.sax.SAXException;
import java.io.IOException;
@@ -21,6 +19,7 @@ import java.io.IOException;
import static com.yahoo.config.provision.Environment.prod;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
@@ -28,9 +27,6 @@ import static org.junit.Assert.assertTrue;
*/
public class CloudWatchValidatorTest {
- @Rule
- public final ExpectedException exceptionRule = ExpectedException.none();
-
@Test
public void cloudwatch_in_public_zones_passes_validation() throws IOException, SAXException {
DeployState deployState = deployState(servicesWithCloudwatch(), true, true);
@@ -49,14 +45,16 @@ public class CloudWatchValidatorTest {
@Test
public void cloudwatch_in_non_public_zones_fails_validation() throws IOException, SAXException {
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(
- "CloudWatch cannot be set up for non-public hosted Vespa and must be removed for consumers: [cloudwatch-consumer]");
-
DeployState deployState = deployState(servicesWithCloudwatch(), true, false);
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
- new CloudWatchValidator().validate(model, deployState);
+ try {
+ new CloudWatchValidator().validate(model, deployState);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("CloudWatch cannot be set up for non-public hosted Vespa and must be removed for consumers: [cloudwatch-consumer]",
+ e.getMessage());
+ }
}
private static DeployState deployState(String servicesXml, boolean isHosted, boolean isPublic) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java
index 6f459b2d427..689f1c70b6e 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java
@@ -24,6 +24,7 @@ import static com.yahoo.config.model.test.TestUtil.joinLines;
*/
public class ComplexAttributeFieldsValidatorTestCase {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
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/ConstantTensorJsonValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java
index ea457e043fb..90d5c0b27a4 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ConstantTensorJsonValidatorTest.java
@@ -22,6 +22,7 @@ public class ConstantTensorJsonValidatorTest {
new ConstantTensorJsonValidator().validate("dummy.json", tensorType, jsonTensorReader);
}
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/EndpointCertificateSecretsValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/EndpointCertificateSecretsValidatorTest.java
index 0bbb2353316..51aa6cb6e42 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/EndpointCertificateSecretsValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/EndpointCertificateSecretsValidatorTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
* @author andreer
*/
public class EndpointCertificateSecretsValidatorTest {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidatorTest.java
index 6a88fa80070..b1847e5d134 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidatorTest.java
@@ -2,17 +2,14 @@
package com.yahoo.vespa.model.application.validation;
import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static com.yahoo.vespa.model.application.validation.RankingConstantsValidator.TensorValidationFailed;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class RankingConstantsValidatorTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
public void ensure_that_valid_ranking_constants_do_not_fail() {
new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/ranking_constants_ok/").create();
@@ -20,12 +17,14 @@ public class RankingConstantsValidatorTest {
@Test
public void ensure_that_failing_ranking_constants_fails() {
- expectedException.expect(TensorValidationFailed.class);
- expectedException.expectMessage("Ranking constant 'constant_tensor_2' (tensors/constant_tensor_2.json): Tensor label is not a string (VALUE_NUMBER_INT)");
- expectedException.expectMessage("Ranking constant 'constant_tensor_3' (tensors/constant_tensor_3.json): Tensor dimension 'cd' does not exist");
- expectedException.expectMessage("Ranking constant 'constant_tensor_4' (tensors/constant_tensor_4.json): Tensor dimension 'z' does not exist");
-
- new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/ranking_constants_fail/").create();
+ try {
+ new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/ranking_constants_fail/").create();
+ fail();
+ } catch (TensorValidationFailed e) {
+ assertTrue(e.getMessage().contains("Ranking constant 'constant_tensor_2' (tensors/constant_tensor_2.json): Tensor label is not a string (VALUE_NUMBER_INT)"));
+ assertTrue(e.getMessage().contains("Ranking constant 'constant_tensor_3' (tensors/constant_tensor_3.json): Tensor dimension 'cd' does not exist"));
+ assertTrue(e.getMessage().contains("Ranking constant 'constant_tensor_4' (tensors/constant_tensor_4.json): Tensor dimension 'z' does not exist"));
+ }
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SecretStoreValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SecretStoreValidatorTest.java
index 7ea8d9b1175..d30de06c459 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SecretStoreValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SecretStoreValidatorTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
* @author gjoranv
*/
public class SecretStoreValidatorTest {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java
index 5d1893a4826..30a77779347 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java
@@ -10,6 +10,7 @@ import org.junit.rules.ExpectedException;
* @author bjorncs
*/
public class StreamingValidatorTest {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exceptionRule = ExpectedException.none();
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/UriBindingsValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/UriBindingsValidatorTest.java
index 525df099c1e..d106120073d 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/UriBindingsValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/UriBindingsValidatorTest.java
@@ -19,6 +19,7 @@ import java.io.IOException;
*/
public class UriBindingsValidatorTest {
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException exceptionRule = ExpectedException.none();
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/UserConfigBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/UserConfigBuilderTest.java
index e3605115d05..bb3a0f26ee9 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/UserConfigBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/UserConfigBuilderTest.java
@@ -21,10 +21,9 @@ import java.io.Reader;
import java.io.StringReader;
import java.util.Optional;
-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;
/**
* @author Ulf Lilleengen
@@ -46,8 +45,8 @@ public class UserConfigBuilderTest {
ConfigDefinitionKey key = new ConfigDefinitionKey("simpletypes", "test");
assertNotNull(map.get(key));
SimpletypesConfig config = createConfig(SimpletypesConfig.class, map.get(key));
- assertThat(config.intval(), is(13));
- assertThat(config.stringval(), is("foolio"));
+ assertEquals(13, config.intval());
+ assertEquals("foolio", config.stringval());
}
private static <ConfigType extends ConfigInstance> ConfigType createConfig(Class<ConfigType> clazz, ConfigPayloadBuilder builder) {
@@ -66,10 +65,10 @@ public class UserConfigBuilderTest {
ConfigDefinitionKey key = new ConfigDefinitionKey("arraytypes", "test");
assertNotNull(map.get(key));
ArraytypesConfig config = createConfig(ArraytypesConfig.class, map.get(key));
- assertThat(config.intarr().size(), is(3));
- assertThat(config.intarr(0), is(13));
- assertThat(config.intarr(1), is(10));
- assertThat(config.intarr(2), is(1337));
+ assertEquals(3, config.intarr().size());
+ assertEquals(13, config.intarr(0));
+ assertEquals(10, config.intarr(1));
+ assertEquals(1337, config.intarr(2));
}
@Test
@@ -93,10 +92,10 @@ public class UserConfigBuilderTest {
ConfigDefinitionKey key = new ConfigDefinitionKey(SpecialtokensConfig.CONFIG_DEF_NAME, SpecialtokensConfig.CONFIG_DEF_NAMESPACE);
assertNotNull(map.get(key));
SpecialtokensConfig config = createConfig(SpecialtokensConfig.class, map.get(key));
- assertThat(config.tokenlist().size(), is(1));
- assertThat(config.tokenlist().get(0).name(), is("default"));
- assertThat(config.tokenlist().get(0).tokens().size(), is(1));
- assertThat(config.tokenlist().get(0).tokens().get(0).token(), is("dvd+-r"));
+ assertEquals(1, config.tokenlist().size());
+ assertEquals("default", config.tokenlist().get(0).name());
+ assertEquals(1, config.tokenlist().get(0).tokens().size());
+ assertEquals("dvd+-r", config.tokenlist().get(0).tokens().get(0).token());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java
index 68c623ec9a3..a27b6786800 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java
@@ -35,13 +35,11 @@ import java.util.List;
import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER;
import static com.yahoo.config.model.api.container.ContainerServiceType.METRICS_PROXY_CONTAINER;
import static com.yahoo.vespa.config.search.core.ProtonConfig.Feeding.Shared_field_writer_executor;
-import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsString;
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.assertTrue;
import static org.junit.Assert.fail;
@@ -50,6 +48,7 @@ import static org.junit.Assert.fail;
*/
public class ContentBuilderTest extends DomBuilderTest {
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -328,7 +327,7 @@ public class ContentBuilderTest extends DomBuilderTest {
assertTrue(b.getRootGroup().getMmapNoCoreLimit().isPresent());
assertEquals(200000, b.getRootGroup().getMmapNoCoreLimit().get().longValue());
- assertThat(s.getSearchNodes().size(), is(2));
+ assertEquals(2, s.getSearchNodes().size());
assertEquals(200000, s.getSearchNodes().get(0).getMMapNoCoreLimit());
assertEquals(200000, s.getSearchNodes().get(1).getMMapNoCoreLimit());
assertEquals("VESPA_MMAP_NOCORE_LIMIT=200000 ", s.getSearchNodes().get(0).getMMapNoCoreEnvVariable());
@@ -357,7 +356,7 @@ public class ContentBuilderTest extends DomBuilderTest {
assertTrue(b.getRootGroup().getCoreOnOOM().isPresent());
assertTrue(b.getRootGroup().getCoreOnOOM().get());
- assertThat(s.getSearchNodes().size(), is(2));
+ assertEquals(2, s.getSearchNodes().size());
assertTrue(s.getSearchNodes().get(0).getCoreOnOOM());
assertTrue(s.getSearchNodes().get(1).getCoreOnOOM());
assertEquals("", s.getSearchNodes().get(0).getCoreOnOOMEnvVariable());
@@ -383,7 +382,7 @@ public class ContentBuilderTest extends DomBuilderTest {
assertEquals(2, b.getStorageCluster().getChildren().size());
assertFalse(b.getRootGroup().getCoreOnOOM().isPresent());
- assertThat(s.getSearchNodes().size(), is(2));
+ assertEquals(2, s.getSearchNodes().size());
assertFalse(s.getSearchNodes().get(0).getCoreOnOOM());
assertFalse(s.getSearchNodes().get(1).getCoreOnOOM());
assertEquals("VESPA_SILENCE_CORE_ON_OOM=true ", s.getSearchNodes().get(0).getCoreOnOOMEnvVariable());
@@ -409,7 +408,7 @@ public class ContentBuilderTest extends DomBuilderTest {
assertEquals(2, b.getStorageCluster().getChildren().size());
assertFalse(b.getRootGroup().getMmapNoCoreLimit().isPresent());
- assertThat(s.getSearchNodes().size(), is(2));
+ assertEquals(2, s.getSearchNodes().size());
assertEquals(200000, s.getSearchNodes().get(0).getMMapNoCoreLimit());
assertEquals(-1, s.getSearchNodes().get(1).getMMapNoCoreLimit());
assertEquals("VESPA_MMAP_NOCORE_LIMIT=200000 ", s.getSearchNodes().get(0).getMMapNoCoreEnvVariable());
@@ -435,7 +434,7 @@ public class ContentBuilderTest extends DomBuilderTest {
assertEquals(2, b.getStorageCluster().getChildren().size());
assertFalse(b.getRootGroup().getCoreOnOOM().isPresent());
- assertThat(s.getSearchNodes().size(), is(2));
+ assertEquals(2, s.getSearchNodes().size());
assertTrue(s.getSearchNodes().get(0).getCoreOnOOM());
assertFalse(s.getSearchNodes().get(1).getCoreOnOOM());
assertEquals("", s.getSearchNodes().get(0).getCoreOnOOMEnvVariable());
@@ -470,7 +469,7 @@ public class ContentBuilderTest extends DomBuilderTest {
assertTrue(b.getRootGroup().getVespaMallocDebugStackTrace().isPresent());
assertEquals("all", b.getRootGroup().getVespaMallocDebugStackTrace().get());
- assertThat(s.getSearchNodes().size(), is(4));
+ assertEquals(4, s.getSearchNodes().size());
for (SearchNode n : s.getSearchNodes()) {
assertEquals("proton", n.getNoVespaMalloc());
assertEquals("VESPA_USE_NO_VESPAMALLOC=\"proton\" ", n.getNoVespaMallocEnvVariable());
@@ -508,7 +507,7 @@ public class ContentBuilderTest extends DomBuilderTest {
assertFalse(b.getRootGroup().getVespaMallocDebug().isPresent());
assertFalse(b.getRootGroup().getVespaMallocDebugStackTrace().isPresent());
- assertThat(s.getSearchNodes().size(), is(4));
+ assertEquals(4, s.getSearchNodes().size());
assertEquals("VESPA_SILENCE_CORE_ON_OOM=true OMP_NUM_THREADS=1 VESPA_USE_NO_VESPAMALLOC=\"proton\" ", s.getSearchNodes().get(0).getEnvVariables());
assertEquals("VESPA_SILENCE_CORE_ON_OOM=true OMP_NUM_THREADS=1 VESPA_USE_VESPAMALLOC_D=\"distributord\" ", s.getSearchNodes().get(1).getEnvVariables());
assertEquals("VESPA_SILENCE_CORE_ON_OOM=true OMP_NUM_THREADS=1 VESPA_USE_VESPAMALLOC_DST=\"all\" ", s.getSearchNodes().get(2).getEnvVariables());
@@ -535,15 +534,15 @@ public class ContentBuilderTest extends DomBuilderTest {
assertNotNull(s.getIndexed());
assertEquals(2, b.getStorageCluster().getChildren().size());
assertTrue(b.getStorageCluster().getChildren().get("0").getAffinity().isPresent());
- assertThat(b.getStorageCluster().getChildren().get("0").getAffinity().get().cpuSocket(), is(0));
+ assertEquals(0, b.getStorageCluster().getChildren().get("0").getAffinity().get().cpuSocket());
assertTrue(b.getStorageCluster().getChildren().get("1").getAffinity().isPresent());
- assertThat(b.getStorageCluster().getChildren().get("1").getAffinity().get().cpuSocket(), is(1));
+ assertEquals(1, b.getStorageCluster().getChildren().get("1").getAffinity().get().cpuSocket());
- assertThat(s.getSearchNodes().size(), is(2));
+ assertEquals(2, s.getSearchNodes().size());
assertTrue(s.getSearchNodes().get(0).getAffinity().isPresent());
- assertThat(s.getSearchNodes().get(0).getAffinity().get().cpuSocket(), is(0));
+ assertEquals(0, s.getSearchNodes().get(0).getAffinity().get().cpuSocket());
assertTrue(s.getSearchNodes().get(1).getAffinity().isPresent());
- assertThat(s.getSearchNodes().get(1).getAffinity().get().cpuSocket(), is(1));
+ assertEquals(1, s.getSearchNodes().get(1).getAffinity().get().cpuSocket());
}
@Test
@@ -571,19 +570,19 @@ public class ContentBuilderTest extends DomBuilderTest {
assertEquals(6, b.getStorageCluster().getChildren().size());
assertTrue(b.getRootGroup().useCpuSocketAffinity());
- assertThat(s.getSearchNodes().size(), is(6));
+ assertEquals(6, s.getSearchNodes().size());
assertTrue(s.getSearchNodes().get(0).getAffinity().isPresent());
assertTrue(s.getSearchNodes().get(1).getAffinity().isPresent());
assertTrue(s.getSearchNodes().get(2).getAffinity().isPresent());
assertTrue(s.getSearchNodes().get(3).getAffinity().isPresent());
assertTrue(s.getSearchNodes().get(4).getAffinity().isPresent());
assertTrue(s.getSearchNodes().get(5).getAffinity().isPresent());
- assertThat(s.getSearchNodes().get(0).getAffinity().get().cpuSocket(),is (0));
- assertThat(s.getSearchNodes().get(1).getAffinity().get().cpuSocket(),is (1));
- assertThat(s.getSearchNodes().get(2).getAffinity().get().cpuSocket(),is (2));
- assertThat(s.getSearchNodes().get(3).getAffinity().get().cpuSocket(),is (0));
- assertThat(s.getSearchNodes().get(4).getAffinity().get().cpuSocket(),is (1));
- assertThat(s.getSearchNodes().get(5).getAffinity().get().cpuSocket(),is (0));
+ assertEquals(0, s.getSearchNodes().get(0).getAffinity().get().cpuSocket());
+ assertEquals(1, s.getSearchNodes().get(1).getAffinity().get().cpuSocket());
+ assertEquals(2, s.getSearchNodes().get(2).getAffinity().get().cpuSocket());
+ assertEquals(0, s.getSearchNodes().get(3).getAffinity().get().cpuSocket());
+ assertEquals(1, s.getSearchNodes().get(4).getAffinity().get().cpuSocket());
+ assertEquals(0, s.getSearchNodes().get(5).getAffinity().get().cpuSocket());
// TODO: Only needed for the search nodes anyway?
assertFalse(b.getStorageCluster().getChildren().get("0").getAffinity().isPresent());
@@ -592,12 +591,12 @@ public class ContentBuilderTest extends DomBuilderTest {
assertFalse(b.getStorageCluster().getChildren().get("3").getAffinity().isPresent());
assertFalse(b.getStorageCluster().getChildren().get("4").getAffinity().isPresent());
assertFalse(b.getStorageCluster().getChildren().get("5").getAffinity().isPresent());
- //assertThat(b.getStorageNodes().getChildren().get("0").getAffinity().get().cpuSocket(), is(0));
- //assertThat(b.getStorageNodes().getChildren().get("1").getAffinity().get().cpuSocket(), is(1));
- //assertThat(b.getStorageNodes().getChildren().get("2").getAffinity().get().cpuSocket(), is(2));
- //assertThat(b.getStorageNodes().getChildren().get("3").getAffinity().get().cpuSocket(), is(0));
- //assertThat(b.getStorageNodes().getChildren().get("4").getAffinity().get().cpuSocket(), is(1));
- //assertThat(b.getStorageNodes().getChildren().get("5").getAffinity().get().cpuSocket(), is(0));
+ //assertEquals(0, b.getStorageNodes().getChildren().get("0").getAffinity().get().cpuSocket());
+ //assertEquals(1, b.getStorageNodes().getChildren().get("1").getAffinity().get().cpuSocket());
+ //assertEquals(2, b.getStorageNodes().getChildren().get("2").getAffinity().get().cpuSocket());
+ //assertEquals(0, b.getStorageNodes().getChildren().get("3").getAffinity().get().cpuSocket());
+ //assertEquals(1, b.getStorageNodes().getChildren().get("4").getAffinity().get().cpuSocket());
+ //assertEquals(0, b.getStorageNodes().getChildren().get("5").getAffinity().get().cpuSocket());
}
@@ -666,10 +665,10 @@ public class ContentBuilderTest extends DomBuilderTest {
a.getSearch().getConfig(pb);
List<String> serialize = ConfigInstance.serialize(new ProtonConfig(pb));
String cfg = StringUtilities.implode(serialize.toArray(new String[serialize.size()]), "\n");
- assertThat(cfg, containsString("summary.cache.maxbytes 8192"));
- assertThat(cfg, containsString("summary.cache.compression.level 8"));
- assertThat(cfg, containsString("summary.cache.compression.type LZ4"));
- assertThat(cfg, containsString("summary.read.io DIRECTIO"));
+ assertTrue(cfg.contains("summary.cache.maxbytes 8192"));
+ assertTrue(cfg.contains("summary.cache.compression.level 8"));
+ assertTrue(cfg.contains("summary.cache.compression.type LZ4"));
+ assertTrue(cfg.contains("summary.read.io DIRECTIO"));
}
@Test
@@ -716,8 +715,8 @@ public class ContentBuilderTest extends DomBuilderTest {
content.getSearch().getIndexed().getSearchNode(0).cascadeConfig(builder);
content.getSearch().getIndexed().getSearchNode(0).addUserConfig(builder);
ProtonConfig config = new ProtonConfig(builder);
- assertThat(config.search().mmap().options().size(), is(1));
- assertThat(config.search().mmap().options(0), is(ProtonConfig.Search.Mmap.Options.POPULATE));
+ assertEquals(1, config.search().mmap().options().size());
+ assertEquals(ProtonConfig.Search.Mmap.Options.POPULATE, config.search().mmap().options(0));
}
private String singleNodeContentXml() {
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..6006b52cf02 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.hamcrest.MatcherAssert.assertThat;
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'"));
}
}
@@ -109,7 +112,7 @@ public class DomSchemaChainsBuilderTest extends DomBuilderTest {
}
private Matcher<ChainedComponent<?>> searcherWithId(final String componentId) {
- return new BaseMatcher<ChainedComponent<?>>() {
+ return new BaseMatcher<>() {
@Override
public boolean matches(Object o) {
return o instanceof ChainedComponent &&
@@ -127,7 +130,7 @@ public class DomSchemaChainsBuilderTest extends DomBuilderTest {
public void checkProviderFederationOptions() {
FederationOptions options = getProvider().federationOptions();
- assertEquals(true, options.getOptional());
+ assertTrue(options.getOptional());
assertEquals(2300, options.getTimeoutInMilliseconds());
}
@@ -135,7 +138,7 @@ public class DomSchemaChainsBuilderTest extends DomBuilderTest {
public void checkSourceFederationOptions() {
FederationOptions options = getSource().federationOptions();
- assertEquals(true, options.getOptional()); //inherited
+ assertTrue(options.getOptional()); //inherited
assertEquals(12, options.getTimeoutInMilliseconds());
}
@@ -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/AccessControlTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessControlTest.java
index 9d85b0ed4d1..f6a5bc14ab5 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessControlTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/AccessControlTest.java
@@ -22,16 +22,8 @@ import java.util.Set;
import java.util.stream.Collectors;
import static com.yahoo.vespa.defaults.Defaults.getDefaults;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.not;
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;
@@ -106,7 +98,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
" </http>");
Set<String> actualBindings = getFilterBindings(http, AccessControl.ACCESS_CONTROL_EXCLUDED_CHAIN_ID);
- assertThat(actualBindings, containsInAnyOrder(
+ assertTrue(actualBindings.containsAll(List.of(
"http://*:4443/ApplicationStatus",
"http://*:4443/status.html",
"http://*:4443/state/v1",
@@ -115,7 +107,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
"http://*:4443/prometheus/v1/*",
"http://*:4443/metrics/v2",
"http://*:4443/metrics/v2/*",
- "http://*:4443/"));
+ "http://*:4443/")));
}
@Test
@@ -131,7 +123,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
Set<String> excludedBindings = getFilterBindings(http, AccessControl.ACCESS_CONTROL_EXCLUDED_CHAIN_ID);
for (String binding : bindings) {
- assertThat(excludedBindings, not(hasItem(binding)));
+ assertFalse(excludedBindings.contains(binding));
}
}
@@ -154,7 +146,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
" </http>");
Set<String> actualBindings = getFilterBindings(http, AccessControl.ACCESS_CONTROL_EXCLUDED_CHAIN_ID);
- assertThat(actualBindings, hasItems("http://*:4443/custom-handler/*", "http://*:4443/search/*", "http://*:4443/status.html"));
+ assertTrue(actualBindings.containsAll(List.of("http://*:4443/custom-handler/*", "http://*:4443/search/*", "http://*:4443/status.html")));
}
@Test
@@ -167,7 +159,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
" </http>");
Set<String> actualBindings = getFilterBindings(http, AccessControl.ACCESS_CONTROL_CHAIN_ID);
- assertThat(actualBindings, empty());
+ assertTrue(actualBindings.isEmpty());
HostedSslConnectorFactory hostedConnectorFactory = (HostedSslConnectorFactory)http.getHttpServer().get().getConnectorFactories().stream()
.filter(connectorFactory -> connectorFactory instanceof HostedSslConnectorFactory)
@@ -182,12 +174,12 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
public void access_control_is_implicitly_added_for_hosted_apps() {
Http http = createModelAndGetHttp("<container version='1.0'/>");
Optional<AccessControl> maybeAccessControl = http.getAccessControl();
- assertThat(maybeAccessControl.isPresent(), is(true));
+ assertTrue(maybeAccessControl.isPresent());
AccessControl accessControl = maybeAccessControl.get();
- assertThat(accessControl.writeEnabled, is(false));
- assertThat(accessControl.readEnabled, is(false));
- assertThat(accessControl.clientAuthentication, is(AccessControl.ClientAuthentication.need));
- assertThat(accessControl.domain, equalTo("my-tenant-domain"));
+ assertFalse(accessControl.writeEnabled);
+ assertFalse(accessControl.readEnabled);
+ assertEquals(AccessControl.ClientAuthentication.need, accessControl.clientAuthentication);
+ assertEquals("my-tenant-domain", accessControl.domain);
}
@Test
@@ -202,9 +194,9 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
" </request-chain>",
" </filtering>",
" </http>");
- assertThat(http.getAccessControl().isPresent(), is(true));
- assertThat(http.getFilterChains().hasChain(AccessControl.ACCESS_CONTROL_CHAIN_ID), is(true));
- assertThat(http.getFilterChains().hasChain(ComponentId.fromString("myChain")), is(true));
+ assertTrue(http.getAccessControl().isPresent());
+ assertTrue(http.getFilterChains().hasChain(AccessControl.ACCESS_CONTROL_CHAIN_ID));
+ assertTrue(http.getFilterChains().hasChain(ComponentId.fromString("myChain")));
}
@Test
@@ -226,7 +218,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
" </http>");
Set<String> actualExcludeBindings = getFilterBindings(http, AccessControl.ACCESS_CONTROL_EXCLUDED_CHAIN_ID);
- assertThat(actualExcludeBindings, containsInAnyOrder(
+ assertTrue(actualExcludeBindings.containsAll(List.of(
"http://*:4443/ApplicationStatus",
"http://*:4443/status.html",
"http://*:4443/state/v1",
@@ -234,10 +226,10 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
"http://*:4443/prometheus/v1",
"http://*:4443/prometheus/v1/*",
"http://*:4443/metrics/v2",
- "http://*:4443/metrics/v2/*"));
+ "http://*:4443/metrics/v2/*")));
Set<String> actualCustomChainBindings = getFilterBindings(http, ComponentId.fromString("my-custom-request-chain"));
- assertThat(actualCustomChainBindings, containsInAnyOrder("http://*/custom-handler/*", "http://*/"));
+ assertTrue(actualCustomChainBindings.containsAll(List.of("http://*/custom-handler/*", "http://*/")));
}
@Test
@@ -261,7 +253,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
" </http>");
Set<String> actualExcludeBindings = getFilterBindings(http, AccessControl.ACCESS_CONTROL_EXCLUDED_CHAIN_ID);
- assertThat(actualExcludeBindings, containsInAnyOrder(
+ assertTrue(actualExcludeBindings.containsAll(List.of(
"http://*:4443/ApplicationStatus",
"http://*:4443/status.html",
"http://*:4443/state/v1",
@@ -271,10 +263,10 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
"http://*:4443/metrics/v2",
"http://*:4443/metrics/v2/*",
"http://*:4443/",
- "http://*:4443/custom-handler/*"));
+ "http://*:4443/custom-handler/*")));
Set<String> actualCustomChainBindings = getFilterBindings(http, ComponentId.fromString("my-custom-response-chain"));
- assertThat(actualCustomChainBindings, containsInAnyOrder("http://*/custom-handler/*"));
+ assertTrue(actualCustomChainBindings.contains("http://*/custom-handler/*"));
}
@Test
@@ -341,7 +333,7 @@ public class AccessControlTest extends ContainerModelBuilderTestBase {
" </http>");
Set<String> actualBindings = getFilterBindings(http, AccessControl.DEFAULT_CONNECTOR_HOSTED_REQUEST_CHAIN_ID);
- assertThat(actualBindings, empty());
+ assertTrue(actualBindings.isEmpty());
ConnectorFactory connectorFactory = http.getHttpServer().get().getConnectorFactories().stream()
.filter(cf -> cf.getListenPort() == Defaults.getDefaults().vespaWebServicePort())
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/JettyContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java
index 5221139ceaa..49c1783c187 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JettyContainerModelBuilderTest.java
@@ -23,12 +23,8 @@ import java.io.StringReader;
import java.util.List;
import java.util.Optional;
-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.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
@@ -54,8 +50,8 @@ public class JettyContainerModelBuilderTest extends ContainerModelBuilderTestBas
);
createModel(root, clusterElem);
ConnectorConfig cfg = root.getConfig(ConnectorConfig.class, "default/http/jdisc-jetty/bananarama");
- assertThat(cfg.requestHeaderSize(), is(300000));
- assertThat(cfg.headerCacheSize(), is(300000));
+ assertEquals(300000, cfg.requestHeaderSize());
+ assertEquals(300000, cfg.headerCacheSize());
}
@Test
@@ -92,15 +88,15 @@ public class JettyContainerModelBuilderTest extends ContainerModelBuilderTestBas
final ComponentsConfig.Components jettyHttpServerComponent = extractComponentByClassName(
containerComponentsConfig(), com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName());
- assertThat(jettyHttpServerComponent, is(not(nullValue())));
+ assertNotNull(jettyHttpServerComponent);
final ComponentsConfig.Components filterBindingsProviderComponent = extractComponentByClassName(
containerComponentsConfig(), FilterBindingsProvider.class.getName());
- assertThat(filterBindingsProviderComponent, is(not(nullValue())));
+ assertNotNull(filterBindingsProviderComponent);
final ComponentsConfig.Components.Inject filterBindingsProviderInjection = extractInjectionById(
jettyHttpServerComponent, filterBindingsProviderComponent.id());
- assertThat(filterBindingsProviderInjection, is(not(nullValue())));
+ assertNotNull(filterBindingsProviderInjection);
}
@Test
@@ -116,15 +112,15 @@ public class JettyContainerModelBuilderTest extends ContainerModelBuilderTestBas
final ComponentsConfig.Components jettyHttpServerComponent = extractComponentByClassName(
clusterComponentsConfig(), com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName());
- assertThat(jettyHttpServerComponent, is(not(nullValue())));
+ assertNotNull(jettyHttpServerComponent);
final ComponentsConfig.Components filterBindingsProviderComponent = extractComponentByClassName(
clusterComponentsConfig(), FilterBindingsProvider.class.getName());
- assertThat(filterBindingsProviderComponent, is(not(nullValue())));
+ assertNotNull(filterBindingsProviderComponent);
final ComponentsConfig.Components.Inject filterBindingsProviderInjection = extractInjectionById(
jettyHttpServerComponent, filterBindingsProviderComponent.id());
- assertThat(filterBindingsProviderInjection, is(not(nullValue())));
+ assertNotNull(filterBindingsProviderInjection);
}
@Test
@@ -168,31 +164,31 @@ public class JettyContainerModelBuilderTest extends ContainerModelBuilderTestBas
createModel(root, clusterElem);
ConnectorConfig minimalCfg = root.getConfig(ConnectorConfig.class, "default/http/jdisc-jetty/minimal/configured-ssl-provider@minimal");
assertTrue(minimalCfg.ssl().enabled());
- assertThat(minimalCfg.ssl().privateKeyFile(), is(equalTo("/foo/key")));
- assertThat(minimalCfg.ssl().certificateFile(), is(equalTo("/foo/cert")));
- assertThat(minimalCfg.ssl().caCertificateFile(), is(equalTo("")));
- assertThat(minimalCfg.ssl().clientAuth(), is(equalTo(ConnectorConfig.Ssl.ClientAuth.Enum.DISABLED)));
+ assertEquals("/foo/key", minimalCfg.ssl().privateKeyFile());
+ assertEquals("/foo/cert", minimalCfg.ssl().certificateFile());
+ assertTrue(minimalCfg.ssl().caCertificateFile().isEmpty());
+ assertEquals(ConnectorConfig.Ssl.ClientAuth.Enum.DISABLED, minimalCfg.ssl().clientAuth());
ConnectorConfig withCaCerts = root.getConfig(ConnectorConfig.class, "default/http/jdisc-jetty/with-cacerts/configured-ssl-provider@with-cacerts");
assertTrue(withCaCerts.ssl().enabled());
- assertThat(withCaCerts.ssl().privateKeyFile(), is(equalTo("/foo/key")));
- assertThat(withCaCerts.ssl().certificateFile(), is(equalTo("/foo/cert")));
- assertThat(withCaCerts.ssl().caCertificateFile(), is(equalTo("/foo/cacerts")));
- assertThat(withCaCerts.ssl().clientAuth(), is(equalTo(ConnectorConfig.Ssl.ClientAuth.Enum.DISABLED)));
+ assertEquals("/foo/key", withCaCerts.ssl().privateKeyFile());
+ assertEquals("/foo/cert", withCaCerts.ssl().certificateFile());
+ assertEquals("/foo/cacerts", withCaCerts.ssl().caCertificateFile());
+ assertEquals(ConnectorConfig.Ssl.ClientAuth.Enum.DISABLED, withCaCerts.ssl().clientAuth());
ConnectorConfig needClientAuth = root.getConfig(ConnectorConfig.class, "default/http/jdisc-jetty/need-client-auth/configured-ssl-provider@need-client-auth");
assertTrue(needClientAuth.ssl().enabled());
- assertThat(needClientAuth.ssl().privateKeyFile(), is(equalTo("/foo/key")));
- assertThat(needClientAuth.ssl().certificateFile(), is(equalTo("/foo/cert")));
- assertThat(needClientAuth.ssl().caCertificateFile(), is(equalTo("")));
- assertThat(needClientAuth.ssl().clientAuth(), is(equalTo(ConnectorConfig.Ssl.ClientAuth.Enum.NEED_AUTH)));
+ assertEquals("/foo/key", needClientAuth.ssl().privateKeyFile());
+ assertEquals("/foo/cert", needClientAuth.ssl().certificateFile());
+ assertTrue(needClientAuth.ssl().caCertificateFile().isEmpty());
+ assertEquals(ConnectorConfig.Ssl.ClientAuth.Enum.NEED_AUTH, needClientAuth.ssl().clientAuth());
ConnectorConfig withCiphersAndProtocols = root.getConfig(ConnectorConfig.class, "default/http/jdisc-jetty/with-ciphers-and-protocols/configured-ssl-provider@with-ciphers-and-protocols");
assertTrue(withCiphersAndProtocols.ssl().enabled());
- assertThat(withCiphersAndProtocols.ssl().privateKeyFile(), is(equalTo("/foo/key")));
- assertThat(withCiphersAndProtocols.ssl().certificateFile(), is(equalTo("/foo/cert")));
- assertThat(withCiphersAndProtocols.ssl().enabledCipherSuites(), is(equalTo(List.of("TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384"))));
- assertThat(withCiphersAndProtocols.ssl().enabledProtocols(), is(equalTo(List.of("TLSv1.3"))));
+ assertEquals("/foo/key", withCiphersAndProtocols.ssl().privateKeyFile());
+ assertEquals("/foo/cert", withCiphersAndProtocols.ssl().certificateFile());
+ assertEquals(List.of("TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384"), withCiphersAndProtocols.ssl().enabledCipherSuites());
+ assertEquals(List.of("TLSv1.3"), withCiphersAndProtocols.ssl().enabledProtocols());
ContainerCluster<?> cluster = (ContainerCluster<?>) root.getChildren().get("default");
List<ConnectorFactory> connectorFactories = cluster.getChildrenByTypeRecursive(ConnectorFactory.class);
@@ -303,20 +299,18 @@ public class JettyContainerModelBuilderTest extends ContainerModelBuilderTestBas
ContainerCluster<?> cluster = (ContainerCluster<?>) root.getChildren().get("default");
List<JettyHttpServer> jettyServers = cluster.getChildrenByTypeRecursive(JettyHttpServer.class);
- assertThat(jettyServers.size(), is(1));
+ assertEquals(1, jettyServers.size());
JettyHttpServer server = jettyServers.get(0);
- assertThat(server.model.bundleInstantiationSpec.classId.toString(),
- is(com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()));
- assertThat(server.model.bundleInstantiationSpec.bundle.toString(),
- is(com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()));
- assertThat(server.getConnectorFactories().size(), is(1));
-
- assertThat(
- extractComponentByClassName(
- containerComponentsConfig(),
- com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()),
- is(not(nullValue())));
+ assertEquals(com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName(),
+ server.model.bundleInstantiationSpec.classId.toString());
+ assertEquals(com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName(),
+ server.model.bundleInstantiationSpec.bundle.toString());
+ assertEquals(1, server.getConnectorFactories().size());
+
+ assertNotNull(extractComponentByClassName(
+ containerComponentsConfig(),
+ com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()));
}
private static ComponentsConfig.Components extractComponentByClassName(
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 4d34df98fb7..8b41ab145ec 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
@@ -25,6 +25,7 @@ import java.util.logging.Level;
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
@@ -166,46 +167,100 @@ public class JvmOptionsTest extends ContainerModelBuilderTestBase {
"$(touch", "/tmp/hello-from-gc-options)");
// Valid options, should not log anything
- verifyLoggingOfJvmGcOptions(true,
- "-XX:+ParallelGCThreads=8");
+ verifyLoggingOfJvmGcOptions(true, "-XX:+ParallelGCThreads=8");
+ verifyLoggingOfJvmGcOptions(true, "-XX:MaxTenuringThreshold"); // No + or - after colon
verifyLoggingOfJvmGcOptions(false, "-XX:+UseConcMarkSweepGC");
}
+ @Test
+ public void requireThatInvalidJvmGcOptionsFailDeployment() throws IOException, SAXException {
+ 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 in services.xml: bar,foo"));
+ }
+ }
private void verifyLoggingOfJvmGcOptions(boolean isHosted, String override, String... invalidOptions) throws IOException, SAXException {
verifyLoggingOfJvmOptions(isHosted, "gc-options", override, invalidOptions);
}
private void verifyLoggingOfJvmOptions(boolean isHosted, String optionName, String override, String... invalidOptions) throws IOException, SAXException {
- String servicesXml =
- "<container version='1.0'>" +
- " <nodes>" +
- " <jvm " + optionName + "='" + override + "'/>" +
- " <node hostalias='mockhost'/>" +
- " </nodes>" +
- "</container>";
- ApplicationPackage app = new MockApplicationPackage.Builder().withServices(servicesXml).build();
TestLogger logger = new TestLogger();
- new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder()
- .applicationPackage(app)
- .deployLogger(logger)
- .properties(new TestProperties().setHostedVespa(isHosted))
- .build());
+ buildModelWithJvmOptions(isHosted, logger, optionName, override);
List<String> strings = Arrays.asList(invalidOptions.clone());
- if (strings.isEmpty()) return;
+ // Verify that nothing is logged if there are no invalid options
+ if (strings.isEmpty()) {
+ assertEquals(0, logger.msgs.size());
+ return;
+ }
Collections.sort(strings);
Pair<Level, String> firstOption = logger.msgs.get(0);
assertEquals(Level.WARNING, firstOption.getFirst());
assertEquals("Invalid JVM " + (optionName.equals("gc-options") ? "GC " : "") +
- "options from services.xml: " + String.join(",", strings), firstOption.getSecond());
+ "options in services.xml: " + String.join(",", strings), firstOption.getSecond());
+ }
+
+ private void buildModelWithJvmOptions(boolean isHosted, TestLogger logger, String optionName, String override) throws IOException, SAXException {
+ buildModelWithJvmOptions(new TestProperties().setHostedVespa(isHosted), logger, optionName, override);
+ }
+
+ private void buildModelWithJvmOptions(TestProperties properties, TestLogger logger, String optionName, String override) throws IOException, SAXException {
+ String servicesXml =
+ "<container version='1.0'>" +
+ " <nodes>" +
+ " <jvm " + optionName + "='" + override + "'/>" +
+ " <node hostalias='mockhost'/>" +
+ " </nodes>" +
+ "</container>";
+ ApplicationPackage app = new MockApplicationPackage.Builder().withServices(servicesXml).build();
+ new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder()
+ .applicationPackage(app)
+ .deployLogger(logger)
+ .properties(properties)
+ .build());
}
@Test
public void requireThatJvmOptionsAreLogged() throws IOException, SAXException {
+ verifyLoggingOfJvmOptions(true,
+ "options",
+ "-Xms2G foo bar",
+ "foo", "bar");
+ verifyLoggingOfJvmOptions(true,
+ "options",
+ "$(touch /tmp/hello-from-gc-options)",
+ "$(touch", "/tmp/hello-from-gc-options)");
+
+ verifyLoggingOfJvmOptions(false,
+ "options",
+ "$(touch /tmp/hello-from-gc-options)",
+ "$(touch", "/tmp/hello-from-gc-options)");
+
+ // Valid options, should not log anything
verifyLoggingOfJvmOptions(true, "options", "-Xms2G");
+ verifyLoggingOfJvmOptions(true, "options", "-verbose:gc");
+ verifyLoggingOfJvmOptions(true, "options", "-Dvespa.freezedetector.disable=true");
verifyLoggingOfJvmOptions(false, "options", "-Xms2G");
}
+ @Test
+ public void requireThatInvalidJvmOptionsFailDeployment() throws IOException, SAXException {
+ try {
+ buildModelWithJvmOptions(new TestProperties().setHostedVespa(true).failDeploymentWithInvalidJvmOptions(true),
+ new TestLogger(),
+ "options",
+ "-Xms2G foo bar");
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().contains("Invalid JVM options in services.xml: bar,foo"));
+ }
+ }
+
}
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..b50261b7568 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,14 +19,12 @@ 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.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.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -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 357ae7e2656..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,15 +38,14 @@ 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;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.OptionalDouble;
import java.util.OptionalInt;
import static org.junit.Assert.assertEquals;
@@ -61,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);
@@ -867,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>" +
@@ -881,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,
@@ -1048,6 +1046,27 @@ public class ContentClusterTest extends ContentBaseTest {
assertEquals(7, resolveMaxCompactBuffers(OptionalInt.of(7)));
}
+ private long resolveMaxTLSSize(OptionalDouble tlsSizeFraction, Optional<Flavor> flavor) throws Exception {
+ TestProperties testProperties = new TestProperties();
+ if (tlsSizeFraction.isPresent()) {
+ testProperties.tlsSizeFraction(tlsSizeFraction.getAsDouble());
+ }
+ ContentCluster cc = createOneNodeCluster(testProperties, flavor);
+ ProtonConfig.Builder protonBuilder = new ProtonConfig.Builder();
+ cc.getSearch().getSearchNodes().get(0).getConfig(protonBuilder);
+ ProtonConfig protonConfig = new ProtonConfig(protonBuilder);
+ return protonConfig.flush().memory().maxtlssize();
+ }
+ @Test
+ public void default_max_tls_size_controlled_by_properties() throws Exception {
+ var flavor = new Flavor(new FlavorsConfig.Flavor(new FlavorsConfig.Flavor.Builder().name("test").minDiskAvailableGb(100)));
+ assertEquals(21474836480L, resolveMaxTLSSize(OptionalDouble.empty(), Optional.empty()));
+ assertEquals(21474836480L, resolveMaxTLSSize(OptionalDouble.of(0.02), Optional.empty()));
+ assertEquals(7516192768L, resolveMaxTLSSize(OptionalDouble.empty(), Optional.of(flavor)));
+ assertEquals(2147483648L, resolveMaxTLSSize(OptionalDouble.of(0.02), Optional.of(flavor)));
+ assertEquals(3221225472L, resolveMaxTLSSize(OptionalDouble.of(0.03), Optional.of(flavor)));
+ }
+
void assertZookeeperServerImplementation(String expectedClassName,
ClusterControllerContainerCluster clusterControllerCluster) {
for (ClusterControllerContainer c : clusterControllerCluster.getContainers()) {
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/NodeResourcesTuningTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/NodeResourcesTuningTest.java
index 781266c8223..e2645e0b39e 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/search/NodeResourcesTuningTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/search/NodeResourcesTuningTest.java
@@ -133,11 +133,13 @@ public class NodeResourcesTuningTest {
@Test
public void require_that_flush_strategy_tls_size_is_set_based_on_available_disk() {
- assertFlushStrategyTlsSize(7 * GB, 100);
- assertFlushStrategyTlsSize(35 * GB, 500);
- assertFlushStrategyTlsSize(84 * GB, 1200);
- assertFlushStrategyTlsSize(100 * GB, 1720);
- assertFlushStrategyTlsSize(100 * GB, 24000);
+ assertFlushStrategyTlsSize(2 * GB, 10, 0.05);
+ assertFlushStrategyTlsSize(7 * GB, 100, 0.07);
+ assertFlushStrategyTlsSize(5 * GB, 100, 0.05);
+ assertFlushStrategyTlsSize(35 * GB, 500, 0.07);
+ assertFlushStrategyTlsSize(84 * GB, 1200, 0.07);
+ assertFlushStrategyTlsSize(100 * GB, 1720, 0.07);
+ assertFlushStrategyTlsSize(100 * GB, 24000, 0.07);
}
@Test
@@ -178,8 +180,8 @@ public class NodeResourcesTuningTest {
assertEquals(expMemoryBytes, configFromMemorySetting(wantedMemoryGb + reservedMemoryGb, 0).flush().memory().each().maxmemory());
}
- private static void assertFlushStrategyTlsSize(long expTlsSizeBytes, int diskGb) {
- assertEquals(expTlsSizeBytes, configFromDiskSetting(diskGb).flush().memory().maxtlssize());
+ private static void assertFlushStrategyTlsSize(long expTlsSizeBytes, int diskGb, double tlsSizeFraction) {
+ assertEquals(expTlsSizeBytes, configFromDiskSetting(diskGb, tlsSizeFraction).flush().memory().maxtlssize());
}
private static void assertSummaryReadIo(ProtonConfig.Summary.Read.Io.Enum expValue, boolean fastDisk) {
@@ -199,51 +201,63 @@ public class NodeResourcesTuningTest {
}
private static ProtonConfig configFromDiskSetting(boolean fastDisk) {
- return getConfig(new FlavorsConfig.Flavor.Builder().fastDisk(fastDisk), 0);
+ return getConfig(new FlavorsConfig.Flavor.Builder().fastDisk(fastDisk));
}
private static ProtonConfig configFromDiskSetting(int diskGb) {
- return getConfig(new FlavorsConfig.Flavor.Builder().minDiskAvailableGb(diskGb), 0);
+ return configFromDiskSetting(diskGb, 0.07);
+ }
+ private static ProtonConfig configFromDiskSetting(int diskGb, double tlsSizeFraction) {
+ return getConfig(new FlavorsConfig.Flavor.Builder().minDiskAvailableGb(diskGb), 0, tlsSizeFraction);
}
private static ProtonConfig configFromMemorySetting(double memoryGb, double fractionOfMemoryReserved) {
- return getConfig(new FlavorsConfig.Flavor.Builder().minMainMemoryAvailableGb(memoryGb), fractionOfMemoryReserved);
+ return getConfig(new FlavorsConfig.Flavor.Builder().minMainMemoryAvailableGb(memoryGb), fractionOfMemoryReserved, 0.07);
}
private static ProtonConfig configFromMemorySetting(double memoryGb, ProtonConfig.Builder builder) {
return getConfig(new FlavorsConfig.Flavor.Builder()
- .minMainMemoryAvailableGb(memoryGb), builder, 0);
+ .minMainMemoryAvailableGb(memoryGb), builder);
}
private static ProtonConfig configFromNumCoresSetting(double numCores) {
- return getConfig(new FlavorsConfig.Flavor.Builder().minCpuCores(numCores), 0);
+ return getConfig(new FlavorsConfig.Flavor.Builder().minCpuCores(numCores));
}
private static ProtonConfig configFromNumCoresSetting(double numCores, int numThreadsPerSearch) {
return getConfig(new FlavorsConfig.Flavor.Builder().minCpuCores(numCores),
- new ProtonConfig.Builder(), numThreadsPerSearch, 0);
+ new ProtonConfig.Builder(), numThreadsPerSearch);
}
private static ProtonConfig configFromEnvironmentType(boolean docker) {
String environment = (docker ? "DOCKER_CONTAINER" : "undefined");
- return getConfig(new FlavorsConfig.Flavor.Builder().environment(environment), 0);
+ return getConfig(new FlavorsConfig.Flavor.Builder().environment(environment));
}
- private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, double fractionOfMemoryReserved) {
- return getConfig(flavorBuilder, new ProtonConfig.Builder(), fractionOfMemoryReserved);
+ private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder) {
+ return getConfig(flavorBuilder, new ProtonConfig.Builder());
}
- private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, double fractionOfMemoryReserved) {
- flavorBuilder.name("my_flavor");
- NodeResourcesTuning tuning = new NodeResourcesTuning(new Flavor(new FlavorsConfig.Flavor(flavorBuilder)).resources(), 1, fractionOfMemoryReserved);
- tuning.getConfig(protonBuilder);
- return new ProtonConfig(protonBuilder);
+ private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, double fractionOfMemoryReserved, double tlsSizeFraction) {
+ return getConfig(flavorBuilder, new ProtonConfig.Builder(), fractionOfMemoryReserved, tlsSizeFraction);
+ }
+
+ private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder) {
+ return getConfig(flavorBuilder, protonBuilder,1);
+ }
+ private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, double fractionOfMemoryReserved, double tlsSizeFraction) {
+ return getConfig(flavorBuilder, protonBuilder, 1, fractionOfMemoryReserved, tlsSizeFraction);
+ }
+
+ private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder,
+ int numThreadsPerSearch) {
+ return getConfig(flavorBuilder, protonBuilder, numThreadsPerSearch, 0, 0.07);
}
private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder,
- int numThreadsPerSearch, double fractionOfMemoryReserved) {
+ int numThreadsPerSearch, double fractionOfMemoryReserved, double tlsSizeFraction) {
flavorBuilder.name("my_flavor");
- NodeResourcesTuning tuning = new NodeResourcesTuning(new Flavor(new FlavorsConfig.Flavor(flavorBuilder)).resources(), numThreadsPerSearch, fractionOfMemoryReserved);
+ NodeResourcesTuning tuning = new NodeResourcesTuning(new Flavor(new FlavorsConfig.Flavor(flavorBuilder)).resources(), numThreadsPerSearch, fractionOfMemoryReserved, tlsSizeFraction);
tuning.getConfig(protonBuilder);
return new ProtonConfig(protonBuilder);
}
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 e8781904786..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;
@@ -52,7 +50,9 @@ public class SchemaNodeTest {
private static SearchNode createSearchNode(MockRoot root, String name, int distributionKey,
NodeSpec nodeSpec, boolean flushOnShutDown, boolean isHosted) {
- return SearchNode.create(root, name, distributionKey, nodeSpec, "mycluster", null, flushOnShutDown, Optional.empty(), Optional.empty(), isHosted, 0.0);
+ return SearchNode.create(root, name, distributionKey, nodeSpec, "mycluster", null, flushOnShutDown,
+ Optional.empty(), Optional.empty(), isHosted, 0.0,
+ root.getDeployState().featureFlags().tlsSizeFraction());
}
private static SearchNode createSearchNode(MockRoot root) {
@@ -90,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-proxy/pom.xml b/config-proxy/pom.xml
index bc79a5327eb..e79aec952db 100644
--- a/config-proxy/pom.xml
+++ b/config-proxy/pom.xml
@@ -54,11 +54,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>filedistribution</artifactId>
<version>${project.version}</version>
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
index 691bc6c43a7..f743c0ed231 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
@@ -20,9 +20,8 @@ import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.time.Duration;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author hmusum
@@ -60,7 +59,7 @@ public class ConfigProxyRpcServerTest {
ProxyServer proxy = createTestServer(new MockConfigSource());
Spec spec = new Spec("localhost", 12345);
ConfigProxyRpcServer server = new ConfigProxyRpcServer(proxy, new Supervisor(new Transport()), spec);
- assertThat(server.getSpec(), is(spec));
+ assertEquals(spec, server.getSpec());
}
/**
@@ -72,8 +71,8 @@ public class ConfigProxyRpcServerTest {
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
- assertThat(req.returnValues().get(0).asInt32(), is(0));
+ assertEquals(1, req.returnValues().size());
+ assertEquals(0, req.returnValues().get(0).asInt32());
}
/**
@@ -88,21 +87,20 @@ public class ConfigProxyRpcServerTest {
assertFalse(req.errorMessage(), req.isError());
String[] ret = req.returnValues().get(0).asStringArray();
- assertThat(req.returnValues().size(), is(1));
- assertThat(ret.length, is(0));
+ assertEquals(1, req.returnValues().size());
+ assertEquals(0, ret.length);
final RawConfig config = ProxyServerTest.fooConfig;
server.proxyServer().memoryCache().update(config);
req = new Request("listCachedConfig");
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
+ assertEquals(1, req.returnValues().size());
ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(1));
- assertThat(ret[0], is(config.getNamespace() + "." + config.getName() + "," +
- config.getConfigId() + "," +
- config.getGeneration() + "," +
- config.getPayloadChecksums()));
+ assertEquals(1, ret.length);
+ assertEquals(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," +
+ config.getGeneration() + "," + config.getPayloadChecksums(),
+ ret[0]);
}
/**
@@ -114,9 +112,9 @@ public class ConfigProxyRpcServerTest {
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
+ assertEquals(1, req.returnValues().size());
String[] ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(0));
+ assertEquals(0, ret.length);
final RawConfig config = ProxyServerTest.fooConfig;
server.proxyServer().memoryCache().update(config);
@@ -124,12 +122,10 @@ public class ConfigProxyRpcServerTest {
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(1));
- assertThat(ret[0], is(config.getNamespace() + "." + config.getName() + "," +
- config.getConfigId() + "," +
- config.getGeneration() + "," +
- config.getPayloadChecksums() + "," +
- config.getPayload().getData()));
+ assertEquals(1, ret.length);
+ assertEquals(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," +
+ config.getGeneration() + "," + config.getPayloadChecksums() + "," + config.getPayload().getData(),
+ ret[0]);
}
/**
@@ -143,11 +139,11 @@ public class ConfigProxyRpcServerTest {
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
+ assertEquals(1, req.returnValues().size());
final String[] ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(2));
- assertThat(ret[0], is("Current source: " + configSourceAddress));
- assertThat(ret[1], is("All sources:\n" + configSourceAddress + "\n"));
+ assertEquals(2, ret.length);
+ assertEquals("Current source: " + configSourceAddress, ret[0]);
+ assertEquals("All sources:\n" + configSourceAddress + "\n", ret[1]);
}
/**
@@ -159,11 +155,11 @@ public class ConfigProxyRpcServerTest {
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
+ assertEquals(1, req.returnValues().size());
final String[] ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(2));
- assertThat(ret[0], is("0"));
- assertThat(ret[1], is("success"));
+ assertEquals(2, ret.length);
+ assertEquals("0", ret[0]);
+ assertEquals("success", ret[1]);
}
/**
@@ -174,26 +170,26 @@ public class ConfigProxyRpcServerTest {
Request req = new Request("getMode");
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
- assertThat(req.returnValues().get(0).asString(), is("default"));
+ assertEquals(1, req.returnValues().size());
+ assertEquals("default", req.returnValues().get(0).asString());
req = new Request("setMode");
String mode = "memorycache";
req.parameters().add(new StringValue(mode));
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
+ assertEquals(1, req.returnValues().size());
String[] ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(2));
- assertThat(ret[0], is("0"));
- assertThat(ret[1], is("success"));
- assertThat(server.proxyServer().getMode().name(), is(mode));
+ assertEquals(2, ret.length);
+ assertEquals("0", ret[0]);
+ assertEquals("success", ret[1]);
+ assertEquals(mode, server.proxyServer().getMode().name());
req = new Request("getMode");
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
- assertThat(req.returnValues().get(0).asString(), is(mode));
+ assertEquals(1, req.returnValues().size());
+ assertEquals(mode, req.returnValues().get(0).asString());
req = new Request("setMode");
String oldMode = mode;
@@ -203,10 +199,10 @@ public class ConfigProxyRpcServerTest {
assertFalse(req.errorMessage(), req.isError());
ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(2));
- assertThat(ret[0], is("1"));
- assertThat(ret[1], is("Unrecognized mode '" + mode + "' supplied. Legal modes are '" + Mode.modes() + "'"));
- assertThat(server.proxyServer().getMode().name(), is(oldMode));
+ assertEquals(2, ret.length);
+ assertEquals("1", ret[0]);
+ assertEquals("Unrecognized mode '" + mode + "' supplied. Legal modes are '" + Mode.modes() + "'", ret[1]);
+ assertEquals(oldMode, server.proxyServer().getMode().name());
}
/**
@@ -222,8 +218,8 @@ public class ConfigProxyRpcServerTest {
req.parameters().add(new StringValue(spec1 + "," + spec2));
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
- assertThat(req.returnValues().get(0).asString(), is("Updated config sources to: " + spec1 + "," + spec2));
+ assertEquals(1, req.returnValues().size());
+ assertEquals("Updated config sources to: " + spec1 + "," + spec2, req.returnValues().get(0).asString());
server.proxyServer().setMode(Mode.ModeName.MEMORYCACHE.name());
@@ -232,17 +228,17 @@ public class ConfigProxyRpcServerTest {
req.parameters().add(new StringValue(spec1 + "," + spec2));
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
- assertThat(req.returnValues().get(0).asString(), is("Cannot update sources when in '" + Mode.ModeName.MEMORYCACHE.name().toLowerCase() + "' mode"));
+ assertEquals(1, req.returnValues().size());
+ assertEquals("Cannot update sources when in '" + Mode.ModeName.MEMORYCACHE.name().toLowerCase() + "' mode", req.returnValues().get(0).asString());
// TODO source connections needs to have deterministic order to work
/*req = new Request("listSourceConnections");
rpcServer.listSourceConnections(req);
assertFalse(req.errorMessage(), req.isError());
final String[] ret = req.returnValues().get(0).asStringArray();
- assertThat(ret.length, is(2));
- assertThat(ret[0], is("Current source: " + spec1));
- assertThat(ret[1], is("All sources:\n" + spec2 + "\n" + spec1 + "\n"));
+ assertEquals(ret.length, is(2));
+ assertEquals(ret[0], is("Current source: " + spec1));
+ assertEquals(ret[1], is("All sources:\n" + spec2 + "\n" + spec1 + "\n"));
*/
}
@@ -256,8 +252,8 @@ public class ConfigProxyRpcServerTest {
req.parameters().add(new StringValue(path));
client.invoke(req);
assertFalse(req.errorMessage(), req.isError());
- assertThat(req.returnValues().size(), is(1));
- assertThat(req.returnValues().get(0).asString(), is("success"));
+ assertEquals(1, req.returnValues().size());
+ assertEquals("success", req.returnValues().get(0).asString());
}
private static ProxyServer createTestServer(ConfigSourceSet source) {
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
index 142f69d41da..d8c03961ddb 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
@@ -7,8 +7,7 @@ import org.junit.Test;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
-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,17 +27,17 @@ public class DelayedResponseTest {
final String configName = "foo";
final JRTServerConfigRequest request = tester.createRequest(configName, configId, namespace, timeout);
DelayedResponse delayedResponse = new DelayedResponse(request, returnTime);
- assertThat(delayedResponse.getRequest(), is(request));
- assertThat(delayedResponse.getReturnTime(), is(returnTime));
+ assertEquals(request, delayedResponse.getRequest());
+ assertEquals(returnTime, delayedResponse.getReturnTime().longValue());
assertTrue(delayedResponse.getDelay(TimeUnit.SECONDS) < returnTime);
DelayedResponse before = new DelayedResponse(request, returnTime - 1000L);
DelayedResponse after = new DelayedResponse(request, returnTime + 1000L);
- assertThat(delayedResponse.compareTo(delayedResponse), is(0));
- assertThat(delayedResponse.compareTo(before), is(1));
- assertThat(delayedResponse.compareTo(after), is(-1));
- assertThat(delayedResponse.compareTo(new Delayed() {
+ assertEquals(0, delayedResponse.compareTo(delayedResponse));
+ assertEquals(1, delayedResponse.compareTo(before));
+ assertEquals(-1, delayedResponse.compareTo(after));
+ assertEquals(0, delayedResponse.compareTo(new Delayed() {
@Override
public long getDelay(TimeUnit unit) {
return 0;
@@ -48,7 +47,7 @@ public class DelayedResponseTest {
public int compareTo(Delayed o) {
return 0;
}
- }), is(0));
+ }));
}
@Test
@@ -75,9 +74,9 @@ public class DelayedResponseTest {
delayed2.getReturnTime() > delayed1.getReturnTime());
// Test compareTo() method
- assertThat(delayed1.compareTo(delayed1), is(0));
- assertThat(delayed1.compareTo(delayed2), is(-1));
- assertThat(delayed2.compareTo(delayed1), is(1));
+ assertEquals(0, delayed1.compareTo(delayed1));
+ assertEquals(-1, delayed1.compareTo(delayed2));
+ assertEquals(1, delayed2.compareTo(delayed1));
}
}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
index f317550228b..c9e714a11a3 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
@@ -3,8 +3,7 @@ package com.yahoo.vespa.config.proxy;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author hmusum
@@ -18,14 +17,14 @@ public class DelayedResponsesTest {
DelayedResponse delayedResponse = new DelayedResponse(tester.createRequest("foo", "id", "bar", 10));
responses.add(delayedResponse);
- assertThat(responses.size(), is(1));
- assertThat(responses.responses().take(), is(delayedResponse));
- assertThat(responses.size(), is(0));
+ assertEquals(1, responses.size());
+ assertEquals(delayedResponse, responses.responses().take());
+ assertEquals(0, responses.size());
responses.add(delayedResponse);
- assertThat(responses.size(), is(1));
+ assertEquals(1, responses.size());
responses.remove(delayedResponse);
- assertThat(responses.size(), is(0));
+ assertEquals(0, responses.size());
}
}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
index 0b590aea789..f84d447e3a1 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
@@ -3,11 +3,10 @@ package com.yahoo.vespa.config.proxy;
import org.junit.Test;
-import java.util.Collections;
+import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
/**
* @author hmusum
@@ -18,11 +17,11 @@ public class MemoryCacheConfigClientTest {
public void basic() {
MemoryCacheConfigClient client = new MemoryCacheConfigClient(new MemoryCache());
client.memoryCache().update(ConfigTester.fooConfig);
- assertThat(client.getConfig(ConfigTester.fooConfig, null), is(ConfigTester.fooConfig));
+ assertEquals(ConfigTester.fooConfig, client.getConfig(ConfigTester.fooConfig, null));
assertNull(client.getConfig(ConfigTester.barConfig, null));
- assertThat(client.getActiveSourceConnection(), is("N/A"));
- assertThat(client.getSourceConnections(), is(Collections.singletonList("N/A")));
+ assertEquals("N/A", client.getActiveSourceConnection());
+ assertEquals(List.of("N/A"), client.getSourceConnections());
}
}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
index 953b67b3ea5..1a919ad3988 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
@@ -14,8 +14,9 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
/**
* @author hmusum
@@ -79,21 +80,21 @@ public class MemoryCacheTest {
cache.update(config);
cache.update(config2);
- assertThat(cache.size(), is(2));
+ assertEquals(2, cache.size());
assertTrue(cache.containsKey(cacheKey));
assertTrue(cache.containsKey(cacheKey2));
RawConfig response = cache.get(cacheKey);
assertNotNull(response);
- assertThat(response.getName(), is(defName));
- assertThat(response.getPayload().toString(), is(payload.toString()));
- assertThat(response.getGeneration(), is(generation));
+ assertEquals(defName, response.getName());
+ assertEquals(payload.toString(), response.getPayload().toString());
+ assertEquals(generation, response.getGeneration());
response = cache.get(cacheKey2);
assertNotNull(response);
- assertThat(response.getName(), is(defName2));
- assertThat(response.getPayload().toString(), is(payload2.toString()));
- assertThat(response.getGeneration(), is(generation));
+ assertEquals(defName2, response.getName());
+ assertEquals(payload2.toString(), response.getPayload().toString());
+ assertEquals(generation, response.getGeneration());
cache.clear();
}
@@ -104,22 +105,22 @@ public class MemoryCacheTest {
cache.update(config);
cache.update(configDifferentMd5); // same name, different defMd5
- assertThat(cache.size(), is(2));
+ assertEquals(2, cache.size());
assertTrue(cache.containsKey(cacheKey));
RawConfig response = cache.get(cacheKey);
assertNotNull(response);
- assertThat(response.getName(), is(defName));
- assertThat(response.getPayload().getData(), is(payload.getData()));
- assertThat(response.getGeneration(), is(generation));
+ assertEquals(defName, response.getName());
+ assertEquals(payload.getData(), response.getPayload().getData());
+ assertEquals(generation, response.getGeneration());
response = cache.get(cacheKeyDifferentMd5);
assertNotNull(response);
- assertThat(response.getName(), is(defName));
- assertThat(response.getPayload().getData(), is(payloadDifferentMd5.getData()));
- assertThat(response.getGeneration(), is(generation));
+ assertEquals(defName, response.getName());
+ assertEquals(payloadDifferentMd5.getData(), response.getPayload().getData());
+ assertEquals(generation, response.getGeneration());
cache.clear();
- assertThat(cache.size(), is(0));
+ assertEquals(0, cache.size());
}
}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
index 15de93b748f..ee058ba903e 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
@@ -16,11 +16,9 @@ import org.junit.rules.TemporaryFolder;
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.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -59,16 +57,16 @@ public class ProxyServerTest {
@Test
public void basic() {
assertTrue(proxy.getMode().isDefault());
- assertThat(proxy.memoryCache().size(), is(0));
+ assertEquals(0, proxy.memoryCache().size());
ConfigTester tester = new ConfigTester();
MemoryCache memoryCache = proxy.memoryCache();
assertEquals(0, memoryCache.size());
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
- assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
+ assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
assertEquals(1, memoryCache.size());
- assertThat(memoryCache.get(new ConfigCacheKey(fooConfig.getKey(), fooConfig.getDefMd5())), is(res));
+ assertEquals(res, memoryCache.get(new ConfigCacheKey(fooConfig.getKey(), fooConfig.getDefMd5())));
}
/**
@@ -81,7 +79,7 @@ public class ProxyServerTest {
for (String mode : Mode.modes()) {
proxy.setMode(mode);
- assertThat(proxy.getMode().name(), is(mode));
+ assertEquals(mode, proxy.getMode().name());
}
// Try setting an invalid mode
@@ -115,9 +113,9 @@ public class ProxyServerTest {
assertEquals(0, memoryCache.size());
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
- assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
+ assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
assertEquals(1, memoryCache.size());
- assertThat(memoryCache.get(new ConfigCacheKey(fooConfig.getKey(), fooConfig.getDefMd5())), is(res));
+ assertEquals(res, memoryCache.get(new ConfigCacheKey(fooConfig.getKey(), fooConfig.getDefMd5())));
// Trying same config again
JRTServerConfigRequest newRequestBasedOnResponse = tester.createRequest(res);
@@ -153,7 +151,7 @@ public class ProxyServerTest {
res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
assertNotNull(res.getPayload().getData());
- assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
+ assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
assertEquals(1, memoryCache.size());
JRTServerConfigRequest newRequestBasedOnResponse = tester.createRequest(res);
@@ -176,7 +174,7 @@ public class ProxyServerTest {
assertEquals(0, cache.size());
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
- assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
+ assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
assertEquals(1, cache.size());
// Simulate an empty response
@@ -187,7 +185,7 @@ public class ProxyServerTest {
res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res.getPayload());
- assertThat(res.getPayload().toString(), is(emptyConfig.getPayload().toString()));
+ assertEquals(emptyConfig.getPayload().toString(), res.getPayload().toString());
assertEquals(0, cache.size());
// Put a version of the same config into backend with new generation and see that it now works (i.e. we are
@@ -197,7 +195,7 @@ public class ProxyServerTest {
// Verify that we get the config now and that it is cached
res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res.getPayload().getData());
- assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
+ assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
assertEquals(1, cache.size());
}
@@ -206,7 +204,7 @@ public class ProxyServerTest {
ConfigTester tester = new ConfigTester();
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig));
assertNotNull(res);
- assertThat(res.getPayload().toString(), is(ConfigTester.fooPayload.toString()));
+ assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
// Simulate deployment, add config with new config generation
long previousGeneration = res.getGeneration();
@@ -220,8 +218,8 @@ public class ProxyServerTest {
@Test
public void testReadingSystemProperties() {
ProxyServer.Properties properties = ProxyServer.getSystemProperties();
- assertThat(properties.configSources.length, is(1));
- assertThat(properties.configSources[0], is(ProxyServer.DEFAULT_PROXY_CONFIG_SOURCES));
+ assertEquals(1, properties.configSources.length);
+ assertEquals(ProxyServer.DEFAULT_PROXY_CONFIG_SOURCES, properties.configSources[0]);
}
private static ProxyServer createTestServer(ConfigSourceSet source, ConfigSourceClient configSourceClient) {
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/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java
index 05e2e7c6ff6..9cf363376cc 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefLineParsingTest.java
@@ -1,11 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Tests parsing of a single line of a .def file
*
@@ -225,9 +227,9 @@ public class DefLineParsingTest {
DefLine i = new DefLine("i int range=[0, 100]");
DefLine l = new DefLine("l long range=[-1e10, 0]");
DefLine d = new DefLine("d double range=[0, 1.0]");
- assertThat(i.getRange(), is("[0, 100]"));
- assertThat(l.getRange(), is("[-1e10, 0]"));
- assertThat(d.getRange(), is("[0, 1.0]"));
+ assertEquals("[0, 100]", i.getRange());
+ assertEquals("[-1e10, 0]", l.getRange());
+ assertEquals("[0, 1.0]", d.getRange());
}
@Test
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java
index 97ee17cb6d5..7921a3aecbe 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserNamespaceTest.java
@@ -8,9 +8,8 @@ import java.io.IOException;
import static com.yahoo.config.codegen.DefParserTest.assertLineFails;
import static com.yahoo.config.codegen.DefParserTest.createDefTemplate;
import static com.yahoo.config.codegen.DefParserTest.createParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
/**
* @author gjoranv
@@ -22,7 +21,7 @@ public class DefParserNamespaceTest {
public void namespace_is_set_on_root_node() {
DefParser parser = createParser("version=1\nnamespace=myproject.config\n");
CNode root = parser.getTree();
- assertThat(root.getNamespace(), is("myproject.config"));
+ assertEquals("myproject.config", root.getNamespace());
}
@Test
@@ -30,7 +29,7 @@ public class DefParserNamespaceTest {
String PACKAGE = "com.github.myproject";
DefParser parser = createParser("package=" + PACKAGE + "\n");
CNode root = parser.getTree();
- assertThat(root.getNamespace(), is(PACKAGE));
+ assertEquals(PACKAGE, root.getNamespace());
}
@Test(expected = CodegenRuntimeException.class)
@@ -48,7 +47,7 @@ public class DefParserNamespaceTest {
public void spaces_are_allowed_around_equals_sign() {
DefParser parser = createParser("version=1\nnamespace = myproject.config\n");
CNode root = parser.getTree();
- assertThat(root.getNamespace(), is("myproject.config"));
+ assertEquals("myproject.config", root.getNamespace());
}
@Test
@@ -69,7 +68,7 @@ public class DefParserNamespaceTest {
parser = createParser("version=1\nnamespace=myproject.config\n");
CNode namespaceRoot = parser.getTree();
- assertThat(root.defMd5, not(namespaceRoot.defMd5));
+ assertNotEquals(root.defMd5, namespaceRoot.defMd5);
}
@@ -82,12 +81,12 @@ public class DefParserNamespaceTest {
}
@Test
- public void number_is_not_allowed_as_namespace_start_char() throws IOException, DefParser.DefParserException {
+ public void number_is_not_allowed_as_namespace_start_char() {
assertLineFails("namespace=2.a.b");
}
@Test
- public void number_is_not_allowed_as_leading_char_in_namespace_token() throws IOException, DefParser.DefParserException {
+ public void number_is_not_allowed_as_leading_char_in_namespace_token() {
assertLineFails("namespace=a.b.2c");
}
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java
index d995ab63886..cd7ca1a89b9 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserPackageTest.java
@@ -5,14 +5,12 @@ import org.junit.Test;
import java.io.IOException;
-import static com.yahoo.config.codegen.DefParser.DEFAULT_PACKAGE_PREFIX;
import static com.yahoo.config.codegen.DefParserTest.assertLineFails;
import static com.yahoo.config.codegen.DefParserTest.createDefTemplate;
import static com.yahoo.config.codegen.DefParserTest.createParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
/**
* Tests setting explicit java package in the def file.
@@ -26,7 +24,7 @@ public class DefParserPackageTest {
public void package_is_set_on_root_node() {
DefParser parser = createParser("package=" + PACKAGE + "\n");
CNode root = parser.getTree();
- assertThat(root.getPackage(), is(PACKAGE));
+ assertEquals(PACKAGE, root.getPackage());
}
@Test
@@ -35,8 +33,8 @@ public class DefParserPackageTest {
DefParser parser = createParser("package=" + PACKAGE +
"\nnamespace=" + namespace +"\n");
CNode root = parser.getTree();
- assertThat(root.getPackage(), is(PACKAGE));
- assertThat(root.getNamespace(), is(namespace));
+ assertEquals(PACKAGE, root.getPackage());
+ assertEquals(namespace, root.getNamespace());
}
// Required by JavaClassBuilder ctor.
@@ -45,7 +43,7 @@ public class DefParserPackageTest {
String namespace = "test.namespace";
DefParser parser = createParser("namespace=" + namespace + "\n");
CNode root = parser.getTree();
- assertThat(root.getPackage(), nullValue());
+ assertNull(root.getPackage());
}
@Test(expected = CodegenRuntimeException.class)
@@ -57,7 +55,7 @@ public class DefParserPackageTest {
public void spaces_are_allowed_around_equals_sign() {
DefParser parser = createParser("package = " + PACKAGE + "\n");
CNode root = parser.getTree();
- assertThat(root.getPackage(), is(PACKAGE));
+ assertEquals(PACKAGE, root.getPackage());
}
@Test
@@ -78,7 +76,7 @@ public class DefParserPackageTest {
parser = createParser("package=" + PACKAGE + "\na string\n");
CNode rootWithPackage = parser.getTree();
- assertThat(root.defMd5, not(rootWithPackage.defMd5));
+ assertNotEquals(root.defMd5, rootWithPackage.defMd5);
}
@@ -91,12 +89,12 @@ public class DefParserPackageTest {
}
@Test
- public void number_is_not_allowed_as_package_start_char() throws IOException, DefParser.DefParserException {
+ public void number_is_not_allowed_as_package_start_char() {
assertLineFails("package=2.a.b");
}
@Test
- public void number_is_not_allowed_as_leading_char_in_package_token() throws IOException, DefParser.DefParserException {
+ public void number_is_not_allowed_as_leading_char_in_package_token() {
assertLineFails("package=a.b.2c");
}
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java
index 22ccf4105c1..e4d9f6cb3bd 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/DefParserTest.java
@@ -1,15 +1,18 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.junit.Test;
import org.junit.Ignore;
-import static org.hamcrest.CoreMatchers.is;
-
-import java.io.*;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
/**
* Unit tests for DefParser.
@@ -28,7 +31,7 @@ public class DefParserTest {
CNode root = new DefParser("test", new FileReader(defFile)).getTree();
assertNotNull(root);
CNode[] children = root.getChildren();
- assertThat(children.length, is(34));
+ assertEquals(34, children.length);
int numGrandChildren = 0;
int numGreatGrandChildren = 0;
@@ -39,45 +42,45 @@ public class DefParserTest {
numGreatGrandChildren += grandChild.getChildren().length;
}
}
- assertThat(numGrandChildren, is(14));
- assertThat(numGreatGrandChildren, is(6));
+ assertEquals(14, numGrandChildren);
+ assertEquals(6, numGreatGrandChildren);
// Verify that each array creates a sub-tree, and that defaults for leafs are handled correctly.
CNode myArray = root.getChild("myArray");
- assertThat(myArray.getChildren().length, is(5));
+ assertEquals(5, myArray.getChildren().length);
// int within array
LeafCNode myArrayInt = (LeafCNode) myArray.getChild("intVal");
- assertThat(myArrayInt.getDefaultValue().getValue(), is("14"));
+ assertEquals("14", myArrayInt.getDefaultValue().getValue());
// enum within array
LeafCNode myArrayEnum = (LeafCNode) myArray.getChild("enumVal");
- assertThat(myArrayEnum.getDefaultValue().getValue(), is("TYPE"));
+ assertEquals("TYPE", myArrayEnum.getDefaultValue().getValue());
// Verify array within array and a default value for a leaf in the inner array.
CNode anotherArray = myArray.getChild("anotherArray");
- assertThat(anotherArray.getChildren().length, is(1));
+ assertEquals(1, anotherArray.getChildren().length);
LeafCNode foo = (LeafCNode) anotherArray.getChild("foo");
- assertThat(foo.getDefaultValue().getValue(), is("-4"));
+ assertEquals("-4", foo.getDefaultValue().getValue());
}
@Test
public void testFileWithNamespaceInFilename() throws IOException {
File defFile = new File(TEST_DIR + "baz.bar.foo.def");
CNode root = new DefParser("test", new FileReader(defFile)).getTree();
- assertThat(root.defMd5, is("31a0f9bda0e5ff929762a29569575a7e"));
+ assertEquals("31a0f9bda0e5ff929762a29569575a7e", root.defMd5);
}
@Test
public void testMd5Sum() throws IOException {
File defFile = new File(DEF_NAME);
CNode root = new DefParser("test", new FileReader(defFile)).getTree();
- assertThat(root.defMd5, is("f901bdc5c96e7005130399c63f247823"));
+ assertEquals("f901bdc5c96e7005130399c63f247823", root.defMd5);
}
@Test
public void testMd5Sum2() {
String def = "version=1\na string\n";
CNode root = new DefParser("testMd5Sum2", new StringReader(def)).getTree();
- assertThat(root.defMd5, is("a5e5fdbb2b27e56ba7d5e60e335c598b"));
+ assertEquals("a5e5fdbb2b27e56ba7d5e60e335c598b", root.defMd5);
}
@Test
@@ -104,7 +107,7 @@ public class DefParserTest {
private void testExpectedVersion(String versionLine, String expectedVersion) {
InnerCNode root = createParser(versionLine).getTree();
- assertThat(root.defVersion, is(expectedVersion));
+ assertEquals(expectedVersion, root.defVersion);
}
@Test
@@ -146,7 +149,7 @@ public class DefParserTest {
@Test(expected = CodegenRuntimeException.class)
@Ignore("Not implemented yet")
- public void testInvalidEnum() throws DefParser.DefParserException {
+ public void testInvalidEnum() {
DefParser parser = createParser("version=1\nanEnum enum {A, B, A}\n");
//parser.validateDef(def);
}
@@ -171,7 +174,7 @@ public class DefParserTest {
CNode root = parser.getTree();
LeafCNode node = (LeafCNode) root.getChild("enum1");
assertNotNull(node);
- assertThat(node.getDefaultValue().getStringRepresentation(), is("A"));
+ assertEquals("A", node.getDefaultValue().getStringRepresentation());
}
@Test(expected = DefParser.DefParserException.class)
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java b/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java
index cce2d66b5f0..d69617ec5da 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/JavaClassBuilderTest.java
@@ -12,9 +12,7 @@ import java.util.List;
import static com.yahoo.config.codegen.ConfiggenUtil.createClassName;
import static com.yahoo.config.codegen.JavaClassBuilder.createUniqueSymbol;
-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.fail;
@@ -82,8 +80,8 @@ public class JavaClassBuilderTest {
"n int\n";
InnerCNode root = new DefParser("test", new StringReader(testDefinition)).getTree();
- assertThat(createUniqueSymbol(root, "foo"), is("f"));
- assertThat(createUniqueSymbol(root, "name"), is("na"));
+ assertEquals("f", createUniqueSymbol(root, "foo"));
+ assertEquals("na", createUniqueSymbol(root, "name"));
assertTrue(createUniqueSymbol(root, "m").startsWith(ReservedWords.INTERNAL_PREFIX + "m"));
// The basis string is not a legal return value, even if unique, to avoid
@@ -93,12 +91,12 @@ public class JavaClassBuilderTest {
@Test
public void testCreateClassName() {
- assertThat(createClassName("simple"), is("SimpleConfig"));
- assertThat(createClassName("a"), is("AConfig"));
- assertThat(createClassName("a-b-c"), is("ABCConfig"));
- assertThat(createClassName("a-1-2b"), is("A12bConfig"));
- assertThat(createClassName("my-app"), is("MyAppConfig"));
- assertThat(createClassName("MyApp"), is("MyAppConfig"));
+ assertEquals("SimpleConfig", createClassName("simple"));
+ assertEquals("AConfig", createClassName("a"));
+ assertEquals("ABCConfig", createClassName("a-b-c"));
+ assertEquals("A12bConfig", createClassName("a-1-2b"));
+ assertEquals("MyAppConfig", createClassName("my-app"));
+ assertEquals("MyAppConfig", createClassName("MyApp"));
}
@Test(expected = CodegenRuntimeException.class)
diff --git a/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java b/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java
index 3c328721b6c..411ac0fe58a 100644
--- a/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java
+++ b/configgen/src/test/java/com/yahoo/config/codegen/NormalizedDefinitionTest.java
@@ -1,14 +1,18 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.codegen;
-import static org.junit.Assert.*;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
import java.util.List;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
@@ -38,13 +42,13 @@ public class NormalizedDefinitionTest {
}
assertNotNull(out);
- assertThat(out.size(), is(6));
- assertThat(out.get(0), is ("version=1\n"));
- assertThat(out.get(1), is ("aString string\n"));
- assertThat(out.get(2), is ("anInt int\n"));
- assertThat(out.get(3), is ("aStringCommentCharacterAfter string default=\"ab\"\n"));
- assertThat(out.get(4), is ("aStringWithCommentCharacter string default=\"a#b\"\n"));
- assertThat(out.get(5), is ("aStringWithEscapedQuote string default=\"a\"b\"\n"));
+ assertEquals(6, out.size());
+ assertEquals("version=1\n", out.get(0));
+ assertEquals("aString string\n", out.get(1));
+ assertEquals("anInt int\n", out.get(2));
+ assertEquals("aStringCommentCharacterAfter string default=\"ab\"\n", out.get(3));
+ assertEquals("aStringWithCommentCharacter string default=\"a#b\"\n", out.get(4));
+ assertEquals("aStringWithEscapedQuote string default=\"a\"b\"\n", out.get(5));
reader.close();
}
@@ -68,7 +72,7 @@ public class NormalizedDefinitionTest {
}
assertNotNull(out);
- assertThat(out.size(), is(72));
+ assertEquals(72, out.size());
assertNotNull(fileReader);
fileReader.close();
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java
index 978241339d2..d69fe4fba89 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java
@@ -203,6 +203,9 @@ public class ModelContextImpl implements ModelContext {
private final boolean useV8GeoPositions;
private final boolean useV8DocManagerCfg;
private final int maxCompactBuffers;
+ private final boolean failDeploymentWithInvalidJvmOptions;
+ private final double tlsSizeFraction;
+ private final boolean enableServerOcspStapling;
public FeatureFlags(FlagSource source, ApplicationId appId) {
this.defaultTermwiseLimit = flagValue(source, appId, Flags.DEFAULT_TERM_WISE_LIMIT);
@@ -244,6 +247,9 @@ public class ModelContextImpl implements ModelContext {
this.useV8GeoPositions = flagValue(source, appId, Flags.USE_V8_GEO_POSITIONS);
this.useV8DocManagerCfg = flagValue(source, appId, Flags.USE_V8_DOC_MANAGER_CFG);
this.maxCompactBuffers = flagValue(source, appId, Flags.MAX_COMPACT_BUFFERS);
+ this.failDeploymentWithInvalidJvmOptions = flagValue(source, appId, Flags.FAIL_DEPLOYMENT_WITH_INVALID_JVM_OPTIONS);
+ this.tlsSizeFraction = flagValue(source, appId, Flags.TLS_SIZE_FRACTION);
+ this.enableServerOcspStapling = flagValue(source, appId, Flags.ENABLE_SERVER_OCSP_STAPLING);
}
@Override public double defaultTermwiseLimit() { return defaultTermwiseLimit; }
@@ -286,6 +292,10 @@ public class ModelContextImpl implements ModelContext {
@Override public boolean unorderedMergeChaining() { return unorderedMergeChaining; }
@Override public boolean useV8GeoPositions() { return useV8GeoPositions; }
@Override public boolean useV8DocManagerCfg() { return useV8DocManagerCfg; }
+ @Override public boolean failDeploymentWithInvalidJvmOptions() { return failDeploymentWithInvalidJvmOptions; }
+ @Override public int maxCompactBuffers() { return maxCompactBuffers; }
+ @Override public double tlsSizeFraction() { return tlsSizeFraction; }
+ @Override public boolean enableServerOcspStapling() { return enableServerOcspStapling; }
private static <V> V flagValue(FlagSource source, ApplicationId appId, UnboundFlag<? extends V, ?, ?> flag) {
return flag.bindTo(source)
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java
index 6d16520d77b..99ffff6403b 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java
@@ -558,7 +558,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
private void invokeRpcIfValidConnection(Request request) {
if (target.isValid()) {
- target.invokeSync(request, 60);
+ target.invokeSync(request, 600);
} else {
throw new RuntimeException("Connection to " + target + " is invalid", target.getConnectionLostReason());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index 63c569fb17a..d3dfae3a6be 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -49,7 +49,6 @@ import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
import com.yahoo.vespa.flags.InMemoryFlagSource;
import com.yahoo.vespa.model.VespaModelFactory;
-import org.hamcrest.core.Is;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -73,14 +72,11 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.IntStream;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.core.Is.is;
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;
@@ -111,6 +107,7 @@ public class ApplicationRepositoryTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException exceptionRule = ExpectedException.none();
@@ -553,13 +550,13 @@ public class ApplicationRepositoryTest {
AllocatedHosts info = session.getAllocatedHosts();
assertNotNull(info);
- assertThat(info.getHosts().size(), is(1));
+ assertEquals(1, info.getHosts().size());
assertTrue(info.getHosts().contains(new HostSpec("mytesthost2",
Collections.emptyList(),
Optional.empty())));
Optional<NetworkPorts> portsCopy = info.getHosts().iterator().next().networkPorts();
assertTrue(portsCopy.isPresent());
- assertThat(portsCopy.get().allocations(), is(list));
+ assertEquals(list, portsCopy.get().allocations());
}
@Test
@@ -571,7 +568,7 @@ public class ApplicationRepositoryTest {
TimeoutBudget timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(10));
long sessionId = applicationRepository.createSession(applicationId(), timeoutBudget, testAppJdiscOnly);
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(containsString("tenant:test1 Session 3 is not prepared"));
+ exceptionRule.expectMessage("tenant:test1 Session 3 is not prepared");
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId, timeoutBudget, false);
Session activeSession = applicationRepository.getActiveSession(applicationId());
@@ -588,7 +585,7 @@ public class ApplicationRepositoryTest {
long sessionId = applicationRepository.createSession(applicationId(), timeoutBudget, testAppJdiscOnly);
applicationRepository.prepare(sessionId, prepareParams());
exceptionRule.expect(RuntimeException.class);
- exceptionRule.expectMessage(containsString("Timeout exceeded when trying to activate 'test1.testapp'"));
+ exceptionRule.expectMessage("Timeout exceeded when trying to activate 'test1.testapp'");
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId, new TimeoutBudget(clock, Duration.ofSeconds(0)), false);
Session activeSession = applicationRepository.getActiveSession(applicationId());
@@ -610,7 +607,7 @@ public class ApplicationRepositoryTest {
applicationRepository.prepare(sessionId2, prepareParams());
exceptionRule.expect(ActivationConflictException.class);
- exceptionRule.expectMessage(containsString("app:test1.testapp.default Cannot activate session 3 because the currently active session (4) has changed since session 3 was created (was 2 at creation time)"));
+ exceptionRule.expectMessage("app:test1.testapp.default Cannot activate session 3 because the currently active session (4) has changed since session 3 was created (was 2 at creation time)");
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId2, timeoutBudget, false);
}
@@ -620,11 +617,11 @@ public class ApplicationRepositoryTest {
long sessionId = result.sessionId();
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(containsString("Session is active: 2"));
+ exceptionRule.expectMessage("Session is active: 2");
applicationRepository.prepare(sessionId, prepareParams());
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage(containsString("app:test1.testapp.default Session 2 is already active"));
+ exceptionRule.expectMessage("app:test1.testapp.default Session 2 is already active");
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId, timeoutBudget, false);
}
@@ -679,9 +676,8 @@ public class ApplicationRepositoryTest {
assertTrue(requestHandler.hasApplication(applicationId(), Optional.of(vespaVersion)));
assertNull(requestHandler.resolveApplicationId("doesnotexist"));
- assertThat(requestHandler.resolveApplicationId("mytesthost"), Is.is(new ApplicationId.Builder()
- .tenant(tenant1)
- .applicationName("testapp").build())); // Host set in application package.
+ assertEquals(new ApplicationId.Builder().tenant(tenant1).applicationName("testapp").build(),
+ requestHandler.resolveApplicationId("mytesthost")); // Host set in application package.
}
@Test
@@ -698,7 +694,7 @@ public class ApplicationRepositoryTest {
// TODO: Revisit this test, I cannot see that we create a model for version 3.2.1
config = resolve(SimpletypesConfig.class, requestHandler, applicationId(), new Version(3, 2, 1));
- assertThat(config.intval(), Is.is(1337));
+ assertEquals(1337, config.intval());
}
@Test
@@ -716,7 +712,7 @@ public class ApplicationRepositoryTest {
applicationRepository.delete(applicationId());
exceptionRule.expect(com.yahoo.vespa.config.server.NotFoundException.class);
- exceptionRule.expectMessage(containsString("No such application id: test1.testapp"));
+ exceptionRule.expectMessage("No such application id: test1.testapp");
resolve(SimpletypesConfig.class, requestHandler, applicationId(), vespaVersion);
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerDBTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerDBTest.java
index b51c30cb991..41289357fab 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerDBTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerDBTest.java
@@ -12,7 +12,7 @@ import java.io.File;
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/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java
index 0e8c69327e2..659bc771ac7 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java
@@ -26,12 +26,9 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.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;
/**
@@ -88,13 +85,13 @@ public class ModelContextImplTest {
assertFalse(context.previousModel().isPresent());
assertTrue(context.getFileRegistry() instanceof MockFileRegistry);
assertTrue(context.configDefinitionRepo() instanceof StaticConfigDefinitionRepo);
- assertThat(context.properties().applicationId(), is(ApplicationId.defaultId()));
+ assertEquals(ApplicationId.defaultId(), context.properties().applicationId());
assertTrue(context.properties().configServerSpecs().isEmpty());
assertTrue(context.properties().multitenant());
assertNotNull(context.properties().zone());
assertFalse(context.properties().hostedVespa());
- assertThat(context.properties().endpoints(), equalTo(endpoints));
- assertThat(context.properties().isFirstTimeDeployment(), equalTo(false));
+ assertEquals(endpoints, context.properties().endpoints());
+ assertFalse(context.properties().isFirstTimeDeployment());
assertEquals(Optional.empty(), context.wantedDockerImageRepo());
assertEquals(new Version(7), context.modelVespaVersion());
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java
index 1eb44c633f6..6bb904a89fa 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelFactoryRegistryTest.java
@@ -16,8 +16,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -44,10 +43,10 @@ public class ModelFactoryRegistryTest {
List<ModelFactory> randomOrder = Arrays.asList(a, b, c, d);
Collections.shuffle(randomOrder);
ModelFactoryRegistry registry = new ModelFactoryRegistry(randomOrder);
- assertThat(registry.getFactory(versionA), is(a));
- assertThat(registry.getFactory(versionB), is(b));
- assertThat(registry.getFactory(versionC), is(c));
- assertThat(registry.getFactory(versionD), is(d));
+ assertEquals(a, registry.getFactory(versionA));
+ assertEquals(b, registry.getFactory(versionB));
+ assertEquals(c, registry.getFactory(versionC));
+ assertEquals(d, registry.getFactory(versionD));
}
}
@@ -58,7 +57,7 @@ public class ModelFactoryRegistryTest {
TestFactory c = new TestFactory(new Version(5, 48, 44));
TestFactory d = new TestFactory(new Version(5, 18, 44));
ModelFactoryRegistry registry = new ModelFactoryRegistry(Arrays.asList(a, b, c, d));
- assertThat(registry.getFactories().size(), is(4));
+ assertEquals(4, registry.getFactories().size());
assertTrue(registry.getFactories().contains(a));
assertTrue(registry.getFactories().contains(b));
assertTrue(registry.getFactories().contains(c));
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
index 5016107c411..2c738e2d519 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
@@ -37,8 +37,7 @@ import java.util.Optional;
import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER;
import static com.yahoo.vespa.config.protocol.JRTClientConfigRequestV3.createWithParams;
-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;
/**
@@ -65,8 +64,8 @@ public class SuperModelControllerTest {
LbServicesConfig.Builder lb = new LbServicesConfig.Builder();
handler.getSuperModel().getConfig(lb);
LbServicesConfig lbc = new LbServicesConfig(lb);
- assertThat(lbc.tenants().size(), is(1));
- assertThat(lbc.tenants("a").applications().size(), is(1));
+ assertEquals(1, lbc.tenants().size());
+ assertEquals(1, lbc.tenants("a").applications().size());
Applications app = lbc.tenants("a").applications("foo:prod:default:default");
assertTrue(app.hosts().size() > 0);
}
@@ -105,10 +104,10 @@ public class SuperModelControllerTest {
LbServicesConfig.Builder lb = new LbServicesConfig.Builder();
han.getSuperModel().getConfig(lb);
LbServicesConfig lbc = new LbServicesConfig(lb);
- assertThat(lbc.tenants().size(), is(2));
- assertThat(lbc.tenants("t1").applications().size(), is(2));
- assertThat(lbc.tenants("t2").applications().size(), is(1));
- assertThat(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default").hosts().size(), is(1));
+ assertEquals(2, lbc.tenants().size());
+ assertEquals(2, lbc.tenants("t1").applications().size());
+ assertEquals(1, lbc.tenants("t2").applications().size());
+ assertEquals(1, lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default").hosts().size());
assertQrServer(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default"));
}
@@ -119,14 +118,14 @@ public class SuperModelControllerTest {
private void assertQrServer(Applications app) {
String host = app.hosts().keySet().iterator().next();
Applications.Hosts hosts = app.hosts(host);
- assertThat(hosts.hostname(), is(host));
+ assertEquals(host, hosts.hostname());
for (Map.Entry<String, Applications.Hosts.Services> e : app.hosts(host).services().entrySet()) {
if (QRSERVER.serviceName.equals(e.getKey())) {
Applications.Hosts.Services s = e.getValue();
- assertThat(s.type(), is("qrserver"));
- assertThat(s.ports().size(), is(4));
- assertThat(s.ports().get(0).number(), is(8000));
- assertThat(s.index(), is(0));
+ assertEquals("qrserver", s.type());
+ assertEquals(4, s.ports().size());
+ assertEquals(8000, s.ports().get(0).number());
+ assertEquals(0, s.index());
return;
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
index a390d6793b4..3f329894cef 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
@@ -22,13 +22,12 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+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.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -61,13 +60,13 @@ public class SuperModelRequestHandlerTest {
long gen = counter.get();
controller.reloadConfig(createApp(foo, 3L));
assertNotNull(controller.getHandler());
- assertThat(controller.getHandler().getGeneration(), is(gen + 1));
+ assertEquals(gen + 1, controller.getHandler().getGeneration());
controller.reloadConfig(createApp(foo, 4L));
- assertThat(controller.getHandler().getGeneration(), is(gen + 2));
+ assertEquals(gen + 2, controller.getHandler().getGeneration());
// Test that a new app is used when there already exist an application with the same id
- assertThat(controller.getHandler().getSuperModel().applicationModels().get(foo).getGeneration(), is(4L));
+ assertEquals(4, controller.getHandler().getSuperModel().applicationModels().get(foo).getGeneration());
controller.reloadConfig(createApp(bar, 2L));
- assertThat(controller.getHandler().getGeneration(), is(gen + 3));
+ assertEquals(gen + 3, controller.getHandler().getGeneration());
}
@Test
@@ -80,17 +79,17 @@ public class SuperModelRequestHandlerTest {
controller.reloadConfig(createApp(foo, 3L));
controller.reloadConfig(createApp(bar, 30L));
controller.reloadConfig(createApp(baz, 9L));
- assertThat(controller.getHandler().getGeneration(), is(gen + 3));
- assertThat(controller.getHandler().getSuperModel().applicationModels().size(), is(3));
- assertEquals(Arrays.asList(foo, bar, baz), new ArrayList<>(controller.getHandler().getSuperModel().applicationModels().keySet()));
+ assertEquals(gen + 3, controller.getHandler().getGeneration());
+ assertEquals(3, controller.getHandler().getSuperModel().applicationModels().size());
+ assertTrue(controller.getHandler().getSuperModel().applicationModels().keySet().containsAll(List.of(foo, bar, baz)));
controller.removeApplication(new ApplicationId.Builder().tenant("a").applicationName("unknown").build());
- assertThat(controller.getHandler().getGeneration(), is(gen + 4));
- assertThat(controller.getHandler().getSuperModel().applicationModels().size(), is(3));
- assertEquals(Arrays.asList(foo, bar, baz), new ArrayList<>(controller.getHandler().getSuperModel().applicationModels().keySet()));
+ assertEquals(gen + 4, controller.getHandler().getGeneration());
+ assertEquals(3, controller.getHandler().getSuperModel().applicationModels().size());
+ assertTrue(controller.getHandler().getSuperModel().applicationModels().keySet().containsAll(List.of(foo, bar, baz)));
controller.removeApplication(bar);
- assertThat(controller.getHandler().getSuperModel().applicationModels().size(), is(2));
+ assertEquals(2, controller.getHandler().getSuperModel().applicationModels().size());
assertEquals(Arrays.asList(foo, baz), new ArrayList<>(controller.getHandler().getSuperModel().applicationModels().keySet()));
- assertThat(controller.getHandler().getGeneration(), is(gen + 5));
+ assertEquals(gen + 5, controller.getHandler().getGeneration());
}
@Test
@@ -103,7 +102,7 @@ public class SuperModelRequestHandlerTest {
long gen = counter.get();
controller.reloadConfig(createApp(foo, 3L));
- assertThat(controller.getHandler().getGeneration(), is(masterGen + gen + 1));
+ assertEquals(masterGen + gen + 1, controller.getHandler().getGeneration());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/TimeoutBudgetTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TimeoutBudgetTest.java
index e93d7113d99..e7666dff7f6 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/TimeoutBudgetTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/TimeoutBudgetTest.java
@@ -8,7 +8,7 @@ import java.time.Duration;
import java.time.Instant;
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/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java
index 92af4a75e51..0acdab7aec4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java
@@ -41,10 +41,9 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
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.assertSame;
import static org.junit.Assert.assertTrue;
/**
@@ -59,12 +58,12 @@ public class ApplicationTest {
ServerCache cache = new ServerCache();
Version vespaVersion = new Version(1, 2, 3);
Application app = new Application(new ModelStub(), cache, 1337L, vespaVersion, MetricUpdater.createTestUpdater(), appId);
- assertThat(app.getApplicationGeneration(), is(1337L));
+ assertEquals(1337L, app.getApplicationGeneration().longValue());
assertNotNull(app.getModel());
- assertThat(app.getCache(), is(cache));
- assertThat(app.getId().application().value(), is("foobar"));
- assertThat(app.getVespaVersion(), is(vespaVersion));
- assertThat(app.toString(), is("application 'foobar', generation 1337, vespa version 1.2.3"));
+ assertEquals(cache, app.getCache());
+ assertEquals("foobar", app.getId().application().value());
+ assertEquals(vespaVersion, app.getVespaVersion());
+ assertEquals("application 'foobar', generation 1337, vespa version 1.2.3", app.toString());
}
private static final String[] emptySchema = new String[0];
@@ -145,7 +144,7 @@ public class ApplicationTest {
assertNotNull(response);
ConfigResponse cached_response = handler.resolveConfig(createRequest(ModelConfig.CONFIG_DEF_NAME, ModelConfig.CONFIG_DEF_NAMESPACE, ModelConfig.CONFIG_DEF_SCHEMA));
assertNotNull(cached_response);
- assertTrue(response == cached_response);
+ assertSame(response, cached_response);
}
private static GetConfigRequest createRequest(String name, String namespace, String[] schema) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStreamTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStreamTest.java
index d5eebb4d617..23444ac53d6 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStreamTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/CompressedApplicationInputStreamTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.application;
-import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
@@ -19,10 +18,8 @@ import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -60,8 +57,8 @@ public class CompressedApplicationInputStreamTest {
private void assertTestApp(File outApp) {
String [] files = outApp.list();
assertNotNull(files);
- assertThat(files.length, is(3));
- assertThat(Arrays.asList(files), containsInAnyOrder(ImmutableList.of(is("hosts.xml"), is("services.xml"), is("deployment.xml"))));
+ assertEquals(3, files.length);
+ assertTrue(List.of(files).containsAll(List.of("hosts.xml", "services.xml", "deployment.xml")));
}
@Test
@@ -96,7 +93,7 @@ public class CompressedApplicationInputStreamTest {
CompressedApplicationInputStream unpacked = CompressedApplicationInputStream.createFromCompressedStream(new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(outFile))));
File outApp = unpacked.decompress();
- assertThat(outApp.getName(), is("application")); // gets the name of the subdir
+ assertEquals("application", outApp.getName()); // gets the name of the subdir
assertTestApp(outApp);
}
@@ -137,7 +134,7 @@ public class CompressedApplicationInputStreamTest {
new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(gzFile))));
File outApp = unpacked.decompress();
List<File> files = Arrays.asList(outApp.listFiles());
- assertThat(files.size(), is(5));
+ assertEquals(5, files.size());
assertTrue(files.contains(new File(outApp, "services.xml")));
assertTrue(files.contains(new File(outApp, "hosts.xml")));
assertTrue(files.contains(new File(outApp, "deployment.xml")));
@@ -145,26 +142,26 @@ public class CompressedApplicationInputStreamTest {
assertTrue(files.contains(new File(outApp, "external")));
File sd = files.get(files.indexOf(new File(outApp, "schemas")));
assertTrue(sd.isDirectory());
- assertThat(sd.listFiles().length, is(1));
- assertThat(sd.listFiles()[0].getAbsolutePath(), is(new File(sd, "keyvalue.sd").getAbsolutePath()));
+ assertEquals(1, sd.listFiles().length);
+ assertEquals(new File(sd, "keyvalue.sd").getAbsolutePath(), sd.listFiles()[0].getAbsolutePath());
File ext = files.get(files.indexOf(new File(outApp, "external")));
assertTrue(ext.isDirectory());
- assertThat(ext.listFiles().length, is(1));
- assertThat(ext.listFiles()[0].getAbsolutePath(), is(new File(ext, "foo").getAbsolutePath()));
+ assertEquals(1, ext.listFiles().length);
+ assertEquals(new File(ext, "foo").getAbsolutePath(), ext.listFiles()[0].getAbsolutePath());
files = Arrays.asList(ext.listFiles());
File foo = files.get(files.indexOf(new File(ext, "foo")));
assertTrue(foo.isDirectory());
- assertThat(foo.listFiles().length, is(1));
- assertThat(foo.listFiles()[0].getAbsolutePath(), is(new File(foo, "bar").getAbsolutePath()));
+ assertEquals(1, foo.listFiles().length);
+ assertEquals(new File(foo, "bar").getAbsolutePath(), foo.listFiles()[0].getAbsolutePath());
files = Arrays.asList(foo.listFiles());
File bar = files.get(files.indexOf(new File(foo, "bar")));
assertTrue(bar.isDirectory());
- assertThat(bar.listFiles().length, is(1));
+ assertEquals(1, bar.listFiles().length);
assertTrue(bar.listFiles()[0].isFile());
- assertThat(bar.listFiles()[0].getAbsolutePath(), is(new File(bar, "lol").getAbsolutePath()));
+ assertEquals(new File(bar, "lol").getAbsolutePath(), bar.listFiles()[0].getAbsolutePath());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java
index 02cc2e603d6..5afcd62a25c 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java
@@ -50,11 +50,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import static com.yahoo.vespa.config.server.application.TenantApplications.RemoveApplicationWaiter;
-import static org.hamcrest.Matchers.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;
import static org.junit.Assert.fail;
@@ -99,11 +97,11 @@ public class TenantApplicationsTest {
writeApplicationData(createApplicationId("bar"), 4L);
TenantApplications repo = createZKAppRepo();
List<ApplicationId> applications = repo.activeApplications();
- assertThat(applications.size(), is(2));
- assertThat(applications.get(0).application().value(), is("bar"));
- assertThat(applications.get(1).application().value(), is("foo"));
- assertThat(repo.requireActiveSessionOf(applications.get(0)), is(4L));
- assertThat(repo.requireActiveSessionOf(applications.get(1)), is(3L));
+ assertEquals(2, applications.size());
+ assertEquals("bar", applications.get(0).application().value());
+ assertEquals("foo", applications.get(1).application().value());
+ assertEquals(4, repo.requireActiveSessionOf(applications.get(0)));
+ assertEquals(3, repo.requireActiveSessionOf(applications.get(1)));
}
@Test(expected = IllegalArgumentException.class)
@@ -130,10 +128,10 @@ public class TenantApplicationsTest {
repo.createPutTransaction(myapp, 3).commit();
String path = TenantRepository.getApplicationsPath(tenantName).append(myapp.serializedForm()).getAbsolute();
assertNotNull(curatorFramework.checkExists().forPath(path));
- assertThat(Utf8.toString(curatorFramework.getData().forPath(path)), is("3"));
+ assertEquals("3", Utf8.toString(curatorFramework.getData().forPath(path)));
repo.createPutTransaction(myapp, 5).commit();
assertNotNull(curatorFramework.checkExists().forPath(path));
- assertThat(Utf8.toString(curatorFramework.getData().forPath(path)), is("5"));
+ assertEquals("5", Utf8.toString(curatorFramework.getData().forPath(path)));
}
@Test
@@ -145,11 +143,11 @@ public class TenantApplicationsTest {
repo.createApplication(id2);
repo.createPutTransaction(id1, 1).commit();
repo.createPutTransaction(id2, 1).commit();
- assertThat(repo.activeApplications().size(), is(2));
+ assertEquals(2, repo.activeApplications().size());
repo.createDeleteTransaction(id1).commit();
- assertThat(repo.activeApplications().size(), is(1));
+ assertEquals(1, repo.activeApplications().size());
repo.createDeleteTransaction(id2).commit();
- assertThat(repo.activeApplications().size(), is(0));
+ assertEquals(0, repo.activeApplications().size());
}
public static class MockReloadListener implements ReloadListener {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java
index f54fb272ed8..e72da13aee6 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java
@@ -8,7 +8,7 @@ import org.junit.Test;
import java.util.List;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static com.yahoo.vespa.config.server.configchange.Utils.*;
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsFormatterTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsFormatterTest.java
index c18035589f2..783f1e19df0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsFormatterTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsFormatterTest.java
@@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server.configchange;
import org.junit.Test;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static com.yahoo.vespa.config.server.configchange.Utils.*;
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsTest.java
index 31ccd2b8f84..6d5646c79e0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RestartActionsTest.java
@@ -9,7 +9,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static com.yahoo.vespa.config.server.configchange.Utils.*;
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java
index 016041cb032..41ac081f68b 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java
@@ -36,9 +36,7 @@ import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.DEFCONFIGS_Z
import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.META_ZK_PATH;
import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.USERAPP_ZK_SUBPATH;
import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.USER_DEFCONFIGS_ZK_SUBPATH;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -92,11 +90,11 @@ public class ZooKeeperClientTest {
ZooKeeperClient zooKeeperClient = new ZooKeeperClient(zk, logger, Path.fromString("/1"));
zooKeeperClient.initialize();
Path appPath = Path.fromString("/");
- assertThat(zk.getChildren(appPath).size(), is(1));
+ assertEquals(1, zk.getChildren(appPath).size());
Path currentAppPath = appPath.append(String.valueOf(generation));
assertTrue(zk.exists(currentAppPath));
assertTrue(zk.exists(currentAppPath.append(DEFCONFIGS_ZK_SUBPATH.replaceFirst("/", ""))));
- assertThat(zk.getChildren(currentAppPath).size(), is(4));
+ assertEquals(4, zk.getChildren(currentAppPath).size());
}
@Test
@@ -106,14 +104,14 @@ public class ZooKeeperClientTest {
List<String> children = zk.getChildren(defsPath);
assertEquals(defsPath + " children", 1, children.size());
Collections.sort(children);
- assertThat(children.get(0), is("a.b.test2"));
+ assertEquals("a.b.test2", children.get(0));
assertTrue(zk.exists(appPath.append(USER_DEFCONFIGS_ZK_SUBPATH.replaceFirst("/", ""))));
Path userDefsPath = appPath.append(USER_DEFCONFIGS_ZK_SUBPATH);
children = zk.getChildren(userDefsPath);
- assertThat(children.size(), is(1));
+ assertEquals(1, children.size());
Collections.sort(children);
- assertThat(children.get(0), is("a.b.test2"));
+ assertEquals("a.b.test2", children.get(0));
}
@Test
@@ -123,11 +121,11 @@ public class ZooKeeperClientTest {
Utf8.toString(zk.getData(appPath.append(META_ZK_PATH)).get()));
assertTrue(metaData.getChecksum().length() > 0);
assertTrue(metaData.isInternalRedeploy());
- assertThat(metaData.getDeployedByUser(), is("foo"));
- assertThat(metaData.getDeployPath(), is("/bar/baz"));
- assertThat(metaData.getDeployTimestamp(), is(1345L));
- assertThat(metaData.getGeneration(), is(3L));
- assertThat(metaData.getPreviousActiveGeneration(), is(2L));
+ assertEquals("foo", metaData.getDeployedByUser());
+ assertEquals("/bar/baz", metaData.getDeployPath());
+ assertEquals(1345, metaData.getDeployTimestamp().longValue());
+ assertEquals(3, metaData.getGeneration().longValue());
+ assertEquals(2, metaData.getPreviousActiveGeneration());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java
index f7d55a34e33..df00d28134f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java
@@ -8,11 +8,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
@@ -30,16 +29,16 @@ public class HostRegistryTest {
assertGetKey(reg, "foo.com", foo);
assertGetKey(reg, "bar.com", foo);
assertGetKey(reg, "baz.com", foo);
- assertThat(reg.getAllHosts().size(), is(3));
+ assertEquals(3, reg.getAllHosts().size());
reg.update(foo, List.of("bar.com", "baz.com"));
assertNull(reg.getKeyForHost("foo.com"));
assertGetKey(reg, "bar.com", foo);
assertGetKey(reg, "baz.com", foo);
- assertThat(reg.getAllHosts().size(), is(2));
- assertThat(reg.getAllHosts(), contains("bar.com", "baz.com"));
+ assertEquals(2, reg.getAllHosts().size());
+ assertTrue(reg.getAllHosts().containsAll(List.of("bar.com", "baz.com")));
reg.removeHostsForKey(foo);
- assertThat(reg.getAllHosts().size(), is(0));
+ assertTrue(reg.getAllHosts().isEmpty());
assertNull(reg.getKeyForHost("foo.com"));
assertNull(reg.getKeyForHost("bar.com"));
}
@@ -67,7 +66,7 @@ public class HostRegistryTest {
HostRegistry reg = new HostRegistry();
reg.update(foo, List.of("foo.com", "bar.com"));
reg.update(bar, List.of("baz.com", "quux.com"));
- assertThat(reg.getAllHosts().size(), is(4));
+ assertEquals(4, reg.getAllHosts().size());
}
@Test
@@ -75,9 +74,9 @@ public class HostRegistryTest {
HostRegistry reg = new HostRegistry();
List<String> hosts = new ArrayList<>(List.of("foo.com", "bar.com", "baz.com"));
reg.update(foo, hosts);
- assertThat(reg.getHostsForKey(foo).size(), is(3));
+ assertEquals(3, reg.getHostsForKey(foo).size());
hosts.remove(2);
- assertThat(reg.getHostsForKey(foo).size(), is(3));
+ assertEquals(3, reg.getHostsForKey(foo).size());
}
@Test
@@ -85,14 +84,14 @@ public class HostRegistryTest {
HostRegistry reg = new HostRegistry();
reg.update(foo, List.of("foo.com", "bar.com", "baz.com"));
Collection<String> hosts = reg.getAllHosts();
- assertThat(hosts.size(), is(3));
+ assertEquals(3, hosts.size());
reg.update(foo, List.of("foo.com"));
- assertThat(hosts.size(), is(3));
+ assertEquals(3, hosts.size());
}
private void assertGetKey(HostRegistry reg, String host, ApplicationId expectedKey) {
assertNotNull(reg.getKeyForHost(host));
- assertThat(reg.getKeyForHost(host), is(expectedKey));
+ assertEquals(expectedKey, reg.getKeyForHost(host));
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java
index 3c9940679b9..f77d7331dea 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java
@@ -14,9 +14,8 @@ import java.util.Collection;
import static com.yahoo.jdisc.Response.Status.BAD_REQUEST;
import static com.yahoo.jdisc.Response.Status.NOT_FOUND;
import static com.yahoo.jdisc.Response.Status.OK;
-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;
public abstract class ContentHandlerTestBase extends SessionHandlerTest {
protected String baseUrl = "http://foo:1337/application/v2/tenant/default/session/1/content/";
@@ -39,7 +38,7 @@ public abstract class ContentHandlerTestBase extends SessionHandlerTest {
public void require_that_nonexistant_file_returns_not_found() {
HttpResponse response = doRequest(HttpRequest.Method.GET, "/test2.txt");
assertNotNull(response);
- assertThat(response.getStatus(), is(NOT_FOUND));
+ assertEquals(NOT_FOUND, response.getStatus());
}
@Test
@@ -50,7 +49,7 @@ public abstract class ContentHandlerTestBase extends SessionHandlerTest {
@Test
public void require_that_illegal_return_property_fails() {
HttpResponse response = doRequest(HttpRequest.Method.GET, "/test.txt?return=foo");
- assertThat(response.getStatus(), is(BAD_REQUEST));
+ assertEquals(BAD_REQUEST, response.getStatus());
}
@Test
@@ -77,17 +76,17 @@ public abstract class ContentHandlerTestBase extends SessionHandlerTest {
HttpResponse response = doRequest(HttpRequest.Method.GET, path);
assertNotNull(response);
final String renderedString = SessionHandlerTest.getRenderedString(response);
- assertThat(renderedString, response.getStatus(), is(OK));
- assertThat(renderedString, is(expectedContent));
- assertThat(response.getContentType(), is(expectedContentType));
+ assertEquals(renderedString, OK, response.getStatus());
+ assertEquals(expectedContent, renderedString);
+ assertEquals(expectedContentType, response.getContentType());
}
protected void assertStatus(String path, String expectedContent) throws IOException {
HttpResponse response = doRequest(HttpRequest.Method.GET, path);
assertNotNull(response);
final String renderedString = SessionHandlerTest.getRenderedString(response);
- assertThat(renderedString, response.getStatus(), is(OK));
- assertThat(renderedString, is(expectedContent));
+ assertEquals(renderedString, OK, response.getStatus());
+ assertEquals(expectedContent, renderedString);
}
protected abstract HttpResponse doRequest(HttpRequest.Method method, String path);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java
index f681dbbc152..69caf86729f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java
@@ -5,9 +5,9 @@ import com.yahoo.container.jdisc.HttpResponse;
import java.io.IOException;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
/**
* Base class for handler tests
@@ -27,14 +27,14 @@ public class HandlerTest {
if (renderedString == null) {
renderedString = "assert failed";
}
- assertThat(renderedString, response.getStatus(), is(statusCode));
+ assertEquals(renderedString, statusCode, response.getStatus());
if (errorCode != null) {
- assertThat(renderedString, containsString(errorCode.name()));
+ assertTrue(renderedString.contains(errorCode.name()));
}
if (contentType != null) {
- assertThat(renderedString, response.getContentType(), is(contentType));
+ assertEquals(renderedString, contentType, response.getContentType());
}
- assertThat(renderedString, containsString(message));
+ assertTrue(renderedString.contains(message));
}
public static void assertHttpStatusCodeErrorCodeAndMessage(HttpResponse response, int statusCode, HttpErrorResponse.ErrorCode errorCode, String message) throws IOException {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java
index 96a1c123da5..f1be638468e 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java
@@ -6,11 +6,8 @@ import com.yahoo.vespa.config.ConfigKey;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -23,7 +20,7 @@ public class HttpConfigRequestTest {
HttpConfigRequest request = HttpConfigRequest.createFromRequestV1(HttpRequest.createTestRequest("http://example.yahoo.com:8080/config/v1/" +
configKey.getNamespace() + "." + configKey.getName() + "/" + configKey.getConfigId(), GET));
- assertThat(request.getConfigKey(), is(configKey));
+ assertEquals(configKey, request.getConfigKey());
assertTrue(request.getDefContent().isEmpty());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java
index f81c3577298..452d05c85ec 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java
@@ -10,8 +10,7 @@ import org.junit.Test;
import java.io.IOException;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author Ulf Lilleengen
@@ -26,6 +25,6 @@ public class HttpConfigResponseTest {
false,
PayloadChecksums.from("", "595f44fec1e92a71d"));
HttpConfigResponse response = HttpConfigResponse.createFromConfig(configResponse);
- assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
+ assertEquals(SessionHandlerTest.getRenderedString(response), "{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}");
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java
index 0023e4dc701..f5c430152f3 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java
@@ -6,7 +6,7 @@ import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static com.yahoo.jdisc.http.HttpResponse.Status.*;
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java
index e055473a245..8f092ec9d54 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java
@@ -13,9 +13,7 @@ import java.io.IOException;
import java.time.Duration;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
@@ -27,12 +25,12 @@ public class HttpHandlerTest {
final String message = "failed";
HttpHandler httpHandler = new HttpTestHandler(new InvalidApplicationException(message));
HttpResponse response = httpHandler.handle(HttpRequest.createTestRequest("foo", com.yahoo.jdisc.http.HttpRequest.Method.GET));
- assertThat(response.getStatus(), is(Response.Status.BAD_REQUEST));
+ assertEquals(Response.Status.BAD_REQUEST, response.getStatus());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.render(baos);
Slime data = SlimeUtils.jsonToSlime(baos.toByteArray());
- assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.ErrorCode.INVALID_APPLICATION_PACKAGE.name()));
- assertThat(data.get().field("message").asString(), is(message));
+ assertEquals(HttpErrorResponse.ErrorCode.INVALID_APPLICATION_PACKAGE.name(), data.get().field("error-code").asString());
+ assertEquals(message, data.get().field("message").asString());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
index 00135a0a11e..322a2b924bd 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
@@ -25,9 +25,8 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
-import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
@@ -108,13 +107,13 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
Tenant tenant1 = applicationRepository.getTenant(appId1);
Session session = applicationRepository.getActiveLocalSession(tenant1, appId1);
assertContent("/test.txt", "foo\n");
- assertThat(session.getStatus(), is(Session.Status.ACTIVATE));
+ assertEquals(Session.Status.ACTIVATE, session.getStatus());
}
private void assertNotFound(HttpRequest request) {
HttpResponse response = handler.handle(request);
assertNotNull(response);
- assertThat(response.getStatus(), is(Response.Status.NOT_FOUND));
+ assertEquals(Response.Status.NOT_FOUND, response.getStatus());
}
@Override
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
index c59375a6085..3d207f9f64a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
@@ -31,9 +31,7 @@ import java.util.Collections;
import static com.yahoo.jdisc.Response.Status.BAD_REQUEST;
import static com.yahoo.jdisc.Response.Status.NOT_FOUND;
import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -97,9 +95,9 @@ public class HttpGetConfigHandlerTest {
String uriLongAppId = "http://foo.com:8080/config/v2/tenant/bill/application/sookie/environment/dev/region/bellefleur/instance/sam/foo.bar/myid";
HttpRequest r = HttpRequest.createTestRequest(uriLongAppId, GET);
HttpConfigRequest req = HttpConfigRequest.createFromRequestV2(r);
- assertThat(req.getApplicationId().tenant().value(), is("bill"));
- assertThat(req.getApplicationId().application().value(), is("sookie"));
- assertThat(req.getApplicationId().instance().value(), is("sam"));
+ assertEquals("bill", req.getApplicationId().tenant().value());
+ assertEquals("sookie", req.getApplicationId().application().value());
+ assertEquals("sam", req.getApplicationId().instance().value());
}
@Test
@@ -107,9 +105,9 @@ public class HttpGetConfigHandlerTest {
String uriShortAppId = "http://foo.com:8080/config/v2/tenant/jason/application/alcide/foo.bar/myid";
HttpRequest r = HttpRequest.createTestRequest(uriShortAppId, GET);
HttpConfigRequest req = HttpConfigRequest.createFromRequestV2(r);
- assertThat(req.getApplicationId().tenant().value(), is("jason"));
- assertThat(req.getApplicationId().application().value(), is("alcide"));
- assertThat(req.getApplicationId().instance().value(), is("default"));
+ assertEquals("jason", req.getApplicationId().tenant().value());
+ assertEquals("alcide", req.getApplicationId().application().value());
+ assertEquals("default", req.getApplicationId().instance().value());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java
index 26346cd8ffe..e2ad65786a4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java
@@ -26,9 +26,8 @@ import static com.yahoo.jdisc.http.HttpRequest.Method.DELETE;
import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
import static com.yahoo.jdisc.http.HttpRequest.Method.POST;
import static com.yahoo.jdisc.http.HttpRequest.Method.PUT;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
* @author Ulf Lilleengen
@@ -122,7 +121,7 @@ public class ListApplicationsHandlerTest {
static void assertResponse(ListApplicationsHandler handler, String url, int expectedStatus, String expectedResponse, Method method) throws IOException {
HttpResponse response = handler.handle(HttpRequest.createTestRequest(url, method));
assertNotNull(response);
- assertThat(response.getStatus(), is(expectedStatus));
- assertThat(SessionHandlerTest.getRenderedString(response), is(expectedResponse));
+ assertEquals(expectedStatus, response.getStatus());
+ assertEquals(expectedResponse, SessionHandlerTest.getRenderedString(response));
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
index cb0d2129112..c6f84c2d6ae 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
@@ -24,7 +24,6 @@ import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
import com.yahoo.vespa.config.server.tenant.TestTenantRepository;
import com.yahoo.vespa.model.VespaModelFactory;
-import org.hamcrest.core.Is;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -43,10 +42,7 @@ import static com.yahoo.jdisc.Response.Status.OK;
import static com.yahoo.vespa.config.server.http.SessionHandlerTest.Cmd;
import static com.yahoo.vespa.config.server.http.SessionHandlerTest.createTestRequest;
import static com.yahoo.vespa.config.server.http.SessionHandlerTest.getRenderedString;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class SessionActiveHandlerTest {
@@ -150,21 +146,21 @@ public class SessionActiveHandlerTest {
activateRequest.invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
- assertThat(message, actResponse.getStatus(), Is.is(OK));
+ assertEquals(message, OK, actResponse.getStatus());
assertActivationMessageOK(activateRequest, message);
}
private void assertActivationMessageOK(ActivateRequest activateRequest, String message) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
new JsonFormat(true).encode(byteArrayOutputStream, activateRequest.getMetaData().getSlime());
- assertThat(message, containsString("\"tenant\":\"" + tenantName + "\",\"message\":\"Session " + activateRequest.getSessionId() + activatedMessage));
- assertThat(message, containsString("/application/v2/tenant/" + tenantName +
+ assertTrue(message.contains("\"tenant\":\"" + tenantName + "\",\"message\":\"Session " + activateRequest.getSessionId() + activatedMessage));
+ assertTrue(message.contains("/application/v2/tenant/" + tenantName +
"/application/" + appName +
"/environment/" + "prod" +
"/region/" + "default" +
"/instance/" + "default"));
assertTrue(provisioner.activated());
- assertThat(provisioner.lastHosts().size(), is(1));
+ assertEquals(1, provisioner.lastHosts().size());
}
private SessionActiveHandler createHandler() {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
index 7b14579d79c..f13ec6cd5c8 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
@@ -31,9 +31,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.time.Clock;
-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;
/**
* @author Ulf Lilleengen
@@ -92,14 +91,14 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
public void require_that_mkdir_with_body_is_illegal(){
HttpResponse response = put("/foobio/", "foo");
assertNotNull(response);
- assertThat(response.getStatus(), is(Response.Status.BAD_REQUEST));
+ assertEquals(Response.Status.BAD_REQUEST, response.getStatus());
}
@Test
public void require_that_nonexistent_session_returns_not_found() {
HttpResponse response = doRequest(HttpRequest.Method.GET, "/test.txt", 9999);
assertNotNull(response);
- assertThat(response.getStatus(), is(Response.Status.NOT_FOUND));
+ assertEquals(Response.Status.NOT_FOUND, response.getStatus());
}
protected HttpResponse put(String path, String content) {
@@ -111,7 +110,7 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
public void require_that_file_write_without_body_is_illegal() {
HttpResponse response = doRequest(HttpRequest.Method.PUT, "/foobio.txt");
assertNotNull(response);
- assertThat(response.getStatus(), is(Response.Status.BAD_REQUEST));
+ assertEquals(Response.Status.BAD_REQUEST, response.getStatus());
}
@Test
@@ -146,10 +145,9 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
private void assertWriteFile(String path, String content) throws IOException {
HttpResponse response = put(path, content);
assertNotNull(response);
- assertThat(response.getStatus(), is(Response.Status.OK));
+ assertEquals(Response.Status.OK, response.getStatus());
assertContent(path, content);
- assertThat(SessionHandlerTest.getRenderedString(response),
- is("{\"prepared\":\"http://foo:1337" + pathPrefix + sessionId + "/prepared\"}"));
+ assertEquals("{\"prepared\":\"http://foo:1337" + pathPrefix + sessionId + "/prepared\"}", SessionHandlerTest.getRenderedString(response));
}
private void assertDeleteFile(int statusCode, String filePath) throws IOException {
@@ -159,16 +157,16 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
private void assertDeleteFile(int statusCode, String filePath, String expectedResponse) throws IOException {
HttpResponse response = doRequest(HttpRequest.Method.DELETE, filePath);
assertNotNull(response);
- assertThat(response.getStatus(), is(statusCode));
- assertThat(SessionHandlerTest.getRenderedString(response), is(expectedResponse));
+ assertEquals(statusCode, response.getStatus());
+ assertEquals(expectedResponse, SessionHandlerTest.getRenderedString(response));
}
private void assertMkdir(String path) throws IOException {
HttpResponse response = doRequest(HttpRequest.Method.PUT, path);
assertNotNull(response);
- assertThat(response.getStatus(), is(Response.Status.OK));
- assertThat(SessionHandlerTest.getRenderedString(response),
- is("{\"prepared\":\"http://foo:1337" + pathPrefix + sessionId + "/prepared\"}"));
+ assertEquals(Response.Status.OK, response.getStatus());
+ assertEquals("{\"prepared\":\"http://foo:1337" + pathPrefix + sessionId + "/prepared\"}",
+ SessionHandlerTest.getRenderedString(response));
}
protected HttpResponse doRequest(HttpRequest.Method method, String path) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
index fced32251ad..4cb69ce5d20 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
@@ -43,10 +43,8 @@ import static com.yahoo.jdisc.Response.Status.OK;
import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
import static com.yahoo.jdisc.http.HttpRequest.Method.POST;
import static com.yahoo.vespa.config.server.http.HandlerTest.assertHttpStatusCodeErrorCodeAndMessage;
-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;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -128,11 +126,11 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
Map<String, String> parameters = Collections.singletonMap("name", "foo");
HttpResponse response = createHandler().handle(post(outFile, postHeaders, parameters));
assertNotNull(response);
- assertThat(response.getStatus(), is(OK));
- assertThat(SessionHandlerTest.getRenderedString(response),
- is("{\"log\":[]" + tenantMessage + ",\"session-id\":\"2\",\"prepared\":\"http://" +
+ assertEquals(OK, response.getStatus());
+ assertEquals(SessionHandlerTest.getRenderedString(response),
+ "{\"log\":[]" + tenantMessage + ",\"session-id\":\"2\",\"prepared\":\"http://" +
hostname + ":" + port + pathPrefix + "2/prepared\",\"content\":\"http://" +
- hostname + ":" + port + pathPrefix + "2/content/\",\"message\":\"Session 2" + createdMessage + "}"));
+ hostname + ":" + port + pathPrefix + "2/content/\",\"message\":\"Session 2" + createdMessage + "}");
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
index 0afe742f345..3c762b7c2e5 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
@@ -42,12 +42,10 @@ import static com.yahoo.jdisc.Response.Status.METHOD_NOT_ALLOWED;
import static com.yahoo.jdisc.Response.Status.NOT_FOUND;
import static com.yahoo.jdisc.Response.Status.OK;
import static com.yahoo.vespa.config.server.http.HandlerTest.assertHttpStatusCodeErrorCodeAndMessage;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.not;
-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;
+import static org.junit.Assert.assertTrue;
/**
* @author hmusum
@@ -128,7 +126,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
long sessionId = applicationRepository.createSession(applicationId(), timeoutBudget, app);
HttpResponse response = request(HttpRequest.Method.PUT, sessionId);
assertNotNull(response);
- assertThat(response.getStatus(), is(OK));
+ assertEquals(OK, response.getStatus());
assertResponseContains(response, "\"activate\":\"http://foo:1337" + pathPrefix + sessionId +
"/active\",\"message\":\"Session " + sessionId + preparedMessage);
}
@@ -137,8 +135,8 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
public void require_debug() throws Exception {
HttpResponse response = createHandler().handle(
createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 9999L, "?debug=true"));
- assertThat(response.getStatus(), is(NOT_FOUND));
- assertThat(SessionHandlerTest.getRenderedString(response), containsString("NotFoundException"));
+ assertEquals(NOT_FOUND, response.getStatus());
+ assertTrue(SessionHandlerTest.getRenderedString(response).contains("NotFoundException"));
}
@Test
@@ -147,8 +145,8 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
HttpResponse response = createHandler().handle(
createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, sessionId, "?verbose=true"));
System.out.println(getRenderedString(response));
- assertThat(response.getStatus(), is(OK));
- assertThat(getRenderedString(response), containsString("Created application "));
+ assertEquals(OK, response.getStatus());
+ assertTrue(getRenderedString(response).contains("Created application "));
}
@Test
@@ -191,7 +189,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
long sessionId = applicationRepository.createSession(applicationId(), timeoutBudget, app);
HttpResponse response = request(HttpRequest.Method.PUT, sessionId);
assertNotNull(response);
- assertThat(response.getStatus(), is(OK));
+ assertEquals(OK, response.getStatus());
assertResponseContains(response, tenantMessage);
}
@@ -207,7 +205,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
pathPrefix = "/application/v2/tenant/" + defaultTenant + "/session/";
HttpResponse response = request(HttpRequest.Method.PUT, sessionId);
assertNotNull(response);
- assertThat(SessionHandlerTest.getRenderedString(response), response.getStatus(), is(OK));
+ assertEquals(SessionHandlerTest.getRenderedString(response), OK, response.getStatus());
String applicationName = "myapp";
ApplicationId applicationId2 = ApplicationId.from(tenant.value(), applicationName, "default");
@@ -218,7 +216,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
"/prepared?applicationName=" + applicationName;
response = handler.handle(SessionHandlerTest.createTestRequest(pathPrefix));
assertNotNull(response);
- assertThat(SessionHandlerTest.getRenderedString(response), response.getStatus(), is(OK));
+ assertEquals(SessionHandlerTest.getRenderedString(response), OK, response.getStatus());
ApplicationId applicationId3 = ApplicationId.from(tenant.value(), applicationName, "quux");
long sessionId3 = applicationRepository.createSession(applicationId3, timeoutBudget, app);
@@ -226,7 +224,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
"/prepared?applicationName=" + applicationName + "&instance=quux";
response = handler.handle(SessionHandlerTest.createTestRequest(pathPrefix));
assertNotNull(response);
- assertThat(SessionHandlerTest.getRenderedString(response), response.getStatus(), is(OK));
+ assertEquals(SessionHandlerTest.getRenderedString(response), OK, response.getStatus());
}
@Test
@@ -256,8 +254,8 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
HttpResponse response = handler.handle(createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, sessionId));
assertEquals(400, response.getStatus());
Slime data = getData(response);
- assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.ErrorCode.OUT_OF_CAPACITY.name()));
- assertThat(data.get().field("message").asString(), is(exceptionMessage));
+ assertEquals(HttpErrorResponse.ErrorCode.OUT_OF_CAPACITY.name(), data.get().field("error-code").asString());
+ assertEquals(exceptionMessage, data.get().field("message").asString());
}
@Test
@@ -271,8 +269,8 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
HttpResponse response = handler.handle(createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, sessionId));
assertEquals(500, response.getStatus());
Slime data = getData(response);
- assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.ErrorCode.INTERNAL_SERVER_ERROR.name()));
- assertThat(data.get().field("message").asString(), is(exceptionMessage));
+ assertEquals(HttpErrorResponse.ErrorCode.INTERNAL_SERVER_ERROR.name(), data.get().field("error-code").asString());
+ assertEquals(exceptionMessage, data.get().field("message").asString());
}
@Test
@@ -286,8 +284,8 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
HttpResponse response = handler.handle(createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, sessionId));
assertEquals(500, response.getStatus());
Slime data = getData(response);
- assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.ErrorCode.APPLICATION_LOCK_FAILURE.name()));
- assertThat(data.get().field("message").asString(), is(exceptionMessage));
+ assertEquals(HttpErrorResponse.ErrorCode.APPLICATION_LOCK_FAILURE.name(), data.get().field("error-code").asString());
+ assertEquals(exceptionMessage, data.get().field("message").asString());
}
@Test
@@ -308,11 +306,11 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
}
private static void assertResponseContains(HttpResponse response, String string) throws IOException {
- assertThat(SessionHandlerTest.getRenderedString(response), containsString(string));
+ assertTrue(SessionHandlerTest.getRenderedString(response).contains(string));
}
private static void assertResponseNotContains(HttpResponse response, String string) throws IOException {
- assertThat(SessionHandlerTest.getRenderedString(response), not(containsString(string)));
+ assertFalse(SessionHandlerTest.getRenderedString(response).contains(string));
}
private SessionHandler createHandler() {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
index fb5fb27cd7a..402e2576591 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
@@ -44,14 +44,9 @@ import static com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications.Endpo
import static com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications.Endpoints.Scope.Enum.global;
import static com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications.Endpoints.Scope.Enum.zone;
import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-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.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
@@ -101,12 +96,12 @@ public class LbServicesProducerTest {
LbServicesConfig conf = getLbServicesConfig(Zone.defaultZone(), testModel);
LbServicesConfig.Tenants.Applications.Hosts.Services services =
conf.tenants("foo").applications("foo:prod:default:default").hosts("foo.foo.yahoo.com").services(QRSERVER.serviceName);
- assertThat(services.servicealiases().size(), is(1));
- assertThat(services.endpointaliases().size(), is(2));
+ assertEquals(1, services.servicealiases().size());
+ assertEquals(2, services.endpointaliases().size());
- assertThat(services.servicealiases(0), is("service1"));
- assertThat(services.endpointaliases(0), is("foo1.bar1.com"));
- assertThat(services.endpointaliases(1), is("foo2.bar2.com"));
+ assertEquals("service1", services.servicealiases(0));
+ assertEquals("foo1.bar1.com", services.endpointaliases(0));
+ assertEquals("foo2.bar2.com", services.endpointaliases(1));
}
@Test
@@ -164,30 +159,30 @@ public class LbServicesProducerTest {
.hosts("foo.foo.yahoo.com")
.services(QRSERVER.serviceName);
- assertThat(services.servicealiases(), contains("service1"));
- assertThat("Missing endpoints in list: " + services.endpointaliases(), services.endpointaliases(), containsInAnyOrder("foo1.bar1.com", "foo2.bar2.com", rotation1, rotation2));
+ assertTrue(services.servicealiases().contains("service1"));
+ assertTrue("Missing endpoints in list: " + services.endpointaliases(), services.endpointaliases().containsAll(List.of("foo1.bar1.com", "foo2.bar2.com", rotation1, rotation2)));
List<Endpoints> endpointList = config.tenants("foo").applications("foo:prod:" + regionName.value() + ":default").endpoints();
// Expect 4 zone endpoints (2 suffixes), 2 global endpoints and 1 application endpoint
assertEquals(7, endpointList.size());
List<Endpoints> zoneEndpoints = endpointList.stream().filter(e -> e.scope() == zone).collect(Collectors.toList());
assertEquals(4, zoneEndpoints.size());
- assertThat(zoneEndpoints.stream()
+ assertTrue(zoneEndpoints.stream()
.filter(e -> e.routingMethod() == sharedLayer4)
- .map(Endpoints::dnsName).collect(Collectors.toList()),
- containsInAnyOrder("mydisc.foo.foo.endpoint1.suffix", "mydisc.foo.foo.endpoint2.suffix"));
+ .map(Endpoints::dnsName).collect(Collectors.toList())
+ .containsAll(List.of("mydisc.foo.foo.endpoint1.suffix", "mydisc.foo.foo.endpoint2.suffix")));
assertContainsEndpoint(zoneEndpoints, "mydisc.foo.foo.endpoint1.suffix", "mydisc", zone, sharedLayer4, 1, List.of("foo.foo.yahoo.com"));
assertContainsEndpoint(zoneEndpoints, "mydisc.foo.foo.endpoint2.suffix", "mydisc", zone, sharedLayer4, 1, List.of("foo.foo.yahoo.com"));
List<Endpoints> globalEndpoints = endpointList.stream().filter(e -> e.scope() == global).collect(Collectors.toList());
assertEquals(2, globalEndpoints.size());
- assertThat(globalEndpoints.stream().map(Endpoints::dnsName).collect(Collectors.toList()), containsInAnyOrder("rotation-1", "rotation-2"));
+ assertTrue(globalEndpoints.stream().map(Endpoints::dnsName).collect(Collectors.toList()).containsAll(List.of("rotation-1", "rotation-2")));
assertContainsEndpoint(globalEndpoints, "rotation-1", "mydisc", global, sharedLayer4, 1, List.of("foo.foo.yahoo.com"));
assertContainsEndpoint(globalEndpoints, "rotation-2", "mydisc", global, sharedLayer4, 1, List.of("foo.foo.yahoo.com"));
List<Endpoints> applicationEndpoints = endpointList.stream().filter(e -> e.scope() == application).collect(Collectors.toList());
assertEquals(1, applicationEndpoints.size());
- assertThat(applicationEndpoints.stream().map(Endpoints::dnsName).collect(Collectors.toList()), containsInAnyOrder("app-endpoint"));
+ assertTrue(applicationEndpoints.stream().map(Endpoints::dnsName).collect(Collectors.toList()).contains("app-endpoint"));
assertContainsEndpoint(applicationEndpoints, "app-endpoint", "mydisc", application, sharedLayer4, 1, List.of("foo.foo.yahoo.com"));
}
@@ -199,8 +194,8 @@ public class LbServicesProducerTest {
Map<TenantName, Set<ApplicationInfo>> testModel = createTestModel(new DeployState.Builder());
LbServicesConfig conf = getLbServicesConfig(Zone.defaultZone(), testModel);
LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:default:default").hosts("foo.foo.yahoo.com").services(QRSERVER.serviceName);
- assertThat(services.servicealiases().size(), is(1));
- assertThat(services.endpointaliases().size(), is(2));
+ assertEquals(1, services.servicealiases().size());
+ assertEquals(2, services.endpointaliases().size());
// No config for tester application
assertNull(getLbServicesConfig(Zone.defaultZone(), testModel)
@@ -209,7 +204,7 @@ public class LbServicesProducerTest {
}
private void assertContainsEndpoint(List<Endpoints> endpoints, String dnsName, String clusterId, Endpoints.Scope.Enum scope, Endpoints.RoutingMethod.Enum routingMethod, int weight, List<String> hosts) {
- assertThat(endpoints, hasItem(new Endpoints.Builder()
+ assertTrue(endpoints.contains(new Endpoints.Builder()
.dnsName(dnsName)
.clusterId(clusterId)
.scope(scope)
@@ -316,8 +311,8 @@ public class LbServicesProducerTest {
private void assertConfig(LbServicesConfig expected, LbServicesConfig actual) {
assertFalse(expected.toString().isEmpty());
assertFalse(actual.toString().isEmpty());
- assertThat(expected.toString(), is(actual.toString()));
- assertThat(ConfigPayload.fromInstance(expected).toString(true), is(ConfigPayload.fromInstance(actual).toString(true)));
+ assertEquals(actual.toString(), expected.toString());
+ assertEquals(ConfigPayload.fromInstance(expected).toString(true), ConfigPayload.fromInstance(actual).toString(true));
}
private TestProperties getTestproperties(ApplicationId applicationId) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java
index 21e1c1f3448..04882fcfa26 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java
@@ -22,9 +22,8 @@ import java.util.List;
import java.util.Optional;
import static com.yahoo.vespa.config.protocol.JRTClientConfigRequestV3.createWithParams;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -40,17 +39,17 @@ public class DelayedConfigResponseTest {
MockRpcServer rpc = new MockRpcServer(13337, temporaryFolder.newFolder());
DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false);
- assertThat(responses.size(), is(0));
+ assertEquals(0, responses.size());
JRTServerConfigRequest req = createRequest("foo", "myid", 3, 1000000, "bar");
req.setDelayedResponse(true);
GetConfigContext context = GetConfigContext.testContext(ApplicationId.defaultId());
responses.delayResponse(req, context);
- assertThat(responses.size(), is(0));
+ assertEquals(0, responses.size());
req.setDelayedResponse(false);
responses.delayResponse(req, context);
responses.delayResponse(createRequest("foolio", "myid", 3, 100000, "bar"), context);
- assertThat(responses.size(), is(2));
+ assertEquals(2, responses.size());
assertTrue(req.isDelayedResponse());
List<DelayedConfigResponses.DelayedConfigResponse> it = responses.allDelayedResponses();
assertFalse(it.isEmpty());
@@ -62,21 +61,21 @@ public class DelayedConfigResponseTest {
MockRpcServer rpc = new MockRpcServer(13337, temporaryFolder.newFolder());
DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false);
responses.delayResponse(createRequest("foolio", "myid", 3, 100000, "bar"), context);
- assertThat(responses.size(), is(1));
+ assertEquals(1, responses.size());
responses.allDelayedResponses().get(0).cancelAndRemove();
- assertThat(responses.size(), is(0));
+ assertEquals(0, responses.size());
}
@Test
public void testDelayedConfigResponse() throws IOException {
MockRpcServer rpc = new MockRpcServer(13337, temporaryFolder.newFolder());
DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false);
- assertThat(responses.size(), is(0));
- assertThat(responses.toString(), is("DelayedConfigResponses. Average Size=0"));
+ assertEquals(0, responses.size());
+ assertEquals("DelayedConfigResponses. Average Size=0", responses.toString());
JRTServerConfigRequest req = createRequest("foo", "myid", 3, 100, "bar");
responses.delayResponse(req, GetConfigContext.testContext(ApplicationId.defaultId()));
rpc.waitUntilSet(Duration.ofSeconds(5));
- assertThat(rpc.latestRequest, is(req));
+ assertEquals(req, rpc.latestRequest);
}
private JRTServerConfigRequest createRequest(String configName, String configId, long generation, long timeout, String namespace) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
index 1b8a7ca2ad6..7ad237e45ed 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
@@ -37,11 +37,9 @@ import java.io.File;
import java.io.IOException;
import java.util.Optional;
-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;
import static org.junit.Assert.assertTrue;
/**
@@ -74,7 +72,7 @@ public class RpcServerTest {
JRTClientConfigRequest clientReq = createSimpleRequest();
tester.performRequest(clientReq.getRequest());
assertFalse(clientReq.validateResponse());
- assertThat(clientReq.errorCode(), is(ErrorCode.APPLICATION_NOT_LOADED));
+ assertEquals(ErrorCode.APPLICATION_NOT_LOADED, clientReq.errorCode());
}
@Test
@@ -127,7 +125,7 @@ public class RpcServerTest {
assertTrue(clientReq.validateParameters());
tester.performRequest(clientReq.getRequest());
assertFalse(clientReq.validateResponse());
- assertThat(clientReq.errorCode(), is(ErrorCode.APPLICATION_NOT_LOADED));
+ assertEquals(ErrorCode.APPLICATION_NOT_LOADED, clientReq.errorCode());
tester.rpcServer().onTenantsLoaded();
clientReq = createRequest(new RawConfig(key, LbServicesConfig.getDefMd5()));
@@ -135,7 +133,7 @@ public class RpcServerTest {
tester.performRequest(clientReq.getRequest());
boolean validResponse = clientReq.validateResponse();
assertTrue(clientReq.errorMessage(), validResponse);
- assertThat(clientReq.errorCode(), is(0));
+ assertEquals(0, clientReq.errorCode());
}
private void testGetConfig(RpcTester tester) {
@@ -143,20 +141,20 @@ public class RpcServerTest {
JRTClientConfigRequest req = createRequest(new RawConfig(key, SimpletypesConfig.getDefMd5()));
assertTrue(req.validateParameters());
tester.performRequest(req.getRequest());
- assertThat(req.errorCode(), is(0));
+ assertEquals(0, req.errorCode());
assertTrue(req.validateResponse());
ConfigPayload payload = ConfigPayload.fromUtf8Array(req.getNewPayload().getData());
assertNotNull(payload);
SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder();
new ConfigPayloadApplier<>(builder).applyPayload(payload);
SimpletypesConfig config = new SimpletypesConfig(builder);
- assertThat(config.intval(), is(0));
+ assertEquals(0, config.intval());
}
private void testPrintStatistics(RpcTester tester) {
Request req = new Request("printStatistics");
tester.performRequest(req);
- assertThat(req.returnValues().get(0).asString(), is("Delayed responses queue size: 0"));
+ assertEquals("Delayed responses queue size: 0", req.returnValues().get(0).asString());
}
private JRTClientConfigRequest createRequest(RawConfig config) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java
index e8749334448..40ed20b7969 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java
@@ -38,10 +38,8 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -163,7 +161,7 @@ public class RpcTester implements AutoCloseable {
}
assertFalse(req.isError());
assertTrue(req.returnValues().size() > 0);
- assertThat(req.returnValues().get(0).asInt32(), is(0));
+ assertEquals(0, req.returnValues().get(0).asInt32());
}
void performRequest(Request req) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java
index f34b59dbc9f..854abee91f5 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java
@@ -59,6 +59,7 @@ public class MultiTenantRpcAuthorizerTest {
private static final HostName HOSTNAME = HostName.from("myhostname");
private static final FileReference FILE_REFERENCE = new FileReference("myfilereference");
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException exceptionRule = ExpectedException.none();
@@ -269,7 +270,7 @@ public class MultiTenantRpcAuthorizerTest {
request.setString("clientHostname", hostname);
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
new JsonFormat(false).encode(out, data);
- return new String(out.toByteArray());
+ return out.toString();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/PrepareParamsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/PrepareParamsTest.java
index cd824967fc3..46c31533598 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/PrepareParamsTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/PrepareParamsTest.java
@@ -2,55 +2,36 @@
package com.yahoo.vespa.config.server.session;
import com.yahoo.config.model.api.ApplicationClusterEndpoint;
-import com.yahoo.config.model.api.ApplicationRoles;
import com.yahoo.config.model.api.ContainerEndpoint;
import com.yahoo.config.model.api.EndpointCertificateMetadata;
import com.yahoo.config.model.api.TenantSecretStore;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.TenantName;
import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.security.KeyAlgorithm;
-import com.yahoo.security.KeyUtils;
-import com.yahoo.security.SignatureAlgorithm;
-import com.yahoo.security.X509CertificateBuilder;
+
import com.yahoo.security.X509CertificateUtils;
-import com.yahoo.security.X509CertificateWithKey;
-import com.yahoo.slime.ArrayInserter;
+
import com.yahoo.slime.Cursor;
import com.yahoo.slime.Injector;
-import com.yahoo.slime.Inspector;
import com.yahoo.slime.ObjectInserter;
-import com.yahoo.slime.ObjectSymbolInserter;
import com.yahoo.slime.Slime;
-import com.yahoo.slime.SlimeInserter;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.vespa.config.server.tenant.ContainerEndpointSerializer;
import com.yahoo.vespa.config.server.tenant.EndpointCertificateMetadataSerializer;
import com.yahoo.vespa.config.server.tenant.TenantSecretStoreSerializer;
import org.junit.Test;
-import javax.security.auth.x500.X500Principal;
import java.io.IOException;
-import java.math.BigInteger;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import java.security.KeyPair;
import java.security.cert.X509Certificate;
import java.time.Duration;
-import java.time.Instant;
-import java.time.temporal.ChronoUnit;
import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
import java.util.OptionalInt;
-import java.util.OptionalLong;
-import java.util.stream.Collectors;
+;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -79,13 +60,13 @@ public class PrepareParamsTest {
public void testCorrectParsing() {
PrepareParams prepareParams = createParams("http://foo:19071/application/v2/", TenantName.defaultName());
- assertThat(prepareParams.getApplicationId(), is(ApplicationId.defaultId()));
+ assertEquals(ApplicationId.defaultId(), prepareParams.getApplicationId());
assertFalse(prepareParams.isDryRun());
assertFalse(prepareParams.isVerbose());
assertFalse(prepareParams.ignoreValidationErrors());
- assertThat(prepareParams.vespaVersion(), is(Optional.<String>empty()));
+ assertTrue(prepareParams.vespaVersion().isEmpty());
assertTrue(prepareParams.getTimeoutBudget().hasTimeLeft());
- assertThat(prepareParams.containerEndpoints().size(), is(0));
+ assertTrue(prepareParams.containerEndpoints().isEmpty());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java
index 79632b8446b..72d7311ed9a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java
@@ -69,10 +69,8 @@ import java.util.logging.Level;
import static com.yahoo.vespa.config.server.session.SessionPreparer.PrepareResult;
import static com.yahoo.vespa.config.server.session.SessionZooKeeperClient.APPLICATION_PACKAGE_REFERENCE_PATH;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -97,6 +95,7 @@ public class SessionPreparerTest {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -216,7 +215,7 @@ public class SessionPreparerTest {
PrepareParams params = new PrepareParams.Builder().applicationId(applicationId()).build();
int sessionId = 1;
prepare(testApp, params);
- assertThat(createSessionZooKeeperClient(sessionId).readApplicationId().get(), is(applicationId()));
+ assertEquals(applicationId(), createSessionZooKeeperClient(sessionId).readApplicationId().get());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
index feae135a508..150df8e303f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
@@ -52,12 +52,10 @@ import java.util.List;
import java.util.Optional;
import java.util.function.LongPredicate;
-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.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -79,6 +77,7 @@ public class SessionRepositoryTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -193,7 +192,7 @@ public class SessionRepositoryTest {
expectedException.expectMessage("Could not load remote session " + sessionIdString);
expectedException.expect(RuntimeException.class);
sessionRepository.loadSessions(new InThreadExecutorService());
- assertThat(sessionRepository.getRemoteSessionsFromZooKeeper().size(), is(0));
+ assertTrue(sessionRepository.getRemoteSessionsFromZooKeeper().isEmpty());
}
@Test(expected = InvalidApplicationException.class)
@@ -302,11 +301,6 @@ public class SessionRepositoryTest {
assertRemoteSessionStatus(sessionId, status);
}
- private void assertSessionRemoved(long sessionId) {
- waitFor(p -> sessionRepository.getRemoteSession(sessionId) == null, sessionId);
- assertNull(sessionRepository.getRemoteSession(sessionId));
- }
-
private void assertRemoteSessionExists(long sessionId) {
assertRemoteSessionStatus(sessionId, Session.Status.NEW);
}
@@ -315,7 +309,7 @@ public class SessionRepositoryTest {
waitFor(p -> sessionRepository.getRemoteSession(sessionId) != null &&
sessionRepository.getRemoteSession(sessionId).getStatus() == status, sessionId);
assertNotNull(sessionRepository.getRemoteSession(sessionId));
- assertThat(sessionRepository.getRemoteSession(sessionId).getStatus(), is(status));
+ assertEquals(status, sessionRepository.getRemoteSession(sessionId).getStatus());
}
private void waitFor(LongPredicate predicate, long sessionId) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
index 814c99bd2fb..2f6e6a19651 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
@@ -22,9 +22,7 @@ import java.util.List;
import java.util.Optional;
import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.SESSIONSTATE_ZK_SUBPATH;
-import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -36,6 +34,7 @@ public class SessionZooKeeperClientTest {
private Curator curator;
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -49,16 +48,16 @@ public class SessionZooKeeperClientTest {
public void require_that_status_can_be_updated() {
SessionZooKeeperClient zkc = createSessionZKClient(1);
zkc.writeStatus(Session.Status.NEW);
- assertThat(zkc.readStatus(), is(Session.Status.NEW));
+ assertEquals(Session.Status.NEW, zkc.readStatus());
zkc.writeStatus(Session.Status.PREPARE);
- assertThat(zkc.readStatus(), is(Session.Status.PREPARE));
+ assertEquals(Session.Status.PREPARE, zkc.readStatus());
zkc.writeStatus(Session.Status.ACTIVATE);
- assertThat(zkc.readStatus(), is(Session.Status.ACTIVATE));
+ assertEquals(Session.Status.ACTIVATE, zkc.readStatus());
zkc.writeStatus(Session.Status.DEACTIVATE);
- assertThat(zkc.readStatus(), is(Session.Status.DEACTIVATE));
+ assertEquals(Session.Status.DEACTIVATE, zkc.readStatus());
}
@Test
@@ -68,7 +67,7 @@ public class SessionZooKeeperClientTest {
zkc.writeStatus(Session.Status.NEW);
Path path = sessionPath(sessionId).append(SESSIONSTATE_ZK_SUBPATH);
assertTrue(curator.exists(path));
- assertThat(Utf8.toString(curator.getData(path).get()), is("NEW"));
+ assertEquals("NEW", Utf8.toString(curator.getData(path).get()));
}
@Test
@@ -76,7 +75,7 @@ public class SessionZooKeeperClientTest {
int sessionId = 3;
SessionZooKeeperClient zkc = createSessionZKClient(sessionId);
curator.set(sessionPath(sessionId).append(SESSIONSTATE_ZK_SUBPATH), Utf8.toBytes("PREPARE"));
- assertThat(zkc.readStatus(), is(Session.Status.PREPARE));
+ assertEquals(Session.Status.PREPARE, zkc.readStatus());
}
@Test
@@ -91,7 +90,7 @@ public class SessionZooKeeperClientTest {
zkc.writeApplicationId(id);
Path path = sessionPath(sessionId).append(SessionZooKeeperClient.APPLICATION_ID_PATH);
assertTrue(curator.exists(path));
- assertThat(Utf8.toString(curator.getData(path).get()), is(id.serializedForm()));
+ assertEquals(id.serializedForm(), Utf8.toString(curator.getData(path).get()));
}
@Test
@@ -125,11 +124,11 @@ public class SessionZooKeeperClientTest {
int sessionId = 3;
SessionZooKeeperClient zkc = createSessionZKClient(sessionId);
curator.delete(sessionPath(sessionId));
- assertThat(zkc.readCreateTime(), is(Instant.EPOCH));
+ assertEquals(Instant.EPOCH, zkc.readCreateTime());
Instant now = Instant.now();
zkc.createNewSession(now);
// resolution is in seconds, so need to go back use that when comparing
- assertThat(zkc.readCreateTime(), is(Instant.ofEpochSecond(now.getEpochSecond())));
+ assertEquals(Instant.ofEpochSecond(now.getEpochSecond()), zkc.readCreateTime());
}
@Test
@@ -137,7 +136,7 @@ public class SessionZooKeeperClientTest {
final FileReference testRef = new FileReference("test-ref");
SessionZooKeeperClient zkc = createSessionZKClient(3);
zkc.writeApplicationPackageReference(Optional.of(testRef));
- assertThat(zkc.readApplicationPackageReference(), is(testRef));
+ assertEquals(testRef, zkc.readApplicationPackageReference());
}
@Test
@@ -164,7 +163,7 @@ public class SessionZooKeeperClientTest {
Path path = sessionPath(sessionId).append(SessionZooKeeperClient.APPLICATION_ID_PATH);
curator.set(path, Utf8.toBytes(idString));
ApplicationId applicationId = zkc.readApplicationId().get();
- assertThat(applicationId.serializedForm(), is(expectedIdString));
+ assertEquals(expectedIdString, applicationId.serializedForm());
}
private SessionZooKeeperClient createSessionZKClient(long sessionId) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
index 4c99264c805..1a394bbb8cd 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
@@ -64,6 +64,7 @@ public class TenantRepositoryTest {
private Curator curator;
private ConfigserverConfig configserverConfig;
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java
index 52d45d9ff5c..a0bd0e1f130 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java
@@ -11,9 +11,8 @@ import org.junit.rules.TemporaryFolder;
import java.io.IOException;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
/**
* @author Ulf Lilleengen
@@ -60,9 +59,9 @@ public class TenantTest {
@Test
public void hashcode() {
- assertThat(t1.hashCode(), is(t2.hashCode()));
- assertThat(t1.hashCode(), is(not(t3.hashCode())));
- assertThat(t1.hashCode(), is(not(t4.hashCode())));
+ assertEquals(t1.hashCode(), t2.hashCode());
+ assertNotEquals(t1.hashCode(), t3.hashCode());
+ assertNotEquals(t1.hashCode(), t4.hashCode());
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java
index ccd330c0193..1f49d496f70 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/version/VersionStateTest.java
@@ -13,9 +13,8 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
-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;
/**
@@ -32,32 +31,32 @@ public class VersionStateTest {
Version unknownVersion = new Version(0, 0, 0);
VersionState state = createVersionState();
- assertThat(state.storedVersion(), is(unknownVersion));
+ assertEquals(unknownVersion, state.storedVersion());
assertTrue(state.isUpgraded());
state.saveNewVersion();
assertFalse(state.isUpgraded());
state.saveNewVersion("badversion");
- assertThat(state.storedVersion(), is(unknownVersion));
+ assertEquals(unknownVersion, state.storedVersion());
assertTrue(state.isUpgraded());
state.saveNewVersion("5.0.0");
- assertThat(state.storedVersion(), is(new Version(5, 0, 0)));
+ assertEquals(new Version(5, 0, 0), state.storedVersion());
assertTrue(state.isUpgraded());
// Remove zk node, should find version in ZooKeeper
curator.delete(VersionState.versionPath);
- assertThat(state.storedVersion(), is(new Version(5, 0, 0)));
+ assertEquals(new Version(5, 0, 0), state.storedVersion());
assertTrue(state.isUpgraded());
// Save new version, remove version in file, should find version in ZooKeeper
state.saveNewVersion("6.0.0");
Files.delete(state.versionFile().toPath());
- assertThat(state.storedVersion(), is(new Version(6, 0, 0)));
+ assertEquals(new Version(6, 0, 0), state.storedVersion());
assertTrue(state.isUpgraded());
state.saveNewVersion();
- assertThat(state.currentVersion(), is(state.storedVersion()));
+ assertEquals(state.currentVersion(), state.storedVersion());
assertFalse(state.isUpgraded());
}
@@ -69,7 +68,7 @@ public class VersionStateTest {
File versionFile = new File(dbDir, "vespa_version");
assertTrue(versionFile.exists());
Version stored = Version.fromString(IOUtils.readFile(versionFile));
- assertThat(stored, is(state.currentVersion()));
+ assertEquals(stored, state.currentVersion());
}
private VersionState createVersionState() throws IOException {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java
index d2c29a7577f..5c87f5bfc52 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java
@@ -6,8 +6,7 @@ import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
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
@@ -22,7 +21,7 @@ public class InitializedCounterTest {
curator.create(Path.fromString("/sessions/2"));
InitializedCounter counter = new InitializedCounter(curator, Path.fromString("/counter"), Path.fromString("/sessions"));
- assertThat(counter.counter.get(), is(2L));
+ assertEquals(2, counter.counter.get());
}
}
diff --git a/container-core/src/main/java/com/yahoo/language/provider/DefaultLinguisticsProvider.java b/container-core/src/main/java/com/yahoo/language/provider/DefaultLinguisticsProvider.java
index 563c9a8bdff..a38f39559f5 100644
--- a/container-core/src/main/java/com/yahoo/language/provider/DefaultLinguisticsProvider.java
+++ b/container-core/src/main/java/com/yahoo/language/provider/DefaultLinguisticsProvider.java
@@ -18,10 +18,12 @@ import com.yahoo.language.opennlp.OpenNlpLinguistics;
public class DefaultLinguisticsProvider implements Provider<Linguistics> {
// Use lazy initialization to avoid expensive (memory-wise) instantiation
- private final Supplier<Linguistics> linguisticsSupplier = Suppliers.memoize(OpenNlpLinguistics::new);
+ private final Supplier<Linguistics> linguisticsSupplier;
@Inject
- public DefaultLinguisticsProvider() { }
+ public DefaultLinguisticsProvider() {
+ linguisticsSupplier = Suppliers.memoize(OpenNlpLinguistics::new);
+ }
@Override
public Linguistics get() { return linguisticsSupplier.get(); }
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..baed2ccdcc8 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);
}
@@ -691,6 +686,7 @@ public class ProcessingHandlerTestCase {
this.stringDataPrefix = stringDataPrefix;
}
+ @SuppressWarnings("unchecked")
@Override
public com.yahoo.processing.Response process(com.yahoo.processing.Request request, Execution execution) {
try {
@@ -727,7 +723,7 @@ public class ProcessingHandlerTestCase {
}
- private String defaultChainResponse =
+ private final String defaultChainResponse =
"{\"datalist\":[" +
"{\"data\":\"StringData.toString()\"}," +
"{\"datalist\":[" +
@@ -736,17 +732,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 +754,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 +765,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 +776,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/container-dev/pom.xml b/container-dev/pom.xml
index a76f295a7b1..034081f4620 100644
--- a/container-dev/pom.xml
+++ b/container-dev/pom.xml
@@ -194,10 +194,6 @@
<version>${project.version}</version>
<exclusions>
<exclusion>
- <groupId>com.optimaize.languagedetector</groupId>
- <artifactId>language-detector</artifactId>
- </exclusion>
- <exclusion>
<groupId>org.apache.opennlp</groupId>
<artifactId>opennlp-tools</artifactId>
</exclusion>
diff --git a/container-disc/src/main/sh/vespa-start-container-daemon.sh b/container-disc/src/main/sh/vespa-start-container-daemon.sh
index 5d47392292d..1aad9f18616 100755
--- a/container-disc/src/main/sh/vespa-start-container-daemon.sh
+++ b/container-disc/src/main/sh/vespa-start-container-daemon.sh
@@ -281,7 +281,6 @@ exec $numactlcmd $envcmd java \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED \
--add-opens=java.base/sun.security.ssl=ALL-UNNAMED \
- --add-opens=java.base/sun.security.util=ALL-UNNAMED \
-Djava.io.tmpdir="${VESPA_HOME}/tmp" \
-Djava.library.path="${VESPA_HOME}/lib64" \
-Djava.awt.headless=true \
diff --git a/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4 b/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4
index 38efba3b511..9af8d83c6d7 100644
--- a/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4
+++ b/container-search/src/main/antlr4/com/yahoo/search/yql/yqlplus.g4
@@ -90,7 +90,7 @@ options {
* LEXER RULES
*------------------------------------------------------------------*/
-ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|':'|'-')*
+IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*
;
LONG_INT : '-'?'0'..'9'+ ('L'|'l')
@@ -117,8 +117,8 @@ LETTER : 'a'..'z'
| 'A'..'Z'
;
-STRING : '"' ( ESC_SEQ | ~('\\'| '"') )* '"'
- | '\'' ( ESC_SEQ | ~('\\' | '\'') )* '\''
+STRING : DQ ( ESC_SEQ | ~('\\'| '"') )* DQ
+ | SQ ( ESC_SEQ | ~('\\' | '\'') )* SQ
;
fragment
@@ -166,24 +166,15 @@ VESPA_GROUPING_ARG
// --------- parser rules ------------
ident
- : keyword_as_ident //{addChild(new TerminalNodeImpl(keyword_as_ident.getText()));}
- | ID
+ : keyword_as_ident
+ | IDENTIFIER
;
keyword_as_ident
: SELECT | LIMIT | OFFSET | WHERE | 'order' | 'by' | DESC | OUTPUT | COUNT | SOURCES | MATCHES | LIKE
;
-program : (statement SEMI)* EOF
- ;
-
-moduleId
- : ID
- ;
-
-moduleName
- : literalString
- | namespaced_name
+program : (statement SEMI?)* EOF
;
statement
@@ -261,7 +252,7 @@ source_spec
;
alias_def
- : (AS? ID)
+ : (AS? IDENTIFIER)
;
data_source
@@ -279,7 +270,7 @@ sequence_source
;
namespaced_name
- : (ident (DOT ident)* (DOT STAR)?)
+ : (dotted_idents (DOT STAR)?)
;
orderby
@@ -311,8 +302,8 @@ field_def
: expression[true] alias_def?
;
-mapExpression
- : LBRACE propertyNameAndValue? (COMMA propertyNameAndValue)* RBRACE
+map_expression
+ : LBRACE property_name_and_value? (COMMA property_name_and_value)* RBRACE
;
arguments[boolean in_select]
@@ -334,90 +325,91 @@ expression [boolean select]
@after {
expression_stack.pop();
}
- : annotateExpression
- | logicalORExpression
- | nullOperator
+ : annotate_expression
+ | logical_OR_expression
+ | null_operator
;
-nullOperator
+null_operator
: 'null'
;
-annotateExpression
- : annotation logicalORExpression
+annotate_expression
+ : annotation logical_OR_expression
;
annotation
- : LBRACKET mapExpression RBRACKET
+ : LBRACKET map_expression RBRACKET
+ | map_expression
;
-logicalORExpression
- : logicalANDExpression (OR logicalANDExpression)+
- | logicalANDExpression
+logical_OR_expression
+ : logical_AND_expression (OR logical_AND_expression)+
+ | logical_AND_expression
;
-logicalANDExpression
- : equalityExpression (AND equalityExpression)*
+logical_AND_expression
+ : equality_expression (AND equality_expression)*
;
-equalityExpression
- : relationalExpression ( ((IN | NOT_IN) inNotInTarget)
+equality_expression
+ : relational_expression ( ((IN | NOT_IN) in_not_in_target)
| (IS_NULL | IS_NOT_NULL)
- | (equalityOp relationalExpression) )
- | relationalExpression
+ | (equality_op relational_expression) )
+ | relational_expression
;
-inNotInTarget
+in_not_in_target
: {expression_stack.peek().in_select}? LPAREN select_statement RPAREN
| literal_list
;
-equalityOp
+equality_op
: (EQ | NEQ | LIKE | NOTLIKE | MATCHES | NOTMATCHES | CONTAINS)
;
-relationalExpression
- : additiveExpression (relationalOp additiveExpression)?
+relational_expression
+ : additive_expression (relational_op additive_expression)?
;
-relationalOp
+relational_op
: (LT | GT | LTEQ | GTEQ)
;
-additiveExpression
- : multiplicativeExpression (additiveOp additiveExpression)?
+additive_expression
+ : multiplicative_expression (additive_op additive_expression)?
;
-additiveOp
+additive_op
: '+'
| '-'
;
-multiplicativeExpression
- : unaryExpression (multOp multiplicativeExpression)?
+multiplicative_expression
+ : unary_expression (mult_op multiplicative_expression)?
;
-multOp
+mult_op
: '*'
| '/'
| '%'
;
-unaryOp
+unary_op
: '-'
| '!'
;
-unaryExpression
- : dereferencedExpression
- | unaryOp dereferencedExpression
+unary_expression
+ : dereferenced_expression
+ | unary_op dereferenced_expression
;
-dereferencedExpression
+dereferenced_expression
@init{
boolean in_select = expression_stack.peek().in_select;
}
- : primaryExpression
+ : primary_expression
(
indexref[in_select]
| propertyref
@@ -428,20 +420,20 @@ indexref[boolean in_select]
: LBRACKET idx=expression[in_select] RBRACKET
;
propertyref
- : DOT nm=ID
+ : DOT nm=IDENTIFIER
;
-primaryExpression
+primary_expression
@init {
boolean in_select = expression_stack.peek().in_select;
}
- : callExpression[in_select]
+ : call_expression[in_select]
| fieldref
- | constantExpression
+ | constant_expression
| LPAREN expression[in_select] RPAREN
;
-callExpression[boolean in_select]
+call_expression[boolean in_select]
: namespaced_name arguments[in_select]
;
@@ -454,24 +446,28 @@ parameter
: AT ident
;
-propertyNameAndValue
- : propertyName ':' constantExpression
+property_name_and_value
+ : property_name ':' constant_expression
;
-propertyName
- : ID
- | literalString
+property_name
+ : dotted_idents
+ | STRING
;
-constantExpression
+dotted_idents
+ : ident (DOT ident)*
+ ;
+
+constant_expression
: scalar_literal
- | mapExpression
- | arrayLiteral
+ | map_expression
+ | array_literal
| parameter
;
-arrayLiteral
- : LBRACKET i+=constantExpression? (COMMA i+=constantExpression)* RBRACKET
+array_literal
+ : LBRACKET i+=constant_expression? (COMMA i+=constant_expression)* RBRACKET
;
scalar_literal
@@ -483,10 +479,6 @@ scalar_literal
| FLOAT
;
-literalString
- : STRING
- ;
-
array_parameter
: AT i=ident {isArrayParameter($i.ctx)}?
;
diff --git a/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java b/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java
index daa77c6fcdd..0259dd66dbe 100644
--- a/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java
+++ b/container-search/src/main/java/com/yahoo/search/result/FieldComparator.java
@@ -9,9 +9,7 @@ import java.util.Comparator;
/**
* Comparator used for ordering hits using the field values and a sorting specification.
- * <p>
- * <b>Note:</b> this comparator imposes orderings that are inconsistent with equals.
- * <p>
+ * Note: This comparator imposes orderings that are inconsistent with equals.
*
* @author Steinar Knutsen
*/
diff --git a/container-search/src/main/java/com/yahoo/search/yql/ExpressionOperator.java b/container-search/src/main/java/com/yahoo/search/yql/ExpressionOperator.java
index 06a095df6dd..762d906585c 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/ExpressionOperator.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/ExpressionOperator.java
@@ -55,7 +55,6 @@ enum ExpressionOperator implements Operator {
READ_RECORD(String.class),
READ_FIELD(String.class, String.class),
- READ_MODULE(TypeCheckers.LIST_OF_STRING),
VESPA_GROUPING(String.class),
@@ -64,7 +63,7 @@ enum ExpressionOperator implements Operator {
private final ArgumentsTypeChecker checker;
- private ExpressionOperator(Object... types) {
+ ExpressionOperator(Object... types) {
checker = TypeCheckers.make(this, types);
}
diff --git a/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java b/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java
index df582ee8141..fc0cef2fb5e 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/ProgramParser.java
@@ -9,25 +9,25 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import com.yahoo.search.yql.yqlplusParser.AnnotateExpressionContext;
+import com.yahoo.search.yql.yqlplusParser.Annotate_expressionContext;
import com.yahoo.search.yql.yqlplusParser.AnnotationContext;
import com.yahoo.search.yql.yqlplusParser.ArgumentContext;
import com.yahoo.search.yql.yqlplusParser.ArgumentsContext;
-import com.yahoo.search.yql.yqlplusParser.ArrayLiteralContext;
+import com.yahoo.search.yql.yqlplusParser.Array_literalContext;
import com.yahoo.search.yql.yqlplusParser.Call_sourceContext;
-import com.yahoo.search.yql.yqlplusParser.ConstantExpressionContext;
-import com.yahoo.search.yql.yqlplusParser.DereferencedExpressionContext;
-import com.yahoo.search.yql.yqlplusParser.EqualityExpressionContext;
+import com.yahoo.search.yql.yqlplusParser.Constant_expressionContext;
+import com.yahoo.search.yql.yqlplusParser.Dereferenced_expressionContext;
+import com.yahoo.search.yql.yqlplusParser.Equality_expressionContext;
import com.yahoo.search.yql.yqlplusParser.Field_defContext;
import com.yahoo.search.yql.yqlplusParser.IdentContext;
-import com.yahoo.search.yql.yqlplusParser.InNotInTargetContext;
+import com.yahoo.search.yql.yqlplusParser.In_not_in_targetContext;
import com.yahoo.search.yql.yqlplusParser.LimitContext;
import com.yahoo.search.yql.yqlplusParser.Literal_elementContext;
import com.yahoo.search.yql.yqlplusParser.Literal_listContext;
-import com.yahoo.search.yql.yqlplusParser.LogicalANDExpressionContext;
-import com.yahoo.search.yql.yqlplusParser.LogicalORExpressionContext;
-import com.yahoo.search.yql.yqlplusParser.MapExpressionContext;
-import com.yahoo.search.yql.yqlplusParser.MultiplicativeExpressionContext;
+import com.yahoo.search.yql.yqlplusParser.Logical_AND_expressionContext;
+import com.yahoo.search.yql.yqlplusParser.Logical_OR_expressionContext;
+import com.yahoo.search.yql.yqlplusParser.Map_expressionContext;
+import com.yahoo.search.yql.yqlplusParser.Multiplicative_expressionContext;
import com.yahoo.search.yql.yqlplusParser.Namespaced_nameContext;
import com.yahoo.search.yql.yqlplusParser.OffsetContext;
import com.yahoo.search.yql.yqlplusParser.OrderbyContext;
@@ -36,10 +36,10 @@ import com.yahoo.search.yql.yqlplusParser.Output_specContext;
import com.yahoo.search.yql.yqlplusParser.Pipeline_stepContext;
import com.yahoo.search.yql.yqlplusParser.ProgramContext;
import com.yahoo.search.yql.yqlplusParser.Project_specContext;
-import com.yahoo.search.yql.yqlplusParser.PropertyNameAndValueContext;
+import com.yahoo.search.yql.yqlplusParser.Property_name_and_valueContext;
import com.yahoo.search.yql.yqlplusParser.Query_statementContext;
-import com.yahoo.search.yql.yqlplusParser.RelationalExpressionContext;
-import com.yahoo.search.yql.yqlplusParser.RelationalOpContext;
+import com.yahoo.search.yql.yqlplusParser.Relational_expressionContext;
+import com.yahoo.search.yql.yqlplusParser.Relational_opContext;
import com.yahoo.search.yql.yqlplusParser.Scalar_literalContext;
import com.yahoo.search.yql.yqlplusParser.Select_source_multiContext;
import com.yahoo.search.yql.yqlplusParser.Select_statementContext;
@@ -49,7 +49,7 @@ import com.yahoo.search.yql.yqlplusParser.Source_specContext;
import com.yahoo.search.yql.yqlplusParser.Source_statementContext;
import com.yahoo.search.yql.yqlplusParser.StatementContext;
import com.yahoo.search.yql.yqlplusParser.TimeoutContext;
-import com.yahoo.search.yql.yqlplusParser.UnaryExpressionContext;
+import com.yahoo.search.yql.yqlplusParser.Unary_expressionContext;
import com.yahoo.search.yql.yqlplusParser.WhereContext;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.CharStream;
@@ -389,7 +389,7 @@ final class ProgramParser {
OperatorNode<SequenceOperator> result = convertQuery(queryStatementContext.getChild(0), scope.getRoot());
for (Pipeline_stepContext step:nodes) {
if (getParseTreeIndex(step.getChild(0)) == yqlplusParser.RULE_vespa_grouping) {
- result = OperatorNode.create(SequenceOperator.PIPE, result, ImmutableList.<String>of(),
+ result = OperatorNode.create(SequenceOperator.PIPE, result, List.of(),
ImmutableList.of(convertExpr(step.getChild(0), scope)));
} else {
List<String> name = readName(step.namespaced_name());
@@ -421,7 +421,6 @@ final class ProgramParser {
} else {
throw new IllegalArgumentException("Unexpected argument type to convertQueryStatement: " + node.toStringTree());
}
-
}
private String assignAlias(String alias, ParserRuleContext node, Scope scope) {
@@ -583,7 +582,7 @@ final class ProgramParser {
String aliasName = null;
if (rulenode.getChildCount() > 1) {
// ^(ALIAS ID)
- aliasName = rulenode.alias_def().ID().getText();
+ aliasName = rulenode.alias_def().IDENTIFIER().getText();
}
proj.addField(aliasName, expr);
// no grammar for the other rule types at this time
@@ -605,7 +604,7 @@ final class ProgramParser {
ParseTree firstChild = parseTree.getChild(0);
if (getParseTreeIndex(firstChild) == yqlplusParser.RULE_annotation) {
ParseTree secondChild = parseTree.getChild(1);
- OperatorNode<ExpressionOperator> annotation = convertExpr(((AnnotationContext) firstChild).mapExpression(), scope);
+ OperatorNode<ExpressionOperator> annotation = convertExpr(((AnnotationContext) firstChild).map_expression(), scope);
OperatorNode<ExpressionOperator> expr = OperatorNode.create(toLocation(scope, secondChild),
ExpressionOperator.VESPA_GROUPING, secondChild.getText());
List<String> names = annotation.getArgument(0);
@@ -619,7 +618,7 @@ final class ProgramParser {
firstChild.getText());
}
}
- case yqlplusParser.RULE_nullOperator:
+ case yqlplusParser.RULE_null_operator:
return OperatorNode.create(ExpressionOperator.NULL);
case yqlplusParser.RULE_argument:
return convertExpr(parseTree.getChild(0), scope);
@@ -631,11 +630,11 @@ final class ProgramParser {
return convertExpr(firstChild, scope);
}
}
- case yqlplusParser.RULE_mapExpression: {
- List<PropertyNameAndValueContext> propertyList = ((MapExpressionContext)parseTree).propertyNameAndValue();
+ case yqlplusParser.RULE_map_expression: {
+ List<Property_name_and_valueContext> propertyList = ((Map_expressionContext)parseTree).property_name_and_value();
List<String> names = Lists.newArrayListWithExpectedSize(propertyList.size());
List<OperatorNode<ExpressionOperator>> exprs = Lists.newArrayListWithCapacity(propertyList.size());
- for (PropertyNameAndValueContext child : propertyList) {
+ for (Property_name_and_valueContext child : propertyList) {
// : propertyName ':' expression[$expression::namespace] ->
// ^(PROPERTY propertyName expression)
names.add(StringUnescaper.unquote(child.getChild(0).getText()));
@@ -643,17 +642,17 @@ final class ProgramParser {
}
return OperatorNode.create(toLocation(scope, parseTree),ExpressionOperator.MAP, names, exprs);
}
- case yqlplusParser.RULE_arrayLiteral: {
- List<ConstantExpressionContext> expressionList = ((ArrayLiteralContext) parseTree).constantExpression();
+ case yqlplusParser.RULE_array_literal: {
+ List<Constant_expressionContext> expressionList = ((Array_literalContext) parseTree).constant_expression();
List<OperatorNode<ExpressionOperator>> values = Lists.newArrayListWithExpectedSize(expressionList.size());
- for (ConstantExpressionContext expr : expressionList) {
+ for (Constant_expressionContext expr : expressionList) {
values.add(convertExpr(expr, scope));
}
return OperatorNode.create(toLocation(scope, expressionList.isEmpty()? parseTree:expressionList.get(0)), ExpressionOperator.ARRAY, values);
}
// dereferencedExpression: primaryExpression(indexref[in_select]| propertyref)*
- case yqlplusParser.RULE_dereferencedExpression: {
- DereferencedExpressionContext dereferencedExpression = (DereferencedExpressionContext) parseTree;
+ case yqlplusParser.RULE_dereferenced_expression: {
+ Dereferenced_expressionContext dereferencedExpression = (Dereferenced_expressionContext) parseTree;
Iterator<ParseTree> it = dereferencedExpression.children.iterator();
OperatorNode<ExpressionOperator> result = convertExpr(it.next(), scope);
while (it.hasNext()) {
@@ -668,14 +667,14 @@ final class ProgramParser {
}
return result;
}
- case yqlplusParser.RULE_primaryExpression: {
+ case yqlplusParser.RULE_primary_expression: {
// ^(CALL namespaced_name arguments)
ParseTree firstChild = parseTree.getChild(0);
switch (getParseTreeIndex(firstChild)) {
case yqlplusParser.RULE_fieldref: {
return convertExpr(firstChild, scope);
}
- case yqlplusParser.RULE_callExpression: {
+ case yqlplusParser.RULE_call_expression: {
List<ArgumentContext> args = ((ArgumentsContext) firstChild.getChild(1)).argument();
List<OperatorNode<ExpressionOperator>> arguments = Lists.newArrayListWithExpectedSize(args.size());
for (ArgumentContext argContext : args) {
@@ -683,7 +682,7 @@ final class ProgramParser {
}
return OperatorNode.create(toLocation(scope, parseTree), ExpressionOperator.CALL, scope.resolvePath(readName((Namespaced_nameContext) firstChild.getChild(0))), arguments);
}
- case yqlplusParser.RULE_constantExpression:
+ case yqlplusParser.RULE_constant_expression:
return convertExpr(firstChild, scope);
case yqlplusParser.LPAREN:
@@ -697,10 +696,10 @@ final class ProgramParser {
IdentContext identContext = parameterContext.getRuleContext(IdentContext.class, 0);
return OperatorNode.create(toLocation(scope, identContext), ExpressionOperator.VARREF, identContext.getText());
}
- case yqlplusParser.RULE_annotateExpression: {
+ case yqlplusParser.RULE_annotate_expression: {
//annotation logicalORExpression
- AnnotationContext annotateExpressionContext = ((AnnotateExpressionContext)parseTree).annotation();
- OperatorNode<ExpressionOperator> annotation = convertExpr(annotateExpressionContext.mapExpression(), scope);
+ AnnotationContext annotateExpressionContext = ((Annotate_expressionContext)parseTree).annotation();
+ OperatorNode<ExpressionOperator> annotation = convertExpr(annotateExpressionContext.map_expression(), scope);
OperatorNode<ExpressionOperator> expr = convertExpr(parseTree.getChild(1), scope);
List<String> names = annotation.getArgument(0);
List<OperatorNode<ExpressionOperator>> annotates = annotation.getArgument(1);
@@ -712,16 +711,16 @@ final class ProgramParser {
case yqlplusParser.RULE_expression: {
return convertExpr(parseTree.getChild(0), scope);
}
- case yqlplusParser.RULE_logicalANDExpression:
- LogicalANDExpressionContext andExpressionContext = (LogicalANDExpressionContext) parseTree;
- return readConjOp(ExpressionOperator.AND, andExpressionContext.equalityExpression(), scope);
- case yqlplusParser.RULE_logicalORExpression: {
+ case yqlplusParser.RULE_logical_AND_expression:
+ Logical_AND_expressionContext andExpressionContext = (Logical_AND_expressionContext) parseTree;
+ return readConjOp(ExpressionOperator.AND, andExpressionContext.equality_expression(), scope);
+ case yqlplusParser.RULE_logical_OR_expression: {
int childCount = parseTree.getChildCount();
- LogicalORExpressionContext logicalORExpressionContext = (LogicalORExpressionContext) parseTree;
+ Logical_OR_expressionContext logicalORExpressionContext = (Logical_OR_expressionContext) parseTree;
if (childCount > 1) {
return readConjOrOp(ExpressionOperator.OR, logicalORExpressionContext, scope);
} else {
- List<EqualityExpressionContext> equalityExpressionList = ((LogicalANDExpressionContext) parseTree.getChild(0)).equalityExpression();
+ List<Equality_expressionContext> equalityExpressionList = ((Logical_AND_expressionContext) parseTree.getChild(0)).equality_expression();
if (equalityExpressionList.size() > 1) {
return readConjOp(ExpressionOperator.AND, equalityExpressionList, scope);
} else {
@@ -729,11 +728,11 @@ final class ProgramParser {
}
}
}
- case yqlplusParser.RULE_equalityExpression: {
- EqualityExpressionContext equalityExpression = (EqualityExpressionContext) parseTree;
- RelationalExpressionContext relationalExpressionContext = equalityExpression.relationalExpression(0);
+ case yqlplusParser.RULE_equality_expression: {
+ Equality_expressionContext equalityExpression = (Equality_expressionContext) parseTree;
+ Relational_expressionContext relationalExpressionContext = equalityExpression.relational_expression(0);
OperatorNode<ExpressionOperator> expr = convertExpr(relationalExpressionContext, scope);
- InNotInTargetContext inNotInTarget = equalityExpression.inNotInTarget();
+ In_not_in_targetContext inNotInTarget = equalityExpression.in_not_in_target();
int childCount = equalityExpression.getChildCount();
if (childCount == 1) {
return expr;
@@ -787,11 +786,11 @@ final class ProgramParser {
}
break;
}
- case yqlplusParser.RULE_relationalExpression: {
- RelationalExpressionContext relationalExpressionContext = (RelationalExpressionContext) parseTree;
- RelationalOpContext opContext = relationalExpressionContext.relationalOp();
+ case yqlplusParser.RULE_relational_expression: {
+ Relational_expressionContext relationalExpressionContext = (Relational_expressionContext) parseTree;
+ Relational_opContext opContext = relationalExpressionContext.relational_op();
if (opContext != null) {
- switch (getParseTreeIndex(relationalExpressionContext.relationalOp().getChild(0))) {
+ switch (getParseTreeIndex(relationalExpressionContext.relational_op().getChild(0))) {
case yqlplusParser.LT:
return readBinOp(ExpressionOperator.LT, parseTree, scope);
case yqlplusParser.LTEQ:
@@ -802,12 +801,12 @@ final class ProgramParser {
return readBinOp(ExpressionOperator.GTEQ, parseTree, scope);
}
} else {
- return convertExpr(relationalExpressionContext.additiveExpression(0), scope);
+ return convertExpr(relationalExpressionContext.additive_expression(0), scope);
}
}
break;
- case yqlplusParser.RULE_additiveExpression:
- case yqlplusParser.RULE_multiplicativeExpression: {
+ case yqlplusParser.RULE_additive_expression:
+ case yqlplusParser.RULE_multiplicative_expression: {
if (parseTree.getChildCount() > 1) {
String opStr = parseTree.getChild(1).getText();
switch (opStr) {
@@ -822,23 +821,23 @@ final class ProgramParser {
case "%":
return readBinOp(ExpressionOperator.MOD, parseTree, scope);
default:
- if (parseTree.getChild(0) instanceof UnaryExpressionContext) {
+ if (parseTree.getChild(0) instanceof Unary_expressionContext) {
return convertExpr(parseTree.getChild(0), scope);
} else {
throw new ProgramCompileException(toLocation(scope, parseTree), "Unknown expression type: " + parseTree.toStringTree());
}
}
} else {
- if (parseTree.getChild(0) instanceof UnaryExpressionContext) {
+ if (parseTree.getChild(0) instanceof Unary_expressionContext) {
return convertExpr(parseTree.getChild(0), scope);
- } else if (parseTree.getChild(0) instanceof MultiplicativeExpressionContext) {
+ } else if (parseTree.getChild(0) instanceof Multiplicative_expressionContext) {
return convertExpr(parseTree.getChild(0), scope);
} else {
throw new ProgramCompileException(toLocation(scope, parseTree), "Unknown expression type: " + parseTree.getText());
}
}
}
- case yqlplusParser.RULE_unaryExpression: {
+ case yqlplusParser.RULE_unary_expression: {
if (1 == parseTree.getChildCount()) {
return convertExpr(parseTree.getChild(0), scope);
} else if (2 == parseTree.getChildCount()) {
@@ -873,17 +872,11 @@ final class ProgramParser {
result = OperatorNode.create(loc, ExpressionOperator.READ_RECORD, alias);
start = 1;
}
- } else if (scope.isBound(alias)) {
- return OperatorNode.create(loc, ExpressionOperator.READ_MODULE, scope.getBinding(alias).toPathWith(path.subList(1, path.size())));
} else if (scope.getCursors().size() == 1) {
alias = scope.getCursors().iterator().next();
result = OperatorNode.create(loc, ExpressionOperator.READ_FIELD, alias, path.get(0));
start = 1;
} else {
- // ah ha, we can't end up with a 'loose' UDF call because it
- // won't be a module or known alias
- // so we need not support implicit imports for constants used in
- // UDFs
throw new ProgramCompileException(loc, "Unknown field or alias '%s'", alias);
}
for (int idx = start; idx < path.size(); ++idx) {
@@ -893,7 +886,7 @@ final class ProgramParser {
}
case yqlplusParser.RULE_scalar_literal:
return OperatorNode.create(toLocation(scope, parseTree), ExpressionOperator.LITERAL, convertLiteral((Scalar_literalContext) parseTree));
- case yqlplusParser.RULE_constantExpression:
+ case yqlplusParser.RULE_constant_expression:
return convertExpr(parseTree.getChild(0), scope);
case yqlplusParser.RULE_literal_list:
if (getParseTreeIndex(parseTree.getChild(1)) == yqlplusParser.RULE_array_parameter) {
@@ -933,7 +926,7 @@ final class ProgramParser {
case yqlplusParser.LONG_INT:
return Long.parseLong(text.substring(0, text.length()-1));
default:
- throw new ProgramCompileException("Unknow literal type " + text);
+ throw new ProgramCompileException("Unknown literal type " + text);
}
}
@@ -975,7 +968,7 @@ final class ProgramParser {
return OperatorNode.create(op, convertExpr(operand1, scope), convertExpr(operand2, scope));
}
- private OperatorNode<ExpressionOperator> readConjOp(ExpressionOperator op, List<EqualityExpressionContext> nodes, Scope scope) {
+ private OperatorNode<ExpressionOperator> readConjOp(ExpressionOperator op, List<Equality_expressionContext> nodes, Scope scope) {
List<OperatorNode<ExpressionOperator>> arguments = Lists.newArrayListWithExpectedSize(nodes.size());
for (ParseTree child : nodes) {
arguments.add(convertExpr(child, scope));
@@ -983,16 +976,16 @@ final class ProgramParser {
return OperatorNode.create(op, arguments);
}
- private OperatorNode<ExpressionOperator> readConjOrOp(ExpressionOperator op, LogicalORExpressionContext node, Scope scope) {
- List<LogicalANDExpressionContext> andExpressionList = node.logicalANDExpression();
+ private OperatorNode<ExpressionOperator> readConjOrOp(ExpressionOperator op, Logical_OR_expressionContext node, Scope scope) {
+ List<Logical_AND_expressionContext> andExpressionList = node.logical_AND_expression();
List<OperatorNode<ExpressionOperator>> arguments = Lists.newArrayListWithExpectedSize(andExpressionList.size());
- for (LogicalANDExpressionContext child : andExpressionList) {
- List<EqualityExpressionContext> equalities = child.equalityExpression();
+ for (Logical_AND_expressionContext child : andExpressionList) {
+ List<Equality_expressionContext> equalities = child.equality_expression();
if (equalities.size() == 1) {
arguments.add(convertExpr(equalities.get(0), scope));
} else {
List<OperatorNode<ExpressionOperator>> andArguments = Lists.newArrayListWithExpectedSize(equalities.size());
- for (EqualityExpressionContext subTreeChild:equalities) {
+ for (Equality_expressionContext subTreeChild:equalities) {
andArguments.add(convertExpr(subTreeChild, scope));
}
arguments.add(OperatorNode.create(ExpressionOperator.AND, andArguments));
@@ -1005,7 +998,7 @@ final class ProgramParser {
// (IS_NULL | IS_NOT_NULL)
// unaryExpression
private OperatorNode<ExpressionOperator> readUnOp(ExpressionOperator op, ParseTree node, Scope scope) {
- assert (node instanceof TerminalNode) || (node.getChildCount() == 1) || (node instanceof UnaryExpressionContext);
+ assert (node instanceof TerminalNode) || (node.getChildCount() == 1) || (node instanceof Unary_expressionContext);
if (node instanceof TerminalNode) {
return OperatorNode.create(op, convertExpr(node, scope));
} else if (node.getChildCount() == 1) {
diff --git a/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java b/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java
index ac7ac0334cc..e7ec28a9b97 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/ProjectionBuilder.java
@@ -9,8 +9,8 @@ import java.util.Set;
class ProjectionBuilder {
- private Map<String, OperatorNode<ExpressionOperator>> fields = Maps.newLinkedHashMap();
- private Set<String> aliasNames = Sets.newHashSet();
+ private final Map<String, OperatorNode<ExpressionOperator>> fields = Maps.newLinkedHashMap();
+ private final Set<String> aliasNames = Sets.newHashSet();
public void addField(String name, OperatorNode<ExpressionOperator> expr) {
String aliasName = name;
diff --git a/container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java b/container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java
index 897bcde4fc3..cc441eb0c3d 100644
--- a/container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java
+++ b/container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java
@@ -178,7 +178,7 @@ public class VespaSerializer {
}
destination.append("([{");
serializeOrigin(destination, image, offset, length);
- destination.append(", \"").append(AND_SEGMENTING).append("\": true");
+ destination.append(", ").append(AND_SEGMENTING).append(": true");
destination.append("}]");
destination.append(PHRASE).append('(');
serializeWords(destination, item);
@@ -287,7 +287,7 @@ public class VespaSerializer {
static String nearAnnotations(NearItem n) {
if (n.getDistance() != NearItem.defaultDistance) {
- return "[{\"" + DISTANCE + "\": " + n.getDistance() + "}]";
+ return "[{" + DISTANCE + ": " + n.getDistance() + "}]";
} else {
return "";
}
@@ -323,12 +323,12 @@ public class VespaSerializer {
StringBuilder b = new StringBuilder();
b.append("[{");
if (item.hasStartAnchor() != item.isStartAnchorDefault()) {
- b.append("\"" + START_ANCHOR + "\": " + item.hasStartAnchor());
+ b.append(START_ANCHOR + ": " + item.hasStartAnchor());
}
if (item.hasEndAnchor() != item.isEndAnchorDefault()) {
if (b.length() > 2)
b.append(", ");
- b.append("\"" + END_ANCHOR + "\": " + item.hasEndAnchor());
+ b.append(END_ANCHOR + ": " + item.hasEndAnchor());
}
b.append("}]");
return b.toString();
@@ -404,11 +404,11 @@ public class VespaSerializer {
int initLen;
if (leftOpen && rightOpen) {
- boundsAnnotation = "\"" + BOUNDS + "\": " + "\"" + BOUNDS_OPEN + "\"";
+ boundsAnnotation = BOUNDS + ": " + "\"" + BOUNDS_OPEN + "\"";
} else if (leftOpen) {
- boundsAnnotation = "\"" + BOUNDS + "\": " + "\"" + BOUNDS_LEFT_OPEN + "\"";
+ boundsAnnotation = BOUNDS + ": " + "\"" + BOUNDS_LEFT_OPEN + "\"";
} else if (rightOpen) {
- boundsAnnotation = "\"" + BOUNDS + "\": " + "\"" + BOUNDS_RIGHT_OPEN + "\"";
+ boundsAnnotation = BOUNDS + ": " + "\"" + BOUNDS_RIGHT_OPEN + "\"";
}
if (annotations.length() > 0 || boundsAnnotation.length() > 0) {
destination.append("([{");
@@ -464,9 +464,7 @@ public class VespaSerializer {
image.append('L');
}
} catch (NumberFormatException e) {
- // somebody has managed to init an IntItem containing noise,
- // just give up
- return;
+ // somebody has managed to init an IntItem containing noise, just give up
}
}
}
@@ -910,7 +908,7 @@ public class VespaSerializer {
}
if (!isFromQuery) {
comma(destination, initLen);
- destination.append('"').append(IMPLICIT_TRANSFORMS).append("\": false");
+ destination.append(IMPLICIT_TRANSFORMS).append(": false");
}
if (annotations.length() > 0) {
comma(destination, initLen);
@@ -957,15 +955,15 @@ public class VespaSerializer {
double scoreThreshold = w.getScoreThreshold();
double thresholdBoostFactor = w.getThresholdBoostFactor();
if (targetNumHits != 10) {
- annotations.append('"').append(TARGET_NUM_HITS).append("\": ").append(targetNumHits);
+ annotations.append(TARGET_NUM_HITS).append(": ").append(targetNumHits);
}
if (scoreThreshold != 0) {
comma(annotations, 0);
- annotations.append('"').append(SCORE_THRESHOLD).append("\": ").append(scoreThreshold);
+ annotations.append(SCORE_THRESHOLD).append(": ").append(scoreThreshold);
}
if (thresholdBoostFactor != 1) {
comma(annotations, 0);
- annotations.append('"').append(THRESHOLD_BOOST_FACTOR).append("\": ").append(thresholdBoostFactor);
+ annotations.append(THRESHOLD_BOOST_FACTOR).append(": ").append(thresholdBoostFactor);
}
return annotations.toString();
}
@@ -999,11 +997,11 @@ public class VespaSerializer {
}
int lengthBeforeAnnotations = destination.length();
if (nonDefaultTargetNumHits(item)) {
- destination.append('"').append(TARGET_NUM_HITS).append("\": ").append(item.getN());
+ destination.append(TARGET_NUM_HITS).append(": ").append(item.getN());
}
if (nonDefaultScoreThreshold(item)) {
comma(destination, lengthBeforeAnnotations);
- destination.append('"').append(SCORE_THRESHOLD).append("\": ").append(item.getScoreThreshold());
+ destination.append(SCORE_THRESHOLD).append(": ").append(item.getScoreThreshold());
}
if (needsAnnotationBlock(item)) {
destination.append("}]");
@@ -1098,41 +1096,41 @@ public class VespaSerializer {
if (!image.substring(offset, offset + length).equals(item.getIndexedString())) {
VespaSerializer.serializeOrigin(annotation, image, offset, length);
}
- if (usePositionData != true) {
+ if ( ! usePositionData) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(USE_POSITION_DATA).append("\": false");
+ annotation.append(USE_POSITION_DATA).append(": false");
}
- if (stemmed == true) {
+ if (stemmed) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(STEM).append("\": false");
+ annotation.append(STEM).append(": false");
}
- if (lowercased == true) {
+ if (lowercased) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(NORMALIZE_CASE).append("\": false");
+ annotation.append(NORMALIZE_CASE).append(": false");
}
- if (accentDrop == false) {
+ if ( ! accentDrop) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(ACCENT_DROP).append("\": false");
+ annotation.append(ACCENT_DROP).append(": false");
}
if (andSegmenting == SegmentingRule.BOOLEAN_AND) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(AND_SEGMENTING).append("\": true");
+ annotation.append(AND_SEGMENTING).append(": true");
}
if (!isFromQuery) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(IMPLICIT_TRANSFORMS).append("\": false");
+ annotation.append(IMPLICIT_TRANSFORMS).append(": false");
}
if (prefix) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(PREFIX).append("\": true");
+ annotation.append(PREFIX).append(": true");
}
if (suffix) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(SUFFIX).append("\": true");
+ annotation.append(SUFFIX).append(": true");
}
if (substring) {
VespaSerializer.comma(annotation, initLen);
- annotation.append('"').append(SUBSTRING).append("\": true");
+ annotation.append(SUBSTRING).append(": true");
}
return annotation.toString();
}
@@ -1328,7 +1326,7 @@ public class VespaSerializer {
private static void serialize(GroupingRequest request, StringBuilder out) {
Iterator<Continuation> it = request.continuations().iterator();
if (it.hasNext()) {
- out.append("[{ 'continuations':[");
+ out.append("[{ continuations:[");
while (it.hasNext()) {
out.append('\'').append(it.next()).append('\'');
if (it.hasNext()) {
@@ -1413,7 +1411,7 @@ public class VespaSerializer {
}
private static StringBuilder annotationKey(StringBuilder annotation, String val) {
- annotation.append("\"").append(val).append("\": ");
+ annotation.append(val).append(": ");
return annotation;
}
@@ -1424,8 +1422,7 @@ public class VespaSerializer {
}
private static String leafAnnotations(TaggableItem item) {
- // TODO there is no usable API for the general annotations map in the
- // Item instances
+ // TODO: There is no usable API for the general annotations map in the Item instances
StringBuilder annotation = new StringBuilder();
int initLen = annotation.length();
{
@@ -1434,19 +1431,19 @@ public class VespaSerializer {
TaggableItem connectedTo = (TaggableItem) item.getConnectedItem();
double significance = item.getSignificance();
if (connectedTo != null && connectedTo.getUniqueID() != 0) {
- annotation.append('"').append(CONNECTIVITY).append("\": {\"")
- .append(CONNECTION_ID).append("\": ")
- .append(connectedTo.getUniqueID()).append(", \"")
- .append(CONNECTION_WEIGHT).append("\": ")
+ annotation.append(CONNECTIVITY).append(": {")
+ .append(CONNECTION_ID).append(": ")
+ .append(connectedTo.getUniqueID()).append(", ")
+ .append(CONNECTION_WEIGHT).append(": ")
.append(connectivity).append("}");
}
if (item.hasExplicitSignificance()) {
comma(annotation, initLen);
- annotation.append('"').append(SIGNIFICANCE).append("\": ").append(significance);
+ annotation.append(SIGNIFICANCE).append(": ").append(significance);
}
if (uniqueId != 0) {
comma(annotation, initLen);
- annotation.append('"').append(UNIQUE_ID).append("\": ").append(uniqueId);
+ annotation.append(UNIQUE_ID).append(": ").append(uniqueId);
}
}
{
@@ -1456,41 +1453,41 @@ public class VespaSerializer {
String label = leaf.getLabel();
int weight = leaf.getWeight();
- if (filter == true) {
+ if (filter) {
comma(annotation, initLen);
- annotation.append("\"").append(FILTER).append("\": true");
+ annotation.append(FILTER).append(": true");
}
- if (isRanked == false) {
+ if ( ! isRanked) {
comma(annotation, initLen);
- annotation.append("\"").append(RANKED).append("\": false");
+ annotation.append(RANKED).append(": false");
}
if (label != null) {
comma(annotation, initLen);
- annotation.append("\"").append(LABEL).append("\": \"");
+ annotation.append(LABEL).append(": \"");
escape(label, annotation);
annotation.append("\"");
}
if (weight != 100) {
comma(annotation, initLen);
- annotation.append('"').append(WEIGHT).append("\": ").append(weight);
+ annotation.append(WEIGHT).append(": ").append(weight);
}
}
if (item instanceof IntItem) {
int hitLimit = ((IntItem) item).getHitLimit();
if (hitLimit != 0) {
comma(annotation, initLen);
- annotation.append('"').append(HIT_LIMIT).append("\": ").append(hitLimit);
+ annotation.append(HIT_LIMIT).append(": ").append(hitLimit);
}
}
return annotation.toString();
}
private static void serializeOrigin(StringBuilder destination, String image, int offset, int length) {
- destination.append('"').append(ORIGIN).append("\": {\"").append(ORIGIN_ORIGINAL).append("\": \"");
+ destination.append(ORIGIN).append(": {").append(ORIGIN_ORIGINAL).append(": \"");
escape(image, destination);
- destination.append("\", \"").append(ORIGIN_OFFSET).append("\": ")
- .append(offset).append(", \"").append(ORIGIN_LENGTH)
- .append("\": ").append(length).append("}");
+ destination.append("\", ").append(ORIGIN_OFFSET).append(": ")
+ .append(offset).append(", ").append(ORIGIN_LENGTH)
+ .append(": ").append(length).append("}");
}
private static String normalizeIndexName(String indexName) {
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
index 5e3c4897d73..061c9bc5681 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
@@ -30,7 +30,7 @@ public class ValidatePredicateSearcherTestCase {
@Test
public void testValidQuery() {
ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
- String q = "select * from sources * where predicate(predicate_field,0,{\"age\":20L});";
+ String q = "select * from sources * where predicate(predicate_field,0,{\"age\":20L})";
Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
assertNull(r.hits().getError());
}
@@ -38,7 +38,7 @@ public class ValidatePredicateSearcherTestCase {
@Test
public void testQueryOutOfBounds() {
ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
- String q = "select * from sources * where predicate(predicate_field,0,{\"age\":200L});";
+ String q = "select * from sources * where predicate(predicate_field,0,{\"age\":200L})";
Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
assertEquals(ErrorMessage.createIllegalQuery("age=200 outside configured predicate bounds."), r.hits().getError());
}
@@ -46,7 +46,7 @@ public class ValidatePredicateSearcherTestCase {
@Test
public void queryFailsWhenPredicateFieldIsUsedInTermSearch() {
ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
- String q = "select * from sources * where predicate_field CONTAINS \"true\";";
+ String q = "select * from sources * where predicate_field CONTAINS \"true\"";
Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
assertEquals(ErrorMessage.createIllegalQuery("Index 'predicate_field' is predicate attribute and can only be used in conjunction with a predicate query operator."), r.hits().getError());
}
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
index 08997244adf..c42aa905dd4 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
@@ -640,7 +640,7 @@ public class GroupingParserTestCase {
private static void assertYqlParsable(String request, String... expectedOperations) {
YqlParser parser = new YqlParser(new ParserEnvironment());
- parser.parse(new Parsable().setQuery("select foo from bar where baz contains 'baz' | " + request + ";"));
+ parser.parse(new Parsable().setQuery("select foo from bar where baz contains 'baz' | " + request));
List<VespaGroupingStep> steps = parser.getGroupingSteps();
List<String> actual = new ArrayList<>(steps.size());
for (VespaGroupingStep step : steps) {
diff --git a/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java b/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java
index 6079c03ec5c..48dfa98768a 100644
--- a/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java
@@ -155,7 +155,7 @@ public class JSONSearchHandlerTestCase {
assertTrue("Do I have a new instance of the search handler?", searchHandler != newSearchHandler);
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) {
ObjectNode json = jsonMapper.createObjectNode();
- json.put("yql", "select * from foo where bar > 1453501295");
+ json.put("yql", "selectz * from foo where bar > 1453501295");
RequestHandlerTestDriver.MockResponseHandler responseHandler = newDriver.sendRequest(uri, com.yahoo.jdisc.http.HttpRequest.Method.POST, json.toString(), JSON_CONTENT_TYPE);
responseHandler.readAll();
assertThat(responseHandler.getStatus(), is(400));
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
index 778b1ea54f3..ef36e16a2b7 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
@@ -99,7 +99,7 @@ public class ValidateNearestNeighborTestCase {
}
private String makeQuery(String attributeTensor, String queryTensor) {
- return "select * from sources * where [{\"targetHits\":1}]nearestNeighbor(" + attributeTensor + ", " + queryTensor + ");";
+ return "select * from sources * where [{targetHits:1}]nearestNeighbor(" + attributeTensor + ", " + queryTensor + ")";
}
@Test
@@ -153,7 +153,7 @@ public class ValidateNearestNeighborTestCase {
@Test
public void testMissingTargetNumHits() {
- String q = "select * from sources * where nearestNeighbor(dvector,qvector);";
+ String q = "select * from sources * where nearestNeighbor(dvector,qvector)";
Tensor t = makeTensor(tt_dense_dvector_3);
Result r = doSearch(searcher, q, t);
assertErrMsg(desc("dvector", "qvector", 0, "has invalid targetHits 0: Must be >= 1"), r);
diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
index 4b94df17fe0..abea2b0f259 100644
--- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
@@ -100,7 +100,7 @@ public class QueryTestCase {
@Ignore
@Test
public void testSimpleProgramParameterAlias() {
- Query q = new Query(httpEncode("/sdfsd.html?yql=select * from source where myfield contains(word);"));
+ Query q = new Query(httpEncode("/sdfsd.html?yql=select * from source where myfield contains(word)"));
assertEquals("", q.getModel().getQueryTree().toString());
}
@@ -901,7 +901,7 @@ public class QueryTestCase {
{ // Select all Persons whose hobbies contains 'sport'
// YQL
- Query yqlQuery = new Query(httpEncode("?query=select * from Persons where hobbies contains 'sports';&type=yql"));
+ Query yqlQuery = new Query(httpEncode("?query=select * from Persons where hobbies contains 'sports'&type=yql"));
assertEquals("hobbies:sports", yqlQuery.getModel().getQueryTree().toString());
// JSON
@@ -916,7 +916,7 @@ public class QueryTestCase {
{ // Select all Persons whose Phones areaCode equals 'NY'
// YQL
- Query yqlQuery = new Query(httpEncode("?query=select * from Persons where phones.areaCode contains 'NY';&type=yql"));
+ Query yqlQuery = new Query(httpEncode("?query=select * from Persons where phones.areaCode contains 'NY'&type=yql"));
assertEquals("phones.areaCode:NY", yqlQuery.getModel().getQueryTree().toString());
// JSON
@@ -931,7 +931,7 @@ public class QueryTestCase {
{ // Select all Persons whose Mother's Birthyear is greater than 1960
// YQL
- Query yqlQuery = new Query(httpEncode("?query=select * from Persons where mother.Birthyear > 1960;&type=yql"));
+ Query yqlQuery = new Query(httpEncode("?query=select * from Persons where mother.Birthyear > 1960&type=yql"));
assertEquals("mother.Birthyear:>1960", yqlQuery.getModel().getQueryTree().toString());
// JSON
diff --git a/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java
index b1093e54b68..8a6a48afd9f 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/FieldFilterTestCase.java
@@ -42,7 +42,7 @@ public class FieldFilterTestCase {
DocumentSourceSearcher mockBackend = new DocumentSourceSearcher();
mockBackend.addResult(query, result);
- searchChain = new Chain<Searcher>(new FieldFilter(), mockBackend);
+ searchChain = new Chain<>(new FieldFilter(), mockBackend);
context = Execution.Context.createContextStub();
execution = new Execution(searchChain, context);
diff --git a/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
index 09d1dc71249..bd666edcba3 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java
@@ -68,7 +68,7 @@ public class MinimalQueryInserterTestCase {
assertEquals("foo", query.getPresentation().getSummaryFields().toArray(new String[1])[0]);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count())));");
+ "| all(group(a) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -76,7 +76,7 @@ public class MinimalQueryInserterTestCase {
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
"| all(group(a) each(output(count()))) " +
- "| all(group(b) each(output(count())));");
+ "| all(group(b) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -89,25 +89,25 @@ public class MinimalQueryInserterTestCase {
URIBuilder builder = new URIBuilder();
builder.setPath("search/");
- builder.setParameter("yql", "select foo from bar where baz contains 'cox';");
+ builder.setParameter("yql", "select foo from bar where baz contains 'cox'");
Query query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
assertGrouping("[]", query);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
- "all(group(a) each(output(count())));");
+ "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
+ "all(group(a) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
assertGrouping("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))]", query);
builder.setParameter("yql", "select foo from bar where baz contains 'cox' " +
- "| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
+ "| { continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }" +
"all(group(a) each(output(count()))) " +
- "| [{ 'continuations':['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]" +
- "all(group(b) each(output(count())));");
+ "| { continuations:['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }" +
+ "all(group(b) each(output(count())))");
query = new Query(builder.toString());
execution.search(query);
assertEquals("baz:cox", query.getModel().getQueryTree().toString());
@@ -119,14 +119,14 @@ public class MinimalQueryInserterTestCase {
@Ignore
// TODO: YQL work in progress (jon)
public void testTmp() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
//execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
}
@Test
public void testSearch() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(Language.ENGLISH, query.getModel().getParsingLanguage());
@@ -135,7 +135,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testExplicitLanguageIsHonoredWithVerbatimQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?language=ja" + "&yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22%3B");
+ Query query = new Query("search/?language=ja" + "&yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("title:"+ japaneseWord, query.getModel().getQueryTree().toString());
@@ -144,7 +144,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserLanguageIsDetectedWithVerbatimQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22%3B");
+ Query query = new Query("search/?yql=select%20ignoredField%20from%20ignoredsource%20where%20title%20contains%20%22" + encode(japaneseWord) + "%22");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("title:"+ japaneseWord, query.getModel().getQueryTree().toString());
@@ -153,7 +153,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserLanguageIsDetectedWithUserInput() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?userString=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userInput(@userString)%3B");
+ Query query = new Query("search/?userString=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userInput(@userString)");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("AND title:madonna default:" + japaneseWord, query.getModel().getQueryTree().toString());
@@ -162,7 +162,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserLanguageIsDetectedWithUserQuery() {
String japaneseWord = "\u30ab\u30bf\u30ab\u30ca";
- Query query = new Query("search/?query=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=" + encode(japaneseWord) + "&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals(Language.JAPANESE, query.getModel().getParsingLanguage());
assertEquals("AND title:madonna " + japaneseWord, query.getModel().getQueryTree().toString());
@@ -170,14 +170,14 @@ public class MinimalQueryInserterTestCase {
@Test
public void testUserQueryFailsWithoutArgument() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
}
@Test
public void testSearchFromAllSourcesWithUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(0, query.getModel().getSources().size());
@@ -185,7 +185,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testSearchFromAllSourcesWithoutUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(0, query.getModel().getSources().size());
@@ -193,7 +193,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testSearchFromSomeSourcesWithoutUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(2, query.getModel().getSources().size());
@@ -203,7 +203,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testSearchFromSomeSourcesWithUserSource() {
- Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ Query query = new Query("search/?query=easilyRecognizedString&sources=abc&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(3, query.getModel().getSources().size());
@@ -214,7 +214,7 @@ public class MinimalQueryInserterTestCase {
@Test
public final void testSearchFromSomeSourcesWithOverlappingUserSource() {
- final Query query = new Query("search/?query=easilyRecognizedString&sources=abc,sourceA&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()%3B");
+ final Query query = new Query("search/?query=easilyRecognizedString&sources=abc,sourceA&yql=select%20ignoredfield%20from%20sources%20sourceA,%20sourceB%20where%20title%20contains%20%22madonna%22%20and%20userQuery()");
execution.search(query);
assertEquals("AND title:madonna easilyRecognizedString", query.getModel().getQueryTree().toString());
assertEquals(3, query.getModel().getSources().size());
@@ -225,7 +225,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testLimitAndOffset() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2031offset%207%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2031offset%207");
execution.search(query);
assertEquals(7, query.getOffset());
assertEquals(24, query.getHits());
@@ -235,7 +235,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testMaxOffset() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040031offset%2040000%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040031offset%2040000");
Result r = execution.search(query);
assertEquals(1, r.hits().getErrorHit().errors().size());
ErrorMessage e = r.hits().getErrorHit().errorIterator().next();
@@ -245,7 +245,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testMaxLimit() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040000offset%207%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040000offset%207");
Result r = execution.search(query);
assertEquals(1, r.hits().getErrorHit().errors().size());
ErrorMessage e = r.hits().getErrorHit().errorIterator().next();
@@ -255,7 +255,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testTimeout() {
- Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20timeout%2051%3B");
+ Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20timeout%2051");
execution.search(query);
assertEquals(51L, query.getTimeout());
assertEquals("select * from sources * where title contains \"madonna\" timeout 51;", query.yqlRepresentation());
@@ -281,7 +281,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testOrdering() {
{
- String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203%3B";
+ String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
assertEquals(2, query.getRanking().getSorting().fieldOrders()
@@ -297,7 +297,7 @@ public class MinimalQueryInserterTestCase {
assertEquals("select ignoredfield from ignoredsource where title contains \"madonna\" order by something, shoesize desc limit 300 timeout 3;", query.yqlRepresentation());
}
{
- String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20other%20limit%20300%20timeout%203%3B";
+ String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20other%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
assertEquals("other", query.getRanking().getSorting().fieldOrders()
@@ -307,7 +307,7 @@ public class MinimalQueryInserterTestCase {
assertEquals("select ignoredfield from ignoredsource where title contains \"madonna\" order by other limit 300 timeout 3;", query.yqlRepresentation());
}
{
- String yql = "select%20foo%20from%20bar%20where%20title%20contains%20%22madonna%22%20order%20by%20%5B%7B%22function%22%3A%20%22uca%22%2C%20%22locale%22%3A%20%22en_US%22%2C%20%22strength%22%3A%20%22IDENTICAL%22%7D%5Dother%20desc%2C%20%5B%7B%22function%22%3A%20%22lowercase%22%7D%5Dsomething%20limit%20300%20timeout%203%3B";
+ String yql = "select%20foo%20from%20bar%20where%20title%20contains%20%22madonna%22%20order%20by%20%5B%7B%22function%22%3A%20%22uca%22%2C%20%22locale%22%3A%20%22en_US%22%2C%20%22strength%22%3A%20%22IDENTICAL%22%7D%5Dother%20desc%2C%20%5B%7B%22function%22%3A%20%22lowercase%22%7D%5Dsomething%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
{
@@ -334,7 +334,7 @@ public class MinimalQueryInserterTestCase {
@Test
public void testStringRepresentation() {
- String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203%3B";
+ String yql = "select%20ignoredfield%20from%20ignoredsource%20where%20title%20contains%20%22madonna%22%20order%20by%20something%2C%20shoesize%20desc%20limit%20300%20timeout%203";
Query query = new Query("search/?yql=" + yql);
execution.search(query);
assertEquals("select ignoredfield from ignoredsource where title contains \"madonna\" order by something, shoesize desc limit 300 timeout 3;",
@@ -345,7 +345,7 @@ public class MinimalQueryInserterTestCase {
public void testAndSegmenting() {
Query query = new Query("?yql=select%20%2A%20from%20sources%20%2A%20where%20%5B%7B%22defaultIndex%22%3A%20%22default%22%2C%22grammar%22%3A%20%22web%22%2C%22stem%22%3A%20true%2C%22allowEmpty%22%3A%20true%7D%5DuserInput%28%40animal%29%3B&animal=m%26m%27s&tracelevel=3");
execution.search(query);
- assertEquals("select * from sources * where (default contains \"m\" AND default contains ([{\"origin\": {\"original\": \"m\\'s\", \"offset\": 0, \"length\": 3}, \"andSegmenting\": true}]phrase(\"m\", \"s\")));",
+ assertEquals("select * from sources * where (default contains \"m\" AND default contains ([{origin: {original: \"m\\'s\", offset: 0, length: 3}, andSegmenting: true}]phrase(\"m\", \"s\")));",
query.yqlRepresentation());
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
index 3eb6f5e7e38..cc1a275af5a 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java
@@ -48,24 +48,21 @@ public class UserInputTestCase {
public void testSimpleUserInput() {
{
URIBuilder builder = searchUri();
- builder.setParameter("yql",
- "select * from sources * where userInput(\"nalle\");");
+ builder.setParameter("yql", "select * from sources * where userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"nalle\";", query.yqlRepresentation());
}
{
URIBuilder builder = searchUri();
builder.setParameter("nalle", "bamse");
- builder.setParameter("yql",
- "select * from sources * where userInput(@nalle);");
+ builder.setParameter("yql", "select * from sources * where userInput(@nalle)");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"bamse\";", query.yqlRepresentation());
}
{
URIBuilder builder = searchUri();
builder.setParameter("nalle", "bamse");
- builder.setParameter("yql",
- "select * from sources * where userInput(nalle);");
+ builder.setParameter("yql", "select * from sources * where userInput(nalle)");
Query query = new Query(builder.toString());
Result r = execution.search(query);
assertNotNull(r.hits().getError());
@@ -75,8 +72,7 @@ public class UserInputTestCase {
@Test
public void testRawUserInput() {
URIBuilder builder = searchUri();
- builder.setParameter("yql",
- "select * from sources * where [{\"grammar\": \"raw\"}]userInput(\"nal le\");");
+ builder.setParameter("yql", "select * from sources * where [{grammar: \"raw\"}]userInput(\"nal le\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"nal le\";", query.yqlRepresentation());
}
@@ -85,16 +81,16 @@ public class UserInputTestCase {
public void testSegmentedUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"grammar\": \"segment\"}]userInput(\"nal le\");");
+ "select * from sources * where [{grammar: \"segment\"}]userInput(\"nal le\")");
Query query = searchAndAssertNoErrors(builder);
- assertEquals("select * from sources * where default contains ([{\"origin\": {\"original\": \"nal le\", \"offset\": 0, \"length\": 6}}]phrase(\"nal\", \"le\"));", query.yqlRepresentation());
+ assertEquals("select * from sources * where default contains ([{origin: {original: \"nal le\", offset: 0, length: 6}}]phrase(\"nal\", \"le\"));", query.yqlRepresentation());
}
@Test
public void testSegmentedNoiseUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"grammar\": \"segment\"}]userInput(\"^^^^^^^^\");");
+ "select * from sources * where [{grammar: \"segment\"}]userInput(\"^^^^^^^^\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where default contains \"^^^^^^^^\";", query.yqlRepresentation());
}
@@ -103,7 +99,7 @@ public class UserInputTestCase {
public void testCustomDefaultIndexUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"defaultIndex\": \"glompf\"}]userInput(\"nalle\");");
+ "select * from sources * where [{defaultIndex: \"glompf\"}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where glompf contains \"nalle\";", query.yqlRepresentation());
}
@@ -112,10 +108,10 @@ public class UserInputTestCase {
public void testAnnotatedUserInputStemming() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"stem\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{stem: false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
- "select * from sources * where default contains ([{\"stem\": false}]\"nalle\");",
+ "select * from sources * where default contains ([{stem: false}]\"nalle\");",
query.yqlRepresentation());
}
@@ -124,7 +120,7 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter("myinput", "-5");
builder.setParameter("yql",
- "select * from ecitem where rank(([{\"defaultIndex\":\"myfield\"}](userInput(@myinput))));");
+ "select * from ecitem where rank(([{defaultIndex:\"myfield\"}](userInput(@myinput))))");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from ecitem where rank(myfield = (-5));", query.yqlRepresentation());
assertEquals("RANK myfield:-5", query.getModel().getQueryTree().getRoot().toString());
@@ -134,10 +130,10 @@ public class UserInputTestCase {
public void testAnnotatedUserInputUnrankedTerms() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"ranked\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{ranked: false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
- "select * from sources * where default contains ([{\"ranked\": false}]\"nalle\");",
+ "select * from sources * where default contains ([{ranked: false}]\"nalle\");",
query.yqlRepresentation());
}
@@ -145,10 +141,10 @@ public class UserInputTestCase {
public void testAnnotatedUserInputFiltersTerms() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"filter\": true}]userInput(\"nalle\");");
+ "select * from sources * where [{filter: true}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
- "select * from sources * where default contains ([{\"filter\": true}]\"nalle\");",
+ "select * from sources * where default contains ([{filter: true}]\"nalle\");",
query.yqlRepresentation());
}
@@ -157,10 +153,10 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter(
"yql",
- "select * from sources * where [{\"normalizeCase\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{normalizeCase: false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
- "select * from sources * where default contains ([{\"normalizeCase\": false}]\"nalle\");",
+ "select * from sources * where default contains ([{normalizeCase: false}]\"nalle\");",
query.yqlRepresentation());
}
@@ -168,10 +164,10 @@ public class UserInputTestCase {
public void testAnnotatedUserInputAccentRemoval() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"accentDrop\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{accentDrop: false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
- "select * from sources * where default contains ([{\"accentDrop\": false}]\"nalle\");",
+ "select * from sources * where default contains ([{accentDrop: false}]\"nalle\");",
query.yqlRepresentation());
}
@@ -179,10 +175,10 @@ public class UserInputTestCase {
public void testAnnotatedUserInputPositionData() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where [{\"usePositionData\": false}]userInput(\"nalle\");");
+ "select * from sources * where [{usePositionData: false}]userInput(\"nalle\")");
Query query = searchAndAssertNoErrors(builder);
assertEquals(
- "select * from sources * where default contains ([{\"usePositionData\": false}]\"nalle\");",
+ "select * from sources * where default contains ([{usePositionData: false}]\"nalle\");",
query.yqlRepresentation());
}
@@ -192,7 +188,7 @@ public class UserInputTestCase {
builder.setParameter("nalle", "bamse");
builder.setParameter("meta", "syntactic");
builder.setParameter("yql",
- "select * from sources * where foo contains @nalle and foo contains phrase(@nalle, @meta, @nalle);");
+ "select * from sources * where foo contains @nalle and foo contains phrase(@nalle, @meta, @nalle)");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where (foo contains \"bamse\" AND foo contains phrase(\"bamse\", \"syntactic\", \"bamse\"));", query.yqlRepresentation());
}
@@ -201,7 +197,7 @@ public class UserInputTestCase {
public void testReferenceInComparison() {
URIBuilder builder = searchUri();
builder.setParameter("varref", "1980");
- builder.setParameter("yql", "select * from sources * where year > @varref;");
+ builder.setParameter("yql", "select * from sources * where year > @varref");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select * from sources * where year > 1980;", query.yqlRepresentation());
}
@@ -212,9 +208,9 @@ public class UserInputTestCase {
builder.setParameter("continuation", "BCBCBCBEBG");
builder.setParameter("yql",
"select * from sources * where myfield contains 'token'" +
- "| [{'continuations':[@continuation, 'BCBKCBACBKCCK'] }] all(group(f) each(output(count())));");
+ "| [{'continuations':[@continuation, 'BCBKCBACBKCCK'] }] all(group(f) each(output(count())))");
Query query = searchAndAssertNoErrors(builder);
- assertEquals("select * from sources * where myfield contains \"token\" | [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(f) each(output(count())));", query.yqlRepresentation());
+ assertEquals("select * from sources * where myfield contains \"token\" | [{ continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(f) each(output(count())));", query.yqlRepresentation());
}
@Test
@@ -222,7 +218,7 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter("term", "A");
builder.setParameter("yql",
- "select foo from bar where fieldName contains equiv(@term,'B');");
+ "select foo from bar where fieldName contains equiv(@term,'B')");
Query query = searchAndAssertNoErrors(builder);
assertEquals("select foo from bar where fieldName contains equiv(\"A\", \"B\");", query.yqlRepresentation());
}
@@ -249,7 +245,7 @@ public class UserInputTestCase {
@Test
public void testEmptyUserInput() {
URIBuilder builder = searchUri();
- builder.setParameter("yql", "select * from sources * where userInput(\"\");");
+ builder.setParameter("yql", "select * from sources * where userInput(\"\")");
assertQueryFails(builder);
}
@@ -257,7 +253,7 @@ public class UserInputTestCase {
public void testEmptyUserInputFromQueryProperty() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
- builder.setParameter("yql", "select * from sources * where userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where userInput(@foo)");
assertQueryFails(builder);
}
@@ -265,7 +261,7 @@ public class UserInputTestCase {
public void testEmptyQueryProperty() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
- builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains @foo);");
+ builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains @foo)");
assertQueryFails(builder);
}
@@ -274,17 +270,17 @@ public class UserInputTestCase {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
builder.setParameter("yql",
- "select * from sources * where bar contains \"a\" and nonEmpty(bar contains \"bar\" and foo contains @foo);");
+ "select * from sources * where bar contains \"a\" and nonEmpty(bar contains \"bar\" and foo contains @foo)");
assertQueryFails(builder);
}
@Test
public void testCompositeWithoutArguments() {
URIBuilder builder = searchUri();
- builder.setParameter("yql", "select * from sources * where bar contains \"a\" and foo contains phrase();");
+ builder.setParameter("yql", "select * from sources * where bar contains \"a\" and foo contains phrase()");
searchAndAssertNoErrors(builder);
builder = searchUri();
- builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains phrase());");
+ builder.setParameter("yql", "select * from sources * where bar contains \"a\" and nonEmpty(foo contains phrase())");
assertQueryFails(builder);
}
@@ -292,7 +288,7 @@ public class UserInputTestCase {
public void testAnnoyingPlacementOfNonEmpty() {
URIBuilder builder = searchUri();
builder.setParameter("yql",
- "select * from sources * where bar contains \"a\" and foo contains nonEmpty(phrase(\"a\", \"b\"));");
+ "select * from sources * where bar contains \"a\" and foo contains nonEmpty(phrase(\"a\", \"b\"))");
assertQueryFails(builder);
}
@@ -305,7 +301,7 @@ public class UserInputTestCase {
public void testAllowEmptyUserInput() {
URIBuilder builder = searchUri();
builder.setParameter("foo", "");
- builder.setParameter("yql", "select * from sources * where [{\"allowEmpty\": true}]userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where [{allowEmpty: true}]userInput(@foo)");
searchAndAssertNoErrors(builder);
}
@@ -313,7 +309,7 @@ public class UserInputTestCase {
public void testAllowEmptyNullFromQueryParsing() {
URIBuilder builder = searchUri();
builder.setParameter("foo", ",,,,,,,,");
- builder.setParameter("yql", "select * from sources * where [{\"allowEmpty\": true}]userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where [{allowEmpty: true}]userInput(@foo)");
searchAndAssertNoErrors(builder);
}
@@ -321,7 +317,7 @@ public class UserInputTestCase {
public void testDisallowEmptyNullFromQueryParsing() {
URIBuilder builder = searchUri();
builder.setParameter("foo", ",,,,,,,,");
- builder.setParameter("yql", "select * from sources * where userInput(@foo);");
+ builder.setParameter("yql", "select * from sources * where userInput(@foo)");
assertQueryFails(builder);
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
index cc13658648d..7057f996041 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
@@ -48,18 +48,18 @@ public class VespaSerializerTestCase {
public void requireThatGroupingRequestsAreSerialized() {
Query query = new Query();
query.getModel().getQueryTree().setRoot(new WordItem("foo"));
- assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\")",
+ assertEquals("default contains ([{implicitTransforms: false}]\"foo\")",
VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("a"))
.addChild(new EachOperation().addOutput(new CountAggregator())));
- assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " +
+ assertEquals("default contains ([{implicitTransforms: false}]\"foo\") " +
"| all(group(attribute(a)) each(output(count())))",
VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("b"))
.addChild(new EachOperation().addOutput(new CountAggregator())));
- assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " +
+ assertEquals("default contains ([{implicitTransforms: false}]\"foo\") " +
"| all(group(attribute(a)) each(output(count()))) " +
"| all(group(attribute(b)) each(output(count())))",
VespaSerializer.serialize(query));
@@ -69,15 +69,15 @@ public class VespaSerializerTestCase {
public void requireThatGroupingContinuationsAreSerialized() {
Query query = new Query();
query.getModel().getQueryTree().setRoot(new WordItem("foo"));
- assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\")",
+ assertEquals("default contains ([{implicitTransforms: false}]\"foo\")",
VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("a"))
.addChild(new EachOperation().addOutput(new CountAggregator())),
Continuation.fromString("BCBCBCBEBG"),
Continuation.fromString("BCBKCBACBKCCK"));
- assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " +
- "| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
+ assertEquals("default contains ([{implicitTransforms: false}]\"foo\") " +
+ "| [{ continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
"all(group(attribute(a)) each(output(count())))",
VespaSerializer.serialize(query));
@@ -85,10 +85,10 @@ public class VespaSerializerTestCase {
.addChild(new EachOperation().addOutput(new CountAggregator())),
Continuation.fromString("BCBBBBBDBF"),
Continuation.fromString("BCBJBPCBJCCJ"));
- assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " +
- "| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
+ assertEquals("default contains ([{implicitTransforms: false}]\"foo\") " +
+ "| [{ continuations:['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" +
"all(group(attribute(a)) each(output(count()))) " +
- "| [{ 'continuations':['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]" +
+ "| [{ continuations:['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]" +
"all(group(attribute(b)) each(output(count())))",
VespaSerializer.serialize(query));
}
@@ -129,17 +129,17 @@ public class VespaSerializerTestCase {
@Test
public void testNear() {
parseAndConfirm("title contains near(\"a\", \"b\")");
- parseAndConfirm("title contains ([{\"distance\": 50}]near(\"a\", \"b\"))");
+ parseAndConfirm("title contains ([{distance: 50}]near(\"a\", \"b\"))");
}
@Test
public void testNearestNeighbor() {
- parseAndConfirm("[{\"label\": \"foo\", \"targetNumHits\": 1000}]nearestNeighbor(semantic_embedding, my_property)");
- parseAndConfirm("[{\"targetNumHits\": 42}]nearestNeighbor(semantic_embedding, my_property)");
- parseAndConfirm("[{\"targetNumHits\": 1, \"hnsw.exploreAdditionalHits\": 76}]nearestNeighbor(semantic_embedding, my_property)");
- parseAndConfirm("[{\"targetNumHits\": 2, \"approximate\": false}]nearestNeighbor(semantic_embedding, my_property)");
- parseAndConfirm("[{\"targetNumHits\": 3, \"hnsw.exploreAdditionalHits\": 67, \"approximate\": false}]nearestNeighbor(semantic_embedding, my_property)");
- parseAndConfirm("[{\"targetNumHits\": 4, \"distanceThreshold\": 100100.25}]nearestNeighbor(semantic_embedding, my_property)");
+ parseAndConfirm("[{label: \"foo\", targetNumHits: 1000}]nearestNeighbor(semantic_embedding, my_property)");
+ parseAndConfirm("[{targetNumHits: 42}]nearestNeighbor(semantic_embedding, my_property)");
+ parseAndConfirm("[{targetNumHits: 1, hnsw.exploreAdditionalHits: 76}]nearestNeighbor(semantic_embedding, my_property)");
+ parseAndConfirm("[{targetNumHits: 2, approximate: false}]nearestNeighbor(semantic_embedding, my_property)");
+ parseAndConfirm("[{targetNumHits: 3, hnsw.exploreAdditionalHits: 67, approximate: false}]nearestNeighbor(semantic_embedding, my_property)");
+ parseAndConfirm("[{targetNumHits: 4, distanceThreshold: 100100.25}]nearestNeighbor(semantic_embedding, my_property)");
}
@Test
@@ -163,11 +163,11 @@ public class VespaSerializerTestCase {
@Test
public void testAnnotatedNumbers() {
- parseAndConfirm("title = ([{\"filter\": true}]500)");
- parseAndConfirm("title > ([{\"filter\": true}]500)");
- parseAndConfirm("title < ([{\"filter\": true}](-500))");
- parseAndConfirm("title <= ([{\"filter\": true}](-500))", "([{\"filter\": true}](-500)) >= title");
- parseAndConfirm("title <= ([{\"filter\": true}](-500))");
+ parseAndConfirm("title = ([{filter: true}]500)");
+ parseAndConfirm("title > ([{filter: true}]500)");
+ parseAndConfirm("title < ([{filter: true}](-500))");
+ parseAndConfirm("title <= ([{filter: true}](-500))", "([{filter: true}](-500)) >= title");
+ parseAndConfirm("title <= ([{filter: true}](-500))");
}
@Test
@@ -177,7 +177,7 @@ public class VespaSerializerTestCase {
@Test
public void testAnnotatedRange() {
- parseAndConfirm("[{\"filter\": true}]range(title, 1, 500)");
+ parseAndConfirm("[{filter: true}]range(title, 1, 500)");
}
@Test
@@ -215,22 +215,22 @@ public class VespaSerializerTestCase {
@Test
public void testAnnotatedPhrase() {
- parseAndConfirm("description contains ([{\"id\": 1}]phrase(\"a\", \"b\"))");
+ parseAndConfirm("description contains ([{id: 1}]phrase(\"a\", \"b\"))");
}
@Test
public void testAnnotatedNear() {
- parseAndConfirm("description contains ([{\"distance\": 37}]near(\"a\", \"b\"))");
+ parseAndConfirm("description contains ([{distance: 37}]near(\"a\", \"b\"))");
}
@Test
public void testAnnotatedOnear() {
- parseAndConfirm("description contains ([{\"distance\": 37}]onear(\"a\", \"b\"))");
+ parseAndConfirm("description contains ([{distance: 37}]onear(\"a\", \"b\"))");
}
@Test
public void testAnnotatedEquiv() {
- parseAndConfirm("description contains ([{\"id\": 1}]equiv(\"a\", \"b\"))");
+ parseAndConfirm("description contains ([{id: 1}]equiv(\"a\", \"b\"))");
}
@Test
@@ -242,7 +242,7 @@ public class VespaSerializerTestCase {
phraseSegment.setLabel("labeled");
phraseSegment.lock();
String q = VespaSerializer.serialize(phraseSegment);
- assertEquals("someIndexName contains ([{\"origin\": {\"original\": \"abc\", \"offset\": 0, \"length\": 3}, \"label\": \"labeled\"}]phrase(\"a\", \"b\"))", q);
+ assertEquals("someIndexName contains ([{origin: {original: \"abc\", offset: 0, length: 3}, label: \"labeled\"}]phrase(\"a\", \"b\"))", q);
}
@Test
@@ -251,7 +251,7 @@ public class VespaSerializerTestCase {
sameElement.addItem(new WordItem("a", "f1"));
sameElement.addItem(new WordItem("b", "f2"));
assertEquals("ss:{f1:a f2:b}", sameElement.toString());
- assertEquals("ss contains sameElement(f1 contains ([{\"implicitTransforms\": false}]\"a\"), f2 contains ([{\"implicitTransforms\": false}]\"b\"))", VespaSerializer.serialize(sameElement));
+ assertEquals("ss contains sameElement(f1 contains ([{implicitTransforms: false}]\"a\"), f2 contains ([{implicitTransforms: false}]\"b\"))", VespaSerializer.serialize(sameElement));
}
@Test
@@ -261,22 +261,22 @@ public class VespaSerializerTestCase {
andSegment.addItem(new WordItem("b", "indexNamePlaceholder"));
andSegment.setLabel("labeled");
String q = VespaSerializer.serialize(andSegment);
- assertEquals("indexNamePlaceholder contains ([{\"origin\": {\"original\": \"abc\", \"offset\": 0, \"length\": 3}, \"andSegmenting\": true}]phrase(\"a\", \"b\"))", q);
+ assertEquals("indexNamePlaceholder contains ([{origin: {original: \"abc\", offset: 0, length: 3}, andSegmenting: true}]phrase(\"a\", \"b\"))", q);
andSegment.setIndexName("someIndexName");
andSegment.lock();
q = VespaSerializer.serialize(andSegment);
- assertEquals("someIndexName contains ([{\"origin\": {\"original\": \"abc\", \"offset\": 0, \"length\": 3}, \"andSegmenting\": true}]phrase(\"a\", \"b\"))", q);
+ assertEquals("someIndexName contains ([{origin: {original: \"abc\", offset: 0, length: 3}, andSegmenting: true}]phrase(\"a\", \"b\"))", q);
}
@Test
public void testPhraseWithAnnotations() {
- parseAndConfirm("description contains phrase(([{\"id\": 15}]\"a\"), \"b\")");
+ parseAndConfirm("description contains phrase(([{id: 15}]\"a\"), \"b\")");
}
@Test
public void testPhraseSegmentInPhrase() {
- parseAndConfirm("description contains phrase(\"a\", \"b\", ([{\"origin\": {\"original\": \"c d\", \"offset\": 0, \"length\": 3}}]phrase(\"c\", \"d\")))");
+ parseAndConfirm("description contains phrase(\"a\", \"b\", ([{origin: {original: \"c d\", offset: 0, length: 3}}]phrase(\"c\", \"d\")))");
}
@Test
@@ -296,10 +296,10 @@ public class VespaSerializerTestCase {
@Test
public void testAnnotatedWeakAnd() {
- parseAndConfirm("([{\"" + YqlParser.TARGET_NUM_HITS + "\": 10}]weakAnd(a contains \"A\", b contains \"B\"))");
- parseAndConfirm("([{\"" + YqlParser.SCORE_THRESHOLD + "\": 10}]weakAnd(a contains \"A\", b contains \"B\"))");
- parseAndConfirm("([{\"" + YqlParser.TARGET_NUM_HITS + "\": 10, \"" + YqlParser.SCORE_THRESHOLD
- + "\": 20}]weakAnd(a contains \"A\", b contains \"B\"))");
+ parseAndConfirm("([{" + YqlParser.TARGET_NUM_HITS + ": 10}]weakAnd(a contains \"A\", b contains \"B\"))");
+ parseAndConfirm("([{" + YqlParser.SCORE_THRESHOLD + ": 10}]weakAnd(a contains \"A\", b contains \"B\"))");
+ parseAndConfirm("([{" + YqlParser.TARGET_NUM_HITS + ": 10, " + YqlParser.SCORE_THRESHOLD
+ + ": 20}]weakAnd(a contains \"A\", b contains \"B\"))");
}
@Test
@@ -309,36 +309,36 @@ public class VespaSerializerTestCase {
@Test
public void testAnnotatedWord() {
- parseAndConfirm("description contains ([{\"andSegmenting\": true}]\"a\")");
- parseAndConfirm("description contains ([{\"weight\": 37}]\"a\")");
- parseAndConfirm("description contains ([{\"id\": 37}]\"a\")");
- parseAndConfirm("description contains ([{\"filter\": true}]\"a\")");
- parseAndConfirm("description contains ([{\"ranked\": false}]\"a\")");
- parseAndConfirm("description contains ([{\"significance\": 37.0}]\"a\")");
- parseAndConfirm("description contains ([{\"implicitTransforms\": false}]\"a\")");
- parseAndConfirm("(description contains ([{\"connectivity\": {\"id\": 2, \"weight\": 0.42}, \"id\": 1}]\"a\") AND description contains ([{\"id\": 2}]\"b\"))");
+ parseAndConfirm("description contains ([{andSegmenting: true}]\"a\")");
+ parseAndConfirm("description contains ([{weight: 37}]\"a\")");
+ parseAndConfirm("description contains ([{id: 37}]\"a\")");
+ parseAndConfirm("description contains ([{filter: true}]\"a\")");
+ parseAndConfirm("description contains ([{ranked: false}]\"a\")");
+ parseAndConfirm("description contains ([{significance: 37.0}]\"a\")");
+ parseAndConfirm("description contains ([{implicitTransforms: false}]\"a\")");
+ parseAndConfirm("(description contains ([{connectivity: {id: 2, weight: 0.42}, id: 1}]\"a\") AND description contains ([{id: 2}]\"b\"))");
}
@Test
public void testPrefix() {
- parseAndConfirm("description contains ([{\"prefix\": true}]\"a\")");
+ parseAndConfirm("description contains ([{prefix: true}]\"a\")");
}
@Test
public void testSuffix() {
- parseAndConfirm("description contains ([{\"suffix\": true}]\"a\")");
+ parseAndConfirm("description contains ([{suffix: true}]\"a\")");
}
@Test
public void testSubstring() {
- parseAndConfirm("description contains ([{\"substring\": true}]\"a\")");
+ parseAndConfirm("description contains ([{substring: true}]\"a\")");
}
@Test
public void testExoticItemTypes() {
Item item = MarkerWordItem.createEndOfHost();
String q = VespaSerializer.serialize(item);
- assertEquals("default contains ([{\"implicitTransforms\": false}]\"$\")", q);
+ assertEquals("default contains ([{implicitTransforms: false}]\"$\")", q);
}
@Test
@@ -357,7 +357,7 @@ public class VespaSerializerTestCase {
item.addItem(new WordItem("c"));
item.addItem(new WordItem("d"));
String q = VespaSerializer.serialize(item);
- assertEquals("(default contains ([{\"implicitTransforms\": false}]\"a\")) AND !(default contains ([{\"implicitTransforms\": false}]\"b\") OR default contains ([{\"implicitTransforms\": false}]\"c\") OR default contains ([{\"implicitTransforms\": false}]\"d\"))", q);
+ assertEquals("(default contains ([{implicitTransforms: false}]\"a\")) AND !(default contains ([{implicitTransforms: false}]\"b\") OR default contains ([{implicitTransforms: false}]\"c\") OR default contains ([{implicitTransforms: false}]\"d\"))", q);
}
@Test
@@ -406,23 +406,23 @@ public class VespaSerializerTestCase {
@Test
public void testAnnotatedLong() {
- parseAndConfirm("title >= ([{\"id\": 2014}](-549755813888L))");
+ parseAndConfirm("title >= ([{id: 2014}](-549755813888L))");
}
@Test
public void testHitLimit() {
- parseAndConfirm("title <= ([{\"hitLimit\": 89}](-500))");
- parseAndConfirm("title <= ([{\"hitLimit\": 89}](-500))");
- parseAndConfirm("[{\"hitLimit\": 89}]range(title, 1, 500)");
+ parseAndConfirm("title <= ([{hitLimit: 89}](-500))");
+ parseAndConfirm("title <= ([{hitLimit: 89}](-500))");
+ parseAndConfirm("[{hitLimit: 89}]range(title, 1, 500)");
}
@Test
public void testOpenIntervals() {
parseAndConfirm("range(title, 0.0, 500.0)");
- parseAndConfirm("([{\"bounds\": \"open\"}]range(title, 0.0, 500.0))");
- parseAndConfirm("([{\"bounds\": \"leftOpen\"}]range(title, 0.0, 500.0))");
- parseAndConfirm("([{\"bounds\": \"rightOpen\"}]range(title, 0.0, 500.0))");
- parseAndConfirm("([{\"id\": 500, \"bounds\": \"rightOpen\"}]range(title, 0.0, 500.0))");
+ parseAndConfirm("([{bounds: \"open\"}]range(title, 0.0, 500.0))");
+ parseAndConfirm("([{bounds: \"leftOpen\"}]range(title, 0.0, 500.0))");
+ parseAndConfirm("([{bounds: \"rightOpen\"}]range(title, 0.0, 500.0))");
+ parseAndConfirm("([{id: 500, bounds: \"rightOpen\"}]range(title, 0.0, 500.0))");
}
@Test
@@ -432,14 +432,14 @@ public class VespaSerializerTestCase {
@Test
public void testWordAlternatives() {
- parseAndConfirm("foo contains" + " ([{\"origin\": {\"original\": \" trees \", \"offset\": 1, \"length\": 5}}]"
+ parseAndConfirm("foo contains" + " ([{origin: {original: \" trees \", offset: 1, length: 5}}]"
+ "alternatives({\"trees\": 1.0, \"tree\": 0.7}))");
}
@Test
public void testWordAlternativesInPhrase() {
parseAndConfirm("foo contains phrase(\"forest\","
- + " ([{\"origin\": {\"original\": \" trees \", \"offset\": 1, \"length\": 5}}]"
+ + " ([{origin: {original: \" trees \", offset: 1, length: 5}}]"
+ "alternatives({\"trees\": 1.0, \"tree\": 0.7}))"
+ ")");
}
diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java
index 0cf5ea75526..27959948536 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/YqlFieldAndSourceTestCase.java
@@ -27,8 +27,7 @@ import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
import static com.yahoo.search.searchchain.testutil.DocumentSourceSearcher.DEFAULT_SUMMARY_CLASS;;
/**
- * Test translation of fields and sources in YQL+ to the associated concepts in
- * Vespa.
+ * Test translation of fields and sources in YQL+ to the associated concepts in Vespa.
*/
public class YqlFieldAndSourceTestCase {
diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
index 2a21214c702..c652c299b08 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
@@ -71,7 +71,7 @@ public class YqlParserTestCase {
@Test(timeout = 120_000)
public void failsGracefullyOnMissingQuoteEscapingAndSubsequentUnicodeCharacter() {
- assertParseFail("select * from bar where rank(ids contains 'http://en.wikipedia.org/wiki/Hors_d'œuvre') limit 10;",
+ assertParseFail("select * from bar where rank(ids contains 'http://en.wikipedia.org/wiki/Hors_d'œuvre') limit 10",
new IllegalInputException("com.yahoo.search.yql.ProgramCompileException: query:L1:79 token recognition error at: 'œ'"));
}
@@ -84,26 +84,26 @@ public class YqlParserTestCase {
@Test
public void testLanguageDetection() {
// SimpleDetector used here can detect japanese and will set that as language at the root of the user input
- QueryTree tree = parse("select * from sources * where userInput(\"\u30ab\u30bf\u30ab\u30ca\");");
+ QueryTree tree = parse("select * from sources * where userInput(\"\u30ab\u30bf\u30ab\u30ca\")");
assertEquals(Language.JAPANESE, tree.getRoot().getLanguage());
}
@Test
public void testGroupingStep() {
- assertParse("select foo from bar where baz contains 'cox';",
+ assertParse("select foo from bar where baz contains 'cox'",
"baz:cox");
assertEquals("[]",
toString(parser.getGroupingSteps()));
assertParse("select foo from bar where baz contains 'cox' " +
- "| all(group(a) each(output(count())));",
+ "| all(group(a) each(output(count())))",
"baz:cox");
assertEquals("[[]all(group(a) each(output(count())))]",
toString(parser.getGroupingSteps()));
assertParse("select foo from bar where baz contains 'cox' " +
"| all(group(a) each(output(count()))) " +
- "| all(group(b) each(output(count())));",
+ "| all(group(b) each(output(count())))",
"baz:cox");
assertEquals("[[]all(group(a) each(output(count())))," +
" []all(group(b) each(output(count())))]",
@@ -113,14 +113,14 @@ public class YqlParserTestCase {
@Test
public void testGroupingContinuation() {
assertParse("select foo from bar where baz contains 'cox' " +
- "| [{ 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(a) each(output(count())));",
+ "| { 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }all(group(a) each(output(count())))",
"baz:cox");
assertEquals("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))]",
toString(parser.getGroupingSteps()));
assertParse("select foo from bar where baz contains 'cox' " +
- "| [{ 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]all(group(a) each(output(count()))) " +
- "| [{ 'continuations': ['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]all(group(b) each(output(count())));",
+ "| { 'continuations': ['BCBCBCBEBG', 'BCBKCBACBKCCK'] }all(group(a) each(output(count()))) " +
+ "| { 'continuations': ['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }all(group(b) each(output(count())))",
"baz:cox");
assertEquals("[[BCBCBCBEBG, BCBKCBACBKCCK]all(group(a) each(output(count())))," +
" [BCBBBBBDBF, BCBJBPCBJCCJ]all(group(b) each(output(count())))]",
@@ -129,57 +129,57 @@ public class YqlParserTestCase {
@Test
public void testHitLimit() {
- assertParse("select artist_name, track_name, track_uri from sources * where (myField contains ([{\"prefix\":true}]\"m\") and ([{\"hitLimit\": 5000, \"descending\": true}]range(static_score,0,Infinity))) limit 30 offset 0;",
+ assertParse("select artist_name, track_name, track_uri from sources * where (myField contains ({prefix:true}\"m\") and ({hitLimit: 5000, descending: true}range(static_score,0,Infinity))) limit 30 offset 0",
"AND myField:m* static_score:[0;;-5000]");
}
@Test
public void test() {
- assertParse("select foo from bar where title contains \"madonna\";",
+ assertParse("select foo from bar where title contains \"madonna\"",
"title:madonna");
}
@Test
public void testKeywordAsFieldName() {
- assertParse("select * from sources * where cast contains sameElement(id contains '16');",
+ assertParse("select * from sources * where cast contains sameElement(id contains '16')",
"cast:{id:16}");
}
@Test
public void testComplexExpression() {
- String queryTreeYql = "rank((((filter contains ([{\"origin\": {\"original\": \"filter:VideoAdsCappingTestCPM\", \"offset\": 7, \"length\": 22}, \"normalizeCase\": false, \"id\": 1}]\"videoadscappingtestcpm\") AND hasRankRestriction contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 2}]\"0\") AND ((objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 3}]\"install_app\") AND availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 4}]\"cpiparams\")) OR (availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 5}]\"appinstallinfo\") AND availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 6}]\"appmetroplexinfo\")) OR (dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 7}]\"default\")) AND !(objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 8}]\"install_app\"))) AND advt_age = ([{\"id\": 9}]2147483647) AND advt_gender contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 10}]\"all\") AND advt_all_segments = ([{\"id\": 11}]2147483647) AND advt_keywords contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 12}]\"all\") AND advMobilePlatform = ([{\"id\": 13}]2147483647) AND advMobileDeviceType = ([{\"id\": 14}]2147483647) AND advMobileCon = ([{\"id\": 15}]2147483647) AND advMobileOSVersions = ([{\"id\": 16}]2147483647) AND advCarrier = ([{\"id\": 17}]2147483647) AND ([{\"id\": 18}]weightedSet(advt_supply, {\"all\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) AND (advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 19, \"weight\": 1}]\"adv_tuesday\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 20, \"weight\": 1}]\"adv_tuesday_17\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 21, \"weight\": 1}]\"adv_tuesday_17_forty_five\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 22}]\"all\")) AND isAppReengagementAd = ([{\"id\": 23}]0) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 24}]\"default\") AND serveWithPromotionOnly = ([{\"id\": 26}]0) AND budgetAdvertiserThrottleRateFilter = ([{\"id\": 27}]0) AND budgetResellerThrottleRateFilter = ([{\"id\": 28}]0) AND (isMystiqueRequired = ([{\"id\": 29}]0) OR (isMystiqueRequired = ([{\"id\": 30}]1) AND useBcFactorFilter = ([{\"id\": 31}]1))) AND (((budgetCampaignThrottleRateBits = ([{\"id\": 32}]55) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 33}]\"default\"))) AND !(useBcFactorFilter = ([{\"id\": 34}]1)) OR ((useBcFactorFilter = ([{\"id\": 35}]1) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 36}]\"default\") AND (bcFactorTiers = ([{\"id\": 38}]127) OR bcFactorTiers = ([{\"id\": 39}]0)) AND ((firstPriceEnforced = ([{\"id\": 40}]0) AND (secondPriceEnforced = ([{\"id\": 41}]1) OR isPrivateDeal = ([{\"id\": 42}]0) OR (dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 43}]\"default\")) AND !(bcActiveTier = ([{\"id\": 44}]0)))) OR mystiqueCampaignThrottleRateBits = ([{\"id\": 45}]18)))) AND !(isOutOfDailyBudget = ([{\"id\": 37}]1))) AND testCreative = ([{\"id\": 46}]0) AND advt_geo = ([{\"id\": 47}]2147483647) AND ((adType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 48}]\"strm_video\") AND isPortraitVideo = ([{\"id\": 49}]0)) OR adType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 50}]\"stream_ad\")) AND ((isCPM = ([{\"id\": 51}]0) AND isOCPC = ([{\"id\": 52}]0) AND isECPC = ([{\"id\": 53}]0) AND ((priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 54}]\"cpcv\") AND bid >= ([{\"id\": 55}]0.005)) OR (priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 56}]\"cpv\") AND bid >= ([{\"id\": 57}]0.01)) OR (priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 58}]\"cpc\") AND bid >= ([{\"id\": 59}]0.05)) OR (objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 60}]\"promote_content\") AND bid >= ([{\"id\": 61}]0.01)) OR hasFloorPriceUsd = ([{\"id\": 62}]1))) OR isECPC = ([{\"id\": 63}]1) OR (isCPM = ([{\"id\": 64}]1) AND isOCPM = ([{\"id\": 65}]0) AND (([{\"id\": 66}]range(bid, 0.25, Infinity)) OR hasFloorPriceUsd = ([{\"id\": 67}]1)))) AND start_date <= ([{\"id\": 68}]1572976776299L) AND end_date >= ([{\"id\": 69}]1572976776299L))) AND !(isHoldoutAd = ([{\"id\": 25}]1))) AND !((disclaimerExtensionsTypes contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 70}]\"pharma\") OR ([{\"id\": 71}]weightedSet(exclusion_advt_supply, {\"extsite223\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) OR isPersonalized = ([{\"id\": 72}]1) OR blocked_section_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 73}]\"223\") OR blocked_publisher_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 74}]\"223\") OR blocked_site_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 75}]\"223\"))), [{\"id\": 76, \"label\": \"ad_ocpc_max_cpc\"}]dotProduct(ocpc_max_cpc, {\"0\": 1}), [{\"id\": 77, \"label\": \"ad_ocpc_min_cpc\"}]dotProduct(ocpc_min_cpc, {\"0\": 1}), [{\"id\": 78, \"label\": \"ad_ocpc_max_alpha\"}]dotProduct(ocpc_max_alpha, {\"0\": 1}), [{\"id\": 79, \"label\": \"ad_ocpc_min_alpha\"}]dotProduct(ocpc_min_alpha, {\"0\": 1}), [{\"id\": 80, \"label\": \"ad_ocpc_alpha_0\"}]dotProduct(ocpc_alpha_0, {\"0\": 1}), [{\"id\": 81, \"label\": \"ad_ocpc_alpha_1\"}]dotProduct(ocpc_alpha_1, {\"0\": 1}), (bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 82, \"weight\": 1}]\"adv_tuesday\") OR bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 83, \"weight\": 1}]\"adv_tuesday_17\") OR bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 84, \"weight\": 1}]\"adv_tuesday_17_forty_five\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 85, \"weight\": 1}]\"adv_tuesday\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 86, \"weight\": 1}]\"adv_tuesday_17\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 87, \"weight\": 1}]\"adv_tuesday_17_forty_five\")), bidAdjustmentForCpi = ([{\"id\": 88, \"weight\": 1}]223), [{\"id\": 89, \"label\": \"boostingForBackfill\"}]dotProduct(boostingForBackfill, {\"priority\": 1000})) limit 0 timeout 3980 | all(group(adTypeForGrouping) each(group(advertiser_id) max(11) output(count() as(groupingCounter)) each(max(1) each(output(summary())))))";
+ String queryTreeYql = "rank((((filter contains ({origin: {original: \"filter:VideoAdsCappingTestCPM\", \"offset\": 7, length: 22}, normalizeCase: false, id: 1}\"videoadscappingtestcpm\") AND hasRankRestriction contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 2}]\"0\") AND ((objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 3}]\"install_app\") AND availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 4}]\"cpiparams\")) OR (availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 5}]\"appinstallinfo\") AND availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 6}]\"appmetroplexinfo\")) OR (dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 7}]\"default\")) AND !(objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 8}]\"install_app\"))) AND advt_age = ([{\"id\": 9}]2147483647) AND advt_gender contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 10}]\"all\") AND advt_all_segments = ([{\"id\": 11}]2147483647) AND advt_keywords contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 12}]\"all\") AND advMobilePlatform = ([{\"id\": 13}]2147483647) AND advMobileDeviceType = ([{\"id\": 14}]2147483647) AND advMobileCon = ([{\"id\": 15}]2147483647) AND advMobileOSVersions = ([{\"id\": 16}]2147483647) AND advCarrier = ([{\"id\": 17}]2147483647) AND ([{\"id\": 18}]weightedSet(advt_supply, {\"all\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) AND (advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 19, \"weight\": 1}]\"adv_tuesday\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 20, \"weight\": 1}]\"adv_tuesday_17\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 21, \"weight\": 1}]\"adv_tuesday_17_forty_five\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 22}]\"all\")) AND isAppReengagementAd = ([{\"id\": 23}]0) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 24}]\"default\") AND serveWithPromotionOnly = ([{\"id\": 26}]0) AND budgetAdvertiserThrottleRateFilter = ([{\"id\": 27}]0) AND budgetResellerThrottleRateFilter = ([{\"id\": 28}]0) AND (isMystiqueRequired = ([{\"id\": 29}]0) OR (isMystiqueRequired = ([{\"id\": 30}]1) AND useBcFactorFilter = ([{\"id\": 31}]1))) AND (((budgetCampaignThrottleRateBits = ([{\"id\": 32}]55) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 33}]\"default\"))) AND !(useBcFactorFilter = ([{\"id\": 34}]1)) OR ((useBcFactorFilter = ([{\"id\": 35}]1) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 36}]\"default\") AND (bcFactorTiers = ([{\"id\": 38}]127) OR bcFactorTiers = ([{\"id\": 39}]0)) AND ((firstPriceEnforced = ([{\"id\": 40}]0) AND (secondPriceEnforced = ([{\"id\": 41}]1) OR isPrivateDeal = ([{\"id\": 42}]0) OR (dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 43}]\"default\")) AND !(bcActiveTier = ([{\"id\": 44}]0)))) OR mystiqueCampaignThrottleRateBits = ([{\"id\": 45}]18)))) AND !(isOutOfDailyBudget = ([{\"id\": 37}]1))) AND testCreative = ([{\"id\": 46}]0) AND advt_geo = ([{\"id\": 47}]2147483647) AND ((adType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 48}]\"strm_video\") AND isPortraitVideo = ([{\"id\": 49}]0)) OR adType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 50}]\"stream_ad\")) AND ((isCPM = ([{\"id\": 51}]0) AND isOCPC = ([{\"id\": 52}]0) AND isECPC = ([{\"id\": 53}]0) AND ((priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 54}]\"cpcv\") AND bid >= ([{\"id\": 55}]0.005)) OR (priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 56}]\"cpv\") AND bid >= ([{\"id\": 57}]0.01)) OR (priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 58}]\"cpc\") AND bid >= ([{\"id\": 59}]0.05)) OR (objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 60}]\"promote_content\") AND bid >= ([{\"id\": 61}]0.01)) OR hasFloorPriceUsd = ([{\"id\": 62}]1))) OR isECPC = ([{\"id\": 63}]1) OR (isCPM = ([{\"id\": 64}]1) AND isOCPM = ([{\"id\": 65}]0) AND (([{\"id\": 66}]range(bid, 0.25, Infinity)) OR hasFloorPriceUsd = ([{\"id\": 67}]1)))) AND start_date <= ([{\"id\": 68}]1572976776299L) AND end_date >= ([{\"id\": 69}]1572976776299L))) AND !(isHoldoutAd = ([{\"id\": 25}]1))) AND !((disclaimerExtensionsTypes contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 70}]\"pharma\") OR ([{\"id\": 71}]weightedSet(exclusion_advt_supply, {\"extsite223\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) OR isPersonalized = ([{\"id\": 72}]1) OR blocked_section_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 73}]\"223\") OR blocked_publisher_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 74}]\"223\") OR blocked_site_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 75}]\"223\"))), [{\"id\": 76, \"label\": \"ad_ocpc_max_cpc\"}]dotProduct(ocpc_max_cpc, {\"0\": 1}), [{\"id\": 77, \"label\": \"ad_ocpc_min_cpc\"}]dotProduct(ocpc_min_cpc, {\"0\": 1}), [{\"id\": 78, \"label\": \"ad_ocpc_max_alpha\"}]dotProduct(ocpc_max_alpha, {\"0\": 1}), [{\"id\": 79, \"label\": \"ad_ocpc_min_alpha\"}]dotProduct(ocpc_min_alpha, {\"0\": 1}), [{\"id\": 80, \"label\": \"ad_ocpc_alpha_0\"}]dotProduct(ocpc_alpha_0, {\"0\": 1}), [{\"id\": 81, \"label\": \"ad_ocpc_alpha_1\"}]dotProduct(ocpc_alpha_1, {\"0\": 1}), (bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 82, \"weight\": 1}]\"adv_tuesday\") OR bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 83, \"weight\": 1}]\"adv_tuesday_17\") OR bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 84, \"weight\": 1}]\"adv_tuesday_17_forty_five\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 85, \"weight\": 1}]\"adv_tuesday\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 86, \"weight\": 1}]\"adv_tuesday_17\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 87, \"weight\": 1}]\"adv_tuesday_17_forty_five\")), bidAdjustmentForCpi = ([{\"id\": 88, \"weight\": 1}]223), [{\"id\": 89, \"label\": \"boostingForBackfill\"}]dotProduct(boostingForBackfill, {\"priority\": 1000})) limit 0 timeout 3980 | all(group(adTypeForGrouping) each(group(advertiser_id) max(11) output(count() as(groupingCounter)) each(max(1) each(output(summary())))))";
QueryTree parsed = assertParse("select * from sources * where " + queryTreeYql + ";",
"RANK (+(+(AND filter:VideoAdsCappingTestCPM hasRankRestriction:0 (OR (AND objective:install_app availableExtendedFields:cpiparams) (AND availableExtendedFields:appinstallinfo availableExtendedFields:appmetroplexinfo) (+dummyField:default -objective:install_app)) advt_age:2147483647 advt_gender:all advt_all_segments:2147483647 advt_keywords:all advMobilePlatform:2147483647 advMobileDeviceType:2147483647 advMobileCon:2147483647 advMobileOSVersions:2147483647 advCarrier:2147483647 WEIGHTEDSET advt_supply{[1]:\"site223\",[1]:\"pub223\",[1]:\"all\",[1]:\"sec223\"} (OR advt_day_parting:adv_tuesday!1 advt_day_parting:adv_tuesday_17!1 advt_day_parting:adv_tuesday_17_forty_five!1 advt_day_parting:all) isAppReengagementAd:0 dummyField:default serveWithPromotionOnly:0 budgetAdvertiserThrottleRateFilter:0 budgetResellerThrottleRateFilter:0 (OR isMystiqueRequired:0 (AND isMystiqueRequired:1 useBcFactorFilter:1)) (OR (+(AND budgetCampaignThrottleRateBits:55 dummyField:default) -useBcFactorFilter:1) (+(AND useBcFactorFilter:1 dummyField:default (OR bcFactorTiers:127 bcFactorTiers:0) (OR (AND firstPriceEnforced:0 (OR secondPriceEnforced:1 isPrivateDeal:0 (+dummyField:default -bcActiveTier:0))) mystiqueCampaignThrottleRateBits:18)) -isOutOfDailyBudget:1)) testCreative:0 advt_geo:2147483647 (OR (AND adType:strm_video isPortraitVideo:0) adType:stream_ad) (OR (AND isCPM:0 isOCPC:0 isECPC:0 (OR (AND priceType:cpcv bid:[0.005;]) (AND priceType:cpv bid:[0.01;]) (AND priceType:cpc bid:[0.05;]) (AND objective:promote_content bid:[0.01;]) hasFloorPriceUsd:1)) isECPC:1 (AND isCPM:1 isOCPM:0 (OR bid:[0.25;] hasFloorPriceUsd:1))) start_date:[;1572976776299] end_date:[1572976776299;]) -isHoldoutAd:1) -(OR disclaimerExtensionsTypes:pharma WEIGHTEDSET exclusion_advt_supply{[1]:\"extsite223\",[1]:\"site223\",[1]:\"pub223\",[1]:\"sec223\"} isPersonalized:1 blocked_section_ids:223 blocked_publisher_ids:223 blocked_site_ids:223)) DOTPRODUCT ocpc_max_cpc{[1]:\"0\"} DOTPRODUCT ocpc_min_cpc{[1]:\"0\"} DOTPRODUCT ocpc_max_alpha{[1]:\"0\"} DOTPRODUCT ocpc_min_alpha{[1]:\"0\"} DOTPRODUCT ocpc_alpha_0{[1]:\"0\"} DOTPRODUCT ocpc_alpha_1{[1]:\"0\"} (OR bidAdjustmentDayParting:adv_tuesday!1 bidAdjustmentDayParting:adv_tuesday_17!1 bidAdjustmentDayParting:adv_tuesday_17_forty_five!1 bidAdjustmentDayPartingForCostCap:adv_tuesday!1 bidAdjustmentDayPartingForCostCap:adv_tuesday_17!1 bidAdjustmentDayPartingForCostCap:adv_tuesday_17_forty_five!1) bidAdjustmentForCpi:223!1 DOTPRODUCT boostingForBackfill{[1000]:\"priority\"}");
String serializedQueryTreeYql = VespaSerializer.serialize(parsed);
// Note: All the details here are not verified
- assertEquals("rank((((filter contains ([{\"normalizeCase\": false, \"id\": 1}]\"VideoAdsCappingTestCPM\") AND hasRankRestriction contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 2}]\"0\") AND ((objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 3}]\"install_app\") AND availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 4}]\"cpiparams\")) OR (availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 5}]\"appinstallinfo\") AND availableExtendedFields contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 6}]\"appmetroplexinfo\")) OR (dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 7}]\"default\")) AND !(objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 8}]\"install_app\"))) AND advt_age = ([{\"id\": 9}]2147483647) AND advt_gender contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 10}]\"all\") AND advt_all_segments = ([{\"id\": 11}]2147483647) AND advt_keywords contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 12}]\"all\") AND advMobilePlatform = ([{\"id\": 13}]2147483647) AND advMobileDeviceType = ([{\"id\": 14}]2147483647) AND advMobileCon = ([{\"id\": 15}]2147483647) AND advMobileOSVersions = ([{\"id\": 16}]2147483647) AND advCarrier = ([{\"id\": 17}]2147483647) AND ([{\"id\": 18}]weightedSet(advt_supply, {\"all\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) AND (advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 19, \"weight\": 1}]\"adv_tuesday\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 20, \"weight\": 1}]\"adv_tuesday_17\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 21, \"weight\": 1}]\"adv_tuesday_17_forty_five\") OR advt_day_parting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 22}]\"all\")) AND isAppReengagementAd = ([{\"id\": 23}]0) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 24}]\"default\") AND serveWithPromotionOnly = ([{\"id\": 26}]0) AND budgetAdvertiserThrottleRateFilter = ([{\"id\": 27}]0) AND budgetResellerThrottleRateFilter = ([{\"id\": 28}]0) AND (isMystiqueRequired = ([{\"id\": 29}]0) OR (isMystiqueRequired = ([{\"id\": 30}]1) AND useBcFactorFilter = ([{\"id\": 31}]1))) AND (((budgetCampaignThrottleRateBits = ([{\"id\": 32}]55) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 33}]\"default\"))) AND !(useBcFactorFilter = ([{\"id\": 34}]1)) OR ((useBcFactorFilter = ([{\"id\": 35}]1) AND dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 36}]\"default\") AND (bcFactorTiers = ([{\"id\": 38}]127) OR bcFactorTiers = ([{\"id\": 39}]0)) AND ((firstPriceEnforced = ([{\"id\": 40}]0) AND (secondPriceEnforced = ([{\"id\": 41}]1) OR isPrivateDeal = ([{\"id\": 42}]0) OR (dummyField contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 43}]\"default\")) AND !(bcActiveTier = ([{\"id\": 44}]0)))) OR mystiqueCampaignThrottleRateBits = ([{\"id\": 45}]18)))) AND !(isOutOfDailyBudget = ([{\"id\": 37}]1))) AND testCreative = ([{\"id\": 46}]0) AND advt_geo = ([{\"id\": 47}]2147483647) AND ((adType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 48}]\"strm_video\") AND isPortraitVideo = ([{\"id\": 49}]0)) OR adType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 50}]\"stream_ad\")) AND ((isCPM = ([{\"id\": 51}]0) AND isOCPC = ([{\"id\": 52}]0) AND isECPC = ([{\"id\": 53}]0) AND ((priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 54}]\"cpcv\") AND bid >= ([{\"id\": 55}]0.005)) OR (priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 56}]\"cpv\") AND bid >= ([{\"id\": 57}]0.01)) OR (priceType contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 58}]\"cpc\") AND bid >= ([{\"id\": 59}]0.05)) OR (objective contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 60}]\"promote_content\") AND bid >= ([{\"id\": 61}]0.01)) OR hasFloorPriceUsd = ([{\"id\": 62}]1))) OR isECPC = ([{\"id\": 63}]1) OR (isCPM = ([{\"id\": 64}]1) AND isOCPM = ([{\"id\": 65}]0) AND ([{\"id\": 66}]range(bid, 0.25, Infinity) OR hasFloorPriceUsd = ([{\"id\": 67}]1)))) AND start_date <= ([{\"id\": 68}]1572976776299L) AND end_date >= ([{\"id\": 69}]1572976776299L))) AND !(isHoldoutAd = ([{\"id\": 25}]1))) AND !((disclaimerExtensionsTypes contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 70}]\"pharma\") OR ([{\"id\": 71}]weightedSet(exclusion_advt_supply, {\"extsite223\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) OR isPersonalized = ([{\"id\": 72}]1) OR blocked_section_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 73}]\"223\") OR blocked_publisher_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 74}]\"223\") OR blocked_site_ids contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 75}]\"223\"))), ([{\"id\": 76, \"label\": \"ad_ocpc_max_cpc\"}]dotProduct(ocpc_max_cpc, {\"0\": 1})), ([{\"id\": 77, \"label\": \"ad_ocpc_min_cpc\"}]dotProduct(ocpc_min_cpc, {\"0\": 1})), ([{\"id\": 78, \"label\": \"ad_ocpc_max_alpha\"}]dotProduct(ocpc_max_alpha, {\"0\": 1})), ([{\"id\": 79, \"label\": \"ad_ocpc_min_alpha\"}]dotProduct(ocpc_min_alpha, {\"0\": 1})), ([{\"id\": 80, \"label\": \"ad_ocpc_alpha_0\"}]dotProduct(ocpc_alpha_0, {\"0\": 1})), ([{\"id\": 81, \"label\": \"ad_ocpc_alpha_1\"}]dotProduct(ocpc_alpha_1, {\"0\": 1})), (bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 82, \"weight\": 1}]\"adv_tuesday\") OR bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 83, \"weight\": 1}]\"adv_tuesday_17\") OR bidAdjustmentDayParting contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 84, \"weight\": 1}]\"adv_tuesday_17_forty_five\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 85, \"weight\": 1}]\"adv_tuesday\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 86, \"weight\": 1}]\"adv_tuesday_17\") OR bidAdjustmentDayPartingForCostCap contains ([{\"normalizeCase\": false, \"implicitTransforms\": false, \"id\": 87, \"weight\": 1}]\"adv_tuesday_17_forty_five\")), bidAdjustmentForCpi = ([{\"id\": 88, \"weight\": 1}]223), ([{\"id\": 89, \"label\": \"boostingForBackfill\"}]dotProduct(boostingForBackfill, {\"priority\": 1000})))",
+ assertEquals("rank((((filter contains ([{normalizeCase: false, id: 1}]\"VideoAdsCappingTestCPM\") AND hasRankRestriction contains ([{normalizeCase: false, implicitTransforms: false, id: 2}]\"0\") AND ((objective contains ([{normalizeCase: false, implicitTransforms: false, id: 3}]\"install_app\") AND availableExtendedFields contains ([{normalizeCase: false, implicitTransforms: false, id: 4}]\"cpiparams\")) OR (availableExtendedFields contains ([{normalizeCase: false, implicitTransforms: false, id: 5}]\"appinstallinfo\") AND availableExtendedFields contains ([{normalizeCase: false, implicitTransforms: false, id: 6}]\"appmetroplexinfo\")) OR (dummyField contains ([{normalizeCase: false, implicitTransforms: false, id: 7}]\"default\")) AND !(objective contains ([{normalizeCase: false, implicitTransforms: false, id: 8}]\"install_app\"))) AND advt_age = ([{id: 9}]2147483647) AND advt_gender contains ([{normalizeCase: false, implicitTransforms: false, id: 10}]\"all\") AND advt_all_segments = ([{id: 11}]2147483647) AND advt_keywords contains ([{normalizeCase: false, implicitTransforms: false, id: 12}]\"all\") AND advMobilePlatform = ([{id: 13}]2147483647) AND advMobileDeviceType = ([{id: 14}]2147483647) AND advMobileCon = ([{id: 15}]2147483647) AND advMobileOSVersions = ([{id: 16}]2147483647) AND advCarrier = ([{id: 17}]2147483647) AND ([{id: 18}]weightedSet(advt_supply, {\"all\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) AND (advt_day_parting contains ([{normalizeCase: false, implicitTransforms: false, id: 19, weight: 1}]\"adv_tuesday\") OR advt_day_parting contains ([{normalizeCase: false, implicitTransforms: false, id: 20, weight: 1}]\"adv_tuesday_17\") OR advt_day_parting contains ([{normalizeCase: false, implicitTransforms: false, id: 21, weight: 1}]\"adv_tuesday_17_forty_five\") OR advt_day_parting contains ([{normalizeCase: false, implicitTransforms: false, id: 22}]\"all\")) AND isAppReengagementAd = ([{id: 23}]0) AND dummyField contains ([{normalizeCase: false, implicitTransforms: false, id: 24}]\"default\") AND serveWithPromotionOnly = ([{id: 26}]0) AND budgetAdvertiserThrottleRateFilter = ([{id: 27}]0) AND budgetResellerThrottleRateFilter = ([{id: 28}]0) AND (isMystiqueRequired = ([{id: 29}]0) OR (isMystiqueRequired = ([{id: 30}]1) AND useBcFactorFilter = ([{id: 31}]1))) AND (((budgetCampaignThrottleRateBits = ([{id: 32}]55) AND dummyField contains ([{normalizeCase: false, implicitTransforms: false, id: 33}]\"default\"))) AND !(useBcFactorFilter = ([{id: 34}]1)) OR ((useBcFactorFilter = ([{id: 35}]1) AND dummyField contains ([{normalizeCase: false, implicitTransforms: false, id: 36}]\"default\") AND (bcFactorTiers = ([{id: 38}]127) OR bcFactorTiers = ([{id: 39}]0)) AND ((firstPriceEnforced = ([{id: 40}]0) AND (secondPriceEnforced = ([{id: 41}]1) OR isPrivateDeal = ([{id: 42}]0) OR (dummyField contains ([{normalizeCase: false, implicitTransforms: false, id: 43}]\"default\")) AND !(bcActiveTier = ([{id: 44}]0)))) OR mystiqueCampaignThrottleRateBits = ([{id: 45}]18)))) AND !(isOutOfDailyBudget = ([{id: 37}]1))) AND testCreative = ([{id: 46}]0) AND advt_geo = ([{id: 47}]2147483647) AND ((adType contains ([{normalizeCase: false, implicitTransforms: false, id: 48}]\"strm_video\") AND isPortraitVideo = ([{id: 49}]0)) OR adType contains ([{normalizeCase: false, implicitTransforms: false, id: 50}]\"stream_ad\")) AND ((isCPM = ([{id: 51}]0) AND isOCPC = ([{id: 52}]0) AND isECPC = ([{id: 53}]0) AND ((priceType contains ([{normalizeCase: false, implicitTransforms: false, id: 54}]\"cpcv\") AND bid >= ([{id: 55}]0.005)) OR (priceType contains ([{normalizeCase: false, implicitTransforms: false, id: 56}]\"cpv\") AND bid >= ([{id: 57}]0.01)) OR (priceType contains ([{normalizeCase: false, implicitTransforms: false, id: 58}]\"cpc\") AND bid >= ([{id: 59}]0.05)) OR (objective contains ([{normalizeCase: false, implicitTransforms: false, id: 60}]\"promote_content\") AND bid >= ([{id: 61}]0.01)) OR hasFloorPriceUsd = ([{id: 62}]1))) OR isECPC = ([{id: 63}]1) OR (isCPM = ([{id: 64}]1) AND isOCPM = ([{id: 65}]0) AND ([{id: 66}]range(bid, 0.25, Infinity) OR hasFloorPriceUsd = ([{id: 67}]1)))) AND start_date <= ([{id: 68}]1572976776299L) AND end_date >= ([{id: 69}]1572976776299L))) AND !(isHoldoutAd = ([{id: 25}]1))) AND !((disclaimerExtensionsTypes contains ([{normalizeCase: false, implicitTransforms: false, id: 70}]\"pharma\") OR ([{id: 71}]weightedSet(exclusion_advt_supply, {\"extsite223\": 1, \"pub223\": 1, \"sec223\": 1, \"site223\": 1})) OR isPersonalized = ([{id: 72}]1) OR blocked_section_ids contains ([{normalizeCase: false, implicitTransforms: false, id: 73}]\"223\") OR blocked_publisher_ids contains ([{normalizeCase: false, implicitTransforms: false, id: 74}]\"223\") OR blocked_site_ids contains ([{normalizeCase: false, implicitTransforms: false, id: 75}]\"223\"))), ([{id: 76, label: \"ad_ocpc_max_cpc\"}]dotProduct(ocpc_max_cpc, {\"0\": 1})), ([{id: 77, label: \"ad_ocpc_min_cpc\"}]dotProduct(ocpc_min_cpc, {\"0\": 1})), ([{id: 78, label: \"ad_ocpc_max_alpha\"}]dotProduct(ocpc_max_alpha, {\"0\": 1})), ([{id: 79, label: \"ad_ocpc_min_alpha\"}]dotProduct(ocpc_min_alpha, {\"0\": 1})), ([{id: 80, label: \"ad_ocpc_alpha_0\"}]dotProduct(ocpc_alpha_0, {\"0\": 1})), ([{id: 81, label: \"ad_ocpc_alpha_1\"}]dotProduct(ocpc_alpha_1, {\"0\": 1})), (bidAdjustmentDayParting contains ([{normalizeCase: false, implicitTransforms: false, id: 82, weight: 1}]\"adv_tuesday\") OR bidAdjustmentDayParting contains ([{normalizeCase: false, implicitTransforms: false, id: 83, weight: 1}]\"adv_tuesday_17\") OR bidAdjustmentDayParting contains ([{normalizeCase: false, implicitTransforms: false, id: 84, weight: 1}]\"adv_tuesday_17_forty_five\") OR bidAdjustmentDayPartingForCostCap contains ([{normalizeCase: false, implicitTransforms: false, id: 85, weight: 1}]\"adv_tuesday\") OR bidAdjustmentDayPartingForCostCap contains ([{normalizeCase: false, implicitTransforms: false, id: 86, weight: 1}]\"adv_tuesday_17\") OR bidAdjustmentDayPartingForCostCap contains ([{normalizeCase: false, implicitTransforms: false, id: 87, weight: 1}]\"adv_tuesday_17_forty_five\")), bidAdjustmentForCpi = ([{id: 88, weight: 1}]223), ([{id: 89, label: \"boostingForBackfill\"}]dotProduct(boostingForBackfill, {\"priority\": 1000})))",
serializedQueryTreeYql);
}
@Test
public void testDottedFieldNames() {
- assertParse("select foo from bar where my.nested.title contains \"madonna\";",
+ assertParse("select foo from bar where my.nested.title contains \"madonna\"",
"my.nested.title:madonna");
}
@Test
public void testDottedNestedFieldNames() {
- assertParse("select foo from bar where my.title contains \"madonna\";",
+ assertParse("select foo from bar where my.title contains \"madonna\"",
"my.title:madonna");
}
@Test
public void testOr() {
- assertParse("select foo from bar where title contains \"madonna\" or title contains \"saint\";",
+ assertParse("select foo from bar where title contains \"madonna\" or title contains \"saint\"",
"OR title:madonna title:saint");
assertParse("select foo from bar where title contains \"madonna\" or title contains \"saint\" or title " +
- "contains \"angel\";",
+ "contains \"angel\"",
"OR title:madonna title:saint title:angel");
}
@Test
public void testAnd() {
- assertParse("select foo from bar where title contains \"madonna\" and title contains \"saint\";",
+ assertParse("select foo from bar where title contains \"madonna\" and title contains \"saint\"",
"AND title:madonna title:saint");
assertParse("select foo from bar where title contains \"madonna\" and title contains \"saint\" and title " +
"contains \"angel\";",
@@ -188,98 +188,98 @@ public class YqlParserTestCase {
@Test
public void testAndNot() {
- assertParse("select foo from bar where title contains \"madonna\" and !(title contains \"saint\");",
+ assertParse("select foo from bar where title contains \"madonna\" and !(title contains \"saint\")",
"+title:madonna -title:saint");
}
@Test
public void testLessThan() {
- assertParse("select foo from bar where price < 500;", "price:<500");
- assertParse("select foo from bar where 500 < price;", "price:>500");
+ assertParse("select foo from bar where price < 500", "price:<500");
+ assertParse("select foo from bar where 500 < price", "price:>500");
}
@Test
public void testGreaterThan() {
- assertParse("select foo from bar where price > 500;", "price:>500");
- assertParse("select foo from bar where 500 > price;", "price:<500");
+ assertParse("select foo from bar where price > 500", "price:>500");
+ assertParse("select foo from bar where 500 > price", "price:<500");
}
@Test
public void testLessThanOrEqual() {
- assertParse("select foo from bar where price <= 500;", "price:[;500]");
- assertParse("select foo from bar where 500 <= price;", "price:[500;]");
+ assertParse("select foo from bar where price <= 500", "price:[;500]");
+ assertParse("select foo from bar where 500 <= price", "price:[500;]");
}
@Test
public void testGreaterThanOrEqual() {
- assertParse("select foo from bar where price >= 500;", "price:[500;]");
- assertParse("select foo from bar where 500 >= price;", "price:[;500]");
+ assertParse("select foo from bar where price >= 500", "price:[500;]");
+ assertParse("select foo from bar where 500 >= price", "price:[;500]");
}
@Test
public void testEquality() {
- assertParse("select foo from bar where price = 500;", "price:500");
- assertParse("select foo from bar where 500 = price;", "price:500");
+ assertParse("select foo from bar where price = 500", "price:500");
+ assertParse("select foo from bar where 500 = price", "price:500");
}
@Test
public void testNegativeLessThan() {
- assertParse("select foo from bar where price < -500;", "price:<-500");
- assertParse("select foo from bar where -500 < price;", "price:>-500");
+ assertParse("select foo from bar where price < -500", "price:<-500");
+ assertParse("select foo from bar where -500 < price", "price:>-500");
}
@Test
public void testNegativeGreaterThan() {
- assertParse("select foo from bar where price > -500;", "price:>-500");
- assertParse("select foo from bar where -500 > price;", "price:<-500");
+ assertParse("select foo from bar where price > -500", "price:>-500");
+ assertParse("select foo from bar where -500 > price", "price:<-500");
}
@Test
public void testNegativeLessThanOrEqual() {
- assertParse("select foo from bar where price <= -500;", "price:[;-500]");
- assertParse("select foo from bar where -500 <= price;", "price:[-500;]");
+ assertParse("select foo from bar where price <= -500", "price:[;-500]");
+ assertParse("select foo from bar where -500 <= price", "price:[-500;]");
}
@Test
public void testNegativeGreaterThanOrEqual() {
- assertParse("select foo from bar where price >= -500;", "price:[-500;]");
- assertParse("select foo from bar where -500 >= price;", "price:[;-500]");
+ assertParse("select foo from bar where price >= -500", "price:[-500;]");
+ assertParse("select foo from bar where -500 >= price", "price:[;-500]");
}
@Test
public void testNegativeEquality() {
- assertParse("select foo from bar where price = -500;", "price:-500");
- assertParse("select foo from bar where -500 = price;", "price:-500");
+ assertParse("select foo from bar where price = -500", "price:-500");
+ assertParse("select foo from bar where -500 = price", "price:-500");
}
@Test
public void testAnnotatedLessThan() {
- assertParse("select foo from bar where price < ([{\"filter\": true}](-500));", "|price:<-500");
- assertParse("select foo from bar where ([{\"filter\": true}]500) < price;", "|price:>500");
+ assertParse("select foo from bar where price < ({filter: true}(-500))", "|price:<-500");
+ assertParse("select foo from bar where ({filter: true}500) < price", "|price:>500");
}
@Test
public void testAnnotatedGreaterThan() {
- assertParse("select foo from bar where price > ([{\"filter\": true}]500);", "|price:>500");
- assertParse("select foo from bar where ([{\"filter\": true}](-500)) > price;", "|price:<-500");
+ assertParse("select foo from bar where price > ({filter: true}500)", "|price:>500");
+ assertParse("select foo from bar where ({filter: true}(-500)) > price", "|price:<-500");
}
@Test
public void testAnnotatedLessThanOrEqual() {
- assertParse("select foo from bar where price <= ([{\"filter\": true}](-500));", "|price:[;-500]");
- assertParse("select foo from bar where ([{\"filter\": true}]500) <= price;", "|price:[500;]");
+ assertParse("select foo from bar where price <= ({filter: true}(-500))", "|price:[;-500]");
+ assertParse("select foo from bar where ({filter: true}500) <= price", "|price:[500;]");
}
@Test
public void testAnnotatedGreaterThanOrEqual() {
- assertParse("select foo from bar where price >= ([{\"filter\": true}]500);", "|price:[500;]");
- assertParse("select foo from bar where ([{\"filter\": true}](-500)) >= price;", "|price:[;-500]");
+ assertParse("select foo from bar where price >= ([{filter: true}]500)", "|price:[500;]");
+ assertParse("select foo from bar where ({filter: true}(-500)) >= price", "|price:[;-500]");
}
@Test
public void testAnnotatedEquality() {
- assertParse("select foo from bar where price = ([{\"filter\": true}](-500));", "|price:-500");
- assertParse("select foo from bar where ([{\"filter\": true}]500) = price;", "|price:500");
+ assertParse("select foo from bar where price = ([{filter: true}](-500))", "|price:-500");
+ assertParse("select foo from bar where ({filter: true}500) = price", "|price:500");
}
@Test
@@ -296,61 +296,68 @@ public class YqlParserTestCase {
public void testTermAnnotations() {
assertEquals("merkelapp",
getRootWord("select foo from bar where baz contains " +
- "([ {\"label\": \"merkelapp\"} ]\"colors\");").getLabel());
+ "({label: \"merkelapp\"}\"colors\");").getLabel());
assertEquals("another",
getRootWord("select foo from bar where baz contains " +
- "([ {\"annotations\": {\"cox\": \"another\"}} ]\"colors\");").getAnnotation("cox"));
+ "({annotations: {cox: \"another\"}}\"colors\")").getAnnotation("cox"));
assertEquals(23.0, getRootWord("select foo from bar where baz contains " +
- "([ {\"significance\": 23.0} ]\"colors\");").getSignificance(), 1E-6);
+ "({significance: 23.0}\"colors\")").getSignificance(), 1E-6);
assertEquals(23, getRootWord("select foo from bar where baz contains " +
- "([ {\"id\": 23} ]\"colors\");").getUniqueID());
+ "({id: 23}\"colors\")").getUniqueID());
assertEquals(150, getRootWord("select foo from bar where baz contains " +
- "([ {\"weight\": 150} ]\"colors\");").getWeight());
+ "({weight: 150}\"colors\")").getWeight());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "([ {\"usePositionData\": false} ]\"colors\");").usePositionData());
+ "({usePositionData: false}\"colors\")").usePositionData());
assertTrue(getRootWord("select foo from bar where baz contains " +
- "([ {\"filter\": true} ]\"colors\");").isFilter());
+ "({filter: true}\"colors\")").isFilter());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "([ {\"ranked\": false} ]\"colors\");").isRanked());
+ "({ranked: false}\"colors\")").isRanked());
Substring origin = getRootWord("select foo from bar where baz contains " +
- "([ {\"origin\": {\"original\": \"abc\", \"offset\": 1, \"length\": 2}} ]" +
- "\"colors\");").getOrigin();
+ "({origin: {original: \"abc\", offset: 1, length: 2}}" +
+ "\"colors\")").getOrigin();
assertEquals("abc", origin.string);
assertEquals(1, origin.start);
assertEquals(3, origin.end);
}
@Test
+ public void testAnnotationsCanBeInBrackets() {
+ assertEquals("merkelapp",
+ getRootWord("select foo from bar where baz contains " +
+ "([ {label: \"merkelapp\"} ]\"colors\");").getLabel());
+ }
+
+ @Test
public void testSameElement() {
- assertParse("select foo from bar where baz contains sameElement(f1 contains \"a\", f2 contains \"b\");",
+ assertParse("select foo from bar where baz contains sameElement(f1 contains \"a\", f2 contains \"b\")",
"baz:{f1:a f2:b}");
- assertParse("select foo from bar where baz contains sameElement(f1 contains \"a\", f2 = 10);",
+ assertParse("select foo from bar where baz contains sameElement(f1 contains \"a\", f2 = 10)",
"baz:{f1:a f2:10}");
- assertParse("select foo from bar where baz contains sameElement(key contains \"a\", value.f2 = 10);",
+ assertParse("select foo from bar where baz contains sameElement(key contains \"a\", value.f2 = 10)",
"baz:{key:a value.f2:10}");
- assertCanonicalParse("select foo from bar where baz contains sameElement(key contains \"a\", value.f2 = 10);",
+ assertCanonicalParse("select foo from bar where baz contains sameElement(key contains \"a\", value.f2 = 10)",
"baz:{key:a value.f2:10}");
- assertCanonicalParse("select foo from bar where baz contains sameElement(key contains \"a\");",
+ assertCanonicalParse("select foo from bar where baz contains sameElement(key contains \"a\")",
"baz.key:a");
}
@Test
public void testPhrase() {
- assertParse("select foo from bar where baz contains phrase(\"a\", \"b\");",
+ assertParse("select foo from bar where baz contains phrase(\"a\", \"b\")",
"baz:\"a b\"");
}
@Test
public void testNestedPhrase() {
- assertParse("select foo from bar where baz contains phrase(\"a\", \"b\", phrase(\"c\", \"d\"));",
+ assertParse("select foo from bar where baz contains phrase(\"a\", \"b\", phrase(\"c\", \"d\"))",
"baz:\"a b c d\"");
}
@Test
public void testNestedPhraseSegment() {
assertParse("select foo from bar where baz contains " +
- "phrase(\"a\", \"b\", [ {\"origin\": {\"original\": \"c d\", \"offset\": 0, \"length\": 3}} ]" +
+ "phrase(\"a\", \"b\", [ {origin: {original: \"c d\", offset: 0, length: 3}} ]" +
"phrase(\"c\", \"d\"));",
"baz:\"a b 'c d'\"");
}
@@ -358,9 +365,9 @@ public class YqlParserTestCase {
@Test
public void testStemming() {
assertTrue(getRootWord("select foo from bar where baz contains " +
- "([ {\"stem\": false} ]\"colors\");").isStemmed());
+ "([ {stem: false} ]\"colors\")").isStemmed());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "([ {\"stem\": true} ]\"colors\");").isStemmed());
+ "([ {stem: true} ]\"colors\")").isStemmed());
assertFalse(getRootWord("select foo from bar where baz contains " +
"\"colors\";").isStemmed());
}
@@ -368,23 +375,23 @@ public class YqlParserTestCase {
@Test
public void testRaw() {
// Default: Not raw, for comparison
- Item root = parse("select foo from bar where baz contains (\"yoni jo dima\");").getRoot();
+ Item root = parse("select foo from bar where baz contains (\"yoni jo dima\")").getRoot();
assertEquals("baz:'yoni jo dima'", root.toString());
assertFalse(root instanceof WordItem);
assertTrue(root instanceof PhraseSegmentItem);
- root = parse("select foo from bar where baz contains ([{\"grammar\":\"raw\"}]\"yoni jo dima\");").getRoot();
+ root = parse("select foo from bar where baz contains ([{grammar:\"raw\"}]\"yoni jo dima\")").getRoot();
assertEquals("baz:yoni jo dima", root.toString());
assertTrue(root instanceof WordItem);
assertFalse(root instanceof ExactStringItem);
assertEquals("yoni jo dima", ((WordItem)root).getWord());
- root = parse("select foo from bar where userInput(\"yoni jo dima\");").getRoot();
+ root = parse("select foo from bar where userInput(\"yoni jo dima\")").getRoot();
assertTrue(root instanceof AndItem);
AndItem andItem = (AndItem) root;
assertEquals(3, andItem.getItemCount());
- root = parse("select foo from bar where [{\"grammar\":\"raw\"}]userInput(\"yoni jo dima\");").getRoot();
+ root = parse("select foo from bar where [{grammar:\"raw\"}]userInput(\"yoni jo dima\")").getRoot();
assertTrue(root instanceof WordItem);
assertTrue(root instanceof ExactStringItem);
assertEquals("yoni jo dima", ((WordItem)root).getWord());
@@ -393,65 +400,65 @@ public class YqlParserTestCase {
@Test
public void testAccentDropping() {
assertFalse(getRootWord("select foo from bar where baz contains " +
- "([ {\"accentDrop\": false} ]\"colors\");").isNormalizable());
+ "([ {accentDrop: false} ]\"colors\")").isNormalizable());
assertTrue(getRootWord("select foo from bar where baz contains " +
- "([ {\"accentDrop\": true} ]\"colors\");").isNormalizable());
+ "([ {accentDrop: true} ]\"colors\")").isNormalizable());
assertTrue(getRootWord("select foo from bar where baz contains " +
- "\"colors\";").isNormalizable());
+ "\"colors\"").isNormalizable());
}
@Test
public void testCaseNormalization() {
assertTrue(getRootWord("select foo from bar where baz contains " +
- "([ {\"normalizeCase\": false} ]\"colors\");").isLowercased());
+ "([ {normalizeCase: false} ]\"colors\")").isLowercased());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "([ {\"normalizeCase\": true} ]\"colors\");").isLowercased());
+ "([ {normalizeCase: true} ]\"colors\")").isLowercased());
assertFalse(getRootWord("select foo from bar where baz contains " +
- "\"colors\";").isLowercased());
+ "\"colors\"").isLowercased());
}
@Test
public void testSegmentingRule() {
assertEquals(SegmentingRule.PHRASE,
getRootWord("select foo from bar where baz contains " +
- "([ {\"andSegmenting\": false} ]\"colors\");").getSegmentingRule());
+ "([ {andSegmenting: false} ]\"colors\")").getSegmentingRule());
assertEquals(SegmentingRule.BOOLEAN_AND,
getRootWord("select foo from bar where baz contains " +
- "([ {\"andSegmenting\": true} ]\"colors\");").getSegmentingRule());
+ "([ {andSegmenting: true} ]\"colors\")").getSegmentingRule());
assertEquals(SegmentingRule.LANGUAGE_DEFAULT,
getRootWord("select foo from bar where baz contains " +
- "\"colors\";").getSegmentingRule());
+ "\"colors\"").getSegmentingRule());
}
@Test
public void testNfkc() {
assertEquals("a\u030a",
getRootWord("select foo from bar where baz contains " +
- "([ {\"nfkc\": false} ]\"a\\u030a\");").getWord());
+ "([ {nfkc: false} ]\"a\\u030a\")").getWord());
assertEquals("\u00e5",
getRootWord("select foo from bar where baz contains " +
- "([ {\"nfkc\": true} ]\"a\\u030a\");").getWord());
+ "([ {nfkc: true} ]\"a\\u030a\")").getWord());
assertEquals("No NKFC by default",
"a\u030a",
getRootWord("select foo from bar where baz contains " +
- "(\"a\\u030a\");").getWord());
+ "(\"a\\u030a\")").getWord());
}
@Test
public void testImplicitTransforms() {
- assertFalse(getRootWord("select foo from bar where baz contains ([ {\"implicitTransforms\": " +
- "false} ]\"cox\");").isFromQuery());
- assertTrue(getRootWord("select foo from bar where baz contains ([ {\"implicitTransforms\": " +
- "true} ]\"cox\");").isFromQuery());
- assertTrue(getRootWord("select foo from bar where baz contains \"cox\";").isFromQuery());
+ assertFalse(getRootWord("select foo from bar where baz contains ([ {implicitTransforms: " +
+ "false} ]\"cox\")").isFromQuery());
+ assertTrue(getRootWord("select foo from bar where baz contains ([ {implicitTransforms: " +
+ "true} ]\"cox\")").isFromQuery());
+ assertTrue(getRootWord("select foo from bar where baz contains \"cox\"").isFromQuery());
}
@Test
public void testConnectivity() {
QueryTree parsed = parse("select foo from bar where " +
- "title contains ([{\"id\": 1, \"connectivity\": {\"id\": 3, \"weight\": 7.0}}]\"madonna\") " +
- "and title contains ([{\"id\": 2}]\"saint\") " +
- "and title contains ([{\"id\": 3}]\"angel\");");
+ "title contains ([{id: 1, connectivity: {\"id\": 3, weight: 7.0}}]\"madonna\") " +
+ "and title contains ([{id: 2}]\"saint\") " +
+ "and title contains ([{id: 3}]\"angel\")");
assertEquals("AND title:madonna title:saint title:angel",
parsed.toString());
AndItem root = (AndItem)parsed.getRoot();
@@ -463,9 +470,9 @@ public class YqlParserTestCase {
assertNull(second.getConnectedItem());
assertParseFail("select foo from bar where " +
- "title contains ([{\"id\": 1, \"connectivity\": {\"id\": 4, \"weight\": 7.0}}]\"madonna\") " +
- "and title contains ([{\"id\": 2}]\"saint\") " +
- "and title contains ([{\"id\": 3}]\"angel\");",
+ "title contains ([{id: 1, connectivity: {id: 4, weight: 7.0}}]\"madonna\") " +
+ "and title contains ({id: 2}\"saint\") " +
+ "and title contains ({id: 3}\"angel\")",
new IllegalArgumentException("Item 'title:madonna' was specified to connect to item with ID 4, " +
"which does not exist in the query."));
}
@@ -473,7 +480,7 @@ public class YqlParserTestCase {
@Test
public void testAnnotatedPhrase() {
QueryTree parsed =
- parse("select foo from bar where baz contains ([{\"label\": \"hello world\"}]phrase(\"a\", \"b\"));");
+ parse("select foo from bar where baz contains ({label: \"hello world\"}phrase(\"a\", \"b\"))");
assertEquals("baz:\"a b\"", parsed.toString());
PhraseItem phrase = (PhraseItem)parsed.getRoot();
assertEquals("hello world", phrase.getLabel());
@@ -481,39 +488,39 @@ public class YqlParserTestCase {
@Test
public void testRange() {
- QueryTree parsed = parse("select foo from bar where range(baz,1,8);");
+ QueryTree parsed = parse("select foo from bar where range(baz,1,8)");
assertEquals("baz:[1;8]", parsed.toString());
}
@Test
public void testRangeWithEndInfinity() {
- QueryTree parsed = parse("select foo from bar where range(baz,1,Infinity);");
+ QueryTree parsed = parse("select foo from bar where range(baz,1,Infinity)");
assertEquals("baz:[1;]", parsed.toString());
}
@Test
public void testRangeWithStartInfinity() {
- QueryTree parsed = parse("select foo from bar where range(baz,-Infinity,8);");
+ QueryTree parsed = parse("select foo from bar where range(baz,-Infinity,8)");
assertEquals("baz:[;8]", parsed.toString());
}
@Test
public void testNegativeRange() {
- QueryTree parsed = parse("select foo from bar where range(baz,-8,-1);");
+ QueryTree parsed = parse("select foo from bar where range(baz,-8,-1)");
assertEquals("baz:[-8;-1]", parsed.toString());
}
@Test
public void testRangeIllegalArguments() {
- assertParseFail("select foo from bar where range(baz,cox,8);",
+ assertParseFail("select foo from bar where range(baz,cox,8)",
new IllegalArgumentException("Expected a numerical argument (or 'Infinity') to range but got 'cox'"));
}
@Test
public void testNear() {
- assertParse("select foo from bar where description contains near(\"a\", \"b\");",
+ assertParse("select foo from bar where description contains near(\"a\", \"b\")",
"NEAR(2) description:a description:b");
- assertParse("select foo from bar where description contains ([ {\"distance\": 100} ]near(\"a\", \"b\"));",
+ assertParse("select foo from bar where description contains ({distance: 100} near(\"a\", \"b\"))",
"NEAR(100) description:a description:b");
}
@@ -521,25 +528,31 @@ public class YqlParserTestCase {
public void testOrderedNear() {
assertParse("select foo from bar where description contains onear(\"a\", \"b\");",
"ONEAR(2) description:a description:b");
- assertParse("select foo from bar where description contains ([ {\"distance\": 100} ]onear(\"a\", \"b\"));",
+ assertParse("select foo from bar where description contains ({distance: 100} onear(\"a\", \"b\"))",
"ONEAR(100) description:a description:b");
}
- //This test is order dependent. Fix this!!
@Test
public void testWand() {
assertParse("select foo from bar where wand(description, {\"a\":1, \"b\":2});",
"WAND(10,0.0,1.0) description{[1]:\"a\",[2]:\"b\"}");
- assertParse("select foo from bar where [ {\"scoreThreshold\": 13.3, \"targetHits\": 7, " +
- "\"thresholdBoostFactor\": 2.3} ]wand(description, {\"a\":1, \"b\":2});",
+ assertParse("select foo from bar where {scoreThreshold : 13.3, targetHits: 7, " +
+ "thresholdBoostFactor: 2.3} wand(description, {\"a\":1, \"b\":2})",
"WAND(7,13.3,2.3) description{[1]:\"a\",[2]:\"b\"}");
}
@Test
+ public void testQuotedAnnotations() {
+ assertParse("select foo from bar where {\"scoreThreshold\": 13.3, \"targetHits\": 7, " +
+ "'thresholdBoostFactor': 2.3} wand(description, {\"a\":1})",
+ "WAND(7,13.3,2.3) description{[1]:\"a\"}");
+ }
+
+ @Test
public void testNumericWand() {
String numWand = "WAND(10,0.0,1.0) description{[1]:\"11\",[2]:\"37\"}";
- assertParse("select foo from bar where wand(description, [[11,1], [37,2]]);", numWand);
- assertParse("select foo from bar where wand(description, [[11L,1], [37L,2]]);", numWand);
+ assertParse("select foo from bar where wand(description, [[11,1], [37,2]])", numWand);
+ assertParse("select foo from bar where wand(description, [[11L,1], [37L,2]])", numWand);
assertParseFail("select foo from bar where wand(description, 12);",
new IllegalArgumentException("Expected ARRAY or MAP, got LITERAL."));
}
@@ -547,9 +560,9 @@ public class YqlParserTestCase {
@Test
//This test is order dependent. Fix it!
public void testWeightedSet() {
- assertParse("select foo from bar where weightedSet(description, {\"a\":1, \"b\":2});",
+ assertParse("select foo from bar where weightedSet(description, {\"a\":1, \"b\":2})",
"WEIGHTEDSET description{[1]:\"a\",[2]:\"b\"}");
- assertParseFail("select foo from bar where weightedSet(description, {\"a\":g, \"b\":2});",
+ assertParseFail("select foo from bar where weightedSet(description, {\"a\":g, \"b\":2})",
new IllegalInputException("com.yahoo.search.yql.ProgramCompileException: " +
"query:L1:56 no viable alternative at input 'weightedSet(description, {\"a\":g'"));
assertParseFail("select foo from bar where weightedSet(description);",
@@ -561,25 +574,25 @@ public class YqlParserTestCase {
public void testDotProduct() {
assertParse("select foo from bar where dotProduct(description, {\"a\":1, \"b\":2});",
"DOTPRODUCT description{[1]:\"a\",[2]:\"b\"}");
- assertParse("select foo from bar where dotProduct(description, {\"a\":2});",
+ assertParse("select foo from bar where dotProduct(description, {\"a\":2})",
"DOTPRODUCT description{[2]:\"a\"}");
}
@Test
public void testGeoLocation() {
- assertParse("select foo from bar where geoLocation(workplace, 63.418417, 10.433033, \"0.5 deg\");",
+ assertParse("select foo from bar where geoLocation(workplace, 63.418417, 10.433033, \"0.5 deg\")",
"GEO_LOCATION workplace:(2,10433033,63418417,500000,0,1,0,1921876103)");
- assertParse("select foo from bar where geoLocation(headquarters, \"37.416383\", \"-122.024683\", \"100 miles\");",
+ assertParse("select foo from bar where geoLocation(headquarters, \"37.416383\", \"-122.024683\", \"100 miles\")",
"GEO_LOCATION headquarters:(2,-122024683,37416383,1450561,0,1,0,3411238761)");
- assertParse("select foo from bar where geoLocation(home, \"E10.433033\", \"N63.418417\", \"5km\");",
+ assertParse("select foo from bar where geoLocation(home, \"E10.433033\", \"N63.418417\", \"5km\")",
"GEO_LOCATION home:(2,10433033,63418417,45066,0,1,0,1921876103)");
- assertParseFail("select foo from bar where geoLocation(qux, 1, 2);",
+ assertParseFail("select foo from bar where geoLocation(qux, 1, 2)",
new IllegalArgumentException("Expected 4 arguments, got 3."));
assertParseFail("select foo from bar where geoLocation(qux, 2.0, \"N5.0\", \"0.5 deg\");",
new IllegalArgumentException(
"Invalid geoLocation coordinates 'Latitude: 2.0 degrees' and 'Latitude: 5.0 degrees'"));
- assertParse("select foo from bar where geoLocation(workplace, -12, -34, \"-77 d\");",
+ assertParse("select foo from bar where geoLocation(workplace, -12, -34, \"-77 d\")",
"GEO_LOCATION workplace:(2,-34000000,-12000000,-1,0,1,0,4201111954)");
}
@@ -587,71 +600,71 @@ public class YqlParserTestCase {
public void testNearestNeighbor() {
assertParse("select foo from bar where nearestNeighbor(semantic_embedding, my_vector);",
"NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=Infinity,approximate=true,targetHits=0}");
- assertParse("select foo from bar where [{\"targetHits\": 37}]nearestNeighbor(semantic_embedding, my_vector);",
+ assertParse("select foo from bar where {targetHits: 37} nearestNeighbor(semantic_embedding, my_vector)",
"NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=Infinity,approximate=true,targetHits=37}");
- assertParse("select foo from bar where [{\"approximate\": false, \"hnsw.exploreAdditionalHits\": 8, \"targetHits\": 3}]nearestNeighbor(semantic_embedding, my_vector);",
+ assertParse("select foo from bar where {approximate: false, hnsw.exploreAdditionalHits: 8, targetHits: 3} nearestNeighbor(semantic_embedding, my_vector)",
"NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=8,distanceThreshold=Infinity,approximate=false,targetHits=3}");
- assertParse("select foo from bar where [{\"targetHits\": 7, \"distanceThreshold\": 100100.25}]nearestNeighbor(semantic_embedding, my_vector);",
+ assertParse("select foo from bar where {targetHits: 7, distanceThreshold: 100100.25} nearestNeighbor(semantic_embedding, my_vector)",
"NEAREST_NEIGHBOR {field=semantic_embedding,queryTensorName=my_vector,hnsw.exploreAdditionalHits=0,distanceThreshold=100100.25,approximate=true,targetHits=7}");
}
@Test
public void testTrueAndFalse() {
- assertParse("select foo from bar where true;", "TRUE");
- assertParse("select foo from bar where false;", "FALSE");
- assertParse("select foo from bar where ((title contains \"foo\") AND true) AND !((title contains \"bar\") or false);",
+ assertParse("select foo from bar where true", "TRUE");
+ assertParse("select foo from bar where false", "FALSE");
+ assertParse("select foo from bar where ((title contains \"foo\") AND true) AND !((title contains \"bar\") or false)",
"+(AND title:foo TRUE) -(OR title:bar FALSE)");
}
@Test
public void testPredicate() {
assertParse("select foo from bar where predicate(predicate_field, " +
- "{\"gender\":\"male\", \"hobby\":[\"music\", \"hiking\"]}, {\"age\":23L});",
+ "{\"gender\":\"male\", \"hobby\":[\"music\", \"hiking\"]}, {\"age\":23L})",
"PREDICATE_QUERY_ITEM gender=male, hobby=music, hobby=hiking, age:23");
assertParse("select foo from bar where predicate(predicate_field, " +
- "{\"gender\":\"male\", \"hobby\":[\"music\", \"hiking\"]}, {\"age\":23});",
+ "{\"gender\":\"male\", \"hobby\":[\"music\", \"hiking\"]}, {\"age\":23})",
"PREDICATE_QUERY_ITEM gender=male, hobby=music, hobby=hiking, age:23");
- assertParse("select foo from bar where predicate(predicate_field, 0, void);",
+ assertParse("select foo from bar where predicate(predicate_field, 0, void)",
"PREDICATE_QUERY_ITEM ");
}
@Test
public void testPredicateWithSubQueries() {
assertParse("select foo from bar where predicate(predicate_field, " +
- "{\"0x03\":{\"gender\":\"male\"},\"0x01\":{\"hobby\":[\"music\", \"hiking\"]}}, {\"0x80ffffffffffffff\":{\"age\":23L}});",
+ "{\"0x03\":{\"gender\":\"male\"},\"0x01\":{\"hobby\":[\"music\", \"hiking\"]}}, {\"0x80ffffffffffffff\":{\"age\":23L}})",
"PREDICATE_QUERY_ITEM gender=male[0x3], hobby=music[0x1], hobby=hiking[0x1], age:23[0x80ffffffffffffff]");
- assertParseFail("select foo from bar where predicate(foo, null, {\"0x80000000000000000\":{\"age\":23}});",
+ assertParseFail("select foo from bar where predicate(foo, null, {\"0x80000000000000000\":{\"age\":23}})",
new NumberFormatException("Too long subquery string: 0x80000000000000000"));
assertParse("select foo from bar where predicate(predicate_field, " +
- "{\"[0,1]\":{\"gender\":\"male\"},\"[0]\":{\"hobby\":[\"music\", \"hiking\"]}}, {\"[62, 63]\":{\"age\":23L}});",
+ "{\"[0,1]\":{\"gender\":\"male\"},\"[0]\":{\"hobby\":[\"music\", \"hiking\"]}}, {\"[62, 63]\":{\"age\":23L}})",
"PREDICATE_QUERY_ITEM gender=male[0x3], hobby=music[0x1], hobby=hiking[0x1], age:23[0xc000000000000000]");
}
@Test
public void testRank() {
- assertParse("select foo from bar where rank(a contains \"A\", b contains \"B\");",
+ assertParse("select foo from bar where rank(a contains \"A\", b contains \"B\")",
"RANK a:A b:B");
assertParse("select foo from bar where rank(a contains \"A\", b contains \"B\", c " +
- "contains \"C\");",
+ "contains \"C\")",
"RANK a:A b:B c:C");
assertParse("select foo from bar where rank(a contains \"A\", b contains \"B\" or c " +
- "contains \"C\");",
+ "contains \"C\")",
"RANK a:A (OR b:B c:C)");
}
@Test
@SuppressWarnings("deprecation")
public void testWeakAnd() {
- assertParse("select foo from bar where weakAnd(a contains \"A\", b contains \"B\");",
+ assertParse("select foo from bar where weakAnd(a contains \"A\", b contains \"B\")",
"WEAKAND(100) a:A b:B");
- assertParse("select foo from bar where [{\"targetHits\": 37}]weakAnd(a contains \"A\", " +
- "b contains \"B\");",
+ assertParse("select foo from bar where {targetHits: 37}weakAnd(a contains \"A\", " +
+ "b contains \"B\")",
"WEAKAND(37) a:A b:B");
- QueryTree tree = parse("select foo from bar where [{\"scoreThreshold\": 41}]weakAnd(a " +
- "contains \"A\", b contains \"B\");");
+ QueryTree tree = parse("select foo from bar where {scoreThreshold: 41}weakAnd(a " +
+ "contains \"A\", b contains \"B\")");
assertEquals("WEAKAND(100) a:A b:B", tree.toString());
assertEquals(WeakAndItem.class, tree.getRoot().getClass());
assertEquals(41, ((WeakAndItem)tree.getRoot()).getScoreThreshold());
@@ -659,111 +672,103 @@ public class YqlParserTestCase {
@Test
public void testEquiv() {
- assertParse("select foo from bar where fieldName contains equiv(\"A\",\"B\");",
+ assertParse("select foo from bar where fieldName contains equiv(\"A\",\"B\")",
"EQUIV fieldName:A fieldName:B");
assertParse("select foo from bar where fieldName contains " +
"equiv(\"ny\",phrase(\"new\",\"york\"));",
"EQUIV fieldName:ny fieldName:\"new york\"");
- assertParseFail("select foo from bar where fieldName contains equiv(\"ny\");",
+ assertParseFail("select foo from bar where fieldName contains equiv(\"ny\")",
new IllegalArgumentException("Expected 2 or more arguments, got 1."));
- assertParseFail("select foo from bar where fieldName contains equiv(\"ny\", nalle(void));",
+ assertParseFail("select foo from bar where fieldName contains equiv(\"ny\", nalle(void))",
new IllegalArgumentException("Expected function 'phrase', got 'nalle'."));
- assertParseFail("select foo from bar where fieldName contains equiv(\"ny\", 42);",
+ assertParseFail("select foo from bar where fieldName contains equiv(\"ny\", 42)",
new ClassCastException("Cannot cast java.lang.Integer to java.lang.String"));
}
@Test
public void testAffixItems() {
- assertRootClass("select foo from bar where baz contains ([ {\"suffix\": true} ]\"colors\");",
+ assertRootClass("select foo from bar where baz contains ({suffix: true}\"colors\")",
SuffixItem.class);
- assertRootClass("select foo from bar where baz contains ([ {\"prefix\": true} ]\"colors\");",
+ assertRootClass("select foo from bar where baz contains ({prefix: true}\"colors\")",
PrefixItem.class);
- assertRootClass("select foo from bar where baz contains ([ {\"substring\": true} ]\"colors\");",
+ assertRootClass("select foo from bar where baz contains ({substring: true}\"colors\")",
SubstringItem.class);
- assertParseFail("select foo from bar where description contains ([ {\"suffix\": true, " +
- "\"prefix\": true} ]\"colors\");",
+ assertParseFail("select foo from bar where description contains ({suffix: true, " +
+ "prefix: true}\"colors\")",
new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
- assertParseFail("select foo from bar where description contains ([ {\"suffix\": true, " +
- "\"substring\": true} ]\"colors\");",
+ assertParseFail("select foo from bar where description contains ({suffix: true, " +
+ "substring: true}\"colors\")",
new IllegalArgumentException("Only one of prefix, substring and suffix can be set."));
}
@Test
public void testLongNumberInSimpleExpression() {
- assertParse("select foo from bar where price = 8589934592L;",
- "price:8589934592");
+ assertParse("select foo from bar where price = 8589934592L", "price:8589934592");
}
@Test
public void testNegativeLongNumberInSimpleExpression() {
- assertParse("select foo from bar where price = -8589934592L;",
- "price:-8589934592");
+ assertParse("select foo from bar where price = -8589934592L", "price:-8589934592");
}
@Test
public void testSources() {
- assertSources("select foo from sourceA where price <= 500;",
- Arrays.asList("sourceA"));
+ assertSources("select foo from sourceA where price <= 500", List.of("sourceA"));
+ }
+
+ @Test
+ public void testQueryWithSemicolon() {
+ assertParse("select foo from bar where price = 1", "price:1");
}
@Test
public void testSourcesWithDash() {
- assertSources("select foo from source-a where price <= 500;",
- Arrays.asList("source-a"));
+ assertSources("select foo from source-a where price <= 500", List.of("source-a"));
}
@Test
public void testWildCardSources() {
- assertSources("select foo from sources * where price <= 500;",
- Collections.<String>emptyList());
+ assertSources("select foo from sources * where price <= 500", List.of());
}
@Test
public void testMultiSources() {
- assertSources("select foo from sources sourceA, sourceB where price <= 500;",
- Arrays.asList("sourceA", "sourceB"));
+ assertSources("select foo from sources sourceA, sourceB where price <= 500", List.of("sourceA", "sourceB"));
}
@Test
public void testFields() {
- assertSummaryFields("select fieldA from bar where price <= 500;",
- Arrays.asList("fieldA"));
- assertSummaryFields("select fieldA, fieldB from bar where price <= 500;",
- Arrays.asList("fieldA", "fieldB"));
- assertSummaryFields("select fieldA, fieldB, fieldC from bar where price <= 500;",
- Arrays.asList("fieldA", "fieldB", "fieldC"));
- assertSummaryFields("select * from bar where price <= 500;",
- Collections.<String>emptyList());
+ assertSummaryFields("select fieldA from bar where price <= 500", List.of("fieldA"));
+ assertSummaryFields("select fieldA, fieldB from bar where price <= 500", List.of("fieldA", "fieldB"));
+ assertSummaryFields("select fieldA, fieldB, fieldC from bar where price <= 500", List.of("fieldA", "fieldB", "fieldC"));
+ assertSummaryFields("select * from bar where price <= 500", List.of());
}
@Test
public void testFieldsRoot() {
- assertParse("select * from bar where price <= 500;",
- "price:[;500]");
+ assertParse("select * from bar where price <= 500", "price:[;500]");
}
@Test
public void testOffset() {
- assertParse("select foo from bar where title contains \"madonna\" offset 37;",
- "title:madonna");
+ assertParse("select foo from bar where title contains \"madonna\" offset 37", "title:madonna");
assertEquals(Integer.valueOf(37), parser.getOffset());
}
@Test
public void testLimit() {
- assertParse("select foo from bar where title contains \"madonna\" limit 29;",
- "title:madonna");
+ assertParse("select foo from bar where title contains \"madonna\" limit 29", "title:madonna");
assertEquals(Integer.valueOf(29), parser.getHits());
}
@Test
public void testOffsetAndLimit() {
- assertParse("select foo from bar where title contains \"madonna\" limit 31 offset 29;",
+ assertParse("select foo from bar where title contains \"madonna\" limit 31 offset 29",
"title:madonna");
assertEquals(Integer.valueOf(29), parser.getOffset());
assertEquals(Integer.valueOf(2), parser.getHits());
- assertParse("select * from bar where title contains \"madonna\" limit 41 offset 37;",
+ assertParse("select * from bar where title contains \"madonna\" limit 41 offset 37",
"title:madonna");
assertEquals(Integer.valueOf(37), parser.getOffset());
assertEquals(Integer.valueOf(4), parser.getHits());
@@ -771,19 +776,17 @@ public class YqlParserTestCase {
@Test
public void testTimeout() {
- assertParse("select * from bar where title contains \"madonna\" timeout 7;",
- "title:madonna");
+ assertParse("select * from bar where title contains \"madonna\" timeout 7", "title:madonna");
assertEquals(Integer.valueOf(7), parser.getTimeout());
- assertParse("select foo from bar where title contains \"madonna\" limit 600 timeout 3;",
- "title:madonna");
+ assertParse("select foo from bar where title contains \"madonna\" limit 600 timeout 3", "title:madonna");
assertEquals(Integer.valueOf(3), parser.getTimeout());
}
@Test
public void testOrdering() {
assertParse("select foo from bar where title contains \"madonna\" order by something asc, " +
- "shoesize desc limit 600 timeout 3;",
+ "shoesize desc limit 600 timeout 3",
"title:madonna");
assertEquals(2, parser.getSorting().fieldOrders().size());
assertEquals("something", parser.getSorting().fieldOrders().get(0).getFieldName());
@@ -792,7 +795,7 @@ public class YqlParserTestCase {
assertEquals(Order.DESCENDING, parser.getSorting().fieldOrders().get(1).getSortOrder());
assertParse("select foo from bar where title contains \"madonna\" order by other limit 600 " +
- "timeout 3;",
+ "timeout 3",
"title:madonna");
assertEquals("other", parser.getSorting().fieldOrders().get(0).getFieldName());
assertEquals(Order.ASCENDING, parser.getSorting().fieldOrders().get(0).getSortOrder());
@@ -802,8 +805,8 @@ public class YqlParserTestCase {
public void testAnnotatedOrdering() {
assertParse(
"select foo from bar where title contains \"madonna\""
- + " order by [{\"function\": \"uca\", \"locale\": \"en_US\", \"strength\": \"IDENTICAL\"}]other desc"
- + " limit 600" + " timeout 3;", "title:madonna");
+ + " order by [{function: \"uca\", locale: \"en_US\", strength: \"IDENTICAL\"}]other desc"
+ + " limit 600" + " timeout 3", "title:madonna");
FieldOrder fieldOrder = parser.getSorting().fieldOrders().get(0);
assertEquals("other", fieldOrder.getFieldName());
assertEquals(Order.DESCENDING, fieldOrder.getSortOrder());
@@ -820,7 +823,7 @@ public class YqlParserTestCase {
"select foo from bar where title contains \"madonna\""
+ " order by [{\"function\": \"uca\", \"locale\": \"en_US\", \"strength\": \"IDENTICAL\"}]other desc,"
+ " [{\"function\": \"lowercase\"}]something asc"
- + " limit 600" + " timeout 3;", "title:madonna");
+ + " limit 600" + " timeout 3", "title:madonna");
{
FieldOrder fieldOrder = parser.getSorting().fieldOrders().get(0);
assertEquals("other", fieldOrder.getFieldName());
@@ -842,32 +845,32 @@ public class YqlParserTestCase {
@Test
public void testSegmenting() {
- assertParse("select * from bar where title contains 'foo.bar';",
- "title:'foo bar'");
-
- assertParse("select * from bar where title contains 'foo&123';",
- "title:'foo 123'");
+ assertParse("select * from bar where title contains 'foo.bar'", "title:'foo bar'");
+ assertParse("select * from bar where title contains 'foo&123'", "title:'foo 123'");
}
@Test
public void testNegativeHitLimit() {
- assertParse("select * from sources * where [{\"hitLimit\": -38}]range(foo, 0, 1);",
- "foo:[0;1;-38]");
+ assertParse("select * from sources * where {hitLimit: -38}range(foo, 0, 1)", "foo:[0;1;-38]");
}
@Test
public void testRangeSearchHitPopulationOrdering() {
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": true}]range(foo, 0, 1);", "foo:[0;1;38]");
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": false}]range(foo, 0, 1);", "foo:[0;1;-38]");
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"descending\": true}]range(foo, 0, 1);", "foo:[0;1;-38]");
- assertParse("select * from sources * where [{\"hitLimit\": 38, \"descending\": false}]range(foo, 0, 1);", "foo:[0;1;38]");
+ assertParse("select * from sources * where {hitLimit: 38, ascending: true}range(foo, 0, 1)",
+ "foo:[0;1;38]");
+ assertParse("select * from sources * where {hitLimit: 38, ascending: false}range(foo, 0, 1)",
+ "foo:[0;1;-38]");
+ assertParse("select * from sources * where {hitLimit: 38, descending: true}range(foo, 0, 1)",
+ "foo:[0;1;-38]");
+ assertParse("select * from sources * where {hitLimit: 38, descending: false}range(foo, 0, 1)",
+ "foo:[0;1;38]");
boolean gotExceptionFromParse = false;
try {
- parse("select * from sources * where [{\"hitLimit\": 38, \"ascending\": true, \"descending\": false}]range(foo, 0, 1);");
+ parse("select * from sources * where {hitLimit: 38, ascending: true, descending: false}range(foo, 0, 1)");
} catch (IllegalArgumentException e) {
assertTrue("Expected information about abuse of settings.",
- e.getMessage().contains("both ascending and descending ordering set"));
+ e.getMessage().contains("both ascending and descending ordering set"));
gotExceptionFromParse = true;
}
assertTrue(gotExceptionFromParse);
@@ -875,23 +878,23 @@ public class YqlParserTestCase {
@Test
public void testOpenIntervals() {
- assertParse("select * from sources * where range(title, 0.0, 500.0);",
+ assertParse("select * from sources * where range(title, 0.0, 500.0)",
"title:[0.0;500.0]");
assertParse(
- "select * from sources * where [{\"bounds\": \"open\"}]range(title, 0.0, 500.0);",
+ "select * from sources * where {bounds: \"open\"}range(title, 0.0, 500.0)",
"title:<0.0;500.0>");
assertParse(
- "select * from sources * where [{\"bounds\": \"leftOpen\"}]range(title, 0.0, 500.0);",
+ "select * from sources * where {bounds: \"leftOpen\"}range(title, 0.0, 500.0)",
"title:<0.0;500.0]");
assertParse(
- "select * from sources * where [{\"bounds\": \"rightOpen\"}]range(title, 0.0, 500.0);",
+ "select * from sources * where {bounds: \"rightOpen\"}range(title, 0.0, 500.0)",
"title:[0.0;500.0>");
}
@Test
public void testInheritedAnnotations() {
{
- QueryTree x = parse("select * from sources * where ([{\"ranked\": false}](foo contains \"a\" and bar contains \"b\")) or foor contains ([{\"ranked\": false}]\"c\");");
+ QueryTree x = parse("select * from sources * where ({ranked: false}(foo contains \"a\" and bar contains \"b\")) or foor contains ({ranked: false}\"c\")");
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(3, terms.size());
for (IndexedItem term : terms) {
@@ -899,7 +902,7 @@ public class YqlParserTestCase {
}
}
{
- QueryTree x = parse("select * from sources * where [{\"ranked\": false}](foo contains \"a\" and bar contains \"b\");");
+ QueryTree x = parse("select * from sources * where {ranked: false}(foo contains \"a\" and bar contains \"b\")");
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(2, terms.size());
for (IndexedItem term : terms) {
@@ -911,10 +914,10 @@ public class YqlParserTestCase {
@Test
public void testMoreInheritedAnnotations() {
String yqlQuery = "select * from sources * where " +
- "([{\"ranked\": false}](foo contains \"a\" " +
- "and ([{\"ranked\": true}](bar contains \"b\" " +
- "or ([{\"ranked\": false}](foo contains \"c\" " +
- "and foo contains ([{\"ranked\": true}]\"d\")))))));";
+ "([{ranked: false}](foo contains \"a\" " +
+ "and ({ranked: true}(bar contains \"b\" " +
+ "or ({ranked: false}(foo contains \"c\" " +
+ "and foo contains ({ranked: true}\"d\")))))))";
QueryTree x = parse(yqlQuery);
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(4, terms.size());
@@ -945,7 +948,7 @@ public class YqlParserTestCase {
ParserEnvironment parserEnvironment = new ParserEnvironment().setIndexFacts(indexFacts);
YqlParser configuredParser = new YqlParser(parserEnvironment);
QueryTree x = configuredParser.parse(new Parsable()
- .setQuery("select * from sources * where title contains \"a\" and song contains \"b\";"));
+ .setQuery("select * from sources * where title contains \"a\" and song contains \"b\""));
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(2, terms.size());
for (IndexedItem term : terms) {
@@ -955,7 +958,7 @@ public class YqlParserTestCase {
@Test
public void testRegexp() {
- QueryTree x = parse("select * from sources * where foo matches \"a b\";");
+ QueryTree x = parse("select * from sources * where foo matches \"a b\"");
Item root = x.getRoot();
assertSame(RegExpItem.class, root.getClass());
assertEquals("a b", ((RegExpItem) root).stringValue());
@@ -963,7 +966,7 @@ public class YqlParserTestCase {
@Test
public void testWordAlternatives() {
- QueryTree x = parse("select * from sources * where foo contains alternatives({\"trees\": 1.0, \"tree\": 0.7});");
+ QueryTree x = parse("select * from sources * where foo contains alternatives({trees: 1.0, \"tree\": 0.7})");
Item root = x.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
WordAlternativesItem alternatives = (WordAlternativesItem) root;
@@ -973,8 +976,8 @@ public class YqlParserTestCase {
@Test
public void testWordAlternativesWithOrigin() {
QueryTree q = parse("select * from sources * where foo contains" +
- " ([{\"origin\": {\"original\": \" trees \", \"offset\": 1, \"length\": 5}}]" +
- "alternatives({\"trees\": 1.0, \"tree\": 0.7}));");
+ " ({origin: {original: \" trees \", offset: 1, length: 5}}" +
+ "alternatives({trees: 1.0, tree: 0.7}))");
Item root = q.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
WordAlternativesItem alternatives = (WordAlternativesItem) root;
@@ -989,7 +992,7 @@ public class YqlParserTestCase {
@Test
public void testWordAlternativesInPhrase() {
QueryTree q = parse("select * from sources * where" +
- " foo contains phrase(\"forest\", alternatives({\"trees\": 1.0, \"tree\": 0.7}));");
+ " foo contains phrase(\"forest\", alternatives({trees: 1.0, tree: 0.7}))");
Item root = q.getRoot();
assertSame(PhraseItem.class, root.getClass());
PhraseItem phrase = (PhraseItem) root;
@@ -1003,7 +1006,7 @@ public class YqlParserTestCase {
@Test
public void testBackslash() {
{
- String queryString = "select * from testtype where title contains \"\\\\\";"; // Java escaping * YQL escaping
+ String queryString = "select * from testtype where title contains \"\\\\\""; // Java escaping * YQL escaping
QueryTree query = parse(queryString);
@@ -1011,7 +1014,7 @@ public class YqlParserTestCase {
}
{
- Query query = new Query("search?yql=select%20*%20from%20testtype%20where%20title%20contains%20%22%5C%5C%22;");
+ Query query = new Query("search?yql=select%20*%20from%20testtype%20where%20title%20contains%20%22%5C%5C%22");
// Cause parsing :-\
Chain<Searcher> searchChain = new Chain<>(new MinimalQueryInserter());
@@ -1030,7 +1033,7 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield.hostname contains uri(\"google.com\");");
+ yql.properties().set("yql", "select * from sources * where urlfield.hostname contains uri(\"google.com\")");
assertUrlQuery("urlfield.hostname", yql, false, true, true);
}
@@ -1041,7 +1044,7 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{\"endAnchor\": false }]uri(\"google.com\"));");
+ yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{endAnchor: false }]uri(\"google.com\"))");
assertUrlQuery("urlfield.hostname", yql, false, false, true);
}
@@ -1052,7 +1055,7 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{\"startAnchor\": true }] uri(\"google.com\"));");
+ yql.properties().set("yql", "select * from sources * where urlfield.hostname contains ([{startAnchor: true }] uri(\"google.com\"))");
assertUrlQuery("urlfield.hostname", yql, true, true, true);
}
@@ -1063,19 +1066,19 @@ public class YqlParserTestCase {
// YQL query
Query yql = new Query();
- yql.properties().set("yql", "select * from sources * where urlfield contains uri(\"google.com\");");
+ yql.properties().set("yql", "select * from sources * where urlfield contains uri(\"google.com\")");
assertUrlQuery("urlfield", yql, false, false, false);
}
@Test
public void testReservedWordInSource() {
- parse("select * from sources like where text contains \"test\";");
+ parse("select * from sources like where text contains \"test\"");
// success: parsed without exception
}
@Test
public void testAndSegmenting() {
- parse("select * from sources * where (default contains ([{\"stem\": false}]\"m\") AND default contains ([{\"origin\": {\"original\": \"m\'s\", \"offset\": 0, \"length\": 3}, \"andSegmenting\": true}]phrase(\"m\", \"s\"))) timeout 472;");
+ parse("select * from sources * where (default contains ({stem: false}\"m\") AND default contains ({origin: {original: \"m\'s\", offset: 0, length: 3}, andSegmenting: true}phrase(\"m\", \"s\"))) timeout 472");
}
private void assertUrlQuery(String field, Query query, boolean startAnchor, boolean endAnchor, boolean endAnchorIsDefault) {
@@ -1112,11 +1115,11 @@ public class YqlParserTestCase {
if (hasAnnotations)
expectedYql.append("([{");
if (startAnchor != startAnchorIsDefault)
- expectedYql.append("\"startAnchor\": " + startAnchor);
+ expectedYql.append("startAnchor: " + startAnchor);
if (endAnchor != endAnchorIsDefault) {
if (startAnchor != startAnchorIsDefault)
expectedYql.append(", ");
- expectedYql.append("\"endAnchor\": " + endAnchor);
+ expectedYql.append("endAnchor: " + endAnchor);
}
if (hasAnnotations)
expectedYql.append("}]");
diff --git a/container-search/src/test/java/com/yahoo/select/SelectTestCase.java b/container-search/src/test/java/com/yahoo/select/SelectTestCase.java
index 2e7e2a3a711..0dcfb8392ef 100644
--- a/container-search/src/test/java/com/yahoo/select/SelectTestCase.java
+++ b/container-search/src/test/java/com/yahoo/select/SelectTestCase.java
@@ -638,7 +638,7 @@ public class SelectTestCase {
@Test
public void testOpenIntervals() {
assertParse("{ \"range\" : { \"children\":[ \"title\", { \">=\" : 0.0, \"<=\" : 500.0 }] } }" +
- "select * from sources * where range(title, 0.0, 500.0);",
+ "select * from sources * where range(title, 0.0, 500.0)",
"title:[0.0;500.0]");
assertParse(
"{ \"range\" : { \"children\":[ \"title\", { \">\" : 0.0, \"<\" : 500.0 }] } }",
diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java
index d1df9b095d5..e4c46cfed1a 100644
--- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java
+++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java
@@ -56,6 +56,7 @@ public class SystemFlagsDataArchiveTest {
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException expectedException = ExpectedException.none();
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/TenantRoleMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/TenantRoleMaintainerTest.java
index c9cd7f41d2b..81daf0cbcfe 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/TenantRoleMaintainerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/TenantRoleMaintainerTest.java
@@ -9,14 +9,13 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.application.pkg.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
-import org.hamcrest.Matchers;
import org.junit.Test;
import java.time.Duration;
import java.util.List;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* @author mortent
@@ -54,7 +53,7 @@ public class TenantRoleMaintainerTest {
var roleService = tester.controller().serviceRegistry().roleService();
List<TenantName> tenantNames = ((MockRoleService) roleService).maintainedTenants();
- assertThat(tenantNames, Matchers.containsInAnyOrder(prodAppTenant2.application().id().tenant(), perfAppTenant1.application().id().tenant()));
+ assertTrue(tenantNames.containsAll(List.of(prodAppTenant2.application().id().tenant(), perfAppTenant1.application().id().tenant())));
}
private long permanentDeployments(Instance instance) {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/proxy/ProxyRequestTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/proxy/ProxyRequestTest.java
index 9d80dd25ec0..8542530628c 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/proxy/ProxyRequestTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/proxy/ProxyRequestTest.java
@@ -17,17 +17,18 @@ import static org.junit.Assert.assertEquals;
*/
public class ProxyRequestTest {
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exception = ExpectedException.none();
@Test
- public void testBadUri() throws Exception {
+ public void testBadUri() {
exception.expectMessage("Request path '/path' does not end with proxy path '/zone/v2/'");
testRequest("http://domain.tld/path", "/zone/v2/");
}
@Test
- public void testUris() throws Exception {
+ public void testUris() {
{
// Root request
ProxyRequest request = testRequest("http://controller.domain.tld/my/path", "");
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/DataTypeTestCase.java b/document/src/test/java/com/yahoo/document/DataTypeTestCase.java
index b6a79f3c60a..4e522af527f 100644
--- a/document/src/test/java/com/yahoo/document/DataTypeTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DataTypeTestCase.java
@@ -21,9 +21,9 @@ public class DataTypeTestCase {
public void testWeightedSetTypes() {
DataType stringDefault = DataType.getWeightedSet(DataType.STRING);
DataType stringTag=DataType.getWeightedSet(DataType.STRING,true,true);
- assertTrue(stringDefault.equals(stringDefault));
- assertTrue(stringTag.equals(stringTag));
- assertFalse(stringDefault.equals(stringTag));
+ assertEquals(stringDefault, stringDefault);
+ assertEquals(stringTag, stringTag);
+ assertNotEquals(stringDefault, stringTag);
assertEquals("WeightedSet<string>",stringDefault.getName());
assertEquals(18, stringTag.getCode());
//assertEquals("WeightedSet<string>;Add;Remove",stringTag.getName());
@@ -55,6 +55,7 @@ public class DataTypeTestCase {
assertEquals(PredicateFieldValue.class, DataType.PREDICATE.createFieldValue().getClass());
}
+ @SuppressWarnings("unchecked")
@Test
public void testCreateFieldValueWithArg() {
{
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/abi-spec.json b/documentapi/abi-spec.json
index 88ec090d324..2e68d4803cb 100644
--- a/documentapi/abi-spec.json
+++ b/documentapi/abi-spec.json
@@ -1565,6 +1565,20 @@
"protected final java.util.Random randomizer"
]
},
+ "com.yahoo.documentapi.messagebus.protocol.ContentPolicy$InstabilityChecker": {
+ "superClass": "java.lang.Object",
+ "interfaces": [],
+ "attributes": [
+ "public",
+ "interface",
+ "abstract"
+ ],
+ "methods": [
+ "public abstract boolean tooManyFailures(int)",
+ "public abstract void addFailure(java.lang.Integer)"
+ ],
+ "fields": []
+ },
"com.yahoo.documentapi.messagebus.protocol.ContentPolicy$Parameters": {
"superClass": "java.lang.Object",
"interfaces": [],
@@ -1576,7 +1590,8 @@
"public java.lang.String getClusterName()",
"public com.yahoo.documentapi.messagebus.protocol.ContentPolicy$SlobrokHostPatternGenerator createPatternGenerator()",
"public com.yahoo.documentapi.messagebus.protocol.ContentPolicy$HostFetcher createHostFetcher(com.yahoo.documentapi.messagebus.protocol.SlobrokPolicy, int)",
- "public com.yahoo.vdslib.distribution.Distribution createDistribution(com.yahoo.documentapi.messagebus.protocol.SlobrokPolicy)"
+ "public com.yahoo.vdslib.distribution.Distribution createDistribution(com.yahoo.documentapi.messagebus.protocol.SlobrokPolicy)",
+ "public com.yahoo.documentapi.messagebus.protocol.ContentPolicy$InstabilityChecker createInstabilityChecker()"
],
"fields": [
"protected final java.lang.String clusterName",
@@ -1585,6 +1600,21 @@
"protected final com.yahoo.documentapi.messagebus.protocol.ContentPolicy$SlobrokHostPatternGenerator slobrokHostPatternGenerator"
]
},
+ "com.yahoo.documentapi.messagebus.protocol.ContentPolicy$PerNodeCountingInstabilityChecker": {
+ "superClass": "java.lang.Object",
+ "interfaces": [
+ "com.yahoo.documentapi.messagebus.protocol.ContentPolicy$InstabilityChecker"
+ ],
+ "attributes": [
+ "public"
+ ],
+ "methods": [
+ "public void <init>(int)",
+ "public boolean tooManyFailures(int)",
+ "public void addFailure(java.lang.Integer)"
+ ],
+ "fields": []
+ },
"com.yahoo.documentapi.messagebus.protocol.ContentPolicy$SlobrokHostFetcher": {
"superClass": "com.yahoo.documentapi.messagebus.protocol.ContentPolicy$HostFetcher",
"interfaces": [],
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java
index 5eaec70ca59..21e621883fe 100644
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java
@@ -232,6 +232,47 @@ public class ContentPolicy extends SlobrokPolicy {
}
+ /**
+ * Tracks "instability" across nodes based on number of failures received versus some
+ * implementation-specific limit.
+ *
+ * Implementations must be thread-safe.
+ *
+ * TODO should ideally be protected, but there's a package mismatch between policy classes and its tests
+ */
+ public interface InstabilityChecker {
+ boolean tooManyFailures(int nodeIndex);
+ void addFailure(Integer calculatedDistributor);
+ }
+
+ /** Class that tracks a failure of a given type per node. */
+ public static class PerNodeCountingInstabilityChecker implements InstabilityChecker {
+ private final List<Integer> nodeFailures = new CopyOnWriteArrayList<>();
+ private final int failureLimit;
+
+ public PerNodeCountingInstabilityChecker(int failureLimit) {
+ this.failureLimit = failureLimit;
+ }
+
+ @Override
+ public boolean tooManyFailures(int nodeIndex) {
+ if (nodeFailures.size() > nodeIndex && nodeFailures.get(nodeIndex) > failureLimit) {
+ nodeFailures.set(nodeIndex, 0);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void addFailure(Integer calculatedDistributor) {
+ while (nodeFailures.size() <= calculatedDistributor) {
+ nodeFailures.add(0);
+ }
+ nodeFailures.set(calculatedDistributor, nodeFailures.get(calculatedDistributor) + 1);
+ }
+ }
+
/** Class parsing the semicolon separated parameter string and exposes the appropriate value to the policy. */
public static class Parameters {
@@ -271,6 +312,9 @@ public class ContentPolicy extends SlobrokPolicy {
return distributionConfig == null ? new Distribution(getDistributionConfigId())
: new Distribution(distributionConfig.cluster(clusterName));
}
+ public InstabilityChecker createInstabilityChecker() {
+ return new PerNodeCountingInstabilityChecker(getAttemptRandomOnFailuresLimit());
+ }
/**
* When we have gotten this amount of failures from a node (Any kind of failures). We try to send to a random other node, just to see if the
@@ -324,27 +368,6 @@ public class ContentPolicy extends SlobrokPolicy {
/** Class handling the logic of picking a distributor */
public static class DistributorSelectionLogic {
- /** Class that tracks a failure of a given type per node. */
- static class InstabilityChecker {
- private final List<Integer> nodeFailures = new CopyOnWriteArrayList<>();
- private final int failureLimit;
-
- InstabilityChecker(int failureLimit) { this.failureLimit = failureLimit; }
-
- boolean tooManyFailures(int nodeIndex) {
- if (nodeFailures.size() > nodeIndex && nodeFailures.get(nodeIndex) > failureLimit) {
- nodeFailures.set(nodeIndex, 0);
- return true;
- } else {
- return false;
- }
- }
-
- void addFailure(Integer calculatedDistributor) {
- while (nodeFailures.size() <= calculatedDistributor) nodeFailures.add(0);
- nodeFailures.set(calculatedDistributor, nodeFailures.get(calculatedDistributor) + 1);
- }
- }
/** Message context class. Contains data we want to inspect about a request at reply time. */
private static class MessageContext {
final Integer calculatedDistributor;
@@ -375,7 +398,7 @@ public class ContentPolicy extends SlobrokPolicy {
try {
hostFetcher = params.createHostFetcher(policy, params.getRequiredUpPercentageToSendToKnownGoodNodes());
distribution = params.createDistribution(policy);
- persistentFailureChecker = new InstabilityChecker(params.getAttemptRandomOnFailuresLimit());
+ persistentFailureChecker = params.createInstabilityChecker();
maxOldClusterVersionBeforeSendingRandom = params.maxOldClusterStatesSeenBeforeThrowingCachedState();
} catch (Throwable e) {
destroy();
@@ -556,10 +579,37 @@ public class ContentPolicy extends SlobrokPolicy {
}
}
+ /**
+ * Returns whether a given error Reply should be counted towards potentially ignoring the cached
+ * cluster state and triggering a random send (and thus likely WrongDistributionReply with the
+ * current cluster state). Certain error codes may be used frequently by the content layer for
+ * purposes that do _not_ indicate that a change in cluster state may have happened, and should
+ * therefore not be counted for this purpose:
+ * - ERROR_TEST_AND_SET_CONDITION_FAILED: may happen for any mutating operation that has an
+ * associated TaS condition. Technically an APP_FATAL_ERROR since resending doesn't make sense.
+ * - ERROR_BUSY: may happen for concurrent mutations and if distributors are in the process of
+ * changing bucket ownership and the grace period hasn't passed yet.
+ */
+ private static boolean shouldCountAsErrorForRandomSendTrigger(Reply reply) {
+ if (reply.getNumErrors() != 1) {
+ return !reply.hasErrors(); // For simplicity, count any reply with > 1 error.
+ }
+ var error = reply.getError(0);
+ switch (error.getCode()) {
+ // TODO this feels like a layering violation, but we use DocumentProtocol directly in other places in this policy anyway...
+ case DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED:
+ case DocumentProtocol.ERROR_BUSY:
+ return false;
+ default: return true;
+ }
+ }
+
void handleErrorReply(Reply reply, Object untypedContext) {
MessageContext messageContext = (MessageContext) untypedContext;
if (messageContext.calculatedDistributor != null) {
- persistentFailureChecker.addFailure(messageContext.calculatedDistributor);
+ if (shouldCountAsErrorForRandomSendTrigger(reply)) {
+ persistentFailureChecker.addFailure(messageContext.calculatedDistributor);
+ }
if (reply.getTrace().shouldTrace(1)) {
reply.getTrace().trace(1, "Failed with " + messageContext.toString());
}
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/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java
index 42625cf193d..c160f67aa9b 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java
@@ -1,9 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol.test.storagepolicy;
+import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;
+import com.yahoo.messagebus.routing.RoutingNode;
import org.junit.Ignore;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class ContentPolicyTest extends Simulator {
/**
@@ -129,6 +133,46 @@ public class ContentPolicyTest extends Simulator {
// Note that we use extra requests here as with only 200 requests there was a pretty good chance of not going to any down node on random anyhow.
}
+ private void setUpSingleNodeFixturesWithInitializedPolicy() {
+ setClusterNodes(new int[]{ 0 });
+ // Seed policy with initial, correct cluster state.
+ {
+ RoutingNode target = select();
+ replyWrongDistribution(target, "foo", null, "version:1234 distributor:1 storage:1");
+ }
+ }
+
+ @Test
+ public void transient_errors_expected_during_normal_feed_are_not_counted_as_errors_that_may_trigger_random_send() {
+ setUpSingleNodeFixturesWithInitializedPolicy();
+ var checker = policyFactory.getLastParameters().instabilityChecker;
+ assertEquals(0, checker.recordedFailures); // WrongDistributionReply not counted as regular error
+ {
+ frame.setMessage(createMessage("id:ns:testdoc:n=2:foo"));
+ RoutingNode target = select();
+ replyError(target, new com.yahoo.messagebus.Error(DocumentProtocol.ERROR_BUSY, "Get busy livin' or get busy resendin'"));
+ }
+ assertEquals(0, checker.recordedFailures); // BUSY not counted as error
+ {
+ frame.setMessage(createMessage("id:ns:testdoc:n=3:foo"));
+ RoutingNode target = select();
+ replyError(target, new com.yahoo.messagebus.Error(DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED, "oh no"));
+ }
+ assertEquals(0, checker.recordedFailures); // TaS failures not counted as error
+ }
+
+ @Test
+ public void other_errors_during_feed_are_counted_as_errors_that_may_trigger_random_send() {
+ setUpSingleNodeFixturesWithInitializedPolicy();
+ var checker = policyFactory.getLastParameters().instabilityChecker;
+ {
+ frame.setMessage(createMessage("id:ns:testdoc:n=1:foo"));
+ RoutingNode target = select();
+ replyError(target, new com.yahoo.messagebus.Error(DocumentProtocol.ERROR_ABORTED, "shop's closing, go home"));
+ }
+ assertEquals(1, checker.recordedFailures);
+ }
+
// Left to test?
// Cluster state down - Not overwrite last good nodes to send random to?
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java
index c75e1c7832e..b6893d69325 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java
@@ -44,7 +44,7 @@ public abstract class ContentPolicyTestEnvironment {
protected PolicyTestFrame frame;
private Set<Integer> nodes;
protected static int[] bucketOneNodePreference = new int[]{ 3, 5, 7, 6, 8, 0, 9, 2, 1, 4 };
- protected boolean debug = true;
+ protected boolean debug = false;
@Before
public void setUp() throws Exception {
@@ -145,14 +145,37 @@ public abstract class ContentPolicyTestEnvironment {
}
}
+ public static class TestWrappingInstabilityChecker implements ContentPolicy.InstabilityChecker {
+
+ public int recordedFailures = 0;
+ private final ContentPolicy.InstabilityChecker fwdChecker;
+
+ TestWrappingInstabilityChecker(ContentPolicy.InstabilityChecker fwdChecker) {
+ this.fwdChecker = fwdChecker;
+ }
+
+ @Override
+ public boolean tooManyFailures(int nodeIndex) {
+ return fwdChecker.tooManyFailures(nodeIndex);
+ }
+
+ @Override
+ public void addFailure(Integer calculatedDistributor) {
+ ++recordedFailures;
+ fwdChecker.addFailure(calculatedDistributor);
+ }
+ }
+
public static class TestParameters extends ContentPolicy.Parameters {
private final TestHostFetcher hostFetcher;
private final Distribution distribution;
+ public final TestWrappingInstabilityChecker instabilityChecker;
public TestParameters(String parameters, Set<Integer> nodes) {
super(SlobrokPolicy.parse(parameters));
hostFetcher = new TestHostFetcher(getClusterName(), nodes);
distribution = new Distribution(Distribution.getDefaultDistributionConfig(2, 10));
+ instabilityChecker = new TestWrappingInstabilityChecker(new ContentPolicy.PerNodeCountingInstabilityChecker(5));
}
@Override
@@ -160,6 +183,9 @@ public abstract class ContentPolicyTestEnvironment {
@Override
public Distribution createDistribution(SlobrokPolicy policy) { return distribution; }
+
+ @Override
+ public ContentPolicy.InstabilityChecker createInstabilityChecker() { return instabilityChecker; }
}
public static class ContentPolicyTestFactory implements RoutingPolicyFactory {
@@ -182,8 +208,6 @@ public abstract class ContentPolicyTestEnvironment {
}
}
public TestParameters getLastParameters() { return parameterInstances.getLast(); }
- public void destroy() {
- }
}
private int findPreferredAvailableNodeForTestBucket() {
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java
index 651a1c15c0b..d40c87e0bd6 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java
@@ -188,7 +188,7 @@ public abstract class Simulator extends ContentPolicyTestEnvironment {
if (badNode != null && randomizer.nextDouble() < badNode.getFailureRate()) {
++failed[half];
switch (badNode.getFailureType()) {
- case TRANSIENT_ERROR: replyError(target, new com.yahoo.messagebus.Error(DocumentProtocol.ERROR_BUSY, "Transient error")); break;
+ case TRANSIENT_ERROR: replyError(target, new com.yahoo.messagebus.Error(DocumentProtocol.ERROR_ABORTED, "Transient error")); break;
case FATAL_ERROR: replyError(target, new com.yahoo.messagebus.Error(DocumentProtocol.ERROR_UNPARSEABLE, "Fatal error")); break;
case OLD_CLUSTER_STATE:
case RESET_CLUSTER_STATE:
diff --git a/eval/CMakeLists.txt b/eval/CMakeLists.txt
index 2e0af3acfa7..eed4fa5ce66 100644
--- a/eval/CMakeLists.txt
+++ b/eval/CMakeLists.txt
@@ -75,6 +75,7 @@ vespa_define_module(
src/tests/instruction/mixed_simple_join_function
src/tests/instruction/pow_as_map_optimizer
src/tests/instruction/remove_trivial_dimension_optimizer
+ src/tests/instruction/sparse_112_dot_product
src/tests/instruction/sparse_dot_product_function
src/tests/instruction/sparse_full_overlap_join_function
src/tests/instruction/sparse_merge_function
diff --git a/eval/src/tests/instruction/sparse_112_dot_product/CMakeLists.txt b/eval/src/tests/instruction/sparse_112_dot_product/CMakeLists.txt
new file mode 100644
index 00000000000..af7f59f091b
--- /dev/null
+++ b/eval/src/tests/instruction/sparse_112_dot_product/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(eval_sparse_112_dot_product_test_app TEST
+ SOURCES
+ sparse_112_dot_product_test.cpp
+ DEPENDS
+ vespaeval
+ GTest::GTest
+)
+vespa_add_test(NAME eval_sparse_112_dot_product_test_app COMMAND eval_sparse_112_dot_product_test_app)
diff --git a/eval/src/tests/instruction/sparse_112_dot_product/sparse_112_dot_product_test.cpp b/eval/src/tests/instruction/sparse_112_dot_product/sparse_112_dot_product_test.cpp
new file mode 100644
index 00000000000..9325a203ff3
--- /dev/null
+++ b/eval/src/tests/instruction/sparse_112_dot_product/sparse_112_dot_product_test.cpp
@@ -0,0 +1,88 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/eval/eval/fast_value.h>
+#include <vespa/eval/eval/simple_value.h>
+#include <vespa/eval/instruction/sparse_112_dot_product.h>
+#include <vespa/eval/eval/test/eval_fixture.h>
+#include <vespa/eval/eval/test/gen_spec.h>
+#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/vespalib/gtest/gtest.h>
+
+using namespace vespalib::eval;
+using namespace vespalib::eval::test;
+
+using vespalib::make_string_short::fmt;
+
+const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
+
+//-----------------------------------------------------------------------------
+
+struct FunInfo {
+ using LookFor = Sparse112DotProduct;
+ void verify(const LookFor &fun) const {
+ EXPECT_TRUE(fun.result_is_mutable());
+ }
+};
+
+void verify_optimized_cell_types(const vespalib::string &expr)
+{
+ CellTypeSpace types(CellTypeUtils::list_types(), 3);
+ EvalFixture::verify<FunInfo>(expr, {FunInfo()}, CellTypeSpace(types).same());
+ EvalFixture::verify<FunInfo>(expr, {}, CellTypeSpace(types).different());
+}
+
+void verify_optimized(const vespalib::string &expr, size_t num_params = 3)
+{
+ CellTypeSpace just_float({CellType::FLOAT}, num_params);
+ EvalFixture::verify<FunInfo>(expr, {FunInfo()}, just_float);
+}
+
+void verify_not_optimized(const vespalib::string &expr) {
+ CellTypeSpace just_double({CellType::DOUBLE}, 3);
+ EvalFixture::verify<FunInfo>(expr, {}, just_double);
+}
+
+//-----------------------------------------------------------------------------
+
+TEST(Sparse112DotProduct, expression_can_be_optimized)
+{
+ verify_optimized_cell_types("reduce(x5_2*y4_2*x5_1y4_1,sum)");
+}
+
+TEST(Sparse112DotProduct, different_input_placement_is_handled)
+{
+ std::array<vespalib::string,3> params = {"x3_1", "y3_1", "x3_1y3_1"};
+ for (size_t p1 = 0; p1 < params.size(); ++p1) {
+ for (size_t p2 = 0; p2 < params.size(); ++p2) {
+ for (size_t p3 = 0; p3 < params.size(); ++p3) {
+ if ((p1 != p2) && (p1 != p3) && (p2 != p3)) {
+ verify_optimized(fmt("reduce((%s*%s)*%s,sum)", params[p1].c_str(), params[p2].c_str(), params[p3].c_str()));
+ verify_optimized(fmt("reduce(%s*(%s*%s),sum)", params[p1].c_str(), params[p2].c_str(), params[p3].c_str()));
+ }
+ }
+ }
+ }
+}
+
+TEST(Sparse112DotProduct, expression_can_be_optimized_with_extra_tensors)
+{
+ verify_optimized("reduce((x5_2*y4_2)*(x5_1y4_1*x3_1),sum)", 4);
+ verify_optimized("reduce((x5_2*x3_1)*(y4_2*x5_1y4_1),sum)", 4);
+}
+
+TEST(Sparse112DotProduct, similar_expressions_are_not_optimized)
+{
+ verify_not_optimized("reduce(x5_2*y4_2*x5_1y4_1,prod)");
+ verify_not_optimized("reduce(x5_2+y4_2*x5_1y4_1,sum)");
+ verify_not_optimized("reduce(x5_2*y4_2+x5_1y4_1,sum)");
+ verify_not_optimized("reduce(x5_2*z4_2*x5_1y4_1,sum)");
+ verify_not_optimized("reduce(x5_2*y4_2*x5_1z4_1,sum)");
+ verify_not_optimized("reduce(x5_2*x1_1y4_2*x5_1y4_1,sum)");
+ verify_not_optimized("reduce(x5_2*y4_2*x5_1,sum)");
+ verify_not_optimized("reduce(x5*y4*x5y4,sum)");
+ verify_not_optimized("reduce(x5*y4_1*x5y4_1,sum)");
+}
+
+//-----------------------------------------------------------------------------
+
+GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/eval/src/vespa/eval/eval/fast_value.hpp b/eval/src/vespa/eval/eval/fast_value.hpp
index 66b44dbbf49..185529b2f51 100644
--- a/eval/src/vespa/eval/eval/fast_value.hpp
+++ b/eval/src/vespa/eval/eval/fast_value.hpp
@@ -153,6 +153,10 @@ inline bool are_fast(const Value::Index &a, const Value::Index &b) {
return (is_fast(a) && is_fast(b));
}
+inline bool are_fast(const Value::Index &a, const Value::Index &b, const Value::Index &c) {
+ return (is_fast(a) && is_fast(b) && is_fast(c));
+}
+
constexpr const FastValueIndex &as_fast(const Value::Index &index) {
return static_cast<const FastValueIndex &>(index);
}
@@ -234,7 +238,16 @@ struct FastValue final : Value, ValueBuilder<T> {
~FastValue() override;
const ValueType &type() const override { return my_type; }
const Value::Index &index() const override { return my_index; }
- TypedCells cells() const override { return TypedCells(my_cells.memory, get_cell_type<T>(), my_cells.size); }
+ TypedCells cells() const override {
+ if constexpr (std::is_same_v<T, uint32_t>) {
+ // allow use of FastValue templated on types that do not
+ // have a corresponding cell type as long as cells() is
+ // not called
+ abort();
+ } else {
+ return TypedCells(my_cells.memory, get_cell_type<T>(), my_cells.size);
+ }
+ }
void add_mapping(ConstArrayRef<vespalib::stringref> addr) {
if constexpr (transient) {
(void) addr;
@@ -273,6 +286,12 @@ struct FastValue final : Value, ValueBuilder<T> {
add_mapping(addr);
return my_cells.add_cells(my_subspace_size);
}
+ ArrayRef<T> get_subspace(size_t subspace) {
+ return {my_cells.get(subspace * my_subspace_size), my_subspace_size};
+ }
+ ConstArrayRef<T> get_raw_cells() const {
+ return {my_cells.get(0), my_cells.size};
+ }
std::unique_ptr<Value> build(std::unique_ptr<ValueBuilder<T>> self) override {
if (my_index.map.addr_size() == 0) {
assert(my_index.map.size() == 1);
diff --git a/eval/src/vespa/eval/eval/interpreted_function.h b/eval/src/vespa/eval/eval/interpreted_function.h
index b5eaf3a8b9c..57d7f79caf4 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.h
+++ b/eval/src/vespa/eval/eval/interpreted_function.h
@@ -50,6 +50,11 @@ public:
stack.pop_back();
stack.back() = value;
}
+ void pop_pop_pop_push(const Value &value) {
+ stack.pop_back();
+ stack.pop_back();
+ stack.back() = value;
+ }
void pop_n_push(size_t n, const Value &value) {
stack.resize(stack.size() - (n - 1), value);
stack.back() = value;
diff --git a/eval/src/vespa/eval/eval/optimize_tensor_function.cpp b/eval/src/vespa/eval/eval/optimize_tensor_function.cpp
index e1520d4deb2..f9d3b1c6f54 100644
--- a/eval/src/vespa/eval/eval/optimize_tensor_function.cpp
+++ b/eval/src/vespa/eval/eval/optimize_tensor_function.cpp
@@ -6,6 +6,7 @@
#include <vespa/eval/instruction/dense_dot_product_function.h>
#include <vespa/eval/instruction/sparse_dot_product_function.h>
+#include <vespa/eval/instruction/sparse_112_dot_product.h>
#include <vespa/eval/instruction/sparse_merge_function.h>
#include <vespa/eval/instruction/sparse_no_overlap_join_function.h>
#include <vespa/eval/instruction/sparse_full_overlap_join_function.h>
@@ -65,6 +66,7 @@ const TensorFunction &optimize_for_factory(const ValueBuilderFactory &, const Te
});
run_optimize_pass(root, [&stash](const Child &child)
{
+ child.set(Sparse112DotProduct::optimize(child.get(), stash));
child.set(BestSimilarityFunction::optimize(child.get(), stash));
child.set(L2Distance::optimize(child.get(), stash));
});
diff --git a/eval/src/vespa/eval/instruction/CMakeLists.txt b/eval/src/vespa/eval/instruction/CMakeLists.txt
index 56184c113d4..b614606199c 100644
--- a/eval/src/vespa/eval/instruction/CMakeLists.txt
+++ b/eval/src/vespa/eval/instruction/CMakeLists.txt
@@ -36,6 +36,7 @@ vespa_add_library(eval_instruction OBJECT
pow_as_map_optimizer.cpp
remove_trivial_dimension_optimizer.cpp
replace_type_function.cpp
+ sparse_112_dot_product.cpp
sparse_dot_product_function.cpp
sparse_full_overlap_join_function.cpp
sparse_merge_function.cpp
diff --git a/eval/src/vespa/eval/instruction/generic_create.cpp b/eval/src/vespa/eval/instruction/generic_create.cpp
index c0be28a2475..11fd2437601 100644
--- a/eval/src/vespa/eval/instruction/generic_create.cpp
+++ b/eval/src/vespa/eval/instruction/generic_create.cpp
@@ -2,7 +2,7 @@
#include "generic_create.h"
#include <vespa/eval/eval/wrap_param.h>
-#include <vespa/eval/eval/array_array_map.h>
+#include <vespa/eval/eval/fast_value.hpp>
#include <vespa/vespalib/util/stash.h>
#include <vespa/vespalib/util/typify.h>
#include <vespa/vespalib/util/shared_string_repo.h>
@@ -19,35 +19,33 @@ using Handle = SharedStringRepo::Handle;
namespace {
struct CreateParam {
- const ValueType res_type;
- size_t num_mapped_dims;
- size_t dense_subspace_size;
+ static constexpr uint32_t npos = -1;
+ FastValue<uint32_t, false> my_spec;
size_t num_children;
- ArrayArrayMap<Handle,size_t> my_spec;
- const ValueBuilderFactory &factory;
- static constexpr size_t npos = -1;
-
- ArrayRef<size_t> indexes(ConstArrayRef<Handle> key) {
- auto [tag, first_time] = my_spec.lookup_or_add_entry(key);
- auto rv = my_spec.get_values(tag);
- if (first_time) {
- for (auto & v : rv) {
- v = npos;
- }
+ ArrayRef<uint32_t> indexes(ConstArrayRef<Handle> key) {
+ SmallVector<string_id> my_key;
+ for (const auto &label: key) {
+ my_key.push_back(label.id());
+ }
+ auto old_subspace = my_spec.my_index.map.lookup(ConstArrayRef<string_id>(my_key));
+ if (old_subspace != FastAddrMap::npos()) {
+ return my_spec.get_subspace(old_subspace);
}
- return rv;
+ auto new_subspace = my_spec.add_subspace(my_key);
+ for (auto &stack_idx: new_subspace) {
+ stack_idx = npos;
+ }
+ return new_subspace;
}
- CreateParam(const ValueType &res_type_in,
- const GenericCreate::SpecMap &spec_in,
- const ValueBuilderFactory &factory_in)
- : res_type(res_type_in),
- num_mapped_dims(res_type.count_mapped_dimensions()),
- dense_subspace_size(res_type.dense_subspace_size()),
- num_children(spec_in.size()),
- my_spec(num_mapped_dims, dense_subspace_size, spec_in.size() / dense_subspace_size),
- factory(factory_in)
+ CreateParam(const ValueType &res_type,
+ const GenericCreate::SpecMap &spec_in)
+ : my_spec(res_type,
+ res_type.count_mapped_dimensions(),
+ res_type.dense_subspace_size(),
+ spec_in.size() / res_type.dense_subspace_size()),
+ num_children(spec_in.size())
{
size_t last_child = num_children - 1;
for (const auto & entry : spec_in) {
@@ -67,7 +65,6 @@ struct CreateParam {
}
}
assert(binding == entry.first.end());
- assert(dense_key < dense_subspace_size);
// note: reverse order of children on stack
size_t stack_idx = last_child - entry.second;
indexes(sparse_key)[dense_key] = stack_idx;
@@ -75,37 +72,24 @@ struct CreateParam {
}
};
-template <typename T>
+template <typename CT>
void my_generic_create_op(State &state, uint64_t param_in) {
const auto &param = unwrap_param<CreateParam>(param_in);
- auto builder = param.factory.create_transient_value_builder<T>(param.res_type,
- param.num_mapped_dims,
- param.dense_subspace_size,
- param.my_spec.size());
- SmallVector<string_id> sparse_addr;
- param.my_spec.each_entry([&](const auto &key, const auto &values)
- {
- sparse_addr.clear();
- for (const auto & label : key) {
- sparse_addr.push_back(label.id());
- }
- T *dst = builder->add_subspace(sparse_addr).begin();
- for (size_t stack_idx : values) {
- if (stack_idx == CreateParam::npos) {
- *dst++ = T{};
- } else {
- const Value &child = state.peek(stack_idx);
- *dst++ = child.as_double();
- }
- }
- });
- const Value &result = *state.stash.create<Value::UP>(builder->build(std::move(builder)));
+ auto spec = param.my_spec.get_raw_cells();
+ auto cells = state.stash.create_uninitialized_array<CT>(spec.size());
+ CT *dst = cells.begin();
+ for (uint32_t stack_idx: spec) {
+ *dst++ = ((stack_idx != CreateParam::npos)
+ ? (CT) state.peek(stack_idx).as_double()
+ : CT{});
+ }
+ const Value &result = state.stash.create<ValueView>(param.my_spec.type(), param.my_spec.my_index, TypedCells(cells));
state.pop_n_push(param.num_children, result);
};
struct SelectGenericCreateOp {
- template <typename T> static auto invoke() {
- return my_generic_create_op<T>;
+ template <typename CT> static auto invoke() {
+ return my_generic_create_op<CT>;
}
};
@@ -116,10 +100,10 @@ struct SelectGenericCreateOp {
Instruction
GenericCreate::make_instruction(const ValueType &result_type,
const SpecMap &spec,
- const ValueBuilderFactory &factory,
+ const ValueBuilderFactory &,
Stash &stash)
{
- const auto &param = stash.create<CreateParam>(result_type, spec, factory);
+ const auto &param = stash.create<CreateParam>(result_type, spec);
auto fun = typify_invoke<1,TypifyCellType,SelectGenericCreateOp>(result_type.cell_type());
return Instruction(fun, wrap_param<CreateParam>(param));
}
diff --git a/eval/src/vespa/eval/instruction/sparse_112_dot_product.cpp b/eval/src/vespa/eval/instruction/sparse_112_dot_product.cpp
new file mode 100644
index 00000000000..080f51e384a
--- /dev/null
+++ b/eval/src/vespa/eval/instruction/sparse_112_dot_product.cpp
@@ -0,0 +1,236 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "sparse_112_dot_product.h"
+#include <vespa/eval/eval/fast_value.hpp>
+#include <vespa/vespalib/util/typify.h>
+#include <vespa/vespalib/util/require.h>
+#include <vespa/eval/eval/visit_stuff.h>
+#include <algorithm>
+
+namespace vespalib::eval {
+
+using namespace tensor_function;
+using namespace operation;
+using namespace instruction;
+
+namespace {
+
+template <typename T, size_t N>
+ConstArrayRef<T> as_car(std::array<T, N> &array) {
+ return {array.data(), array.size()};
+}
+
+template <typename T, size_t N>
+ConstArrayRef<const T *> as_ccar(std::array<T *, N> &array) {
+ return {array.data(), array.size()};
+}
+
+template <typename T>
+ConstArrayRef<T> as_car(T &value) {
+ return {&value, 1};
+}
+
+constexpr std::array<size_t, 2> both_dims = { 0, 1 };
+
+template <typename CT>
+double my_sparse_112_dot_product_fallback(const Value::Index &a_idx, const Value::Index &b_idx, const Value::Index &c_idx,
+ const CT *a_cells, const CT *b_cells, const CT *c_cells) __attribute__((noinline));
+template <typename CT>
+double my_sparse_112_dot_product_fallback(const Value::Index &a_idx, const Value::Index &b_idx, const Value::Index &c_idx,
+ const CT *a_cells, const CT *b_cells, const CT *c_cells)
+{
+ double result = 0.0;
+ size_t a_space = 0;
+ size_t b_space = 0;
+ size_t c_space = 0;
+ std::array<string_id, 2> c_addr;
+ std::array<string_id*, 2> c_addr_ref = {&c_addr[0], &c_addr[1]};
+ auto outer = a_idx.create_view({});
+ auto inner = b_idx.create_view({});
+ auto model = c_idx.create_view({&both_dims[0], 2});
+ outer->lookup({});
+ while (outer->next_result(as_car(c_addr_ref[0]), a_space)) {
+ inner->lookup({});
+ while (inner->next_result(as_car(c_addr_ref[1]), b_space)) {
+ model->lookup(as_ccar(c_addr_ref));
+ if (model->next_result({}, c_space)) {
+ result += (a_cells[a_space] * b_cells[b_space] * c_cells[c_space]);
+ }
+ }
+ }
+ return result;
+}
+
+template <typename CT>
+double my_fast_sparse_112_dot_product(const FastAddrMap *a_map, const FastAddrMap *b_map, const FastAddrMap *c_map,
+ const CT *a_cells, const CT *b_cells, const CT *c_cells)
+{
+ double result = 0.0;
+ std::array<string_id, 2> c_addr;
+ const auto &a_labels = a_map->labels();
+ for (size_t a_space = 0; a_space < a_labels.size(); ++a_space) {
+ if (a_cells[a_space] != 0.0) { // handle pseudo-sparse input
+ c_addr[0] = a_labels[a_space];
+ const auto &b_labels = b_map->labels();
+ for (size_t b_space = 0; b_space < b_labels.size(); ++b_space) {
+ if (b_cells[b_space] != 0.0) { // handle pseudo-sparse input
+ c_addr[1] = b_labels[b_space];
+ auto c_space = c_map->lookup(as_car(c_addr));
+ if (c_space != FastAddrMap::npos()) {
+ result += (a_cells[a_space] * b_cells[b_space] * c_cells[c_space]);
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+template <typename CT>
+void my_sparse_112_dot_product_op(InterpretedFunction::State &state, uint64_t) {
+ const auto &a_idx = state.peek(2).index();
+ const auto &b_idx = state.peek(1).index();
+ const auto &c_idx = state.peek(0).index();
+ const CT *a_cells = state.peek(2).cells().unsafe_typify<CT>().cbegin();
+ const CT *b_cells = state.peek(1).cells().unsafe_typify<CT>().cbegin();
+ const CT *c_cells = state.peek(0).cells().unsafe_typify<CT>().cbegin();
+ double result = __builtin_expect(are_fast(a_idx, b_idx, c_idx), true)
+ ? my_fast_sparse_112_dot_product<CT>(&as_fast(a_idx).map, &as_fast(b_idx).map, &as_fast(c_idx).map,
+ a_cells, b_cells, c_cells)
+ : my_sparse_112_dot_product_fallback<CT>(a_idx, b_idx, c_idx, a_cells, b_cells, c_cells);
+ state.pop_pop_pop_push(state.stash.create<DoubleValue>(result));
+}
+
+struct MyGetFun {
+ template <typename CT>
+ static auto invoke() { return my_sparse_112_dot_product_op<CT>; }
+};
+
+using MyTypify = TypifyValue<TypifyCellType>;
+
+// Try to collect input nodes and organize them into a dot product
+// between (n sparse non-overlapping single-dimension tensors) and (a
+// sparse n-dimensional tensor) all having the same cell type.
+
+struct InputState {
+ std::vector<const TensorFunction *> single;
+ const TensorFunction *multi = nullptr;
+ bool collision = false;
+
+ void collect(const TensorFunction &node) {
+ const auto &type = node.result_type();
+ if (type.is_sparse()) {
+ if (type.dimensions().size() == 1) {
+ single.push_back(&node);
+ } else {
+ if (multi) {
+ collision = true;
+ } else {
+ multi = &node;
+ }
+ }
+ }
+ }
+ void finalize() {
+ std::sort(single.begin(), single.end(), [](const auto *a, const auto *b)
+ { return (a->result_type().dimensions()[0].name < b->result_type().dimensions()[0].name); });
+ }
+ bool verify(size_t n) const {
+ if (collision || (single.size() != n) || (multi == nullptr) || (multi->result_type().dimensions().size() != n)) {
+ return false;
+ }
+ const auto &multi_type = multi->result_type();
+ for (size_t i = 0; i < n; ++i) {
+ const auto &single_type = single[i]->result_type();
+ if ((single_type.cell_type() != multi_type.cell_type()) ||
+ (single_type.dimensions()[0].name != multi_type.dimensions()[i].name))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+};
+
+// Try to find inputs that form a 112 dot product.
+
+struct FindInputs {
+ const TensorFunction *a = nullptr;
+ const TensorFunction *b = nullptr;
+ const TensorFunction *c = nullptr;
+
+ bool try_match(const TensorFunction &one, const TensorFunction &two) {
+ auto join = as<Join>(two);
+ if (join && (join->function() == Mul::f)) {
+ InputState state;
+ state.collect(one);
+ state.collect(join->lhs());
+ state.collect(join->rhs());
+ state.finalize();
+ if (state.verify(2)) {
+ a = state.single[0];
+ b = state.single[1];
+ c = state.multi;
+ return true;
+ }
+ }
+ return false;
+ }
+};
+
+} // namespace <unnamed>
+
+Sparse112DotProduct::Sparse112DotProduct(const TensorFunction &a_in,
+ const TensorFunction &b_in,
+ const TensorFunction &c_in)
+ : tensor_function::Node(DoubleValue::shared_type()),
+ _a(a_in),
+ _b(b_in),
+ _c(c_in)
+{
+}
+
+InterpretedFunction::Instruction
+Sparse112DotProduct::compile_self(const ValueBuilderFactory &, Stash &) const
+{
+ REQUIRE_EQ(_a.get().result_type().cell_type(), _b.get().result_type().cell_type());
+ REQUIRE_EQ(_a.get().result_type().cell_type(), _c.get().result_type().cell_type());
+ auto op = typify_invoke<1,MyTypify,MyGetFun>(_a.get().result_type().cell_type());
+ return InterpretedFunction::Instruction(op);
+}
+
+void
+Sparse112DotProduct::push_children(std::vector<Child::CREF> &children) const
+{
+ children.emplace_back(_a);
+ children.emplace_back(_b);
+ children.emplace_back(_c);
+}
+
+void
+Sparse112DotProduct::visit_children(vespalib::ObjectVisitor &visitor) const
+{
+ ::visit(visitor, "a", _a.get());
+ ::visit(visitor, "b", _b.get());
+ ::visit(visitor, "c", _c.get());
+}
+
+const TensorFunction &
+Sparse112DotProduct::optimize(const TensorFunction &expr, Stash &stash)
+{
+ auto reduce = as<Reduce>(expr);
+ if (reduce && (reduce->aggr() == Aggr::SUM) && expr.result_type().is_double()) {
+ auto join = as<Join>(reduce->child());
+ if (join && (join->function() == Mul::f)) {
+ FindInputs inputs;
+ if (inputs.try_match(join->lhs(), join->rhs()) ||
+ inputs.try_match(join->rhs(), join->lhs()))
+ {
+ return stash.create<Sparse112DotProduct>(*inputs.a, *inputs.b, *inputs.c);
+ }
+ }
+ }
+ return expr;
+}
+
+} // namespace
diff --git a/eval/src/vespa/eval/instruction/sparse_112_dot_product.h b/eval/src/vespa/eval/instruction/sparse_112_dot_product.h
new file mode 100644
index 00000000000..2344a5eee2d
--- /dev/null
+++ b/eval/src/vespa/eval/instruction/sparse_112_dot_product.h
@@ -0,0 +1,31 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/eval/eval/tensor_function.h>
+
+namespace vespalib::eval {
+
+/**
+ * Tensor function for the dot product between the expansion of two 1d
+ * sparse tensors and a 2d sparse tensor.
+ */
+class Sparse112DotProduct : public tensor_function::Node
+{
+private:
+ Child _a;
+ Child _b;
+ Child _c;
+
+public:
+ Sparse112DotProduct(const TensorFunction &a_in,
+ const TensorFunction &b_in,
+ const TensorFunction &c_in);
+ InterpretedFunction::Instruction compile_self(const ValueBuilderFactory &factory, Stash &stash) const override;
+ bool result_is_mutable() const override { return true; }
+ void push_children(std::vector<Child::CREF> &children) const final override;
+ void visit_children(vespalib::ObjectVisitor &visitor) const final override;
+ static const TensorFunction &optimize(const TensorFunction &expr, Stash &stash);
+};
+
+} // namespace
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
index 97b06c802dd..5ef22580f28 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
@@ -47,21 +47,28 @@ public class Flags {
public static final UnboundDoubleFlag DEFAULT_TERM_WISE_LIMIT = defineDoubleFlag(
"default-term-wise-limit", 1.0,
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Default limit for when to apply termwise query evaluation",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
+ public static final UnboundDoubleFlag TLS_SIZE_FRACTION = defineDoubleFlag(
+ "tls-size-fraction", 0.07,
+ List.of("baldersheim"), "2021-12-20", "2022-02-01",
+ "Fraction of disk available for transaction log",
+ "Takes effect at redeployment",
+ ZONE_ID, APPLICATION_ID);
+
public static final UnboundStringFlag FEED_SEQUENCER_TYPE = defineStringFlag(
"feed-sequencer-type", "LATENCY",
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Selects type of sequenced executor used for feeding in proton, valid values are LATENCY, ADAPTIVE, THROUGHPUT",
"Takes effect at redeployment (requires restart)",
ZONE_ID, APPLICATION_ID);
public static final UnboundIntFlag FEED_TASK_LIMIT = defineIntFlag(
"feed-task-limit", 1000,
- List.of("geirst, baldersheim"), "2021-10-14", "2022-01-01",
+ List.of("geirst, baldersheim"), "2021-10-14", "2022-02-01",
"The task limit used by the executors handling feed in proton",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
@@ -83,56 +90,56 @@ public class Flags {
public static final UnboundIntFlag MAX_UNCOMMITTED_MEMORY = defineIntFlag(
"max-uncommitted-memory", 130000,
- List.of("geirst, baldersheim"), "2021-10-21", "2022-01-01",
+ List.of("geirst, baldersheim"), "2021-10-21", "2022-02-01",
"Max amount of memory holding updates to an attribute before we do a commit.",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundStringFlag RESPONSE_SEQUENCER_TYPE = defineStringFlag(
"response-sequencer-type", "ADAPTIVE",
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Selects type of sequenced executor used for mbus responses, valid values are LATENCY, ADAPTIVE, THROUGHPUT",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundIntFlag RESPONSE_NUM_THREADS = defineIntFlag(
"response-num-threads", 2,
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Number of threads used for mbus responses, default is 2, negative number = numcores/4",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundBooleanFlag SKIP_COMMUNICATIONMANAGER_THREAD = defineFeatureFlag(
"skip-communicationmanager-thread", false,
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Should we skip the communicationmanager thread",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundBooleanFlag SKIP_MBUS_REQUEST_THREAD = defineFeatureFlag(
"skip-mbus-request-thread", false,
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Should we skip the mbus request thread",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundBooleanFlag SKIP_MBUS_REPLY_THREAD = defineFeatureFlag(
"skip-mbus-reply-thread", false,
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Should we skip the mbus reply thread",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundBooleanFlag USE_THREE_PHASE_UPDATES = defineFeatureFlag(
"use-three-phase-updates", false,
- List.of("vekterli"), "2020-12-02", "2022-01-01",
+ List.of("vekterli"), "2020-12-02", "2022-02-01",
"Whether to enable the use of three-phase updates when bucket replicas are out of sync.",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundBooleanFlag HIDE_SHARED_ROUTING_ENDPOINT = defineFeatureFlag(
"hide-shared-routing-endpoint", false,
- List.of("tokle", "bjormel"), "2020-12-02", "2022-01-01",
+ List.of("tokle", "bjormel"), "2020-12-02", "2022-02-01",
"Whether the controller should hide shared routing layer endpoint",
"Takes effect immediately",
APPLICATION_ID
@@ -140,35 +147,35 @@ public class Flags {
public static final UnboundBooleanFlag USE_ASYNC_MESSAGE_HANDLING_ON_SCHEDULE = defineFeatureFlag(
"async-message-handling-on-schedule", false,
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"Optionally deliver async messages in own thread",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundDoubleFlag FEED_CONCURRENCY = defineDoubleFlag(
"feed-concurrency", 0.5,
- List.of("baldersheim"), "2020-12-02", "2022-01-01",
+ List.of("baldersheim"), "2020-12-02", "2022-02-01",
"How much concurrency should be allowed for feed",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundDoubleFlag DISK_BLOAT_FACTOR = defineDoubleFlag(
"disk-bloat-factor", 0.2,
- List.of("baldersheim"), "2021-10-08", "2022-01-01",
+ List.of("baldersheim"), "2021-10-08", "2022-02-01",
"Amount of bloat allowed before compacting file",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundIntFlag DOCSTORE_COMPRESSION_LEVEL = defineIntFlag(
"docstore-compression-level", 3,
- List.of("baldersheim"), "2021-10-08", "2022-01-01",
+ List.of("baldersheim"), "2021-10-08", "2022-02-01",
"Default compression level used for document store",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundIntFlag NUM_DEPLOY_HELPER_THREADS = defineIntFlag(
"num-model-builder-threads", -1,
- List.of("balder"), "2021-09-09", "2022-01-01",
+ List.of("balder"), "2021-09-09", "2022-02-01",
"Number of threads used for speeding up building of models.",
"Takes effect on first (re)start of config server");
@@ -181,14 +188,14 @@ public class Flags {
public static final UnboundBooleanFlag CONTAINER_DUMP_HEAP_ON_SHUTDOWN_TIMEOUT = defineFeatureFlag(
"container-dump-heap-on-shutdown-timeout", false,
- List.of("baldersheim"), "2021-09-25", "2022-01-01",
+ List.of("baldersheim"), "2021-09-25", "2022-02-01",
"Will trigger a heap dump during if container shutdown times out",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundDoubleFlag CONTAINER_SHUTDOWN_TIMEOUT = defineDoubleFlag(
"container-shutdown-timeout", 50.0,
- List.of("baldersheim"), "2021-09-25", "2022-01-01",
+ List.of("baldersheim"), "2021-09-25", "2022-02-01",
"Timeout for shutdown of a jdisc container",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
@@ -216,14 +223,14 @@ public class Flags {
public static final UnboundIntFlag MAX_CONCURRENT_MERGES_PER_NODE = defineIntFlag(
"max-concurrent-merges-per-node", 128,
- List.of("balder", "vekterli"), "2021-06-06", "2022-01-01",
+ List.of("balder", "vekterli"), "2021-06-06", "2022-02-01",
"Specifies max concurrent merges per content node.",
"Takes effect at redeploy",
ZONE_ID, APPLICATION_ID);
public static final UnboundIntFlag MAX_MERGE_QUEUE_SIZE = defineIntFlag(
"max-merge-queue-size", 1024,
- List.of("balder", "vekterli"), "2021-06-06", "2022-01-01",
+ List.of("balder", "vekterli"), "2021-06-06", "2022-02-01",
"Specifies max size of merge queue.",
"Takes effect at redeploy",
ZONE_ID, APPLICATION_ID);
@@ -238,7 +245,7 @@ public class Flags {
public static final UnboundIntFlag LARGE_RANK_EXPRESSION_LIMIT = defineIntFlag(
"large-rank-expression-limit", 8192,
- List.of("baldersheim"), "2021-06-09", "2022-01-01",
+ List.of("baldersheim"), "2021-06-09", "2022-02-01",
"Limit for size of rank expressions distributed by filedistribution",
"Takes effect on next internal redeployment",
APPLICATION_ID);
@@ -252,14 +259,14 @@ public class Flags {
public static final UnboundIntFlag METRICSPROXY_NUM_THREADS = defineIntFlag(
"metricsproxy-num-threads", 2,
- List.of("balder"), "2021-09-01", "2022-01-01",
+ List.of("balder"), "2021-09-01", "2022-02-01",
"Number of threads for metrics proxy",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
public static final UnboundBooleanFlag ENABLED_HORIZON_DASHBOARD = defineFeatureFlag(
"enabled-horizon-dashboard", false,
- List.of("olaa"), "2021-09-13", "2021-12-31",
+ List.of("olaa"), "2021-09-13", "2022-02-01",
"Enable Horizon dashboard",
"Takes effect immediately",
TENANT_ID, CONSOLE_USER_EMAIL
@@ -267,7 +274,7 @@ public class Flags {
public static final UnboundBooleanFlag ENABLE_ONPREM_TENANT_S3_ARCHIVE = defineFeatureFlag(
"enable-onprem-tenant-s3-archive", false,
- List.of("bjorncs"), "2021-09-14", "2021-12-31",
+ List.of("bjorncs"), "2021-09-14", "2022-02-01",
"Enable tenant S3 buckets in cd/main. Must be set on controller cluster only.",
"Takes effect immediately",
ZONE_ID, TENANT_ID
@@ -275,13 +282,13 @@ public class Flags {
public static final UnboundBooleanFlag DELETE_UNMAINTAINED_CERTIFICATES = defineFeatureFlag(
"delete-unmaintained-certificates", false,
- List.of("andreer"), "2021-09-23", "2021-12-21",
+ List.of("andreer"), "2021-09-23", "2022-02-01",
"Whether to delete certificates that are known by provider but not by controller",
"Takes effect on next run of EndpointCertificateMaintainer"
);
public static final UnboundBooleanFlag USE_NEW_ENDPOINT_CERTIFICATE_PROVIDER_URL = defineFeatureFlag(
- "use-new-endpoint-certificate-provider-url", false,
+ "use-new-endpoint-certificate-provider-url", true,
List.of("andreer"), "2021-12-14", "2022-01-14",
"Use the new URL for the endpoint certificate provider API",
"Takes effect immediately"
@@ -289,15 +296,15 @@ public class Flags {
public static final UnboundBooleanFlag ENABLE_TENANT_DEVELOPER_ROLE = defineFeatureFlag(
"enable-tenant-developer-role", false,
- List.of("bjorncs"), "2021-09-23", "2021-12-31",
+ List.of("bjorncs"), "2021-09-23", "2022-02-01",
"Enable tenant developer Athenz role in cd/main. Must be set on controller cluster only.",
"Takes effect immediately",
TENANT_ID
);
public static final UnboundBooleanFlag ENABLE_ROUTING_REUSE_PORT = defineFeatureFlag(
- "enable-routing-reuse-port", false,
- List.of("mortent"), "2021-09-29", "2021-12-31",
+ "enable-routing-reuse-port", true,
+ List.of("mortent"), "2021-09-29", "2022-02-01",
"Enable reuse port in routing configuration",
"Takes effect on container restart",
HOSTNAME
@@ -305,7 +312,7 @@ public class Flags {
public static final UnboundBooleanFlag ENABLE_TENANT_OPERATOR_ROLE = defineFeatureFlag(
"enable-tenant-operator-role", false,
- List.of("bjorncs"), "2021-09-29", "2021-12-31",
+ List.of("bjorncs"), "2021-09-29", "2022-02-01",
"Enable tenant specific operator roles in public systems. For controllers only.",
"Takes effect on subsequent maintainer invocation",
TENANT_ID
@@ -367,7 +374,7 @@ public class Flags {
public static final UnboundBooleanFlag USE_LEGACY_LB_SERVICES = defineFeatureFlag(
"use-legacy-lb-services", false,
- List.of("tokle"), "2021-11-22", "2021-12-31",
+ List.of("tokle"), "2021-11-22", "2022-02-01",
"Whether to generate routing table based on legacy lb-services config",
"Takes effect on container reboot",
ZONE_ID, HOSTNAME);
@@ -386,6 +393,20 @@ public class Flags {
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);
+ public static final UnboundBooleanFlag FAIL_DEPLOYMENT_WITH_INVALID_JVM_OPTIONS = defineFeatureFlag(
+ "fail-deployment-with-invalid-jvm-options", false,
+ List.of("hmusum"), "2021-12-20", "2022-01-20",
+ "Whether to fail deployments with invalid JVM options in services.xml",
+ "Takes effect at redeployment",
+ ZONE_ID, APPLICATION_ID);
+
+ public static final UnboundBooleanFlag ENABLE_SERVER_OCSP_STAPLING = defineFeatureFlag(
+ "enable-server-ocsp-stapling", false,
+ List.of("bjorncs"), "2021-12-17", "2022-06-01",
+ "Enable server OCSP stapling for jdisc containers",
+ "Takes effect on redeployment",
+ ZONE_ID, APPLICATION_ID);
+
/** WARNING: public for testing: All flags should be defined in {@link Flags}. */
public static UnboundBooleanFlag defineFeatureFlag(String flagId, boolean defaultValue, List<String> owners,
String createdAt, String expiresAt, String description,
diff --git a/indexinglanguage/pom.xml b/indexinglanguage/pom.xml
index cfc7b09a934..32d8068dfcd 100644
--- a/indexinglanguage/pom.xml
+++ b/indexinglanguage/pom.xml
@@ -44,6 +44,11 @@
<artifactId>predicate-search-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
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/linguistics/pom.xml b/linguistics/pom.xml
index a09f2ecb031..d9ab942a0b8 100644
--- a/linguistics/pom.xml
+++ b/linguistics/pom.xml
@@ -22,6 +22,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
@@ -61,10 +62,6 @@
<groupId>org.apache.opennlp</groupId>
<artifactId>opennlp-tools</artifactId>
</dependency>
- <dependency>
- <groupId>com.optimaize.languagedetector</groupId>
- <artifactId>language-detector</artifactId>
- </dependency>
</dependencies>
<build>
<plugins>
diff --git a/linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java b/linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java
new file mode 100644
index 00000000000..27c23d8d3e6
--- /dev/null
+++ b/linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java
@@ -0,0 +1,32 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.language.opennlp;
+
+import opennlp.tools.ngram.NGramCharModel;
+import opennlp.tools.util.normalizer.CharSequenceNormalizer;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Avoids using the unnecessarily slow {@link NGramCharModel}.
+ *
+ * @author jonmv
+ */
+public class DefaultLanguageDetectorContextGenerator extends opennlp.tools.langdetect.DefaultLanguageDetectorContextGenerator {
+
+ public DefaultLanguageDetectorContextGenerator(int minLength, int maxLength, CharSequenceNormalizer... normalizers) {
+ super(minLength, maxLength, normalizers);
+ }
+
+ @Override
+ public String[] getContext(CharSequence document) {
+ int[] normalized = normalizer.normalize(document).codePoints().map(Character::toLowerCase).toArray();
+ Set<String> grams = new HashSet<>();
+ for (int i = 0; i < normalized.length; i++)
+ for (int j = minLength; j <= maxLength && i + j < normalized.length; j++)
+ grams.add(new String(normalized, i, j));
+
+ return grams.toArray(new String[grams.size()]);
+ }
+
+}
diff --git a/linguistics/src/main/java/com/yahoo/language/opennlp/LanguageDetectorFactory.java b/linguistics/src/main/java/com/yahoo/language/opennlp/LanguageDetectorFactory.java
new file mode 100644
index 00000000000..305aead056b
--- /dev/null
+++ b/linguistics/src/main/java/com/yahoo/language/opennlp/LanguageDetectorFactory.java
@@ -0,0 +1,28 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.language.opennlp;
+
+import opennlp.tools.langdetect.LanguageDetectorContextGenerator;
+import opennlp.tools.util.normalizer.EmojiCharSequenceNormalizer;
+import opennlp.tools.util.normalizer.NumberCharSequenceNormalizer;
+import opennlp.tools.util.normalizer.ShrinkCharSequenceNormalizer;
+import opennlp.tools.util.normalizer.TwitterCharSequenceNormalizer;
+
+/**
+ * Overrides the UrlCharSequenceNormalizer, which has a bad regex, until fixed: https://issues.apache.org/jira/browse/OPENNLP-1350
+ *
+ * @author jonmv
+ */
+@SuppressWarnings("unused") // Loaded by black magic: specified in properties in the loaded model.
+public class LanguageDetectorFactory extends opennlp.tools.langdetect.LanguageDetectorFactory {
+
+ @Override
+ public LanguageDetectorContextGenerator getContextGenerator() {
+ return new DefaultLanguageDetectorContextGenerator(1, 3,
+ EmojiCharSequenceNormalizer.getInstance(),
+ UrlCharSequenceNormalizer.getInstance(),
+ TwitterCharSequenceNormalizer.getInstance(),
+ NumberCharSequenceNormalizer.getInstance(),
+ ShrinkCharSequenceNormalizer.getInstance());
+ }
+
+}
diff --git a/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java b/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java
new file mode 100644
index 00000000000..d7a7d3a4744
--- /dev/null
+++ b/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java
@@ -0,0 +1,92 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.language.opennlp;
+
+import com.yahoo.language.Language;
+import com.yahoo.language.detect.Detection;
+import com.yahoo.language.detect.Detector;
+import com.yahoo.language.detect.Hint;
+import com.yahoo.language.simple.SimpleDetector;
+import opennlp.tools.langdetect.LanguageDetectorConfig;
+import opennlp.tools.langdetect.LanguageDetectorME;
+import opennlp.tools.langdetect.LanguageDetectorModel;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+/**
+ * Detects text language using patched OpenNLP, with fallback to {@link SimpleDetector} for undetected CJK input.
+ *
+ * @author jonmv
+ */
+class OpenNlpDetector implements Detector {
+
+ private static final Object monitor = new Object();
+ private static LanguageDetectorModel model;
+
+ private final SimpleDetector simple = new SimpleDetector();
+ private final Map<String, Language> languagesByISO3 = new HashMap<>();
+ private final LanguageDetectorME detector;
+ private final LanguageDetectorConfig config;
+
+ OpenNlpDetector() {
+ detector = new LanguageDetectorME(loadModel());
+ config = new LanguageDetectorConfig();
+ config.setMinDiff(0.02);
+ config.setChunkSize(32);
+ config.setMaxLength(256);
+ for (Locale locale : Locale.getAvailableLocales()) {
+ Language language = Language.fromLocale(locale);
+ if (language != null)
+ languagesByISO3.put(locale.getISO3Language(), language);
+ }
+ }
+
+ private static LanguageDetectorModel loadModel() {
+ synchronized (monitor) {
+ if (model == null) {
+ try {
+ model = new LanguageDetectorModel(OpenNlpDetector.class.getResourceAsStream("/models/langdetect-183.bin"));
+ }
+ catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+ }
+ return model;
+ }
+
+ @Override
+ public Detection detect(byte[] input, int offset, int length, Hint hint) {
+ Charset encoding = Charset.forName(simple.guessEncoding(input, offset, length));
+ return new Detection(detectLanguage(new String(input, offset, length, encoding)), encoding.name(), false);
+ }
+
+ @Override
+ public Detection detect(ByteBuffer input, Hint hint) {
+ if (input.hasArray())
+ return detect(input.array(), input.arrayOffset() + input.position(), input.remaining(), hint);
+
+ byte[] buffer = new byte[input.remaining()];
+ input.get(buffer);
+ return detect(buffer, 0, buffer.length, hint);
+ }
+
+ @Override
+ public Detection detect(String input, Hint hint) {
+ return new Detection(detectLanguage(input), UTF_8.name(), false);
+ }
+
+ private Language detectLanguage(String input) {
+ var prediction = detector.probingPredictLanguages(input, config).getLanguages()[0];
+ var result = prediction.getConfidence() > 0.02 ? languagesByISO3.get(prediction.getLang()) : null;
+ return result != null ? result : simple.guessLanguage(input.substring(0, Math.min(input.length(), 256)));
+ }
+
+}
diff --git a/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java b/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java
index a27e726cda8..c749679024a 100644
--- a/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java
+++ b/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java
@@ -7,36 +7,21 @@ import com.yahoo.language.detect.Detector;
import com.yahoo.language.process.Tokenizer;
import com.yahoo.language.simple.SimpleDetector;
import com.yahoo.language.simple.SimpleLinguistics;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+import opennlp.tools.langdetect.LanguageDetectorModel;
/**
- * Returns a linguistics implementation based on OpenNlp,
- * and (optionally, default on) Optimaize for language detection.
+ * Returns a linguistics implementation based on OpenNlp.
*
* @author bratseth
+ * @author jonmv
*/
public class OpenNlpLinguistics extends SimpleLinguistics {
- private static final Logger log = Logger.getLogger(OpenNlpLinguistics.class.getName());
private final Detector detector;
- public OpenNlpLinguistics() {
- this(true);
- }
-
@Inject
- public OpenNlpLinguistics(OpennlpLinguisticsConfig config) {
- this(config.detector().enableOptimaize());
- }
-
- public OpenNlpLinguistics(boolean enableOptimaize) {
- this(enableOptimaize ? new OptimaizeDetector() : new SimpleDetector());
- log.log(Level.FINE, "using "+(enableOptimaize ? "Optimaize" : "Simple")+" detector");
- }
-
- private OpenNlpLinguistics(Detector detector) {
- this.detector = detector;
+ public OpenNlpLinguistics() {
+ this.detector = new OpenNlpDetector();
}
@Override
diff --git a/linguistics/src/main/java/com/yahoo/language/opennlp/OptimaizeDetector.java b/linguistics/src/main/java/com/yahoo/language/opennlp/OptimaizeDetector.java
deleted file mode 100644
index 83947c795fb..00000000000
--- a/linguistics/src/main/java/com/yahoo/language/opennlp/OptimaizeDetector.java
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.language.opennlp;
-
-import com.google.common.base.Optional;
-import com.optimaize.langdetect.LanguageDetector;
-import com.optimaize.langdetect.LanguageDetectorBuilder;
-import com.optimaize.langdetect.i18n.LdLocale;
-import com.optimaize.langdetect.ngram.NgramExtractors;
-import com.optimaize.langdetect.profiles.LanguageProfile;
-import com.optimaize.langdetect.profiles.LanguageProfileReader;
-import com.optimaize.langdetect.text.CommonTextObjectFactories;
-import com.optimaize.langdetect.text.TextObjectFactory;
-import com.yahoo.language.Language;
-import com.yahoo.language.detect.Detection;
-import com.yahoo.language.detect.Detector;
-import com.yahoo.language.detect.Hint;
-import com.yahoo.language.simple.SimpleDetector;
-import com.yahoo.text.Utf8;
-
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Locale;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-/**
- * Detects the language of some sample text using SimpleDetector for CJK and Optimaize otherwise.
- *
- * @author bratseth
- */
-public class OptimaizeDetector implements Detector {
-
- private static final Object initGuard = new Object();
- private static TextObjectFactory textObjectFactory = null;
- private static LanguageDetector languageDetector = null;
- private static final Logger log = Logger.getLogger(OptimaizeDetector.class.getName());
-
- static private void initOptimaize() {
- synchronized (initGuard) {
- if ((textObjectFactory != null) && (languageDetector != null)) return;
-
- // origin: https://github.com/optimaize/language-detector
- // load all languages:
- List<LanguageProfile> languageProfiles;
- try {
- languageProfiles = new LanguageProfileReader().readAllBuiltIn();
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
-
- //build language detector:
- languageDetector = LanguageDetectorBuilder.create(NgramExtractors.standard())
- .withProfiles(languageProfiles)
- .build();
-
- //create a text object factory
- textObjectFactory = CommonTextObjectFactories.forDetectingOnLargeText();
- }
- }
-
- private final SimpleDetector simpleDetector = new SimpleDetector();
-
- public OptimaizeDetector() {
- initOptimaize();
- }
-
- @Override
- public Detection detect(byte[] input, int offset, int length, Hint hint) {
- return new Detection(guessLanguage(input, offset, length), simpleDetector.guessEncoding(input), false);
- }
-
- @Override
- public Detection detect(ByteBuffer input, Hint hint) {
- byte[] buf = new byte[input.remaining()];
- input.get(buf, 0, buf.length);
- return detect(buf, 0, buf.length, hint);
- }
-
- @Override
- public Detection detect(String input, Hint hint) {
- return new Detection(guessLanguage(input), Utf8.getCharset().name(), false);
- }
-
- private Language guessLanguage(byte[] buf, int offset, int length) {
- return guessLanguage(Utf8.toString(buf, offset, length));
- }
-
- public Language guessLanguage(String input) {
- if (input == null || input.length() == 0) return Language.UNKNOWN;
-
- Language result = simpleDetector.guessLanguage(input);
- if (result != Language.UNKNOWN) return result;
-
- return guessLanguageUsingOptimaize(input);
- }
-
- private static Language guessLanguageUsingOptimaize(String input) {
- Optional<LdLocale> result = languageDetector.detect(textObjectFactory.forText(input));
- if ( ! result.isPresent()) return Language.UNKNOWN;
- log.log(Level.FINE, () -> "guessing language "+result.get()+" from input: "+input);
-
- return Language.fromLocale(new Locale(result.get().getLanguage()));
- }
-
-}
diff --git a/linguistics/src/main/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizer.java b/linguistics/src/main/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizer.java
new file mode 100644
index 00000000000..883319e2f8b
--- /dev/null
+++ b/linguistics/src/main/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizer.java
@@ -0,0 +1,31 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.language.opennlp;
+
+import opennlp.tools.util.normalizer.CharSequenceNormalizer;
+
+import java.util.regex.Pattern;
+
+/**
+ * Modifies {@link opennlp.tools.util.normalizer.UrlCharSequenceNormalizer} to avoid the bad email regex.
+ *
+ * @author jonmv
+ */
+public class UrlCharSequenceNormalizer implements CharSequenceNormalizer {
+
+ private static final Pattern URL_REGEX =
+ Pattern.compile("https?://[-_.?&~;+=/#0-9A-Za-z]+");
+ private static final Pattern MAIL_REGEX =
+ Pattern.compile("(?<![-+_.0-9A-Za-z])[-+_.0-9A-Za-z]+@[-0-9A-Za-z]+[-.0-9A-Za-z]+");
+
+ private static final UrlCharSequenceNormalizer INSTANCE = new UrlCharSequenceNormalizer();
+
+ public static UrlCharSequenceNormalizer getInstance() {
+ return INSTANCE;
+ }
+
+ public CharSequence normalize(CharSequence text) {
+ String modified = URL_REGEX.matcher(text).replaceAll(" ");
+ return MAIL_REGEX.matcher(modified).replaceAll(" ");
+ }
+
+}
diff --git a/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java b/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java
index 53b8ad7ad70..61d446cd8d0 100644
--- a/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java
+++ b/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java
@@ -130,10 +130,14 @@ public class SimpleDetector implements Detector {
}
public String guessEncoding(byte[] input) {
+ return guessEncoding(input, 0, input.length);
+ }
+
+ public String guessEncoding(byte[] input, int offset, int length) {
boolean isUtf8 = true;
boolean hasHighs = false;
scan:
- for (int i = 0; i < input.length; i++) {
+ for (int i = offset; i < offset + length; i++) {
final int l = isLeadingFor(input[i]);
if (l < 0 || i + l >= input.length) {
hasHighs = true;
diff --git a/linguistics/src/main/java/com/yahoo/language/simple/SimpleLinguistics.java b/linguistics/src/main/java/com/yahoo/language/simple/SimpleLinguistics.java
index 3ca46dcc4f1..b10beb8c9af 100644
--- a/linguistics/src/main/java/com/yahoo/language/simple/SimpleLinguistics.java
+++ b/linguistics/src/main/java/com/yahoo/language/simple/SimpleLinguistics.java
@@ -2,8 +2,7 @@
package com.yahoo.language.simple;
import com.google.inject.Inject;
-import com.yahoo.collections.Tuple2;
-import com.yahoo.component.Version;
+import com.yahoo.component.AbstractComponent;
import com.yahoo.language.Linguistics;
import com.yahoo.language.detect.Detector;
import com.yahoo.language.process.CharacterClasses;
@@ -16,7 +15,6 @@ import com.yahoo.language.process.Stemmer;
import com.yahoo.language.process.StemmerImpl;
import com.yahoo.language.process.Tokenizer;
import com.yahoo.language.process.Transformer;
-import com.yahoo.vespa.configdefinition.SpecialtokensConfig;
import java.util.List;
diff --git a/linguistics/src/main/resources/configdefinitions/language.opennlp.opennlp-linguistics.def b/linguistics/src/main/resources/configdefinitions/language.opennlp.opennlp-linguistics.def
deleted file mode 100644
index 361a8a5f50c..00000000000
--- a/linguistics/src/main/resources/configdefinitions/language.opennlp.opennlp-linguistics.def
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-namespace=language.opennlp
-
-# Enable Optimaize language detector
-detector.enableOptimaize bool default=true
-
diff --git a/linguistics/src/main/resources/models/langdetect-183.bin b/linguistics/src/main/resources/models/langdetect-183.bin
new file mode 100644
index 00000000000..c3cde217050
--- /dev/null
+++ b/linguistics/src/main/resources/models/langdetect-183.bin
Binary files differ
diff --git a/linguistics/src/test/java/com/yahoo/language/opennlp/OpenNlpDetectorTestCase.java b/linguistics/src/test/java/com/yahoo/language/opennlp/OpenNlpDetectorTestCase.java
new file mode 100644
index 00000000000..746ed10da1c
--- /dev/null
+++ b/linguistics/src/test/java/com/yahoo/language/opennlp/OpenNlpDetectorTestCase.java
@@ -0,0 +1,87 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.language.opennlp;
+
+import com.yahoo.language.Language;
+import com.yahoo.language.detect.Detector;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author jonmv
+ */
+public class OpenNlpDetectorTestCase {
+
+ @Test
+ public void testDetection() {
+ Detector detector = new OpenNlpDetector();
+
+ assertLanguage(Language.UNKNOWN,
+ "",
+ detector);
+
+ assertLanguage(Language.UNKNOWN,
+ "Hello!",
+ detector);
+
+ // from https://en.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.ENGLISH,
+ "Yahoo became a public company via an initial public offering in April 1996 and its stock price rose 600% within two years.",
+ detector);
+
+ // from https://de.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.GERMAN,
+ "1996 ging Yahoo mit 46 Angestellten an die Börse. 2009 arbeiteten insgesamt rund 13.500 Mitarbeiter für Yahoo.",
+ detector);
+
+ // from https://fr.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.FRENCH,
+ "À l'origine, Yahoo! était uniquement un annuaire Web.",
+ detector);
+
+ // Test fallback to SimpleDetector
+ assertLanguage(Language.CHINESE_TRADITIONAL, // CHINESE_SIMPLIFIED input
+ "我能吞下玻璃而不伤身体。",
+ detector);
+
+ // from https://zh.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.CHINESE_TRADITIONAL,
+ "Yahoo! Next是一个展示雅虎新技术、新产品的场所,目前在测试阶段。",
+ detector);
+
+ // from https://th.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.THAI,
+ "เดือนกรกฎาคม 2012 Yahoo! ก็ได้ประธานเจ้าหน้าที่บริหารคนใหม่ \"มาริสสา เมเยอร์\" อดีตผู้บริหารจาก Google มาทำหน้าที่พลิกฟื้นบริษัท",
+ detector);
+
+ // from https://ar.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.ARABIC,
+ "وفقًا لمزودي تحليلات الويب دائما كأليكسا وسميلارويب،وصل موقع ياهولأكثر من 7 مليارات مشاهدة شهريًا - حيث احتل المرتبة السادسة بين أكثر مواقع الويب زيارة على مستوى العالم في عام 2016.",
+ detector);
+
+ // from https://ko.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.KOREAN,
+ "야후!의 전신인 디렉터리 사이트는 1994년 1월에 스탠퍼드 대학교 출신의 제리 양과 데이비드 파일로가 만들었으며, 회사는 1995년 3월 2일에 설립되었다.",
+ detector);
+
+ // from https://ja.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.JAPANESE,
+ "日本では、ヤフー株式会社がYahoo!(後にベライゾンがアルタバに売却)とソフトバンクの合弁会社として1996年に設立した。",
+ detector);
+
+ // from https://ru.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.RUSSIAN,
+ "7 февраля 2000 года Yahoo.com подвергся DDoS атаке и на несколько часов приостановил работу.",
+ detector);
+
+ // from https://he.wikipedia.org/wiki/Yahoo
+ assertLanguage(Language.HEBREW,
+ "אתר יאהו! הוא אחד מאתרי האינטרנט הפופולריים ביותר בעולם, עם מעל 500 מיליון כניסות בכל יום",
+ detector);
+ }
+
+ private void assertLanguage(Language language, String input, Detector detector) {
+ assertEquals(language, detector.detect(input, null).getLanguage());
+ }
+
+}
diff --git a/linguistics/src/test/java/com/yahoo/language/opennlp/OptimaizeDetectorTestCase.java b/linguistics/src/test/java/com/yahoo/language/opennlp/OptimaizeDetectorTestCase.java
deleted file mode 100644
index 20b5de3b165..00000000000
--- a/linguistics/src/test/java/com/yahoo/language/opennlp/OptimaizeDetectorTestCase.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.language.opennlp;
-
-import com.yahoo.language.Language;
-import com.yahoo.language.detect.Detector;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author bratseth
- */
-public class OptimaizeDetectorTestCase {
-
- private static final Detector detector = new OptimaizeDetector();
-
- @Test
- public void testDetection() {
- assertLanguage(Language.UNKNOWN, "Hello!");
-
- // Test fallback to SimpleDetector
- assertLanguage(Language.CHINESE_TRADITIONAL, // CHINESE_SIMPLIFIED input
- "\u6211\u80FD\u541E\u4E0B\u73BB\u7483\u800C\u4E0D\u4F24\u8EAB\u4F53\u3002");
-
- // from https://ru.wikipedia.org/wiki/%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F
- assertLanguage(Language.RUSSIAN, "Материал из Википедии — свободной энциклопедии");
- // https://he.wikipedia.org/wiki/Yahoo!
- assertLanguage(Language.HEBREW, "אתר יאהו! הוא אחד מאתרי האינטרנט הפופולריים ביותר בעולם, עם מעל 500 מיליון כניסות בכל יום");
- }
-
- private static void assertLanguage(Language language, String input) {
- assertEquals(language, detector.detect(input, null).getLanguage());
- }
-
-}
diff --git a/linguistics/src/test/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizerTest.java b/linguistics/src/test/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizerTest.java
new file mode 100644
index 00000000000..a8c637bc6ec
--- /dev/null
+++ b/linguistics/src/test/java/com/yahoo/language/opennlp/UrlCharSequenceNormalizerTest.java
@@ -0,0 +1,20 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.language.opennlp;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author jonmv
+ */
+public class UrlCharSequenceNormalizerTest {
+
+ @Test
+ public void testNormalization() {
+ String text = "xxx+yyy_.dude@mail.com foo bar@baz_bax https://host.tld/path?query=boo a@b §boo@boo";
+ assertEquals(" foo _bax a@b § ",
+ UrlCharSequenceNormalizer.getInstance().normalize(text));
+ }
+
+}
diff --git a/logd/src/logd/watcher.cpp b/logd/src/logd/watcher.cpp
index 23d1580dbf4..c3752fcc3e8 100644
--- a/logd/src/logd/watcher.cpp
+++ b/logd/src/logd/watcher.cpp
@@ -366,7 +366,7 @@ Watcher::removeOldLogs(const char *prefix)
}
}
} else if (globresult == GLOB_NOMATCH) {
- LOG(info, "no old logfiles matching %s", pattern);
+ LOG(debug, "no old logfiles matching %s", pattern);
} else {
LOG(warning, "glob %s failed: %d", pattern, globresult);
}
diff --git a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java
index 2c897814b8c..2640fbc8db3 100644
--- a/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java
+++ b/messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java
@@ -53,9 +53,12 @@ public class RoutingTestCase {
static Slobrok slobrok;
static RetryTransientErrorsPolicy retryPolicy;
static TestServer srcServer, dstServer;
+ static int sessionNumber = 0;
SourceSession srcSession;
DestinationSession dstSession;
+ String sessName = "session";
+ String dstSessName = "dst/session";
@BeforeClass
public static void commonSetup() throws ListenFailedException {
@@ -85,12 +88,15 @@ public class RoutingTestCase {
srcServer.mb.putProtocol(new SimpleProtocol());
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME));
// create sessions:
+ ++sessionNumber;
+ sessName = "session" + sessionNumber;
+ dstSessName = "dst/" + sessName;
dstSession = dstServer.mb.createDestinationSession(
- new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
+ new DestinationSessionParams().setName(sessName).setMessageHandler(new Receptor()));
srcSession = srcServer.mb.createSourceSession(
new SourceSessionParams().setTimeout(600.0).setThrottlePolicy(null).setReplyHandler(new Receptor()));
// wait for session register visible:
- assertTrue(srcServer.waitSlobrok("dst/session", 1));
+ assertTrue(srcServer.waitSlobrok(dstSessName, 1));
}
@After
@@ -98,7 +104,7 @@ public class RoutingTestCase {
dstSession.destroy();
srcSession.destroy();
// wait for session unregister visible:
- assertTrue(srcServer.waitSlobrok("dst/session", 0));
+ assertTrue(srcServer.waitSlobrok(dstSessName, 0));
}
@Test
@@ -129,7 +135,7 @@ public class RoutingTestCase {
public void requireThatHopNameIsExpanded() {
log.log(Level.INFO, "Starting: requireThatHopNameIsExpanded");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
- .addHop(new HopSpec("dst", "dst/session")));
+ .addHop(new HopSpec("dst", dstSessName)));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -145,7 +151,7 @@ public class RoutingTestCase {
public void requireThatRouteDirectiveWorks() {
log.log(Level.INFO, "Starting: requireThatRouteDirectiveWorks");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
- .addRoute(new RouteSpec("dst").addHop("dst/session"))
+ .addRoute(new RouteSpec("dst").addHop(dstSessName))
.addHop(new HopSpec("dir", "route:dst")));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dir")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
@@ -162,7 +168,7 @@ public class RoutingTestCase {
public void requireThatRouteNameIsExpanded() {
log.log(Level.INFO, "Starting: requireThatRouteNameIsExpanded");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
- .addRoute(new RouteSpec("dst").addHop("dst/session")));
+ .addRoute(new RouteSpec("dst").addHop(dstSessName)));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -207,7 +213,7 @@ public class RoutingTestCase {
public void requireThatRouteExpansionOnlyReplacesFirstHop() {
log.log(Level.INFO, "Starting: requireThatRouteExpansionOnlyReplacesFirstHop");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
- .addRoute(new RouteSpec("foo").addHop("dst/session").addHop("bar")));
+ .addRoute(new RouteSpec("foo").addHop(dstSessName).addHop("bar")));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("route:foo baz")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -275,7 +281,7 @@ public class RoutingTestCase {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session]")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:"+dstSessName+"]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
@@ -289,7 +295,7 @@ public class RoutingTestCase {
@Test
public void requireThatTransientErrorsAreRetried() {
log.log(Level.INFO, "Starting: requireThatTransientErrorsAreRetried");
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse(dstSessName)).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
@@ -320,7 +326,7 @@ public class RoutingTestCase {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session]")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:"+dstSessName+"]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
@@ -339,41 +345,41 @@ public class RoutingTestCase {
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("Source session accepted a 3 byte message. 1 message(s) now pending.",
"Running routing policy 'Custom'.",
- "Selecting [dst/session].",
- "Component 'dst/session' selected by policy 'Custom'.",
- "Resolving 'dst/session'.",
- "Sending message (version ${VERSION}) from client to 'dst/session'",
- "Message (type 1) received at 'dst' for session 'session'.",
+ "Selecting ["+dstSessName+"].",
+ "Component '"+dstSessName+"' selected by policy 'Custom'.",
+ "Resolving '"+dstSessName+"'.",
+ "Sending message (version ${VERSION}) from client to '"+dstSessName+"'",
+ "Message (type 1) received at 'dst' for session '"+sessName+"'.",
"[APP_TRANSIENT_ERROR @ localhost]: err1",
"Sending reply (version ${VERSION}) from 'dst'.",
"Reply (type 0) received at client.",
"Routing policy 'Custom' merging replies.",
- "Merged [dst/session].",
+ "Merged ["+dstSessName+"].",
"Message scheduled for retry 1 in 0.0 seconds.",
"Resender resending message.",
"Running routing policy 'Custom'.",
- "Selecting [dst/session].",
- "Component 'dst/session' selected by policy 'Custom'.",
- "Resolving 'dst/session'.",
- "Sending message (version ${VERSION}) from client to 'dst/session'",
- "Message (type 1) received at 'dst' for session 'session'.",
+ "Selecting ["+dstSessName+"].",
+ "Component '"+dstSessName+"' selected by policy 'Custom'.",
+ "Resolving '"+dstSessName+"'.",
+ "Sending message (version ${VERSION}) from client to '"+dstSessName+"'",
+ "Message (type 1) received at 'dst' for session '"+sessName+"'.",
"[APP_TRANSIENT_ERROR @ localhost]: err2",
"Sending reply (version ${VERSION}) from 'dst'.",
"Reply (type 0) received at client.",
"Routing policy 'Custom' merging replies.",
- "Merged [dst/session].",
+ "Merged ["+dstSessName+"].",
"Message scheduled for retry 2 in 0.0 seconds.",
"Resender resending message.",
"Running routing policy 'Custom'.",
- "Selecting [dst/session].",
- "Component 'dst/session' selected by policy 'Custom'.",
- "Resolving 'dst/session'.",
- "Sending message (version ${VERSION}) from client to 'dst/session'",
- "Message (type 1) received at 'dst' for session 'session'.",
+ "Selecting ["+dstSessName+"].",
+ "Component '"+dstSessName+"' selected by policy 'Custom'.",
+ "Resolving '"+dstSessName+"'.",
+ "Sending message (version ${VERSION}) from client to '"+dstSessName+"'",
+ "Message (type 1) received at 'dst' for session '"+sessName+"'.",
"Sending reply (version ${VERSION}) from 'dst'.",
"Reply (type 0) received at client.",
"Routing policy 'Custom' merging replies.",
- "Merged [dst/session].",
+ "Merged ["+dstSessName+"].",
"Source session received reply. 0 message(s) now pending."),
reply.getTrace());
log.log(Level.INFO, "Finished: requireThatTransientErrorsAreRetriedWithPolicy");
@@ -383,14 +389,15 @@ public class RoutingTestCase {
public void requireThatRetryCanBeDisabled() {
log.log(Level.INFO, "Starting: requireThatRetryCanBeDisabled");
retryPolicy.setEnabled(false);
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse(dstSessName)).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
reply.swapState(msg);
reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "err"));
dstSession.reply(reply);
- assertNotNull(reply = ((Receptor)srcSession.getReplyHandler()).getReply(60));
+ reply = ((Receptor)srcSession.getReplyHandler()).getReply(60);
+ assertNotNull(reply);
System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.APP_TRANSIENT_ERROR, reply.getError(0).getCode());
@@ -403,7 +410,7 @@ public class RoutingTestCase {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session]")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:"+dstSessName+"]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
@@ -415,13 +422,13 @@ public class RoutingTestCase {
assertNotNull(reply = ((Receptor)srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- assertTrace(Arrays.asList("Selecting [dst/session].",
+ assertTrace(Arrays.asList("Selecting ["+dstSessName+"].",
"[APP_TRANSIENT_ERROR @ localhost]",
"-[APP_TRANSIENT_ERROR @ localhost]",
- "Merged [dst/session].",
- "Selecting [dst/session].",
+ "Merged ["+dstSessName+"].",
+ "Selecting ["+dstSessName+"].",
"Sending reply",
- "Merged [dst/session]."),
+ "Merged ["+dstSessName+"]."),
reply.getTrace());
log.log(Level.INFO, "Finished: requireThatRetryCallsSelect");
}
@@ -432,7 +439,7 @@ public class RoutingTestCase {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(false));
srcServer.mb.putProtocol(protocol);
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session]")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:"+dstSessName+"]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
@@ -444,13 +451,13 @@ public class RoutingTestCase {
assertNotNull(reply = ((Receptor)srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- assertTrace(Arrays.asList("Selecting [dst/session].",
+ assertTrace(Arrays.asList("Selecting ["+dstSessName+"].",
"[APP_TRANSIENT_ERROR @ localhost]",
"-[APP_TRANSIENT_ERROR @ localhost]",
- "Merged [dst/session].",
- "-Selecting [dst/session].",
+ "Merged ["+dstSessName+"].",
+ "-Selecting ["+dstSessName+"].",
"Sending reply",
- "Merged [dst/session]."),
+ "Merged ["+dstSessName+"]."),
reply.getTrace());
log.log(Level.INFO, "Finished: requireThatPolicyCanDisableReselectOnRetry");
}
@@ -462,7 +469,7 @@ public class RoutingTestCase {
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(true, ErrorCode.NO_ADDRESS_FOR_SERVICE));
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session,dst/unknown]")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:"+dstSessName+",dst/unknown]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
@@ -471,10 +478,10 @@ public class RoutingTestCase {
System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(0).getCode());
- assertTrace(Arrays.asList("Selecting [dst/session, dst/unknown].",
+ assertTrace(Arrays.asList("Selecting ["+dstSessName+", dst/unknown].",
"[NO_ADDRESS_FOR_SERVICE @ localhost]",
"Sending reply",
- "Merged [dst/session, dst/unknown]."),
+ "Merged ["+dstSessName+", dst/unknown]."),
reply.getTrace());
log.log(Level.INFO, "Finished: requireThatPolicyCanConsumeErrors");
}
@@ -507,7 +514,7 @@ public class RoutingTestCase {
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"),
- Route.parse("[Custom:[Custom:dst/session],[Custom:dst/unknown]]")).isAccepted());
+ Route.parse("[Custom:[Custom:"+dstSessName+"],[Custom:dst/unknown]]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
@@ -536,7 +543,7 @@ public class RoutingTestCase {
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"),
- Route.parse("[Custom:[Custom:dst/session],[Custom:dst/unknown]]")).isAccepted());
+ Route.parse("[Custom:[Custom:"+dstSessName+"],[Custom:dst/unknown]]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
@@ -567,7 +574,7 @@ public class RoutingTestCase {
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(
- srcSession.send(createMessage("msg"), Route.parse("[Select:[SetReply:foo],dst/session]")).isAccepted());
+ srcSession.send(createMessage("msg"), Route.parse("[Select:[SetReply:foo],"+dstSessName+"]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
@@ -604,7 +611,7 @@ public class RoutingTestCase {
});
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"),
- Route.parse("[ReuseReply:[SetReply:foo],dst/session]")).isAccepted());
+ Route.parse("[ReuseReply:[SetReply:foo],"+dstSessName+"]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
@@ -644,7 +651,7 @@ public class RoutingTestCase {
});
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession
- .send(createMessage("msg"), Route.parse("[RemoveReply:[SetReply:foo],dst/session]")).isAccepted());
+ .send(createMessage("msg"), Route.parse("[RemoveReply:[SetReply:foo],"+dstSessName+"]")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
@@ -655,9 +662,9 @@ public class RoutingTestCase {
assertEquals(ErrorCode.APP_FATAL_ERROR, reply.getError(0).getCode());
assertEquals("foo", reply.getError(0).getMessage());
assertTrace(Arrays.asList("Resolving '[SetReply:foo]'.",
- "Resolving 'dst/session'.",
+ "Resolving '"+dstSessName+"'.",
"Resender resending message.",
- "Resolving 'dst/session'.",
+ "Resolving '"+dstSessName+"'.",
"Resolving '[SetReply:foo]'."),
reply.getTrace());
log.log(Level.INFO, "Finished: requireThatReplyCanBeRemovedAndRetried");
@@ -666,7 +673,7 @@ public class RoutingTestCase {
@Test
public void requireThatIgnoreResultWorks() {
log.log(Level.INFO, "Starting: requireThatIgnoreResultWorks");
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("?dst/session")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse("?"+dstSessName)).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
@@ -676,7 +683,7 @@ public class RoutingTestCase {
assertNotNull(reply = ((Receptor)srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- assertTrace(Arrays.asList("Not waiting for a reply from 'dst/session'."),
+ assertTrace(Arrays.asList("Not waiting for a reply from '"+dstSessName+"'."),
reply.getTrace());
log.log(Level.INFO, "Finished: requireThatIgnoreResultWorks");
}
@@ -685,7 +692,7 @@ public class RoutingTestCase {
public void requireThatIgnoreResultCanBeSetInHopBlueprint() {
log.log(Level.INFO, "Starting: requireThatIgnoreResultCanBeSetInHopBlueprint");
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME)
- .addHop(new HopSpec("foo", "dst/session").setIgnoreResult(true)));
+ .addHop(new HopSpec("foo", dstSessName).setIgnoreResult(true)));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("foo")).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
@@ -696,7 +703,7 @@ public class RoutingTestCase {
assertNotNull(reply = ((Receptor)srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
- assertTrace(Arrays.asList("Not waiting for a reply from 'dst/session'."),
+ assertTrace(Arrays.asList("Not waiting for a reply from '"+dstSessName+"'."),
reply.getTrace());
log.log(Level.INFO, "Finished: requireThatIgnoreResultCanBeSetInHopBlueprint");
}
@@ -731,7 +738,7 @@ public class RoutingTestCase {
@Test
public void requireThatIgnoreFlagIsSerializedWithMessage() {
log.log(Level.INFO, "Starting: requireThatIgnoreFlagIsSerializedWithMessage");
- assertSend("dst/session foo ?bar");
+ assertSend(dstSessName+" foo ?bar");
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Route route = msg.getRoute();
@@ -750,7 +757,7 @@ public class RoutingTestCase {
@Test
public void requireThatIgnoreFlagDoesNotInterfere() {
log.log(Level.INFO, "Starting: requireThatIgnoreFlagDoesNotInterfere");
- setupPolicy("Custom", MyPolicy.newSelectAndMerge("dst/session"));
+ setupPolicy("Custom", MyPolicy.newSelectAndMerge(dstSessName));
assertSend("?[Custom]");
assertTrace("-Ignoring errors in reply.");
log.log(Level.INFO, "Finished: requireThatIgnoreFlagDoesNotInterfere");
@@ -786,7 +793,7 @@ public class RoutingTestCase {
@Test
public void requireThatSelectAndThrowCanBeIgnored() {
log.log(Level.INFO, "Starting: requireThatSelectAndThrowCanBeIgnored");
- setupPolicy("Custom", MyPolicy.newSelectAndThrow("dst/session", new RuntimeException()));
+ setupPolicy("Custom", MyPolicy.newSelectAndThrow(dstSessName, new RuntimeException()));
assertSend("?[Custom]");
assertTrace("Ignoring errors in reply.");
log.log(Level.INFO, "Finished: requireThatSelectAndThrowCanBeIgnored");
@@ -795,7 +802,7 @@ public class RoutingTestCase {
@Test
public void requireThatEmptyMergeCanBeIgnored() {
log.log(Level.INFO, "Starting: requireThatEmptyMergeCanBeIgnored");
- setupPolicy("Custom", MyPolicy.newEmptyMerge("dst/session"));
+ setupPolicy("Custom", MyPolicy.newEmptyMerge(dstSessName));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
@@ -805,7 +812,7 @@ public class RoutingTestCase {
@Test
public void requireThatMergeErrorCanBeIgnored() {
log.log(Level.INFO, "Starting: requireThatMergeErrorCanBeIgnored");
- setupPolicy("Custom", MyPolicy.newMergeError("dst/session", ErrorCode.APP_FATAL_ERROR, "foo"));
+ setupPolicy("Custom", MyPolicy.newMergeError(dstSessName, ErrorCode.APP_FATAL_ERROR, "foo"));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
@@ -815,7 +822,7 @@ public class RoutingTestCase {
@Test
public void requireThatMergeExceptionCanBeIgnored() {
log.log(Level.INFO, "Starting: requireThatMergeExceptionCanBeIgnored");
- setupPolicy("Custom", MyPolicy.newMergeException("dst/session", new RuntimeException()));
+ setupPolicy("Custom", MyPolicy.newMergeException(dstSessName, new RuntimeException()));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
@@ -825,7 +832,7 @@ public class RoutingTestCase {
@Test
public void requireThatMergeAndThrowCanBeIgnored() {
log.log(Level.INFO, "Starting: requireThatMergeAndThrowCanBeIgnored");
- setupPolicy("Custom", MyPolicy.newMergeAndThrow("dst/session", new RuntimeException()));
+ setupPolicy("Custom", MyPolicy.newMergeAndThrow(dstSessName, new RuntimeException()));
assertSend("?[Custom]");
assertAcknowledge();
assertTrace("Ignoring errors in reply.");
@@ -852,7 +859,7 @@ public class RoutingTestCase {
@Test
public void requireThatRouteCanBeEmptyInDestination() {
log.log(Level.INFO, "Starting: requireThatRouteCanBeEmptyInDestination");
- assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
+ assertTrue(srcSession.send(createMessage("msg"), Route.parse(dstSessName)).isAccepted());
Message msg = ((Receptor)dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
assertNull(msg.getRoute());
@@ -881,7 +888,7 @@ public class RoutingTestCase {
});
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"),
- Route.parse("[Custom:[SetReply:foo],?bar,dst/session]")).isAccepted());
+ Route.parse("[Custom:[SetReply:foo],?bar,"+dstSessName+"]")).isAccepted());
Reply reply = ((Receptor)srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
System.out.println(reply.getTrace());
@@ -984,7 +991,7 @@ public class RoutingTestCase {
@Override
public void select(RoutingContext context) {
- context.addChild(Route.parse("dst/session"));
+ context.addChild(Route.parse(dstSessName));
}
@Override
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java
index 3c5af5d1447..eba8d3d4d66 100644
--- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java
+++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java
@@ -51,12 +51,8 @@ import java.util.Set;
import static com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN;
import static com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus.NO_REMARKS;
-import static org.hamcrest.collection.IsEmptyCollection.empty;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsCollectionContaining.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;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
@@ -123,44 +119,44 @@ public class OrchestratorImplTest {
@Test
public void application_has_initially_no_remarks() throws Exception {
- assertThat(orchestrator.getApplicationInstanceStatus(app1), is(NO_REMARKS));
+ assertEquals(NO_REMARKS, orchestrator.getApplicationInstanceStatus(app1));
}
@Test
public void application_can_be_set_in_suspend() throws Exception {
orchestrator.suspend(app1);
- assertThat(orchestrator.getApplicationInstanceStatus(app1), is(ALLOWED_TO_BE_DOWN));
+ assertEquals(ALLOWED_TO_BE_DOWN, orchestrator.getApplicationInstanceStatus(app1));
}
@Test
public void application_can_be_removed_from_suspend() throws Exception {
orchestrator.suspend(app1);
orchestrator.resume(app1);
- assertThat(orchestrator.getApplicationInstanceStatus(app1), is(NO_REMARKS));
+ assertEquals(NO_REMARKS, orchestrator.getApplicationInstanceStatus(app1));
}
@Test
public void appliations_list_returns_empty_initially() {
- assertThat(orchestrator.getAllSuspendedApplications(), is(empty()));
+ assertTrue(orchestrator.getAllSuspendedApplications().isEmpty());
}
@Test
public void appliations_list_returns_suspended_apps() throws Exception {
// One suspended app
orchestrator.suspend(app1);
- assertThat(orchestrator.getAllSuspendedApplications().size(), is(1));
- assertThat(orchestrator.getAllSuspendedApplications(), hasItem(app1));
+ assertEquals(1, orchestrator.getAllSuspendedApplications().size());
+ assertTrue(orchestrator.getAllSuspendedApplications().contains(app1));
// Two suspended apps
orchestrator.suspend(app2);
- assertThat(orchestrator.getAllSuspendedApplications().size(), is(2));
- assertThat(orchestrator.getAllSuspendedApplications(), hasItem(app1));
- assertThat(orchestrator.getAllSuspendedApplications(), hasItem(app2));
+ assertEquals(2, orchestrator.getAllSuspendedApplications().size());
+ assertTrue(orchestrator.getAllSuspendedApplications().contains(app1));
+ assertTrue(orchestrator.getAllSuspendedApplications().contains(app2));
// Back to one when resetting one app to no_remarks
orchestrator.resume(app1);
- assertThat(orchestrator.getAllSuspendedApplications().size(), is(1));
- assertThat(orchestrator.getAllSuspendedApplications(), hasItem(app2));
+ assertEquals(1, orchestrator.getAllSuspendedApplications().size());
+ assertTrue(orchestrator.getAllSuspendedApplications().contains(app2));
}
@@ -169,23 +165,23 @@ public class OrchestratorImplTest {
// Two suspends
orchestrator.suspend(app1);
orchestrator.suspend(app1);
- assertThat(orchestrator.getApplicationInstanceStatus(app1), is(ALLOWED_TO_BE_DOWN));
- assertThat(orchestrator.getApplicationInstanceStatus(app2), is(NO_REMARKS));
+ assertEquals(ALLOWED_TO_BE_DOWN, orchestrator.getApplicationInstanceStatus(app1));
+ assertEquals(NO_REMARKS, orchestrator.getApplicationInstanceStatus(app2));
// Three no_remarks
orchestrator.resume(app1);
orchestrator.resume(app1);
orchestrator.resume(app1);
- assertThat(orchestrator.getApplicationInstanceStatus(app1), is(NO_REMARKS));
- assertThat(orchestrator.getApplicationInstanceStatus(app2), is(NO_REMARKS));
+ assertEquals(NO_REMARKS, orchestrator.getApplicationInstanceStatus(app1));
+ assertEquals(NO_REMARKS, orchestrator.getApplicationInstanceStatus(app2));
// Two suspends and two on two applications interleaved
orchestrator.suspend(app2);
orchestrator.resume(app1);
orchestrator.suspend(app2);
orchestrator.resume(app1);
- assertThat(orchestrator.getApplicationInstanceStatus(app1), is(NO_REMARKS));
- assertThat(orchestrator.getApplicationInstanceStatus(app2), is(ALLOWED_TO_BE_DOWN));
+ assertEquals(NO_REMARKS, orchestrator.getApplicationInstanceStatus(app1));
+ assertEquals(ALLOWED_TO_BE_DOWN, orchestrator.getApplicationInstanceStatus(app2));
}
@Test
@@ -274,7 +270,7 @@ public class OrchestratorImplTest {
}
@Test
- public void suspendAllWorks() throws Exception {
+ public void suspendAllWorks() {
// A spy is preferential because suspendAll() relies on delegating the hard work to suspend() and resume().
OrchestratorImpl orchestrator = spy(this.orchestrator);
@@ -307,7 +303,7 @@ public class OrchestratorImplTest {
}
@Test
- public void whenSuspendAllFails() throws Exception {
+ public void whenSuspendAllFails() {
// A spy is preferential because suspendAll() relies on delegating the hard work to suspend() and resume().
OrchestratorImpl orchestrator = spy(this.orchestrator);
@@ -340,7 +336,7 @@ public class OrchestratorImplTest {
}
@Test
- public void testLargeLocks() throws Exception {
+ public void testLargeLocks() {
var tenantId = new TenantId("tenant");
var applicationInstanceId = new ApplicationInstanceId("app:dev:us-east-1:default");
var applicationInstanceReference = new ApplicationInstanceReference(tenantId, applicationInstanceId);
@@ -480,7 +476,7 @@ public class OrchestratorImplTest {
}
@Test
- public void testGetHost() throws Exception {
+ public void testGetHost() {
ClusterControllerClientFactory clusterControllerClientFactory = new ClusterControllerClientFactoryMock();
StatusService statusService = new ZkStatusService(
new MockCurator(),
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java
index 5951a3b0e21..698c7b544b3 100644
--- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java
+++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java
@@ -32,8 +32,7 @@ import org.junit.Test;
import java.util.List;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -101,8 +100,8 @@ public class OrchestratorTest {
orchestrator.acquirePermissionToRemove(toApplicationModelHostName(cfg2));
fail();
} catch (HostStateChangeDeniedException e) {
- assertThat(e.getMessage(), containsString("Changing the state of cfg2 would violate enough-services-up"));
- assertThat(e.getMessage(), containsString("[cfg1] are suspended."));
+ assertTrue(e.getMessage().contains("Changing the state of cfg2 would violate enough-services-up"));
+ assertTrue(e.getMessage().contains("[cfg1] are suspended."));
}
// cfg1 is removed from the application
@@ -113,8 +112,8 @@ public class OrchestratorTest {
orchestrator.acquirePermissionToRemove(toApplicationModelHostName(cfg2));
fail();
} catch (HostStateChangeDeniedException e) {
- assertThat(e.getMessage(), containsString("Changing the state of cfg2 would violate enough-services-up"));
- assertThat(e.getMessage(), containsString("[1 missing config server] are down."));
+ assertTrue(e.getMessage().contains("Changing the state of cfg2 would violate enough-services-up"));
+ assertTrue(e.getMessage().contains("[1 missing config server] are down."));
}
// cfg1 is reprovisioned, added to the node repo, and activated
@@ -128,8 +127,8 @@ public class OrchestratorTest {
orchestrator.acquirePermissionToRemove(toApplicationModelHostName(cfg1));
fail();
} catch (HostStateChangeDeniedException e) {
- assertThat(e.getMessage(), containsString("Changing the state of cfg1 would violate enough-services-up"));
- assertThat(e.getMessage(), containsString("[cfg2] are suspended"));
+ assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up"));
+ assertTrue(e.getMessage().contains("[cfg2] are suspended"));
}
// etc (should be the same as for cfg1)
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java
index babfa666577..1563a54a029 100644
--- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java
+++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java
@@ -36,10 +36,8 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
@@ -180,9 +178,8 @@ public class ClusterApiImplTest {
policy.verifyGroupGoingDownIsFine(clusterApi);
fail();
} catch (HostStateChangeDeniedException e) {
- assertThat(e.getMessage(),
- containsString("Changing the state of cfg1 would violate enough-services-up: 33% of the config " +
- "servers are down or suspended already: [1 missing config server] are down."));
+ assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up: 33% of the config " +
+ "servers are down or suspended already: [1 missing config server] are down."));
}
}
@@ -200,9 +197,8 @@ public class ClusterApiImplTest {
policy.verifyGroupGoingDownIsFine(clusterApi);
fail();
} catch (HostStateChangeDeniedException e) {
- assertThat(e.getMessage(),
- containsString("Changing the state of cfg1 would violate enough-services-up: 33% of the config " +
- "server hosts are down or suspended already: [1 missing config server host] are down."));
+ assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up: 33% of the config " +
+ "server hosts are down or suspended already: [1 missing config server host] are down."));
}
}
@@ -216,9 +212,8 @@ public class ClusterApiImplTest {
policy.verifyGroupGoingDownIsFine(clusterApi);
fail();
} catch (HostStateChangeDeniedException e) {
- assertThat(e.getMessage(),
- containsString("Changing the state of cfg1 would violate enough-services-up: 33% of the config " +
- "servers are down or suspended already: [1 missing config server] are down."));
+ assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up: 33% of the config " +
+ "servers are down or suspended already: [1 missing config server] are down."));
}
}
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusServiceTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusServiceTest.java
index 874b3d32325..c5ce69bb648 100644
--- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusServiceTest.java
+++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusServiceTest.java
@@ -10,7 +10,6 @@ import com.yahoo.test.ManualClock;
import com.yahoo.vespa.applicationmodel.ApplicationInstanceReference;
import com.yahoo.vespa.applicationmodel.HostName;
import com.yahoo.vespa.curator.Curator;
-import com.yahoo.vespa.flags.InMemoryFlagSource;
import com.yahoo.vespa.orchestrator.OrchestratorContext;
import com.yahoo.vespa.orchestrator.OrchestratorUtil;
import com.yahoo.vespa.orchestrator.TestIds;
@@ -51,11 +50,10 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsCollectionContaining.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -108,14 +106,13 @@ public class ZkStatusServiceTest {
}
@Test
- public void host_state_for_unknown_hosts_is_no_remarks() throws Exception {
- assertThat(
- statusService.getHostInfo(TestIds.APPLICATION_INSTANCE_REFERENCE, TestIds.HOST_NAME1).status(),
- is(HostStatus.NO_REMARKS));
+ public void host_state_for_unknown_hosts_is_no_remarks() {
+ assertEquals(HostStatus.NO_REMARKS,
+ statusService.getHostInfo(TestIds.APPLICATION_INSTANCE_REFERENCE, TestIds.HOST_NAME1).status());
}
@Test
- public void setting_host_state_is_idempotent() throws Exception {
+ public void setting_host_state_is_idempotent() {
when(timer.currentTime()).thenReturn(
Instant.ofEpochMilli((1)),
Instant.ofEpochMilli((3)),
@@ -128,8 +125,7 @@ public class ZkStatusServiceTest {
for (int i = 0; i < 2; i++) {
lock.setHostState(TestIds.HOST_NAME1, hostStatus);
- assertThat(lock.getHostInfos().getOrNoRemarks(TestIds.HOST_NAME1).status(),
- is(hostStatus));
+ assertEquals(hostStatus, lock.getHostInfos().getOrNoRemarks(TestIds.HOST_NAME1).status());
}
}
}
@@ -238,13 +234,11 @@ public class ZkStatusServiceTest {
}
@Test
- public void suspend_and_resume_application_works_and_is_symmetric() throws Exception {
+ public void suspend_and_resume_application_works_and_is_symmetric() {
// Initial state is NO_REMARK
- assertThat(
- statusService
- .getApplicationInstanceStatus(TestIds.APPLICATION_INSTANCE_REFERENCE),
- is(ApplicationInstanceStatus.NO_REMARKS));
+ assertEquals(ApplicationInstanceStatus.NO_REMARKS,
+ statusService.getApplicationInstanceStatus(TestIds.APPLICATION_INSTANCE_REFERENCE));
// Suspend
try (ApplicationLock lock = statusService
@@ -252,10 +246,8 @@ public class ZkStatusServiceTest {
lock.setApplicationInstanceStatus(ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN);
}
- assertThat(
- statusService
- .getApplicationInstanceStatus(TestIds.APPLICATION_INSTANCE_REFERENCE),
- is(ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN));
+ assertEquals(ApplicationInstanceStatus.ALLOWED_TO_BE_DOWN,
+ statusService.getApplicationInstanceStatus(TestIds.APPLICATION_INSTANCE_REFERENCE));
// Resume
try (ApplicationLock lock = statusService
@@ -263,16 +255,14 @@ public class ZkStatusServiceTest {
lock.setApplicationInstanceStatus(ApplicationInstanceStatus.NO_REMARKS);
}
- assertThat(
- statusService
- .getApplicationInstanceStatus(TestIds.APPLICATION_INSTANCE_REFERENCE),
- is(ApplicationInstanceStatus.NO_REMARKS));
+ assertEquals(ApplicationInstanceStatus.NO_REMARKS,
+ statusService.getApplicationInstanceStatus(TestIds.APPLICATION_INSTANCE_REFERENCE));
}
@Test
- public void suspending_two_applications_returns_two_applications() throws Exception {
+ public void suspending_two_applications_returns_two_applications() {
Set<ApplicationInstanceReference> suspendedApps = statusService.getAllSuspendedApplications();
- assertThat(suspendedApps.size(), is(0));
+ assertEquals(0, suspendedApps.size());
try (ApplicationLock statusRegistry = statusService
.lockApplication(context, TestIds.APPLICATION_INSTANCE_REFERENCE)) {
@@ -285,13 +275,13 @@ public class ZkStatusServiceTest {
}
suspendedApps = statusService.getAllSuspendedApplications();
- assertThat(suspendedApps.size(), is(2));
- assertThat(suspendedApps, hasItem(TestIds.APPLICATION_INSTANCE_REFERENCE));
- assertThat(suspendedApps, hasItem(TestIds.APPLICATION_INSTANCE_REFERENCE2));
+ assertEquals(2, suspendedApps.size());
+ assertTrue(suspendedApps.contains(TestIds.APPLICATION_INSTANCE_REFERENCE));
+ assertTrue(suspendedApps.contains(TestIds.APPLICATION_INSTANCE_REFERENCE2));
}
@Test
- public void zookeeper_cleanup() throws Exception {
+ public void zookeeper_cleanup() {
HostName strayHostname = new HostName("stray1.com");
verify(antiServiceMonitor, times(0)).disallowDuperModelLockAcquisition(any());
diff --git a/parent/pom.xml b/parent/pom.xml
index 2cebaf21833..2395991896a 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -496,11 +496,6 @@
<version>${onnxruntime.version}</version>
</dependency>
<dependency>
- <groupId>com.optimaize.languagedetector</groupId>
- <artifactId>language-detector</artifactId>
- <version>0.6</version>
- </dependency>
- <dependency>
<groupId>com.yahoo.athenz</groupId>
<artifactId>athenz-zms-java-client</artifactId>
<version>${athenz.version}</version>
@@ -573,7 +568,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.12</version>
+ <version>4.13.2</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
@@ -704,7 +699,7 @@
<dependency>
<groupId>org.apache.opennlp</groupId>
<artifactId>opennlp-tools</artifactId>
- <version>1.8.4</version>
+ <version>1.9.3</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
@@ -870,7 +865,7 @@
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
- <version>2.12.0</version>
+ <version>2.12.1</version>
</dependency>
</dependencies>
</dependencyManagement>
diff --git a/screwdriver/release-java-artifacts.sh b/screwdriver/release-java-artifacts.sh
index a91585d6ad5..7aaa821998a 100755
--- a/screwdriver/release-java-artifacts.sh
+++ b/screwdriver/release-java-artifacts.sh
@@ -40,6 +40,14 @@ find . -name "pom.xml" -exec sed -i'' -e "s,<version>.*SNAPSHOT.*</version>,<ver
-e "s,<test-framework.version>.*project.version.*</test-framework.version>,<test-framework.version>$VESPA_RELEASE</test-framework.version>," \
{} \;
+# We disable javadoc for all modules not marked as public API
+for MODULE in $(comm -2 -3 \
+ <(find . -name "*.java" | awk -F/ '{print $2}' | sort -u)
+ <(find . -name "package-info.java" -exec grep -HnE "@(com.yahoo.api.annotations.)?PublicApi.*" {} \; | awk -F/ '{print $2}' | sort -u)); do
+ mkdir -p $MODULE/src/main/javadoc
+ echo "No javadoc available for module" > $MODULE/src/main/javadoc/README
+done
+
./bootstrap.sh
COMMON_MAVEN_OPTS="--batch-mode --no-snapshot-updates --settings $(pwd)/screwdriver/settings-publish.xml --activate-profiles ossrh-deploy-vespa -DskipTests"
diff --git a/searchlib/src/vespa/searchlib/attribute/changevector.h b/searchlib/src/vespa/searchlib/attribute/changevector.h
index f1fb58eb9d0..271497398a8 100644
--- a/searchlib/src/vespa/searchlib/attribute/changevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/changevector.h
@@ -25,32 +25,33 @@ struct ChangeBase {
DIV,
CLEARDOC
};
- enum {UNSET_ENUM = 0xffffffffu};
+ enum {UNSET_ENTRY_REF = 0xffffffffu};
ChangeBase() :
_type(NOOP),
_doc(0),
_weight(1),
- _enumScratchPad(UNSET_ENUM)
+ _cached_entry_ref(UNSET_ENTRY_REF)
{ }
ChangeBase(Type type, uint32_t d, int32_t w = 1) :
_type(type),
_doc(d),
_weight(w),
- _enumScratchPad(UNSET_ENUM)
+ _cached_entry_ref(UNSET_ENTRY_REF)
{ }
int cmp(const ChangeBase &b) const { int diff(_doc - b._doc); return diff; }
bool operator <(const ChangeBase & b) const { return cmp(b) < 0; }
- uint32_t getEnum() const { return _enumScratchPad; }
- void setEnum(uint32_t value) const { _enumScratchPad = value; }
- bool isEnumValid() const { return _enumScratchPad != UNSET_ENUM; }
+ uint32_t get_entry_ref() const { return _cached_entry_ref; }
+ void set_entry_ref(uint32_t entry_ref) const { _cached_entry_ref = entry_ref; }
+ bool has_entry_ref() const { return _cached_entry_ref != UNSET_ENTRY_REF; }
+ void clear_entry_ref() const { _cached_entry_ref = UNSET_ENTRY_REF; }
Type _type;
uint32_t _doc;
int32_t _weight;
- mutable uint32_t _enumScratchPad;
+ mutable uint32_t _cached_entry_ref;
};
template <typename T>
diff --git a/searchlib/src/vespa/searchlib/attribute/enumattribute.h b/searchlib/src/vespa/searchlib/attribute/enumattribute.h
index 8136e654152..f0ff23a06b4 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumattribute.h
@@ -56,6 +56,7 @@ protected:
virtual void considerAttributeChange(const Change & c, EnumStoreBatchUpdater & inserter) = 0;
vespalib::MemoryUsage getEnumStoreValuesMemoryUsage() const override;
void populate_address_space_usage(AddressSpaceUsage& usage) const override;
+ void cache_change_data_entry_ref(const Change& c) const;
public:
EnumAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & cfg);
~EnumAttribute();
diff --git a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
index 3e578856c2b..c0680fd9238 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
@@ -84,6 +84,15 @@ EnumAttribute<B>::populate_address_space_usage(AddressSpaceUsage& usage) const
usage.set(AddressSpaceComponents::enum_store, _enumStore.get_values_address_space_usage());
}
+template <typename B>
+void
+EnumAttribute<B>::cache_change_data_entry_ref(const Change& c) const
+{
+ EnumIndex new_idx;
+ _enumStore.find_index(c._data.raw(), new_idx);
+ c.set_entry_ref(new_idx.ref());
+}
+
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp
index 251bbd7c8a7..7df30b895d2 100644
--- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp
@@ -25,10 +25,10 @@ template <typename B, typename M>
bool
MultiValueEnumAttribute<B, M>::extractChangeData(const Change & c, EnumIndex & idx)
{
- if ( ! c.isEnumValid() ) {
+ if ( ! c.has_entry_ref() ) {
return this->_enumStore.find_index(c._data.raw(), idx);
}
- idx = EnumIndex(vespalib::datastore::EntryRef(c.getEnum()));
+ idx = EnumIndex(vespalib::datastore::EntryRef(c.get_entry_ref()));
return true;
}
@@ -42,9 +42,9 @@ MultiValueEnumAttribute<B, M>::considerAttributeChange(const Change & c, EnumSto
{
EnumIndex idx;
if (!this->_enumStore.find_index(c._data.raw(), idx)) {
- c.setEnum(inserter.insert(c._data.raw()).ref());
+ c.set_entry_ref(inserter.insert(c._data.raw()).ref());
} else {
- c.setEnum(idx.ref());
+ c.set_entry_ref(idx.ref());
}
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp
index dde853cbc90..a51c9804cf2 100644
--- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp
@@ -140,9 +140,9 @@ SingleValueEnumAttribute<B>::considerUpdateAttributeChange(const Change & c, Enu
{
EnumIndex idx;
if (!this->_enumStore.find_index(c._data.raw(), idx)) {
- c.setEnum(inserter.insert(c._data.raw()).ref());
+ c.set_entry_ref(inserter.insert(c._data.raw()).ref());
} else {
- c.setEnum(idx.ref());
+ c.set_entry_ref(idx.ref());
}
considerUpdateAttributeChange(c); // for numeric
}
@@ -168,8 +168,8 @@ SingleValueEnumAttribute<B>::applyUpdateValueChange(const Change& c, EnumStoreBa
{
EnumIndex oldIdx = _enumIndices[c._doc];
EnumIndex newIdx;
- if (c.isEnumValid()) {
- newIdx = EnumIndex(vespalib::datastore::EntryRef(c.getEnum()));
+ if (c.has_entry_ref()) {
+ newIdx = EnumIndex(vespalib::datastore::EntryRef(c.get_entry_ref()));
} else {
this->_enumStore.find_index(c._data.raw(), newIdx);
}
@@ -181,6 +181,8 @@ void
SingleValueEnumAttribute<B>::applyValueChanges(EnumStoreBatchUpdater& updater)
{
ValueModifier valueGuard(this->getValueModifier());
+ // This avoids searching for the defaultValue in the enum store for each CLEARDOC in the change vector.
+ this->cache_change_data_entry_ref(this->_defaultValue);
for (const auto& change : this->_changes.getInsertOrder()) {
if (change._type == ChangeBase::UPDATE) {
applyUpdateValueChange(change, updater);
@@ -192,6 +194,8 @@ SingleValueEnumAttribute<B>::applyValueChanges(EnumStoreBatchUpdater& updater)
applyUpdateValueChange(clearDoc, updater);
}
}
+ // We must clear the cached entry ref as the defaultValue might be located in another data buffer on later invocations.
+ this->_defaultValue.clear_entry_ref();
}
template <typename B>
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
index d6622f7c880..c6b720ba14e 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
@@ -38,9 +38,9 @@ SingleValueNumericEnumAttribute<B>::considerArithmeticAttributeChange(const Chan
EnumIndex idx;
if (!this->_enumStore.find_index(newValue, idx)) {
- c.setEnum(inserter.insert(newValue).ref());
+ c.set_entry_ref(inserter.insert(newValue).ref());
} else {
- c.setEnum(idx.ref());
+ c.set_entry_ref(idx.ref());
}
_currDocValues[c._doc] = newValue;
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
index 1083d0f4cb8..4d37171e151 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
@@ -47,8 +47,8 @@ SingleValueNumericPostingAttribute<B>::applyUpdateValueChange(const Change & c,
std::map<DocId, EnumIndex> & currEnumIndices)
{
EnumIndex newIdx;
- if (c.isEnumValid()) {
- newIdx = EnumIndex(vespalib::datastore::EntryRef(c.getEnum()));
+ if (c.has_entry_ref()) {
+ newIdx = EnumIndex(vespalib::datastore::EntryRef(c.get_entry_ref()));
} else {
enumStore.find_index(c._data.raw(), newIdx);
}
@@ -89,6 +89,8 @@ SingleValueNumericPostingAttribute<B>::applyValueChanges(EnumStoreBatchUpdater&
// used to make sure several arithmetic operations on the same document in a single commit works
std::map<DocId, EnumIndex> currEnumIndices;
+ // This avoids searching for the defaultValue in the enum store for each CLEARDOC in the change vector.
+ this->cache_change_data_entry_ref(this->_defaultValue);
for (const auto& change : this->_changes.getInsertOrder()) {
auto enumIter = currEnumIndices.find(change._doc);
EnumIndex oldIdx;
@@ -114,6 +116,8 @@ SingleValueNumericPostingAttribute<B>::applyValueChanges(EnumStoreBatchUpdater&
applyUpdateValueChange(clearDoc, enumStore, currEnumIndices);
}
}
+ // We must clear the cached entry ref as the defaultValue might be located in another data buffer on later invocations.
+ this->_defaultValue.clear_entry_ref();
makePostingChange(enumStore.get_comparator(), currEnumIndices, changePost);
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
index e77c59e915d..4670ee075fe 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
@@ -45,8 +45,8 @@ SingleValueStringPostingAttributeT<B>::applyUpdateValueChange(const Change & c,
std::map<DocId, EnumIndex> &currEnumIndices)
{
EnumIndex newIdx;
- if (c.isEnumValid()) {
- newIdx = EnumIndex(vespalib::datastore::EntryRef(c.getEnum()));
+ if (c.has_entry_ref()) {
+ newIdx = EnumIndex(vespalib::datastore::EntryRef(c.get_entry_ref()));
} else {
enumStore.find_index(c._data.raw(), newIdx);
}
@@ -90,6 +90,8 @@ SingleValueStringPostingAttributeT<B>::applyValueChanges(EnumStoreBatchUpdater&
// used to make sure several arithmetic operations on the same document in a single commit works
std::map<DocId, EnumIndex> currEnumIndices;
+ // This avoids searching for the defaultValue in the enum store for each CLEARDOC in the change vector.
+ this->cache_change_data_entry_ref(this->_defaultValue);
for (const auto& change : this->_changes.getInsertOrder()) {
auto enumIter = currEnumIndices.find(change._doc);
EnumIndex oldIdx;
@@ -105,6 +107,8 @@ SingleValueStringPostingAttributeT<B>::applyValueChanges(EnumStoreBatchUpdater&
applyUpdateValueChange(this->_defaultValue, enumStore, currEnumIndices);
}
}
+ // We must clear the cached entry ref as the defaultValue might be located in another data buffer on later invocations.
+ this->_defaultValue.clear_entry_ref();
makePostingChange(enumStore.get_folded_comparator(), dictionary, currEnumIndices, changePost);
diff --git a/security-utils/pom.xml b/security-utils/pom.xml
index 39a52fb12db..55b4b190f97 100644
--- a/security-utils/pom.xml
+++ b/security-utils/pom.xml
@@ -40,11 +40,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.yahoo.vespa</groupId>
<artifactId>testutil</artifactId>
<version>${project.version}</version>
diff --git a/security-utils/src/test/java/com/yahoo/security/KeyUtilsTest.java b/security-utils/src/test/java/com/yahoo/security/KeyUtilsTest.java
index b0d587bb19a..f6f48d8b1b8 100644
--- a/security-utils/src/test/java/com/yahoo/security/KeyUtilsTest.java
+++ b/security-utils/src/test/java/com/yahoo/security/KeyUtilsTest.java
@@ -7,10 +7,9 @@ import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
-import static org.hamcrest.CoreMatchers.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;
/**
* @author bjorncs
@@ -55,8 +54,8 @@ public class KeyUtilsTest {
public void can_serialize_and_deserialize_rsa_publickey_using_pem_format() {
KeyPair keyPair = KeyUtils.generateKeypair(KeyAlgorithm.RSA);
String pem = KeyUtils.toPem(keyPair.getPublic());
- assertThat(pem, containsString("BEGIN PUBLIC KEY"));
- assertThat(pem, containsString("END PUBLIC KEY"));
+ assertTrue(pem.contains("BEGIN PUBLIC KEY"));
+ assertTrue(pem.contains("END PUBLIC KEY"));
PublicKey deserializedKey = KeyUtils.fromPemEncodedPublicKey(pem);
assertEquals(keyPair.getPublic(), deserializedKey);
assertEquals(KeyAlgorithm.RSA.getAlgorithmName(), deserializedKey.getAlgorithm());
@@ -66,8 +65,8 @@ public class KeyUtilsTest {
public void can_serialize_and_deserialize_ec_publickey_using_pem_format() {
KeyPair keyPair = KeyUtils.generateKeypair(KeyAlgorithm.EC);
String pem = KeyUtils.toPem(keyPair.getPublic());
- assertThat(pem, containsString("BEGIN PUBLIC KEY"));
- assertThat(pem, containsString("END PUBLIC KEY"));
+ assertTrue(pem.contains("BEGIN PUBLIC KEY"));
+ assertTrue(pem.contains("END PUBLIC KEY"));
PublicKey deserializedKey = KeyUtils.fromPemEncodedPublicKey(pem);
assertEquals(keyPair.getPublic(), deserializedKey);
assertEquals(KeyAlgorithm.EC.getAlgorithmName(), deserializedKey.getAlgorithm());
@@ -76,8 +75,8 @@ public class KeyUtilsTest {
private static void testPrivateKeySerialization(KeyAlgorithm keyAlgorithm, KeyFormat keyFormat, String pemLabel) {
KeyPair keyPair = KeyUtils.generateKeypair(keyAlgorithm);
String pem = KeyUtils.toPem(keyPair.getPrivate(), keyFormat);
- assertThat(pem, containsString("BEGIN " + pemLabel));
- assertThat(pem, containsString("END " + pemLabel));
+ assertTrue(pem.contains("BEGIN " + pemLabel));
+ assertTrue(pem.contains("END " + pemLabel));
PrivateKey deserializedKey = KeyUtils.fromPemEncodedPrivateKey(pem);
assertEquals(keyPair.getPrivate(), deserializedKey);
assertEquals(keyAlgorithm.getAlgorithmName(), deserializedKey.getAlgorithm());
diff --git a/security-utils/src/test/java/com/yahoo/security/Pkcs10CsrUtilsTest.java b/security-utils/src/test/java/com/yahoo/security/Pkcs10CsrUtilsTest.java
index ff0076b9cc4..32b8dfc5bcd 100644
--- a/security-utils/src/test/java/com/yahoo/security/Pkcs10CsrUtilsTest.java
+++ b/security-utils/src/test/java/com/yahoo/security/Pkcs10CsrUtilsTest.java
@@ -6,9 +6,8 @@ import org.junit.Test;
import javax.security.auth.x500.X500Principal;
import java.security.KeyPair;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* @author bjorncs
@@ -22,8 +21,8 @@ public class Pkcs10CsrUtilsTest {
Pkcs10Csr csr = Pkcs10CsrBuilder.fromKeypair(subject, keypair, SignatureAlgorithm.SHA512_WITH_ECDSA).build();
String pem = Pkcs10CsrUtils.toPem(csr);
Pkcs10Csr deserializedCsr = Pkcs10CsrUtils.fromPem(pem);
- assertThat(pem, containsString("BEGIN CERTIFICATE REQUEST"));
- assertThat(pem, containsString("END CERTIFICATE REQUEST"));
+ assertTrue(pem.contains("BEGIN CERTIFICATE REQUEST"));
+ assertTrue(pem.contains("END CERTIFICATE REQUEST"));
assertEquals(subject, deserializedCsr.getSubject());
}
diff --git a/security-utils/src/test/java/com/yahoo/security/X509CertificateUtilsTest.java b/security-utils/src/test/java/com/yahoo/security/X509CertificateUtilsTest.java
index 7075179234e..b2e800542b8 100644
--- a/security-utils/src/test/java/com/yahoo/security/X509CertificateUtilsTest.java
+++ b/security-utils/src/test/java/com/yahoo/security/X509CertificateUtilsTest.java
@@ -13,12 +13,9 @@ import java.util.Arrays;
import java.util.List;
import static com.yahoo.security.SubjectAlternativeName.Type.DNS_NAME;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-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;
/**
@@ -32,8 +29,8 @@ public class X509CertificateUtilsTest {
X509Certificate cert = TestUtils.createCertificate(keypair, subject);
assertEquals(subject, cert.getSubjectX500Principal());
String pem = X509CertificateUtils.toPem(cert);
- assertThat(pem, containsString("BEGIN CERTIFICATE"));
- assertThat(pem, containsString("END CERTIFICATE"));
+ assertTrue(pem.contains("BEGIN CERTIFICATE"));
+ assertTrue(pem.contains("END CERTIFICATE"));
X509Certificate deserializedCert = X509CertificateUtils.fromPem(pem);
assertEquals(subject, deserializedCert.getSubjectX500Principal());
}
@@ -70,8 +67,8 @@ public class X509CertificateUtilsTest {
.build();
List<SubjectAlternativeName> sans = X509CertificateUtils.getSubjectAlternativeNames(cert);
- assertThat(sans.size(), is(1));
- assertThat(sans.get(0), equalTo(san));
+ assertEquals(1, sans.size());
+ assertEquals(san, sans.get(0));
}
@Test
diff --git a/storage/src/tests/storageserver/communicationmanagertest.cpp b/storage/src/tests/storageserver/communicationmanagertest.cpp
index 3e08a6d3901..ba5e0c3c116 100644
--- a/storage/src/tests/storageserver/communicationmanagertest.cpp
+++ b/storage/src/tests/storageserver/communicationmanagertest.cpp
@@ -6,6 +6,7 @@
#include <vespa/messagebus/rpcmessagebus.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h>
+#include <vespa/storage/persistence/messages.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
#include <tests/common/teststorageapp.h>
#include <tests/common/dummystoragelink.h>
@@ -331,4 +332,11 @@ TEST_F(CommunicationManagerTest, unmapped_bucket_space_for_get_documentapi_reque
EXPECT_EQ(uint64_t(1), f.comm_mgr->metrics().bucketSpaceMappingFailures.getValue());
}
+TEST_F(CommunicationManagerTest, communication_manager_swallows_internal_replies) {
+ CommunicationManagerFixture f;
+ auto msg = std::make_unique<RecheckBucketInfoCommand>(makeDocumentBucket({16, 1}));
+ auto reply = std::shared_ptr<api::StorageReply>(msg->makeReply());
+ EXPECT_TRUE(f.comm_mgr->onUp(reply)); // true == handled by storage link
+}
+
} // storage
diff --git a/storage/src/vespa/storage/common/storagelink.cpp b/storage/src/vespa/storage/common/storagelink.cpp
index b94ef03fad5..fe753d9c350 100644
--- a/storage/src/vespa/storage/common/storagelink.cpp
+++ b/storage/src/vespa/storage/common/storagelink.cpp
@@ -9,8 +9,6 @@
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".application.link");
-using std::shared_ptr;
-using std::ostringstream;
using namespace storage::api;
namespace storage {
@@ -46,14 +44,16 @@ void StorageLink::open()
assert(false);
}
link->_state = OPENED;
- if (link->_down.get() == 0) break;
+ if (!link->_down) {
+ break;
+ }
link = link->_down.get();
}
// When give all links an onOpen call, bottoms up. Do it bottoms up, as
// links are more likely to send messages down in their onOpen() call
// than up. Thus, chances are best that the component is ready to
// receive messages sent during onOpen().
- while (link != 0) {
+ while (link != nullptr) {
link->onOpen();
link = link->_up;
}
@@ -64,7 +64,9 @@ void StorageLink::doneInit()
StorageLink* link = this;
while (true) {
link->onDoneInit();
- if (link->_down.get() == 0) break;
+ if (!link->_down) {
+ break;
+ }
link = link->_down.get();
}
}
@@ -79,7 +81,7 @@ void StorageLink::close()
}
void StorageLink::closeNextLink() {
- _down.reset(0);
+ _down.reset();
}
void StorageLink::flush()
@@ -114,7 +116,7 @@ void StorageLink::flush()
void StorageLink::sendDown(const StorageMessage::SP& msg)
{
- // Verify acceptable state to send messages down
+ // Verify acceptable state to send messages down
switch(getState()) {
case OPENED:
case CLOSING:
@@ -129,20 +131,20 @@ void StorageLink::sendDown(const StorageMessage::SP& msg)
LOG(spam, "Storage Link %s to handle %s", toString().c_str(), msg->toString().c_str());
if (isBottom()) {
LOG(spam, "Storage link %s at bottom of chain got message %s.", toString().c_str(), msg->toString().c_str());
- ostringstream ost;
+ std::ostringstream ost;
ost << "Unhandled message at bottom of chain " << *msg << " (message type "
<< msg->getType().getName() << "). " << vespalib::getStackTrace(0);
if (!msg->getType().isReply()) {
LOGBP(warning, "%s", ost.str().c_str());
- StorageCommand& cmd = static_cast<StorageCommand&>(*msg);
- shared_ptr<StorageReply> reply(cmd.makeReply().release());
+ auto& cmd = dynamic_cast<StorageCommand&>(*msg);
+ std::shared_ptr<StorageReply> reply(cmd.makeReply());
- if (reply.get()) {
+ if (reply) {
reply->setResult(ReturnCode(ReturnCode::NOT_IMPLEMENTED, msg->getType().getName()));
sendUp(reply);
}
} else {
- ost << " Return code: " << static_cast<const StorageReply&>(*msg).getResult();
+ ost << " Return code: " << dynamic_cast<const StorageReply&>(*msg).getResult();
LOGBP(warning, "%s", ost.str().c_str());
}
} else if (!_down->onDown(msg)) {
@@ -153,7 +155,7 @@ void StorageLink::sendDown(const StorageMessage::SP& msg)
}
}
-void StorageLink::sendUp(const shared_ptr<StorageMessage> & msg)
+void StorageLink::sendUp(const std::shared_ptr<StorageMessage> & msg)
{
// Verify acceptable state to send messages up
switch(getState()) {
@@ -169,20 +171,20 @@ void StorageLink::sendUp(const shared_ptr<StorageMessage> & msg)
}
assert(msg);
if (isTop()) {
- ostringstream ost;
+ std::ostringstream ost;
ost << "Unhandled message at top of chain " << *msg << ".";
ost << vespalib::getStackTrace(0);
if (!msg->getType().isReply()) {
LOGBP(warning, "%s", ost.str().c_str());
- auto& cmd = static_cast<StorageCommand&>(*msg);
- shared_ptr<StorageReply> reply(cmd.makeReply().release());
+ auto& cmd = dynamic_cast<StorageCommand&>(*msg);
+ std::shared_ptr<StorageReply> reply(cmd.makeReply());
if (reply.get()) {
reply->setResult(ReturnCode(ReturnCode::NOT_IMPLEMENTED, msg->getType().getName()));
sendDown(reply);
}
} else {
- ost << " Return code: " << static_cast<const StorageReply&>(*msg).getResult();
+ ost << " Return code: " << dynamic_cast<const StorageReply&>(*msg).getResult();
LOGBP(warning, "%s", ost.str().c_str());
}
} else if (!_up->onUp(msg)) {
@@ -195,7 +197,7 @@ void StorageLink::printChain(std::ostream& out, std::string indent) const {
if (!isTop()) out << ", not top";
out << ")";
const StorageLink* lastlink = _up;
- for (const StorageLink* link = this; link != 0; link = link->_down.get()) {
+ for (const StorageLink* link = this; link != nullptr; link = link->_down.get()) {
out << "\n";
link->print(out, false, indent + " ");
if (link->_up != lastlink) out << ", broken linkage";
@@ -203,12 +205,12 @@ void StorageLink::printChain(std::ostream& out, std::string indent) const {
}
}
-bool StorageLink::onDown(const shared_ptr<StorageMessage> & msg)
+bool StorageLink::onDown(const std::shared_ptr<StorageMessage> & msg)
{
return msg->callHandler(*this, msg);
}
-bool StorageLink::onUp(const shared_ptr<StorageMessage> & msg)
+bool StorageLink::onUp(const std::shared_ptr<StorageMessage> & msg)
{
return msg->callHandler(*this, msg);
}
@@ -236,8 +238,7 @@ StorageLink::stateToString(State state)
case CLOSED:
return "CLOSED";
default:
- assert(false);
- return 0;
+ abort();
}
}
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
index c09908e93c7..9b67830b3dc 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
@@ -737,7 +737,10 @@ CommunicationManager::sendReply(
if (!context) {
LOG(spam, "No transport context in reply %s", reply->toString().c_str());
- return false;
+ // If it's an autogenerated reply for an internal message type, just throw it away
+ // by returning that we've handled it. No one else will handle the reply, the
+ // alternative is that it ends up as warning noise in the log.
+ return (reply->getType().getId() == api::MessageType::INTERNAL_REPLY_ID);
}
framework::MilliSecTimer startTime(_component.getClock());
diff --git a/vespa-feed-client-api/abi-spec.json b/vespa-feed-client-api/abi-spec.json
index a9047365a7a..8af7798984f 100644
--- a/vespa-feed-client-api/abi-spec.json
+++ b/vespa-feed-client-api/abi-spec.json
@@ -103,6 +103,8 @@
"public abstract java.util.concurrent.CompletableFuture put(ai.vespa.feed.client.DocumentId, java.lang.String, ai.vespa.feed.client.OperationParameters)",
"public abstract java.util.concurrent.CompletableFuture update(ai.vespa.feed.client.DocumentId, java.lang.String, ai.vespa.feed.client.OperationParameters)",
"public abstract java.util.concurrent.CompletableFuture remove(ai.vespa.feed.client.DocumentId, ai.vespa.feed.client.OperationParameters)",
+ "public static java.util.List await(java.util.List)",
+ "public static varargs java.util.List await(java.util.concurrent.CompletableFuture[])",
"public abstract ai.vespa.feed.client.OperationStats stats()",
"public abstract ai.vespa.feed.client.FeedClient$CircuitBreaker$State circuitBreakerState()",
"public abstract void close(boolean)",
@@ -221,6 +223,19 @@
],
"fields": []
},
+ "ai.vespa.feed.client.MultiFeedException": {
+ "superClass": "java.lang.RuntimeException",
+ "interfaces": [],
+ "attributes": [
+ "public"
+ ],
+ "methods": [
+ "public void <init>(java.util.Collection)",
+ "public java.util.Collection feedExceptions()",
+ "public java.util.Set documentIds()"
+ ],
+ "fields": []
+ },
"ai.vespa.feed.client.OperationParameters": {
"superClass": "java.lang.Object",
"interfaces": [],
diff --git a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClient.java b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClient.java
index d463c611d6a..5e95990a078 100644
--- a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClient.java
+++ b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClient.java
@@ -2,6 +2,7 @@
package ai.vespa.feed.client;
import java.io.Closeable;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
@@ -37,6 +38,24 @@ public interface FeedClient extends Closeable {
*/
CompletableFuture<Result> remove(DocumentId documentId, OperationParameters params);
+ /**
+ * Waits for all feed operations to complete, either successfully or with exception.
+ * @throws MultiFeedException if any operation fails
+ * @return list of results with the same ordering as the {@code promises} parameter
+ * */
+ static List<Result> await(List<CompletableFuture<Result>> promises) throws MultiFeedException {
+ return Helper.await(promises);
+ }
+
+ /**
+ * Same as {@link #await(List)} except {@code promises} parameter is a vararg
+ * @see #await(List)
+ */
+ @SafeVarargs
+ static List<Result> await(CompletableFuture<Result>... promises) throws MultiFeedException {
+ return Helper.await(promises);
+ }
+
/** Returns a snapshot of the stats for this feed client, such as requests made, and responses by status. */
OperationStats stats();
diff --git a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/Helper.java b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/Helper.java
new file mode 100644
index 00000000000..59c12077bef
--- /dev/null
+++ b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/Helper.java
@@ -0,0 +1,42 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.stream.Collectors;
+
+/**
+ * @author bjorncs
+ */
+class Helper {
+
+ private Helper() {}
+
+ @SafeVarargs
+ static List<Result> await(CompletableFuture<Result>... promises) throws MultiFeedException {
+ List<CompletableFuture<Result>> list = new ArrayList<>();
+ for (CompletableFuture<Result> p : promises) list.add(p);
+ return await(list);
+ }
+
+ static List<Result> await(List<CompletableFuture<Result>> promises) throws MultiFeedException {
+ try {
+ CompletableFuture.allOf(promises.toArray(new CompletableFuture<?>[0])).join();
+ return promises.stream()
+ .map(p -> Objects.requireNonNull(p.getNow(null)))
+ .collect(Collectors.toList());
+ } catch (CompletionException e) {
+ List<FeedException> exceptions = new ArrayList<>();
+ for (CompletableFuture<Result> promise : promises) {
+ if (promise.isCompletedExceptionally()) {
+ // Lambda is executed on this thread since the future is already completed
+ promise.whenComplete((__, error) -> exceptions.add((FeedException) error));
+ }
+ }
+ throw new MultiFeedException(exceptions);
+ }
+ }
+}
diff --git a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/MultiFeedException.java b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/MultiFeedException.java
new file mode 100644
index 00000000000..5db687b49ff
--- /dev/null
+++ b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/MultiFeedException.java
@@ -0,0 +1,38 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Aggregates multiple instances of {@link FeedException}
+ *
+ * @author bjorncs
+ */
+public class MultiFeedException extends RuntimeException {
+
+ private final List<FeedException> exceptions;
+
+ public MultiFeedException(Collection<FeedException> exceptions) {
+ super(toMessage(exceptions));
+ this.exceptions = Collections.unmodifiableList(new ArrayList<>(exceptions));
+ }
+
+ public Collection<FeedException> feedExceptions() { return exceptions; }
+
+ public Set<DocumentId> documentIds() {
+ return exceptions.stream()
+ .filter(e -> e.documentId().isPresent())
+ .map(e -> e.documentId().get())
+ .collect(Collectors.toSet());
+ }
+
+ private static String toMessage(Collection<FeedException> exceptions) {
+ return String.format("%d feed operations failed", exceptions.size());
+ }
+
+}
diff --git a/vespa-feed-client-api/src/test/java/ai/vespa/feed/client/FeedClientTest.java b/vespa-feed-client-api/src/test/java/ai/vespa/feed/client/FeedClientTest.java
new file mode 100644
index 00000000000..688f311bb05
--- /dev/null
+++ b/vespa-feed-client-api/src/test/java/ai/vespa/feed/client/FeedClientTest.java
@@ -0,0 +1,105 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * @author bjorncs
+ */
+class FeedClientTest {
+
+ private ExecutorService executor;
+
+ @BeforeEach
+ void setUp() {
+ executor = Executors.newSingleThreadExecutor();
+ }
+
+ @AfterEach
+ void tearDown() throws InterruptedException {
+ executor.shutdown();
+ assertTrue(executor.awaitTermination(60, TimeUnit.SECONDS));
+ }
+
+ @Test
+ void await_returns_list_of_result_on_success() {
+ MyResult r1 = new MyResult();
+ CompletableFuture<Result> f1 = CompletableFuture.completedFuture(r1);
+ MyResult r2 = new MyResult();
+ CompletableFuture<Result> f2 = CompletableFuture.completedFuture(r2);
+ MyResult r3 = new MyResult();
+ CompletableFuture<Result> f3 = CompletableFuture.completedFuture(r3);
+
+ List<Result> aggregated = FeedClient.await(f1, f2, f3);
+ assertEquals(3, aggregated.size());
+ assertEquals(r1, aggregated.get(0));
+ assertEquals(r2, aggregated.get(1));
+ assertEquals(r3, aggregated.get(2));
+ }
+
+ @Test
+ void await_handles_async_completion_with_success() throws ExecutionException, InterruptedException {
+ CompletableFuture<Result> f1 = new CompletableFuture<>();
+ CompletableFuture<Result> f2 = new CompletableFuture<>();
+ CompletableFuture<Result> f3 = new CompletableFuture<>();
+
+ CompletableFuture<List<Result>> awaitPromise = CompletableFuture.supplyAsync(() -> FeedClient.await(f1, f2, f3), executor);
+ // Completed in reverse order
+ MyResult r3 = new MyResult();
+ f3.complete(r3);
+ MyResult r2 = new MyResult();
+ f2.complete(r2);
+ MyResult r1 = new MyResult();
+ f1.complete(r1);
+
+ List<Result> aggregated = awaitPromise.get();
+ assertEquals(3, aggregated.size());
+ assertEquals(r1, aggregated.get(0));
+ assertEquals(r2, aggregated.get(1));
+ assertEquals(r3, aggregated.get(2));
+ }
+
+ @Test
+ void await_throws_when_some_results_completes_exceptionally() {
+ CompletableFuture<Result> f1 = new CompletableFuture<>();
+ DocumentId docId1 = DocumentId.of("music", "music", "doc1");
+ FeedException exceptionDoc1 = new FeedException(docId1, "Doc1 failed");
+ f1.completeExceptionally(exceptionDoc1);
+ CompletableFuture<Result> f2 = new CompletableFuture<>();
+ DocumentId docId2 = DocumentId.of("music", "music", "doc2");
+ FeedException exceptionDoc2 = new FeedException(docId2, "Doc2 failed");
+ f2.completeExceptionally(exceptionDoc2);
+ CompletableFuture<Result> f3 = CompletableFuture.completedFuture(new MyResult());
+
+ MultiFeedException multiException = assertThrows(MultiFeedException.class, () -> FeedClient.await(f1, f2, f3));
+ Set<DocumentId> expectedDocsIds = new HashSet<>(Arrays.asList(docId1, docId2));
+ assertEquals(expectedDocsIds, new HashSet<>(multiException.documentIds()));
+ Set<FeedException> expectedExceptions = new HashSet<>(Arrays.asList(exceptionDoc1, exceptionDoc2));
+ assertEquals(expectedExceptions, new HashSet<>(multiException.feedExceptions()));
+ assertEquals("2 feed operations failed", multiException.getMessage());
+ }
+
+ static class MyResult implements Result {
+ @Override public Type type() { return null; }
+ @Override public DocumentId documentId() { return null; }
+ @Override public Optional<String> resultMessage() { return Optional.empty(); }
+ @Override public Optional<String> traceMessage() { return Optional.empty(); }
+ }
+}
diff --git a/vespa-hadoop/pom.xml b/vespa-hadoop/pom.xml
index 9c3ec0d5e07..d6d9d0e2141 100644
--- a/vespa-hadoop/pom.xml
+++ b/vespa-hadoop/pom.xml
@@ -28,12 +28,32 @@
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.pig</groupId>
@@ -73,8 +93,31 @@
<artifactId>hadoop-minicluster</artifactId>
<version>${hadoop.version}</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
+ <!-- Use slf4j's replacement for log4j to avoid log4j in the dependency tree -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <!-- Bind to java.util.logging -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
index a102e8fffd4..3eac4ff5c5d 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
@@ -34,6 +34,7 @@ import com.yahoo.documentapi.DocumentAccess;
import com.yahoo.documentapi.DocumentOperationParameters;
import com.yahoo.documentapi.DocumentResponse;
import com.yahoo.documentapi.ProgressToken;
+import com.yahoo.documentapi.Response.Outcome;
import com.yahoo.documentapi.Result;
import com.yahoo.documentapi.VisitorControlHandler;
import com.yahoo.documentapi.VisitorDataHandler;
@@ -65,6 +66,7 @@ import com.yahoo.restapi.Path;
import com.yahoo.search.query.ParameterParser;
import com.yahoo.text.Text;
import com.yahoo.vespa.config.content.AllClustersBucketSpacesConfig;
+import com.yahoo.vespa.http.server.MetricNames;
import com.yahoo.yolean.Exceptions;
import com.yahoo.yolean.Exceptions.RunnableThrowingIOException;
@@ -93,8 +95,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Phaser;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
@@ -450,7 +450,8 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
DocumentOperationParameters parameters = parametersFromRequest(request, ROUTE)
.withResponseHandler(response -> {
outstanding.decrementAndGet();
- handle(path, handler, response);
+ updatePutMetrics(response.outcome());
+ handleFeedOperation(path, handler, response);
});
return () -> dispatchOperation(() -> asyncSession.put(put, parameters));
});
@@ -467,7 +468,8 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
DocumentOperationParameters parameters = parametersFromRequest(request, ROUTE)
.withResponseHandler(response -> {
outstanding.decrementAndGet();
- handle(path, handler, response);
+ updateUpdateMetrics(response.outcome(), update.getCreateIfNonExistent());
+ handleFeedOperation(path, handler, response);
});
return () -> dispatchOperation(() -> asyncSession.update(update, parameters));
});
@@ -482,7 +484,8 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
DocumentOperationParameters parameters = parametersFromRequest(request, ROUTE)
.withResponseHandler(response -> {
outstanding.decrementAndGet();
- handle(path, handler, response);
+ updateRemoveMetrics(response.outcome());
+ handleFeedOperation(path, handler, response);
});
return () -> dispatchOperation(() -> asyncSession.remove(remove, parameters));
});
@@ -1032,10 +1035,36 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
}
}
- private static void handle(DocumentPath path, ResponseHandler handler, com.yahoo.documentapi.Response response) {
+ private static void handleFeedOperation(DocumentPath path, ResponseHandler handler, com.yahoo.documentapi.Response response) {
handle(path, handler, response, (document, jsonResponse) -> jsonResponse.commit(Response.Status.OK));
}
+ private void updatePutMetrics(Outcome outcome) {
+ switch (outcome) {
+ case SUCCESS: metric.add(MetricNames.SUCCEEDED, 1, null); break;
+ case CONDITION_FAILED: metric.add(MetricNames.CONDITION_NOT_MET, 1, null); break;
+ default: metric.add(MetricNames.FAILED, 1, null); break;
+ }
+ }
+
+ private void updateUpdateMetrics(Outcome outcome, boolean create) {
+ if (create && outcome == Outcome.NOT_FOUND) outcome = Outcome.SUCCESS; // >_<
+ switch (outcome) {
+ case SUCCESS: metric.add(MetricNames.SUCCEEDED, 1, null); break;
+ case NOT_FOUND: metric.add(MetricNames.NOT_FOUND, 1, null); break;
+ case CONDITION_FAILED: metric.add(MetricNames.CONDITION_NOT_MET, 1, null); break;
+ default: metric.add(MetricNames.FAILED, 1, null); break;
+ }
+ }
+
+ private void updateRemoveMetrics(Outcome outcome) {
+ switch (outcome) {
+ case SUCCESS: metric.add(MetricNames.SUCCEEDED, 1, null); break;
+ case CONDITION_FAILED: metric.add(MetricNames.CONDITION_NOT_MET, 1, null); break;
+ default: metric.add(MetricNames.FAILED, 1, null); break;
+ }
+ }
+
// ------------------------------------------------- Visits ------------------------------------------------
private VisitorParameters parseGetParameters(HttpRequest request, DocumentPath path, boolean streamed) {
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/documentapi/metrics/DocumentOperationStatus.java b/vespaclient-container-plugin/src/main/java/com/yahoo/documentapi/metrics/DocumentOperationStatus.java
index 522652212a9..97e5e9e63d8 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/documentapi/metrics/DocumentOperationStatus.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/documentapi/metrics/DocumentOperationStatus.java
@@ -19,15 +19,6 @@ public enum DocumentOperationStatus {
OK, REQUEST_ERROR, SERVER_ERROR;
- public static DocumentOperationStatus fromHttpStatusCode(int httpStatus) {
- switch (httpStatus / 100) {
- case 2: return OK;
- case 4: return REQUEST_ERROR;
- case 5: return SERVER_ERROR;
- default: return null;
- }
- }
-
public static DocumentOperationStatus fromMessageBusErrorCodes(Set<Integer> errorCodes) {
if (errorCodes.size() == 1 && errorCodes.contains(DocumentProtocol.ERROR_NO_SPACE))
return SERVER_ERROR;
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java
index 50f79c0a828..2fbb80d9fcc 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedReplyReader.java
@@ -2,6 +2,8 @@
package com.yahoo.vespa.http.server;
import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;
+import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage;
+import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentReply;
import com.yahoo.documentapi.metrics.DocumentApiMetrics;
import com.yahoo.documentapi.metrics.DocumentOperationStatus;
import com.yahoo.documentapi.metrics.DocumentOperationType;
@@ -13,9 +15,13 @@ import com.yahoo.vespa.http.client.core.ErrorCode;
import com.yahoo.vespa.http.client.core.OperationStatus;
import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;
+import static java.util.function.Predicate.not;
+
/**
* Catch message bus replies and make the available to a given session.
*
@@ -54,14 +60,24 @@ public class FeedReplyReader implements ReplyHandler {
} else {
metricsHelper.reportSuccessful(type, latencyInSeconds);
metric.add(MetricNames.SUCCEEDED, 1, null);
- if (!conditionMet)
+ if ( ! conditionMet)
metric.add(MetricNames.CONDITION_NOT_MET, 1, testAndSetMetricCtx);
+ if ( ! updateNotFound(reply))
+ metric.add(MetricNames.NOT_FOUND, 1, null);
enqueue(context, "Document processed.", ErrorCode.OK, !conditionMet, reply.getTrace());
}
}
private static boolean conditionMet(Reply reply) {
- return !reply.hasErrors() || reply.getError(0).getCode() != DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED;
+ return ! reply.hasErrors() || reply.getError(0).getCode() != DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED;
+ }
+
+ private static boolean updateNotFound(Reply reply) {
+ return reply instanceof UpdateDocumentReply
+ && ! ((UpdateDocumentReply) reply).wasFound()
+ && reply.getMessage() instanceof UpdateDocumentMessage
+ && ((UpdateDocumentMessage) reply.getMessage()).getDocumentUpdate() != null
+ && ! ((UpdateDocumentMessage) reply.getMessage()).getDocumentUpdate().getCreateIfNonExistent();
}
private void enqueue(ReplyContext context, String message, ErrorCode status, boolean isConditionNotMet, Trace trace) {
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
index 6ded410ff68..a5987f2398e 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
@@ -19,6 +19,7 @@ public final class MetricNames {
public static final String LATENCY = PREFIX + "latency";
public static final String FAILED = PREFIX + "failed";
public static final String CONDITION_NOT_MET = PREFIX + "condition_not_met";
+ public static final String NOT_FOUND = PREFIX + "not_found";
public static final String PARSE_ERROR = PREFIX + "parse_error";
public static final String SUCCEEDED = PREFIX + "succeeded";
public static final String PENDING = PREFIX + "pending";
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java
index de907f70c19..232d49129d7 100644
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java
+++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java
@@ -3,7 +3,6 @@ package com.yahoo.document.restapi.resource;
import com.yahoo.cloud.config.ClusterListConfig;
import com.yahoo.container.jdisc.RequestHandlerTestDriver;
-import com.yahoo.docproc.jdisc.metric.NullMetric;
import com.yahoo.document.BucketId;
import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
@@ -44,6 +43,7 @@ import com.yahoo.documentapi.VisitorResponse;
import com.yahoo.documentapi.VisitorSession;
import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage;
import com.yahoo.jdisc.Metric;
+import com.yahoo.jdisc.test.MockMetric;
import com.yahoo.messagebus.StaticThrottlePolicy;
import com.yahoo.messagebus.Trace;
import com.yahoo.messagebus.TraceNode;
@@ -126,7 +126,7 @@ public class DocumentV1ApiTest {
Map.of("music", "default")));
ManualClock clock;
MockDocumentAccess access;
- Metric metric;
+ MockMetric metric;
MetricReceiver metrics;
DocumentV1ApiHandler handler;
@@ -134,7 +134,7 @@ public class DocumentV1ApiTest {
public void setUp() {
clock = new ManualClock();
access = new MockDocumentAccess(docConfig);
- metric = new NullMetric();
+ metric = new MockMetric();
metrics = new MetricReceiver.MockReceiver();
handler = new DocumentV1ApiHandler(clock, Duration.ofMillis(1), metric, metrics, access, docConfig,
executorConfig, clusterConfig, bucketConfig);
@@ -614,6 +614,23 @@ public class DocumentV1ApiTest {
"}", response.readAll());
assertEquals(400, response.getStatus());
+ // PUT on document which is not found is a 200
+ access.session.expect((update, parameters) -> {
+ parameters.responseHandler().get().handleResponse(new UpdateResponse(0, false));
+ return new Result(Result.ResultType.SUCCESS, null);
+ });
+ response = driver.sendRequest("http://localhost/document/v1/space/music/docid/sonny", PUT,
+ "{" +
+ " \"fields\": {" +
+ " \"artist\": { \"assign\": \"The Shivers\" }" +
+ " }" +
+ "}");
+ assertSameJson("{" +
+ " \"pathId\": \"/document/v1/space/music/docid/sonny\"," +
+ " \"id\": \"id:space:music::sonny\"" +
+ "}", response.readAll());
+ assertEquals(200, response.getStatus());
+
// DELETE with full document ID is a document remove operation.
access.session.expect((remove, parameters) -> {
DocumentRemove expectedRemove = new DocumentRemove(doc2.getId());
@@ -667,7 +684,7 @@ public class DocumentV1ApiTest {
parameters.responseHandler().get().handleResponse(new Response(0, "disk full", Response.Outcome.INSUFFICIENT_STORAGE));
return new Result(Result.ResultType.SUCCESS, null);
});
- response = driver.sendRequest("http://localhost/document/v1/space/music/number/1/two");
+ response = driver.sendRequest("http://localhost/document/v1/space/music/number/1/two", DELETE);
assertSameJson("{" +
" \"pathId\": \"/document/v1/space/music/number/1/two\"," +
" \"id\": \"id:space:music:n=1:two\"," +
@@ -680,7 +697,7 @@ public class DocumentV1ApiTest {
parameters.responseHandler().get().handleResponse(new Response(0, "no dice", Response.Outcome.CONDITION_FAILED));
return new Result(Result.ResultType.SUCCESS, null);
});
- response = driver.sendRequest("http://localhost/document/v1/space/music/number/1/two");
+ response = driver.sendRequest("http://localhost/document/v1/space/music/number/1/two", DELETE);
assertSameJson("{" +
" \"pathId\": \"/document/v1/space/music/number/1/two\"," +
" \"id\": \"id:space:music:n=1:two\"," +
@@ -746,6 +763,10 @@ public class DocumentV1ApiTest {
handler.get().handleResponse(new Response(0)); // response may eventually arrive, but too late.
}
+ assertEquals(3, metric.metrics().get("httpapi_succeeded").get(Map.of()), 0);
+ assertEquals(1, metric.metrics().get("httpapi_condition_not_met").get(Map.of()), 0);
+ assertEquals(1, metric.metrics().get("httpapi_not_found").get(Map.of()), 0);
+ assertEquals(1, metric.metrics().get("httpapi_failed").get(Map.of()), 0);
driver.close();
}
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java
index 642805f9927..950ecd799e8 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertTrue;
public class VespaFeederTestCase {
+ @SuppressWarnings("deprecation")
@Rule
public ExpectedException exception = ExpectedException.none();
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java
index b7fd1f535f0..6af2344e36e 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/CommandLineOptionsTest.java
@@ -36,6 +36,7 @@ public class CommandLineOptionsTest {
}
};
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exception = ExpectedException.none();
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java
index b0207c7620b..098319f24dc 100644
--- a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java
+++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java
@@ -62,6 +62,7 @@ public class DocumentRetrieverTest {
private PrintStream oldOut;
private PrintStream oldErr;
+ @SuppressWarnings("deprecation")
@Rule
public final ExpectedException exception = ExpectedException.none();
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/main/java/com/yahoo/tensor/TensorType.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
index 5b23d5d92ae..dfbcb06c365 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.tensor;
-import com.google.common.collect.ImmutableList;
import com.yahoo.text.Ascii7BitMatcher;
import java.util.ArrayList;
@@ -86,7 +85,7 @@ public class TensorType {
private final Value valueType;
/** Sorted list of the dimensions of this */
- private final ImmutableList<Dimension> dimensions;
+ private final List<Dimension> dimensions;
private final TensorType mappedSubtype;
@@ -94,7 +93,7 @@ public class TensorType {
this.valueType = valueType;
List<Dimension> dimensionList = new ArrayList<>(dimensions);
Collections.sort(dimensionList);
- this.dimensions = ImmutableList.copyOf(dimensionList);
+ this.dimensions = List.copyOf(dimensionList);
if (dimensionList.stream().allMatch(d -> d.isIndexed()))
mappedSubtype = empty;
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
diff --git a/zookeeper-client-common/pom.xml b/zookeeper-client-common/pom.xml
index f991fa5dea9..7e23e0cb1c8 100644
--- a/zookeeper-client-common/pom.xml
+++ b/zookeeper-client-common/pom.xml
@@ -25,6 +25,16 @@
<artifactId>zookeeper</artifactId>
<version>${zookeeper.client.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- compile scope -->
diff --git a/zookeeper-command-line-client/pom.xml b/zookeeper-command-line-client/pom.xml
index f1fc49dcb1c..a8105c78881 100644
--- a/zookeeper-command-line-client/pom.xml
+++ b/zookeeper-command-line-client/pom.xml
@@ -15,6 +15,17 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <!-- This is the log4j 1.2 binding for slf4j. Must not be used with log4j-over-slf4j (see below) -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
@@ -38,6 +49,19 @@
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <!-- Bind to slf4j's SimpleLogger -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <!-- slf4j's replacement for log4j. See http://www.slf4j.org/legacy.html#log4j-over-slf4j -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
</dependencies>
<build>
<plugins>
diff --git a/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/FourLetterWordMain.java b/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/FourLetterWordMain.java
index 9d2cdc1c4b8..ed79fed908c 100644
--- a/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/FourLetterWordMain.java
+++ b/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/FourLetterWordMain.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.zookeeper.cli;
import com.yahoo.vespa.zookeeper.client.ZkClientConfigBuilder;
import org.apache.zookeeper.common.X509Exception;
+import org.slf4j.impl.SimpleLogger;
import java.io.IOException;
import java.util.Map;
@@ -14,6 +15,10 @@ import java.util.Map;
*/
public class FourLetterWordMain {
+ static {
+ System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "WARN");
+ }
+
public static void main(String[] args) throws X509Exception.SSLContextException, IOException {
Map<String, String> zkClientConfig = new ZkClientConfigBuilder().toConfigProperties();
zkClientConfig.forEach(System::setProperty);
diff --git a/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/Main.java b/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/Main.java
index 3c89e5105ca..7f7965f82eb 100644
--- a/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/Main.java
+++ b/zookeeper-command-line-client/src/main/java/com/yahoo/vespa/zookeeper/cli/Main.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.zookeeper.cli;
import com.yahoo.vespa.zookeeper.client.ZkClientConfigBuilder;
import org.apache.zookeeper.ZooKeeperMain;
+import org.slf4j.impl.SimpleLogger;
import java.io.IOException;
@@ -10,6 +11,11 @@ import java.io.IOException;
* @author bjorncs
*/
public class Main {
+
+ static {
+ System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "WARN");
+ }
+
public static void main(String[] args) throws IOException, InterruptedException {
new ZkClientConfigBuilder()
.toConfigProperties()