use of com.codahale.metrics.jdbi3.strategies.TimedAnnotationNameStrategy in project dropwizard by dropwizard.
the class JdbiTest method setUp.
@BeforeEach
void setUp() throws Exception {
environment = new Environment("test");
metricRegistry = environment.metrics();
DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setUrl("jdbc:h2:mem:jdbi3-test");
dataSourceFactory.setUser("sa");
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.asSingleConnectionPool();
dbi = new JdbiFactory(new TimedAnnotationNameStrategy()).build(environment, dataSourceFactory, "h2");
dbi.useTransaction(h -> {
h.createScript(new String(ByteStreams.toByteArray(getClass().getResourceAsStream("/schema.sql")), StandardCharsets.UTF_8)).execute();
h.createScript(new String(ByteStreams.toByteArray(getClass().getResourceAsStream("/data.sql")), StandardCharsets.UTF_8)).execute();
});
dao = dbi.onDemand(GameDao.class);
for (LifeCycle lc : environment.lifecycle().getManagedObjects()) {
lc.start();
}
}
Aggregations