use of com.sun.jersey.api.core.ClassNamesResourceConfig in project druid by druid-io.
the class WebserverTestUtils method createServer.
public static HttpServer createServer(String SERVICE_NAME, URI baseUri, String resourceClassName, Consumer<Binder> extender) throws IOException {
Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(binder -> {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to(SERVICE_NAME);
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(baseUri.getPort());
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(baseUri.getPort() + 1);
binder.bind(Key.get(ServiceEmitter.class)).toInstance(new NoopServiceEmitter());
binder.bind(Key.get(AuthConfig.class)).toInstance(new AuthConfig());
binder.bind(AuthorizerMapper.class).toInstance(AuthTestUtils.TEST_AUTHORIZER_MAPPER);
binder.bind(AuthenticatorMapper.class).toInstance(AuthTestUtils.TEST_AUTHENTICATOR_MAPPER);
binder.bind(Key.get(HttpClient.class, Client.class)).toInstance(EasyMock.createMock(HttpClient.class));
extender.accept(binder);
}));
ResourceConfig resourceConfig = new ClassNamesResourceConfig(resourceClassName + ';' + MockHttpServletRequest.class.getName());
IoCComponentProviderFactory ioc = new GuiceComponentProviderFactory(resourceConfig, injector);
HttpServer server = GrizzlyServerFactory.createHttpServer(baseUri, resourceConfig, ioc);
return server;
}
Aggregations