use of io.dropwizard.jersey.setup.JerseyEnvironment in project dropwizard by dropwizard.
the class HibernateBundleTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
when(environment.healthChecks()).thenReturn(healthChecks);
when(environment.jersey()).thenReturn(jerseyEnvironment);
when(jerseyEnvironment.getResourceConfig()).thenReturn(new DropwizardResourceConfig());
when(factory.build(eq(bundle), any(Environment.class), any(DataSourceFactory.class), anyList(), eq("hibernate"))).thenReturn(sessionFactory);
}
use of io.dropwizard.jersey.setup.JerseyEnvironment in project keywhiz by square.
the class KeywhizService method run.
@SuppressWarnings("unchecked")
@Override
public void run(KeywhizConfig config, Environment environment) throws Exception {
if (injector == null) {
logger.debug("No existing guice injector; creating new one");
injector = Guice.createInjector(new ServiceModule(config, environment));
}
JerseyEnvironment jersey = environment.jersey();
logger.debug("Registering resource filters");
jersey.register(injector.getInstance(ClientCertificateFilter.class));
logger.debug("Registering servlet filters");
environment.servlets().addFilter("security-headers-filter", injector.getInstance(SecurityHeadersFilter.class)).addMappingForUrlPatterns(null, /* Default is for requests */
false, /* Can be after other filters */
"/*");
jersey.register(injector.getInstance(CookieRenewingFilter.class));
environment.servlets().addFilter("xsrf-filter", injector.getInstance(XsrfServletFilter.class)).addMappingForUrlPatterns(null, /* Default is for requests */
false, /* Can be after other filters */
"/admin/*");
logger.debug("Registering providers");
jersey.register(new AuthResolver.Binder(injector.getInstance(ClientAuthFactory.class), injector.getInstance(AutomationClientAuthFactory.class), injector.getInstance(UserAuthFactory.class)));
logger.debug("Registering resources");
jersey.register(injector.getInstance(ClientResource.class));
jersey.register(injector.getInstance(ClientsResource.class));
jersey.register(injector.getInstance(GroupResource.class));
jersey.register(injector.getInstance(GroupsResource.class));
jersey.register(injector.getInstance(MembershipResource.class));
jersey.register(injector.getInstance(SecretsDeliveryResource.class));
jersey.register(injector.getInstance(SecretResource.class));
jersey.register(injector.getInstance(SecretsResource.class));
jersey.register(injector.getInstance(SecretDeliveryResource.class));
jersey.register(injector.getInstance(SessionLoginResource.class));
jersey.register(injector.getInstance(SessionLogoutResource.class));
jersey.register(injector.getInstance(SessionMeResource.class));
jersey.register(injector.getInstance(AutomationClientResource.class));
jersey.register(injector.getInstance(AutomationGroupResource.class));
jersey.register(injector.getInstance(AutomationSecretResource.class));
jersey.register(injector.getInstance(AutomationEnrollClientGroupResource.class));
jersey.register(injector.getInstance(AutomationSecretAccessResource.class));
jersey.register(injector.getInstance(StatusResource.class));
ManualStatusHealthCheck mshc = new ManualStatusHealthCheck();
environment.healthChecks().register("manualStatus", mshc);
environment.admin().addServlet("manualStatus", new ManualStatusServlet(mshc)).addMapping("/status/*");
validateDatabase(config);
logger.debug("Keywhiz configuration complete");
}
use of io.dropwizard.jersey.setup.JerseyEnvironment in project dropwizard by dropwizard.
the class DBIExceptionsBundleTest method test.
@Test
public void test() {
Environment environment = mock(Environment.class);
JerseyEnvironment jerseyEnvironment = mock(JerseyEnvironment.class);
when(environment.jersey()).thenReturn(jerseyEnvironment);
new DBIExceptionsBundle().run(environment);
verify(jerseyEnvironment, times(1)).register(isA(LoggingSQLExceptionMapper.class));
verify(jerseyEnvironment, times(1)).register(isA(LoggingDBIExceptionMapper.class));
}
Aggregations