Search in sources :

Example 11 with BQRuntime

use of io.bootique.BQRuntime in project bootique-jdbc by bootique.

the class TableMatcherIT method setupDB.

@BeforeClass
public static void setupDB() {
    BQRuntime runtime = TEST_FACTORY.app("-c", "classpath:io/bootique/jdbc/test/matcher/TableMatcherIT.yml").autoLoadModules().createRuntime();
    DatabaseChannel channel = DatabaseChannel.get(runtime);
    channel.execStatement().exec("CREATE TABLE \"t1\" (\"c1\" INT, \"c2\" VARCHAR(10), \"c3\" VARCHAR(10))");
    channel.execStatement().exec("CREATE TABLE \"t2\" (\"c1\" INT, \"c2\" INT, \"c3\" DATE, \"c4\" TIMESTAMP)");
    channel.execStatement().exec("CREATE TABLE \"t3\" (\"c1\" INT, \"c2\" VARCHAR (10) FOR BIT DATA)");
    T1 = channel.newTable("t1").columnNames("c1", "c2", "c3").initColumnTypesFromDBMetadata().build();
    T2 = channel.newTable("t2").columnNames("c1", "c2", "c3", "c4").initColumnTypesFromDBMetadata().build();
    T3 = channel.newTable("t3").columnNames("c1", "c2").initColumnTypesFromDBMetadata().build();
}
Also used : DatabaseChannel(io.bootique.jdbc.test.DatabaseChannel) BQRuntime(io.bootique.BQRuntime) BeforeClass(org.junit.BeforeClass)

Example 12 with BQRuntime

use of io.bootique.BQRuntime in project bootique-jdbc by bootique.

the class TomcatInstrumentedJdbcModuleIT method testMetrics.

@Test
public void testMetrics() {
    BQRuntime runtime = TEST_FACTORY.app("-c", "classpath:io/bootique/jdbc/instrumented/dummy-ds.yml").autoLoadModules().createRuntime();
    DataSourceFactory factory = runtime.getInstance(DataSourceFactory.class);
    DataSource dataSource = factory.forName("DerbyDatabaseIT");
    assertNotNull(dataSource);
    MetricRegistry metricRegistry = runtime.getInstance(MetricRegistry.class);
    assertNotEquals(metricRegistry.getGauges().size(), 0);
}
Also used : DataSourceFactory(io.bootique.jdbc.DataSourceFactory) BQRuntime(io.bootique.BQRuntime) MetricRegistry(com.codahale.metrics.MetricRegistry) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 13 with BQRuntime

use of io.bootique.BQRuntime in project bootique-jdbc by bootique.

the class InstrumentedJdbcModuleProviderTest method testModuleDeclaresDependencies.

@Test
public void testModuleDeclaresDependencies() {
    final BQRuntime bqRuntime = testFactory.app().module(new InstrumentedJdbcModuleProvider()).createRuntime();
    BQRuntimeChecker.testModulesLoaded(bqRuntime, JdbcModule.class, HealthCheckModule.class);
}
Also used : BQRuntime(io.bootique.BQRuntime) Test(org.junit.Test)

Example 14 with BQRuntime

use of io.bootique.BQRuntime in project bootique-jdbc by bootique.

the class TomcatJdbcModuleIT method testDataSource.

@Test
public void testDataSource() {
    BQRuntime runtime = testFactory.app("-c", "classpath:TomcatJdbcModuleIT_full.yml").autoLoadModules().createRuntime();
    DataSource ds = runtime.getInstance(DataSourceFactory.class).forName("derby1");
    assertNotNull(ds);
    assertTrue(ds instanceof org.apache.tomcat.jdbc.pool.DataSource);
    org.apache.tomcat.jdbc.pool.DataSource tomcatDS = (org.apache.tomcat.jdbc.pool.DataSource) ds;
    assertEquals("jdbc:derby:target/derby1;create=true", tomcatDS.getUrl());
    assertEquals("sa", tomcatDS.getUsername());
    assertEquals(0, tomcatDS.getInitialSize());
    assertEquals(1, tomcatDS.getMinIdle());
    assertEquals(3, tomcatDS.getMaxIdle());
    assertEquals(6, tomcatDS.getMaxActive());
}
Also used : DataSourceFactory(io.bootique.jdbc.DataSourceFactory) BQRuntime(io.bootique.BQRuntime) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 15 with BQRuntime

use of io.bootique.BQRuntime in project bootique-jdbc by bootique.

the class TomcatJdbcModuleProviderIT method testModuleDeclaresDependencies.

@Test
public void testModuleDeclaresDependencies() {
    final BQRuntime bqRuntime = testFactory.app().module(new TomcatJdbcModuleProvider()).createRuntime();
    BQRuntimeChecker.testModulesLoaded(bqRuntime, TomcatJdbcModule.class, JdbcModule.class);
}
Also used : BQRuntime(io.bootique.BQRuntime) Test(org.junit.Test)

Aggregations

BQRuntime (io.bootique.BQRuntime)45 Test (org.junit.Test)39 DataSource (javax.sql.DataSource)23 DataSourceFactory (io.bootique.jdbc.DataSourceFactory)22 HikariDataSource (com.zaxxer.hikari.HikariDataSource)12 ProvisionException (com.google.inject.ProvisionException)10 BootiqueException (io.bootique.BootiqueException)10 BQTestFactory (io.bootique.test.junit.BQTestFactory)10 JsonTypeName (com.fasterxml.jackson.annotation.JsonTypeName)9 Injector (com.google.inject.Injector)9 Map (java.util.Map)9 Optional (java.util.Optional)9 Assert.assertNotNull (org.junit.Assert.assertNotNull)9 Assert.assertTrue (org.junit.Assert.assertTrue)9 Assert.fail (org.junit.Assert.fail)9 Rule (org.junit.Rule)9 Mockito.mock (org.mockito.Mockito.mock)9 JdbcModule (io.bootique.jdbc.JdbcModule)8 Connection (java.sql.Connection)7 ConfigurationFactory (io.bootique.config.ConfigurationFactory)6