diff options
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/handler/test/SearchHandlerTestCase.java')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/handler/test/SearchHandlerTestCase.java | 75 |
1 files changed, 19 insertions, 56 deletions
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 5ef13eba2ed..20b18ba6723 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 @@ -15,7 +15,7 @@ import com.yahoo.search.Result; import com.yahoo.search.Searcher; import com.yahoo.search.handler.HttpSearchResponse; import com.yahoo.search.handler.SearchHandler; -import com.yahoo.search.rendering.DefaultRenderer; +import com.yahoo.search.rendering.XmlRenderer; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.result.Hit; import com.yahoo.search.searchchain.Execution; @@ -105,12 +105,12 @@ public class SearchHandlerTestCase { } @Test - public void testFailing() throws Exception { + public void testFailing() { assertTrue(driver.sendRequest("http://localhost?query=test&searchChain=classLoadingError").readAll().contains("NoClassDefFoundError")); } @Test - public synchronized void testPluginError() throws Exception { + public synchronized void testPluginError() { assertTrue(driver.sendRequest("http://localhost?query=test&searchChain=exceptionInPlugin").readAll().contains("NullPointerException")); } @@ -158,11 +158,11 @@ public class SearchHandlerTestCase { Result r = new Result(q); r.hits().addError(ErrorMessage.createUnspecifiedError("bamse")); r.hits().add(new Hit("http://localhost/dummy", 0.5)); - HttpSearchResponse s = new HttpSearchResponse(200, r, q, new DefaultRenderer()); + HttpSearchResponse s = new HttpSearchResponse(200, r, q, new XmlRenderer()); assertEquals("text/xml", s.getContentType()); assertNull(s.getCoverage()); assertEquals("query 'dummy'", s.getParsedQuery()); - assertEquals(5000, s.getTiming().getTimeout()); + assertEquals(500, s.getTiming().getTimeout()); } @Test @@ -191,7 +191,7 @@ public class SearchHandlerTestCase { } } @Test - public void testInvalidQueryParamWithoutQueryProfile() throws Exception { + public void testInvalidQueryParamWithoutQueryProfile() { testInvalidQueryParam(driver); } private void testInvalidQueryParam(final RequestHandlerTestDriver testDriver) { @@ -213,45 +213,35 @@ public class SearchHandlerTestCase { } @Test - public void testNormalResultImplicitDefaultRendering() throws Exception { + public void testNormalResultImplicitDefaultRendering() { assertJsonResult("http://localhost?query=abc", driver); } @Test - public void testNormalResultExplicitDefaultRendering() throws Exception { + public void testNormalResultExplicitDefaultRendering() { assertJsonResult("http://localhost?query=abc&format=default", driver); } @Test - public void testNormalResultXmlAliasRendering() throws Exception { + public void testNormalResultXmlAliasRendering() { assertXmlResult("http://localhost?query=abc&format=xml", driver); } @Test - public void testNormalResultJsonAliasRendering() throws Exception { + public void testNormalResultJsonAliasRendering() { assertJsonResult("http://localhost?query=abc&format=json", driver); } @Test - public void testNormalResultExplicitDefaultRenderingFullRendererName1() throws Exception { - assertXmlResult("http://localhost?query=abc&format=DefaultRenderer", driver); + public void testNormalResultExplicitDefaultRenderingFullRendererName1() { + assertXmlResult("http://localhost?query=abc&format=XmlRenderer", driver); } @Test - public void testNormalResultExplicitDefaultRenderingFullRendererName2() throws Exception { + public void testNormalResultExplicitDefaultRenderingFullRendererName2() { assertJsonResult("http://localhost?query=abc&format=JsonRenderer", driver); } - @Test - public void testResultLegacyTiledFormat() throws Exception { - assertTiledResult("http://localhost?query=abc&format=tiled", driver); - } - - @Test - public void testResultLegacyPageFormat() throws Exception { - assertPageResult("http://localhost?query=abc&format=page", driver); - } - private static final String xmlResult = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<result total-hit-count=\"0\">\n" + @@ -260,10 +250,12 @@ public class SearchHandlerTestCase { " <field name=\"uri\">testHit</field>\n" + " </hit>\n" + "</result>\n"; - private void assertXmlResult(String request, RequestHandlerTestDriver driver) throws Exception { + + private void assertXmlResult(String request, RequestHandlerTestDriver driver) { assertOkResult(driver.sendRequest(request), xmlResult); } - private void assertXmlResult(RequestHandlerTestDriver driver) throws Exception { + + private void assertXmlResult(RequestHandlerTestDriver driver) { assertXmlResult("http://localhost?query=abc", driver); } @@ -272,38 +264,9 @@ public class SearchHandlerTestCase { + "\"children\":[" + "{\"id\":\"testHit\",\"relevance\":1.0,\"fields\":{\"uri\":\"testHit\"}}" + "]}}"; - private void assertJsonResult(String request, RequestHandlerTestDriver driver) throws Exception { - assertOkResult(driver.sendRequest(request), jsonResult); - } - - private static final String tiledResult = - "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + - "<result version=\"1.0\">\n" + - "\n" + - " <hit relevance=\"1.0\">\n" + - " <id>testHit</id>\n" + - " <uri>testHit</uri>\n" + - " </hit>\n" + - "\n" + - "</result>\n"; - private void assertTiledResult(String request, RequestHandlerTestDriver driver) throws Exception { - assertOkResult(driver.sendRequest(request), tiledResult); - } - private static final String pageResult = - "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + - "<page version=\"1.0\">\n" + - "\n" + - " <content>\n" + - " <hit relevance=\"1.0\">\n" + - " <id>testHit</id>\n" + - " <uri>testHit</uri>\n" + - " </hit>\n" + - " </content>\n" + - "\n" + - "</page>\n"; - private void assertPageResult(String request, RequestHandlerTestDriver driver) throws Exception { - assertOkResult(driver.sendRequest(request), pageResult); + private void assertJsonResult(String request, RequestHandlerTestDriver driver) { + assertOkResult(driver.sendRequest(request), jsonResult); } private void assertOkResult(RequestHandlerTestDriver.MockResponseHandler response, String expected) { |