use of io.bootique.BQRuntime in project bootique-jdbc by bootique.
the class HikariCPInstrumentedModuleIT method testHealthChecks_TurnedOn.
@Test
public void testHealthChecks_TurnedOn() {
BQRuntime runtime = TEST_FACTORY.app("-c", "classpath:io/bootique/jdbc/instrumented/hikaricp/hikaricp-ds-health.yml").autoLoadModules().createRuntime();
DataSourceFactory factory = runtime.getInstance(DataSourceFactory.class);
String dataSourceName = "derby1";
HikariDataSource dataSource = (HikariDataSource) factory.forName(dataSourceName);
assertNotNull(dataSource);
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
assertTrue(registry.containsHealthCheck(ConnectivityCheck.healthCheckName(dataSourceName)));
assertTrue(registry.containsHealthCheck(Connection99PercentCheck.healthCheckName(dataSourceName)));
/**
* embedded health check {@link io.bootique.jdbc.instrumented.healthcheck.DataSourceHealthCheck}
*/
assertTrue(registry.containsHealthCheck(DataSourceHealthCheck.healthCheckName(dataSourceName)));
Map<String, HealthCheckOutcome> results = registry.runHealthChecks();
assertEquals(results.size(), 3);
}
use of io.bootique.BQRuntime in project bootique-jdbc by bootique.
the class HikariCPInstrumentedModuleProviderTest method testModuleDeclaresDependencies.
@Test
public void testModuleDeclaresDependencies() {
final BQRuntime bqRuntime = testFactory.app().module(new HikariCPInstrumentedModuleProvider()).createRuntime();
BQRuntimeChecker.testModulesLoaded(bqRuntime, InstrumentedJdbcModule.class, MetricsModule.class, JdbcModule.class);
}
use of io.bootique.BQRuntime in project bootique-jdbc by bootique.
the class HikariCPDerbyIT method testDerbyDriver_ConnectionAttributes.
@Test
public void testDerbyDriver_ConnectionAttributes() throws SQLException {
BQRuntime runtime = testFactory.app("-c", "classpath:HikariCPDerbyIT_connAttrs.yml").autoLoadModules().createRuntime();
DataSource ds7 = runtime.getInstance(DataSourceFactory.class).forName("derby7");
assertNotNull(ds7);
HikariDataSource hikariDS = (HikariDataSource) ds7;
try (Connection c = hikariDS.getConnection()) {
assertEquals("jdbc:derby:target/derby7", c.getMetaData().getURL());
}
}
use of io.bootique.BQRuntime in project bootique-jdbc by bootique.
the class HikariCPDerbyIT method testDerbyDriverDataSource.
@Test
public void testDerbyDriverDataSource() throws SQLException {
BQRuntime runtime = testFactory.app("-c", "classpath:HikariCPDerbyIT.yml").autoLoadModules().createRuntime();
DataSource ds5 = runtime.getInstance(DataSourceFactory.class).forName("derby5");
assertNotNull(ds5);
assertTrue(ds5 instanceof HikariDataSource);
HikariDataSource hikariDS = (HikariDataSource) ds5;
assertEquals("org.apache.derby.jdbc.EmbeddedDriver", hikariDS.getDriverClassName());
HikariPool pool = (HikariPool) hikariDS.getHikariPoolMXBean();
assertTrue(pool.getUnwrappedDataSource() instanceof DriverDataSource);
try (Connection c = hikariDS.getConnection()) {
assertEquals("jdbc:derby:", c.getMetaData().getURL());
}
}
use of io.bootique.BQRuntime in project bootique-jdbc by bootique.
the class HikariCPModuleIT method testDataSource_TypeAutoDetected.
@Test
public void testDataSource_TypeAutoDetected() {
BQRuntime runtime = testFactory.app("-c", "classpath:HikariCPModuleIT_notype.yml").autoLoadModules().createRuntime();
DataSource ds = runtime.getInstance(DataSourceFactory.class).forName("derby3");
assertNotNull(ds);
assertTrue(ds instanceof HikariDataSource);
HikariDataSource hikariDS = (HikariDataSource) ds;
assertEquals("jdbc:derby:target/derby3;create=true", hikariDS.getJdbcUrl());
}
Aggregations