public void testGuiceInjectionWithResources()
throws Exception
{
final DummyServlet servlet = new DummyServlet();
Bootstrap app = bootstrapApplication("test-application")
.doNotInitializeLogging()
.withModules(
new TestingNodeModule(),
new TestingHttpServerModule(),
new Module()
{
@Override
public void configure(Binder binder)
{
binder.bind(Servlet.class).annotatedWith(TheServlet.class).toInstance(servlet);
binder.bind(new TypeLiteral<Map<String, String>>()
{
}).annotatedWith(TheServlet.class).toInstance(ImmutableMap.<String, String>of());
httpServerBinder(binder).bindResource("/", "webapp/user").withWelcomeFile("user-welcome.txt");
httpServerBinder(binder).bindResource("/", "webapp/user2");
httpServerBinder(binder).bindResource("path", "webapp/user").withWelcomeFile("user-welcome.txt");
httpServerBinder(binder).bindResource("path", "webapp/user2");
}
});
Injector injector = app.initialize();
LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
TestingHttpServer server = injector.getInstance(TestingHttpServer.class);
try (HttpClient client = new JettyHttpClient(new HttpClientConfig().setConnectTimeout(new Duration(1, SECONDS)))) {