use of io.dropwizard.setup.Environment in project dropwizard by dropwizard.
the class DefaultServerFactoryTest method doesNotDefaultExceptionMappers.
@Test
public void doesNotDefaultExceptionMappers() throws Exception {
http.setRegisterDefaultExceptionMappers(false);
assertThat(http.getRegisterDefaultExceptionMappers()).isFalse();
Environment environment = new Environment("test", Jackson.newObjectMapper(), Validators.newValidator(), new MetricRegistry(), ClassLoader.getSystemClassLoader());
http.build(environment);
assertThat(environment.jersey().getResourceConfig().getSingletons()).filteredOn(x -> x instanceof ExceptionMapperBinder).isEmpty();
}
use of io.dropwizard.setup.Environment in project dropwizard by dropwizard.
the class EnvironmentCommand method run.
@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
final Environment environment = new Environment(bootstrap.getApplication().getName(), bootstrap.getObjectMapper(), bootstrap.getValidatorFactory().getValidator(), bootstrap.getMetricRegistry(), bootstrap.getClassLoader(), bootstrap.getHealthCheckRegistry());
configuration.getMetricsFactory().configure(environment.lifecycle(), bootstrap.getMetricRegistry());
configuration.getServerFactory().configure(environment);
bootstrap.run(configuration, environment);
application.run(configuration, environment);
run(environment, namespace, configuration);
}
use of io.dropwizard.setup.Environment in project keywhiz by square.
the class ServiceModule method configure.
@Override
protected void configure() {
// Initialize the BouncyCastle security provider for cryptography support.
BouncyCastle.require();
bind(Clock.class).toInstance(Clock.systemUTC());
install(new CookieModule(config.getCookieKey()));
install(new CryptoModule(config.getDerivationProviderClass(), config.getContentKeyStore()));
bind(CookieConfig.class).annotatedWith(SessionCookie.class).toInstance(config.getSessionCookieConfig());
bind(CookieConfig.class).annotatedWith(Xsrf.class).toInstance(config.getXsrfCookieConfig());
// TODO(justin): Consider https://github.com/HubSpot/dropwizard-guice.
bind(Environment.class).toInstance(environment);
bind(Configuration.class).toInstance(config);
bind(KeywhizConfig.class).toInstance(config);
}
use of io.dropwizard.setup.Environment 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));
}
use of io.dropwizard.setup.Environment in project dropwizard by dropwizard.
the class DBIClient method before.
@Override
protected void before() throws Throwable {
final Environment environment = new Environment("test", Jackson.newObjectMapper(), Validators.newValidator(), new MetricRegistry(), getClass().getClassLoader());
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:tcp://localhost/fldb");
dataSourceFactory.setUser("sa");
dataSourceFactory.setPassword("");
// Set the time zone of the database
final DBIFactory dbiFactory = new DBIFactory() {
@Override
protected Optional<TimeZone> databaseTimeZone() {
return Optional.of(dbTimeZone);
}
};
dbi = dbiFactory.build(environment, dataSourceFactory, "test-jdbi-time-zones");
// Start the DB pool
managedObjects = environment.lifecycle().getManagedObjects();
for (LifeCycle managedObject : managedObjects) {
managedObject.start();
}
}
Aggregations