diff options
Diffstat (limited to 'container-search/src/test/java/com/yahoo')
3 files changed, 9 insertions, 71 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java index e1987aa50ca..a6ae5f2b1b9 100644 --- a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java +++ b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java @@ -186,7 +186,7 @@ public class SearchHandlerTest { RequestHandlerTestDriver.MockResponseHandler responseHandler = newDriver.sendRequest( "http://localhost/search/?yql=select%20*%20from%20foo%20where%20bar%20%3E%201453501295%27%3B"); responseHandler.readAll(); - assertEquals(400, responseHandler.getStatus()); + assertThat(responseHandler.getStatus(), is(400)); assertEquals(Request.RequestType.READ, responseHandler.getResponse().getRequestType()); } } diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java index 3542e1413eb..231020c4fa5 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java @@ -1,11 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile.test; -import ai.vespa.cloud.ApplicationId; -import ai.vespa.cloud.Environment; -import ai.vespa.cloud.Zone; -import ai.vespa.cloud.ZoneInfo; -import com.yahoo.jdisc.application.Application; import com.yahoo.jdisc.http.HttpRequest.Method; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.processing.request.CompoundName; @@ -1336,53 +1331,6 @@ public class QueryProfileVariantsTestCase { assertEquals("yahoo/alerts", cAlert.get("vertical.custid", toMap("entry=alert", "intl=us", "lang=en-US"))); } - @Test - public void testZoneInfoInContext() { - QueryProfileRegistry registry = new QueryProfileRegistry(); - QueryProfile profile = new QueryProfile("test"); - profile.setDimensions(new String[] { "environment", "region", "instance" }); - profile.set("value", "default", registry); - profile.set("value", "prod-region1-instance1", - toMap("environment=prod", "region=region1", "instance=instance1"), - registry); - profile.set("value", "prod-instance2", - toMap("environment=prod", "instance=instance2"), - registry); - profile.set("value", "prod-region3", - toMap("environment=prod", "region=region3"), - registry); - profile.set("value", "dev", - toMap("environment=dev"), - registry); - registry.register(profile); - - CompiledQueryProfileRegistry cRegistry = registry.compile(); - CompiledQueryProfile cTest = cRegistry.findQueryProfile("test"); - - assertValueForZone("default", ZoneInfo.defaultInfo(), cTest); - assertValueForZone("prod-region1-instance1", - new ZoneInfo(new ApplicationId("tenant1", "application1", "instance1"), - new Zone(Environment.prod, "region1")), - cTest); - assertValueForZone("prod-instance2", - new ZoneInfo(new ApplicationId("tenant2", "application2", "instance2"), - new Zone(Environment.prod, "region1")), - cTest); - assertValueForZone("prod-region3", - new ZoneInfo(new ApplicationId("tenant3", "application3", "instance3"), - new Zone(Environment.prod, "region3")), - cTest); - assertValueForZone("dev", - new ZoneInfo(new ApplicationId("tenant4", "application4", "instance4"), - new Zone(Environment.dev, "region4")), - cTest); - } - - private void assertValueForZone(String expected, ZoneInfo zoneInfo, CompiledQueryProfile cTest) { - assertEquals(expected, - new Query.Builder().setQueryProfile(cTest).setZoneInfo(zoneInfo).build().properties().get("value")); - } - private void assertGet(String expectedValue, String parameter, String[] dimensionValues, QueryProfile profile, CompiledQueryProfile cprofile) { Map<String,String> context=toMap(profile,dimensionValues); assertEquals("Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'",expectedValue,cprofile.get(parameter,context)); diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java index d6e99ec3a44..a642d14b368 100644 --- a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java @@ -5,7 +5,6 @@ import com.yahoo.config.search.IntConfig; import com.yahoo.config.search.StringConfig; import com.yahoo.container.core.config.HandlersConfigurerDi; import com.yahoo.container.core.config.testutil.HandlersConfigurerTestWrapper; -import com.yahoo.lang.MutableInteger; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; @@ -39,7 +38,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertThat; @@ -131,7 +129,7 @@ public class SearchChainConfigurerTestCase { @Test public void testConfigurableSearcher() { - HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir); + HandlersConfigurerTestWrapper configurer=new HandlersConfigurerTestWrapper("dir:" + testDir); SearchChain configurable = getSearchChainRegistryFrom(configurer).getComponent("configurable"); assertNotNull(configurable); @@ -139,8 +137,9 @@ public class SearchChainConfigurerTestCase { Searcher s = configurable.searchers().get(0); assertThat(s, instanceOf(ConfigurableSearcher.class)); ConfigurableSearcher searcher = (ConfigurableSearcher)s; - assertEquals("Value from int.cfg file", 7, searcher.intConfig.intVal()); - assertEquals("Value from string.cfg file", "com.yahoo.search.searchchain.config.test", searcher.stringConfig.stringVal()); + assertThat("Value from int.cfg file", searcher.intConfig.intVal(), is(7)); + assertThat("Value from string.cfg file", searcher.stringConfig.stringVal(), + is("com.yahoo.search.searchchain.config.test")); configurer.shutdown(); } @@ -343,7 +342,7 @@ public class SearchChainConfigurerTestCase { if (append) { Pattern p = Pattern.compile("^[a-z]+" + "\\[\\d+\\]\\.id (.+)"); BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(componentsFile), StandardCharsets.UTF_8)); + new FileInputStream(new File(componentsFile)), StandardCharsets.UTF_8)); while ((line = reader.readLine()) != null) { Matcher m = p.matcher(line); if (m.matches() && !m.group(1).equals(HandlersConfigurerDi.RegistriesHack.class.getName())) { @@ -354,7 +353,7 @@ public class SearchChainConfigurerTestCase { reader.close(); } BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(configFile), StandardCharsets.UTF_8)); + new FileInputStream(new File(configFile)), StandardCharsets.UTF_8)); Pattern component = Pattern.compile("^" + componentType + "\\[\\d+\\]\\.id (.+)"); while ((line = reader.readLine()) != null) { Matcher m = component.matcher(line); @@ -367,22 +366,13 @@ public class SearchChainConfigurerTestCase { buf.append("components[").append(i++).append("].id ").append(HandlersConfigurerDi.RegistriesHack.class.getName()).append("\n"); if (componentType.equals("components")) - i = addStandardComponents(i, buf); + buf.append("components[").append(i++).append("].id ").append(ExecutionFactory.class.getName()).append("\n"); buf.insert(0, "components["+i+"]\n"); - Writer writer = new OutputStreamWriter(new FileOutputStream(componentsFile), StandardCharsets.UTF_8); + Writer writer = new OutputStreamWriter(new FileOutputStream(new File(componentsFile)), StandardCharsets.UTF_8); writer.write(buf.toString()); writer.flush(); writer.close(); } - private static int addStandardComponents(int i, StringBuilder builder) { - addComponent(ExecutionFactory.class.getName(), i++, builder); - return i; - } - - private static void addComponent(String component, int i, StringBuilder builder) { - builder.append("components[").append(i).append("].id ").append(component).append("\n"); - } - } |