use of com.zaxxer.hikari.HikariConfig in project HikariCP by brettwooldridge.
the class ShutdownTest method testShutdown4.
@Test
public void testShutdown4() throws SQLException {
StubConnection.slowCreate = true;
HikariConfig config = newHikariConfig();
config.setMinimumIdle(10);
config.setMaximumPoolSize(10);
config.setInitializationFailTimeout(Long.MAX_VALUE);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
try (HikariDataSource ds = new HikariDataSource(config)) {
quietlySleep(500L);
ds.close();
long startTime = currentTime();
while (elapsedMillis(startTime) < SECONDS.toMillis(5) && threadCount() > 0) {
quietlySleep(250);
}
assertSame("Unreleased connections after shutdown", 0, getPool(ds).getTotalConnections());
}
}
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"));
}
}
Aggregations