diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-09 12:15:43 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-09 12:15:43 +0200 |
commit | 20513f2cb1f9c65406c32dd717e738d394fc1d1b (patch) | |
tree | 8801ffcd7fb2f7f31f66f2ce4db99c6752b909ef /container-search/src/test/java/com/yahoo/search | |
parent | 79cd883d5df45dc236e5cebf2c21b5487c791df6 (diff) |
Extract execution creation into ExecutionFactory
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search')
5 files changed, 18 insertions, 12 deletions
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 87d92e1344a..02e2152d7c9 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 @@ -78,8 +78,8 @@ public class JSONSearchHandlerTestCase { File activeConfig = new File(tempDir); SearchChainConfigurerTestCase. createComponentsConfig(new File(activeConfig, "chains.cfg").getPath(), - new File(activeConfig, "handlers.cfg").getPath(), - new File(activeConfig, "components.cfg").getPath()); + new File(activeConfig, "handlers.cfg").getPath(), + new File(activeConfig, "components.cfg").getPath()); } private SearchHandler fetchSearchHandler(HandlersConfigurerTestWrapper configurer) { @@ -129,7 +129,7 @@ public class JSONSearchHandlerTestCase { assertNotSame("Have a new instance of the search handler", searchHandler, newSearchHandler); assertNotNull("Have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("hello")); assertNull("Don't have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("classLoadingError")); - try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(searchHandler)) { + try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) { assertJsonResult(json, newDriver); } } diff --git a/container-search/src/test/java/com/yahoo/search/handler/test/SearchHandlerTestCase.java b/container-search/src/test/java/com/yahoo/search/handler/test/SearchHandlerTestCase.java index 20b18ba6723..c96af2ed4d1 100644 --- a/container-search/src/test/java/com/yahoo/search/handler/test/SearchHandlerTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/handler/test/SearchHandlerTestCase.java @@ -36,6 +36,7 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -92,7 +93,7 @@ public class SearchHandlerTestCase { } @Test - public void testNullQuery() throws Exception { + public void testNullQuery() { assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<result total-hit-count=\"0\">\n" + " <hit relevancy=\"1.0\">\n" + @@ -125,10 +126,10 @@ public class SearchHandlerTestCase { // ...and check the resulting config SearchHandler newSearchHandler = fetchSearchHandler(configurer); - assertTrue("Have a new instance of the search handler", searchHandler != newSearchHandler); + assertNotSame("Have a new instance of the search handler", searchHandler, newSearchHandler); assertNotNull("Have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("hello")); assertNull("Don't have the new search chain", fetchSearchHandler(configurer).getSearchChainRegistry().getChain("classLoadingError")); - try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(searchHandler)) { + try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) { assertJsonResult("http://localhost?query=abc", newDriver); } } diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/typed/components.cfg b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/typed/components.cfg index 1110d76f887..a047ae1cb73 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/typed/components.cfg +++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/typed/components.cfg @@ -9,3 +9,4 @@ components[3].id DefaultSearcher components[3].classId com.yahoo.search.query.profile.config.test.QueryProfileIntegrationTestCase$DefaultSearcher components[4].id com.yahoo.search.handler.SearchHandler components[5].id com.yahoo.container.core.config.HandlersConfigurerDi$RegistriesHack +components[6].id com.yahoo.search.searchchain.ExecutionFactory diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/untyped/components.cfg b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/untyped/components.cfg index 70f5452b74d..ef9d4490a77 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/untyped/components.cfg +++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/untyped/components.cfg @@ -1,4 +1,4 @@ -components[6] +components[7] components[0].id SettingSearcher components[0].classId com.yahoo.search.query.profile.config.test.QueryProfileIntegrationTestCase$SettingSearcher components[1].id ReceivingSearcher @@ -8,4 +8,5 @@ components[2].classId com.yahoo.search.query.profile.config.test.QueryProfileInt components[3].id DefaultSearcher components[3].classId com.yahoo.search.query.profile.config.test.QueryProfileIntegrationTestCase$DefaultSearcher components[4].id com.yahoo.search.handler.SearchHandler -components[5].id com.yahoo.container.core.config.HandlersConfigurerDi$RegistriesHack
\ No newline at end of file +components[5].id com.yahoo.container.core.config.HandlersConfigurerDi$RegistriesHack +components[6].id com.yahoo.search.searchchain.ExecutionFactory 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 699e8619cd0..a57ed07017f 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 @@ -10,6 +10,7 @@ import com.yahoo.search.Result; import com.yahoo.search.Searcher; import com.yahoo.search.handler.SearchHandler; import com.yahoo.search.searchchain.Execution; +import com.yahoo.search.searchchain.ExecutionFactory; import com.yahoo.search.searchchain.SearchChain; import com.yahoo.search.searchchain.SearchChainRegistry; import com.yahoo.search.searchchain.SearcherRegistry; @@ -309,6 +310,7 @@ public class SearchChainConfigurerTestCase { /** * Copies the component ids from another config, e.g. 'handlers' to a 'components' array in a new components file, * to avoid a manually written 'components' file for tests where the bundle spec is given by the component id. + * * @param configFile Full path to the original config file, e.g. 'handlers' * @param componentsFile Full path to the new 'components' file * @param componentType The type of component, e.g. 'handler' @@ -324,7 +326,7 @@ public class SearchChainConfigurerTestCase { if (append) { Pattern p = Pattern.compile("^[a-z]+" + "\\[\\d+\\]\\.id (.+)"); BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(new File(componentsFile)), "UTF-8")); + new FileInputStream(new File(componentsFile)), "UTF-8")); while ((line = reader.readLine()) != null) { Matcher m = p.matcher(line); if (m.matches() && !m.group(1).equals(HandlersConfigurerDi.RegistriesHack.class.getName())) { @@ -344,10 +346,11 @@ public class SearchChainConfigurerTestCase { i++; } } - buf.append("components[").append(i).append("].id "). - append(HandlersConfigurerDi.RegistriesHack.class.getName()).append("\n"); - i++; reader.close(); + + buf.append("components[").append(i++).append("].id ").append(HandlersConfigurerDi.RegistriesHack.class.getName()).append("\n"); + if (componentType.equals("components")) + 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(new File(componentsFile)), "UTF-8"); |