use of com.zaxxer.hikari.HikariConfig in project HikariCP by brettwooldridge.
the class ShutdownTest method testShutdown2.
@Test
public void testShutdown2() throws SQLException {
assertSame("StubConnection count not as expected", 0, StubConnection.count.get());
StubConnection.slowCreate = true;
HikariConfig config = newHikariConfig();
config.setMinimumIdle(10);
config.setMaximumPoolSize(10);
config.setInitializationFailTimeout(0);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
try (HikariDataSource ds = new HikariDataSource(config)) {
HikariPool pool = getPool(ds);
quietlySleep(1200L);
assertTrue("Total connection count not as expected, ", pool.getTotalConnections() > 0);
ds.close();
assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
assertSame("Total connection count not as expected, ", 0, pool.getTotalConnections());
assertTrue(ds.toString().startsWith("HikariDataSource (") && ds.toString().endsWith(")"));
}
}
use of com.zaxxer.hikari.HikariConfig in project HikariCP by brettwooldridge.
the class ShutdownTest method testAfterShutdown.
@Test
public void testAfterShutdown() throws Exception {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(5);
config.setInitializationFailTimeout(0);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
try (HikariDataSource ds = new HikariDataSource(config)) {
ds.close();
try {
ds.getConnection();
} catch (SQLException e) {
Assert.assertTrue(e.getMessage().contains("has been closed."));
}
}
}
use of com.zaxxer.hikari.HikariConfig in project HikariCP by brettwooldridge.
the class StatementTest method setup.
@Before
public void setup() {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(1);
config.setMaximumPoolSize(2);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
ds = new HikariDataSource(config);
}
use of com.zaxxer.hikari.HikariConfig in project HikariCP by brettwooldridge.
the class TestValidation method validateMissingProperties.
@Test
public void validateMissingProperties() {
try {
HikariConfig config = new HikariConfig("missing");
config.validate();
} catch (IllegalArgumentException ise) {
assertTrue(ise.getMessage().contains("property file"));
}
}
use of com.zaxxer.hikari.HikariConfig in project HikariCP by brettwooldridge.
the class TestValidation method validateMissingDS.
@Test
public void validateMissingDS() {
try {
HikariConfig config = newHikariConfig();
config.validate();
fail();
} catch (IllegalArgumentException ise) {
assertTrue(ise.getMessage().contains("dataSource or dataSourceClassName or jdbcUrl is required."));
}
}
Aggregations