use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class MockUserDatabaseClientTest method setupJDisc.
private void setupJDisc(Collection<Chain<Processor>> chains) {
driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
ChainRegistry<Processor> registry = new ChainRegistry<>();
for (Chain<Processor> chain : chains) registry.register(chain.getId(), chain);
builder.clientBindings().bind("pio://endpoint/*", new MockUserDatabaseRequestHandler());
driver.activateContainer(builder);
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class MbusRequestHandlerTestCase method newTestDriver.
private static TestDriver newTestDriver(MbusRequestHandler handler) {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("mbus://*/*", handler);
driver.activateContainer(builder);
return driver;
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ContainerTerminationTestCase method requireThatAppContextIsFromBuilder.
@Test
public void requireThatAppContextIsFromBuilder() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
Object obj = new Object();
builder.setAppContext(obj);
driver.activateContainer(builder);
DeactivatedContainer container = driver.activateContainer(null);
assertSame(obj, container.appContext());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ServerProviderConformanceTest method runTest.
private <T extends ServerProvider, U, V> void runTest(final Adapter<T, U, V> adapter, final Module testConfig, final RequestType requestType, final TestRequestHandler requestHandler) throws Throwable {
final Module config = Modules.override(newDefaultConfig(), adapter.newConfigModule()).with(testConfig);
final TestDriver driver = TestDriver.newSimpleApplicationInstance(config);
final ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind(builder.getInstance(Key.get(String.class, Names.named("serverBinding"))), requestHandler);
final T serverProvider = builder.guiceModules().getInstance(adapter.getServerProviderClass());
builder.serverProviders().install(serverProvider);
if (builder.getInstance(Key.get(Boolean.class, Names.named("activateContainer")))) {
driver.activateContainer(builder);
}
serverProvider.start();
serverProvider.release();
for (int i = 0; i < NUM_RUNS_EACH_TEST; ++i) {
log.fine("Test run #" + i);
requestHandler.reset(adapter.newResponseContent());
final U client = adapter.newClient(serverProvider);
final boolean withRequestContent = requestType == RequestType.WITH_CONTENT;
final V result = adapter.executeRequest(client, withRequestContent);
adapter.validateResponse(result);
if (client instanceof Closeable) {
((Closeable) client).close();
}
requestHandler.awaitAsyncTasks();
}
serverProvider.close();
driver.close();
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class LatencyTestCase method runLatencyMeasurements.
@Test
public void runLatencyMeasurements() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
MyRequestHandler foo = new MyRequestHandler("foo");
MyRequestHandler bar = new MyRequestHandler("bar");
MyRequestHandler baz = new MyRequestHandler("baz");
builder.serverBindings().bind(foo.uri, foo);
builder.serverBindings().bind(bar.uri, bar);
builder.serverBindings().bind(baz.uri, baz);
driver.activateContainer(builder);
measureLatencies(NUM_REQUESTS, driver, foo, bar, baz);
TimeTrack time = measureLatencies(NUM_REQUESTS, driver, foo, bar, baz);
System.err.println("\n" + time);
foo.release();
bar.release();
baz.release();
assertTrue(driver.close());
}
Aggregations