Search in sources :

Example 1 with StupidSingleThreadedHttpServer

use of com.yahoo.search.StupidSingleThreadedHttpServer in project vespa by vespa-engine.

the class HttpPostTestCase method testPostingSearcher.

@Test
public void testPostingSearcher() throws Exception {
    StupidSingleThreadedHttpServer server = new StupidSingleThreadedHttpServer();
    server.start();
    TestPostSearcher searcher = new TestPostSearcher(new ComponentId("foo:1"), Arrays.asList(new Connection("localhost", server.getServerPort())), "/");
    Query q = new Query("");
    q.setTimeout(10000000L);
    Execution e = new Execution(searcher, Execution.Context.createContextStub());
    searcher.search(q, e);
    assertThat(server.getRequest(), containsString("My POST body"));
    server.stop();
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) StupidSingleThreadedHttpServer(com.yahoo.search.StupidSingleThreadedHttpServer) Connection(com.yahoo.search.federation.http.Connection) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 2 with StupidSingleThreadedHttpServer

use of com.yahoo.search.StupidSingleThreadedHttpServer in project vespa by vespa-engine.

the class HttpTestCase method setUp.

@Override
public void setUp() throws Exception {
    httpServer = new StupidSingleThreadedHttpServer(0, 0) {

        @Override
        protected byte[] getResponse(String request) {
            return Utf8.toBytes("HTTP/1.1 200 OK\r\n" + "Content-Type: text/xml; charset=UTF-8\r\n" + "Connection: close\r\n" + "Content-Length: 5\r\n" + "\r\n" + "hello");
        }
    };
    httpServer.start();
}
Also used : StupidSingleThreadedHttpServer(com.yahoo.search.StupidSingleThreadedHttpServer)

Aggregations

StupidSingleThreadedHttpServer (com.yahoo.search.StupidSingleThreadedHttpServer)2 ComponentId (com.yahoo.component.ComponentId)1 Query (com.yahoo.search.Query)1 Connection (com.yahoo.search.federation.http.Connection)1 Execution (com.yahoo.search.searchchain.Execution)1 Test (org.junit.Test)1