Search in sources :

Example 1 with Container

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

the class ContainerResourceTestCase method requireThatServerProvidersAreReleasedOnTermination.

@Test
public void requireThatServerProvidersAreReleasedOnTermination() {
    MyServerProvider server = new MyServerProvider();
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverProviders().install(server);
    driver.activateContainer(builder);
    Container container = driver.newReference(URI.create("http://localhost/"));
    assertEquals(1, server.retainCnt.get());
    driver.activateContainer(null);
    assertEquals(1, server.retainCnt.get());
    container.release();
    assertEquals(0, server.retainCnt.get());
    assertTrue(driver.close());
}
Also used : Container(com.yahoo.jdisc.Container) ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 2 with Container

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

the class ConnectionControlSearcherTestCase method doSearch.

private Result doSearch(URI uri, long connectedAtMillis, long nowMillis) {
    SocketAddress remoteAddress = Mockito.mock(SocketAddress.class);
    Version version = Version.HTTP_1_1;
    Method method = Method.GET;
    CurrentContainer container = Mockito.mock(CurrentContainer.class);
    Mockito.when(container.newReference(Mockito.any())).thenReturn(Mockito.mock(Container.class));
    final com.yahoo.jdisc.http.HttpRequest serverRequest = com.yahoo.jdisc.http.HttpRequest.newServerRequest(container, uri, method, version, remoteAddress, connectedAtMillis);
    HttpRequest incoming = new HttpRequest(serverRequest, new ByteArrayInputStream(new byte[0]));
    Query query = new Query(incoming);
    Execution e = new Execution(new Chain<Searcher>(ConnectionControlSearcher.createTestInstance(() -> nowMillis)), Execution.Context.createContextStub());
    Result r = e.search(query);
    return r;
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) ConnectionControlSearcher(com.yahoo.search.searchers.ConnectionControlSearcher) Method(com.yahoo.jdisc.http.HttpRequest.Method) CurrentContainer(com.yahoo.jdisc.service.CurrentContainer) Result(com.yahoo.search.Result) Container(com.yahoo.jdisc.Container) CurrentContainer(com.yahoo.jdisc.service.CurrentContainer) Execution(com.yahoo.search.searchchain.Execution) Version(com.yahoo.jdisc.http.HttpRequest.Version) ByteArrayInputStream(java.io.ByteArrayInputStream) SocketAddress(java.net.SocketAddress)

Example 3 with Container

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

the class ContainerShutdownTestCase method requireThatContainerBlocksTermination.

@Test
public void requireThatContainerBlocksTermination() {
    Context ctx = Context.newInstance();
    Container container = ctx.driver.newReference(URI.create("http://host/path"));
    assertFalse(ctx.shutdown());
    container.release();
    assertTrue(ctx.terminated);
    assertTrue(ctx.driver.close());
}
Also used : Container(com.yahoo.jdisc.Container) Test(org.junit.Test)

Example 4 with Container

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

the class ContainerResourceTestCase method requireThatBoundRequestHandlersAreReleasedOnTermination.

@Test
public void requireThatBoundRequestHandlersAreReleasedOnTermination() {
    MyRequestHandler handler = new MyRequestHandler();
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverBindings().bind("http://localhost/", handler);
    driver.activateContainer(builder);
    Container container = driver.newReference(URI.create("http://localhost/"));
    assertEquals(1, handler.retainCnt.get());
    driver.activateContainer(null);
    assertEquals(1, handler.retainCnt.get());
    container.release();
    assertEquals(0, handler.retainCnt.get());
    assertTrue(driver.close());
}
Also used : Container(com.yahoo.jdisc.Container) ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Aggregations

Container (com.yahoo.jdisc.Container)4 Test (org.junit.Test)3 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)2 TestDriver (com.yahoo.jdisc.test.TestDriver)2 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 Method (com.yahoo.jdisc.http.HttpRequest.Method)1 Version (com.yahoo.jdisc.http.HttpRequest.Version)1 CurrentContainer (com.yahoo.jdisc.service.CurrentContainer)1 Query (com.yahoo.search.Query)1 Result (com.yahoo.search.Result)1 Searcher (com.yahoo.search.Searcher)1 Execution (com.yahoo.search.searchchain.Execution)1 ConnectionControlSearcher (com.yahoo.search.searchers.ConnectionControlSearcher)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 SocketAddress (java.net.SocketAddress)1