use of io.dropwizard.db.DataSourceFactory in project dropwizard by dropwizard.
the class SessionFactoryFactoryTest method setUp.
@Before
public void setUp() throws Exception {
when(environment.metrics()).thenReturn(metricRegistry);
when(environment.lifecycle()).thenReturn(lifecycleEnvironment);
config = new DataSourceFactory();
config.setUrl("jdbc:hsqldb:mem:DbTest-" + System.currentTimeMillis());
config.setUser("sa");
config.setDriverClass("org.hsqldb.jdbcDriver");
config.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
final ImmutableMap<String, String> properties = ImmutableMap.of("hibernate.show_sql", "true", "hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
config.setProperties(properties);
}
use of io.dropwizard.db.DataSourceFactory in project dropwizard by dropwizard.
the class OptionalDoubleTest method setupTests.
@Before
public void setupTests() throws IOException {
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:mem:optional-double-" + System.currentTimeMillis() + "?user=sa");
dataSourceFactory.setInitialSize(1);
final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
try (Handle h = dbi.open()) {
h.execute("CREATE TABLE test (id INT PRIMARY KEY, optional DOUBLE)");
}
dao = dbi.onDemand(TestDao.class);
}
use of io.dropwizard.db.DataSourceFactory in project dropwizard by dropwizard.
the class OptionalIntTest method setupTests.
@Before
public void setupTests() throws IOException {
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:mem:optional-int-" + System.currentTimeMillis() + "?user=sa");
dataSourceFactory.setInitialSize(1);
final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
try (Handle h = dbi.open()) {
h.execute("CREATE TABLE test (id INT PRIMARY KEY, optional INT)");
}
dao = dbi.onDemand(TestDao.class);
}
use of io.dropwizard.db.DataSourceFactory in project dropwizard by dropwizard.
the class GuavaOptionalLocalDateTest method setupTests.
@Before
public void setupTests() throws IOException {
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:mem:guava-local-date-" + System.currentTimeMillis() + "?user=sa");
dataSourceFactory.setInitialSize(1);
final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
try (Handle h = dbi.open()) {
h.execute("CREATE TABLE IF NOT EXISTS tasks (" + "id INT PRIMARY KEY, " + "assignee VARCHAR(255) NOT NULL, " + "start_date TIMESTAMP, " + "end_date TIMESTAMP, " + "comments VARCHAR(1024) " + ")");
}
dao = dbi.onDemand(TaskDao.class);
}
use of io.dropwizard.db.DataSourceFactory in project dropwizard by dropwizard.
the class GuavaOptionalZonedDateTimeTest method setupTests.
@Before
public void setupTests() throws IOException {
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:mem:guava-zoned-date-time-" + System.currentTimeMillis() + "?user=sa");
dataSourceFactory.setInitialSize(1);
final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
try (Handle h = dbi.open()) {
h.execute("CREATE TABLE IF NOT EXISTS tasks (" + "id INT PRIMARY KEY, " + "assignee VARCHAR(255) NOT NULL, " + "start_date TIMESTAMP, " + "end_date TIMESTAMP, " + "comments VARCHAR(1024) " + ")");
}
dao = dbi.onDemand(TaskDao.class);
}
Aggregations