Search in sources :

Example 1 with JdbiExceptionsBundle

use of io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle in project dropwizard by dropwizard.

the class JdbiExceptionsBundleTest method test.

@Test
void test() {
    Environment environment = mock(Environment.class);
    JerseyEnvironment jerseyEnvironment = mock(JerseyEnvironment.class);
    when(environment.jersey()).thenReturn(jerseyEnvironment);
    new JdbiExceptionsBundle().run(new Configuration(), environment);
    verify(jerseyEnvironment).register(isA(LoggingSQLExceptionMapper.class));
    verify(jerseyEnvironment).register(isA(LoggingJdbiExceptionMapper.class));
}
Also used : JerseyEnvironment(io.dropwizard.jersey.setup.JerseyEnvironment) Configuration(io.dropwizard.Configuration) LoggingSQLExceptionMapper(io.dropwizard.jdbi3.jersey.LoggingSQLExceptionMapper) LoggingJdbiExceptionMapper(io.dropwizard.jdbi3.jersey.LoggingJdbiExceptionMapper) Environment(io.dropwizard.setup.Environment) JerseyEnvironment(io.dropwizard.jersey.setup.JerseyEnvironment) Test(org.junit.jupiter.api.Test)

Example 2 with JdbiExceptionsBundle

use of io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle in project consent by DataBiosphere.

the class ConsentApplication method initialize.

@Override
public void initialize(Bootstrap<ConsentConfiguration> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/assets/", "/api-docs", "index.html"));
    bootstrap.addBundle(new MultiPartBundle());
    bootstrap.addBundle(new JdbiExceptionsBundle());
}
Also used : MultiPartBundle(io.dropwizard.forms.MultiPartBundle) JdbiExceptionsBundle(io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle) AssetsBundle(io.dropwizard.assets.AssetsBundle)

Example 3 with JdbiExceptionsBundle

use of io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle in project pay-ledger by alphagov.

the class LedgerApp method initialize.

@Override
public void initialize(Bootstrap<LedgerConfig> bootstrap) {
    bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false)));
    bootstrap.addBundle(new MigrationsBundle<>() {

        @Override
        public DataSourceFactory getDataSourceFactory(LedgerConfig configuration) {
            return configuration.getDataSourceFactory();
        }
    });
    bootstrap.addBundle(new JdbiExceptionsBundle());
    bootstrap.addCommand(new DependentResourceWaitCommand());
    bootstrap.getObjectMapper().getSubtypeResolver().registerSubtypes(LogstashConsoleAppenderFactory.class);
    bootstrap.getObjectMapper().getSubtypeResolver().registerSubtypes(GovUkPayDropwizardRequestJsonLogLayoutFactory.class);
}
Also used : SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) DataSourceFactory(io.dropwizard.db.DataSourceFactory) JdbiExceptionsBundle(io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor) DependentResourceWaitCommand(uk.gov.pay.ledger.healthcheck.DependentResourceWaitCommand)

Example 4 with JdbiExceptionsBundle

use of io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle in project pay-publicauth by alphagov.

the class PublicAuthApp method initialize.

@Override
public void initialize(Bootstrap<PublicAuthConfiguration> bootstrap) {
    bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false)));
    bootstrap.addBundle(new JdbiExceptionsBundle());
    bootstrap.addBundle(new MigrationsBundle<PublicAuthConfiguration>() {

        @Override
        public DataSourceFactory getDataSourceFactory(PublicAuthConfiguration configuration) {
            return configuration.getDataSourceFactory();
        }
    });
    bootstrap.addCommand(new DependentResourceWaitCommand());
    bootstrap.getObjectMapper().getSubtypeResolver().registerSubtypes(LogstashConsoleAppenderFactory.class);
    bootstrap.getObjectMapper().getSubtypeResolver().registerSubtypes(GovUkPayDropwizardRequestJsonLogLayoutFactory.class);
}
Also used : SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) DataSourceFactory(io.dropwizard.db.DataSourceFactory) JdbiExceptionsBundle(io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle) PublicAuthConfiguration(uk.gov.pay.publicauth.app.config.PublicAuthConfiguration) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor) DependentResourceWaitCommand(uk.gov.pay.publicauth.util.DependentResourceWaitCommand)

Example 5 with JdbiExceptionsBundle

use of io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle in project FrameworkBenchmarks by TechEmpower.

the class HelloJDBIService method initialize.

@Override
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
    bootstrap.addBundle(new ViewBundle<>());
    // Provides automatic unwrapping of SQLException and DBIException
    bootstrap.addBundle(new JdbiExceptionsBundle());
}
Also used : JdbiExceptionsBundle(io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle)

Aggregations

JdbiExceptionsBundle (io.dropwizard.jdbi3.bundles.JdbiExceptionsBundle)5 EnvironmentVariableSubstitutor (io.dropwizard.configuration.EnvironmentVariableSubstitutor)3 SubstitutingSourceProvider (io.dropwizard.configuration.SubstitutingSourceProvider)3 AssetsBundle (io.dropwizard.assets.AssetsBundle)2 DataSourceFactory (io.dropwizard.db.DataSourceFactory)2 ZipkinFactory (com.smoketurner.dropwizard.zipkin.ZipkinFactory)1 ArlasServerConfiguration (io.arlas.server.core.app.ArlasServerConfiguration)1 Configuration (io.dropwizard.Configuration)1 MultiPartBundle (io.dropwizard.forms.MultiPartBundle)1 LoggingJdbiExceptionMapper (io.dropwizard.jdbi3.jersey.LoggingJdbiExceptionMapper)1 LoggingSQLExceptionMapper (io.dropwizard.jdbi3.jersey.LoggingSQLExceptionMapper)1 JerseyEnvironment (io.dropwizard.jersey.setup.JerseyEnvironment)1 Environment (io.dropwizard.setup.Environment)1 SwaggerBundleConfiguration (io.federecio.dropwizard.swagger.SwaggerBundleConfiguration)1 Test (org.junit.jupiter.api.Test)1 DependentResourceWaitCommand (uk.gov.pay.ledger.healthcheck.DependentResourceWaitCommand)1 PublicAuthConfiguration (uk.gov.pay.publicauth.app.config.PublicAuthConfiguration)1 DependentResourceWaitCommand (uk.gov.pay.publicauth.util.DependentResourceWaitCommand)1