Search in sources :

Example 6 with RequestHandlerTestDriver

use of com.yahoo.container.jdisc.RequestHandlerTestDriver in project vespa by vespa-engine.

the class SearchHandlerTestCase method assertHandlerResponse.

private void assertHandlerResponse(int status, String responseData, String handlerName) throws Exception {
    RequestHandler forwardingHandler = configurer.getRequestHandlerRegistry().getComponent("com.yahoo.search.handler.test.SearchHandlerTestCase$" + handlerName + "Handler");
    try (RequestHandlerTestDriver forwardingDriver = new RequestHandlerTestDriver(forwardingHandler)) {
        RequestHandlerTestDriver.MockResponseHandler response = forwardingDriver.sendRequest("http://localhost/" + handlerName + "?query=test");
        response.awaitResponse();
        assertEquals("Expected HTTP status", status, response.getStatus());
        if (responseData == null)
            assertEquals("Connection closed with no data", null, response.read());
        else
            assertEquals(responseData, response.readAll());
    }
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) ThreadedHttpRequestHandler(com.yahoo.container.jdisc.ThreadedHttpRequestHandler) RequestHandlerTestDriver(com.yahoo.container.jdisc.RequestHandlerTestDriver)

Example 7 with RequestHandlerTestDriver

use of com.yahoo.container.jdisc.RequestHandlerTestDriver in project vespa by vespa-engine.

the class SearchHandlerTestCase method driverWithConfig.

private RequestHandlerTestDriver driverWithConfig(String configDirectory) throws Exception {
    IOUtils.copyDirectory(new File(testDir, configDirectory), new File(tempDir), 1);
    generateComponentsConfigForActive();
    configurer.reloadConfig();
    SearchHandler newSearchHandler = fetchSearchHandler(configurer);
    assertTrue("Should have a new instance of the search handler", searchHandler != newSearchHandler);
    return new RequestHandlerTestDriver(newSearchHandler);
}
Also used : SearchHandler(com.yahoo.search.handler.SearchHandler) RequestHandlerTestDriver(com.yahoo.container.jdisc.RequestHandlerTestDriver) File(java.io.File)

Aggregations

RequestHandlerTestDriver (com.yahoo.container.jdisc.RequestHandlerTestDriver)7 SearchHandler (com.yahoo.search.handler.SearchHandler)5 File (java.io.File)5 Test (org.junit.Test)3 ThreadedHttpRequestHandler (com.yahoo.container.jdisc.ThreadedHttpRequestHandler)2 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)2 Container (com.yahoo.container.Container)1 HandlersConfigurerTestWrapper (com.yahoo.container.core.config.testutil.HandlersConfigurerTestWrapper)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1