|
|
|
@ -75,10 +75,12 @@ public class TestConnections
|
|
|
|
|
ds.setLoginTimeout(10);
|
|
|
|
|
Assert.assertSame(10, ds.getLoginTimeout());
|
|
|
|
|
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection.close();
|
|
|
|
|
Assert.assertSame("Totals connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
|
|
|
|
|
Assert.assertSame("Idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
|
|
|
|
|
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection = ds.getConnection();
|
|
|
|
|
Assert.assertNotNull(connection);
|
|
|
|
|
|
|
|
|
|
Assert.assertSame("Totals connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
|
|
|
|
@ -121,10 +123,12 @@ public class TestConnections
|
|
|
|
|
|
|
|
|
|
ds.setMaxLifetime(700);
|
|
|
|
|
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection.close();
|
|
|
|
|
Assert.assertSame("Total connections not as expected", 0, TestElf.getPool(ds).getTotalConnections());
|
|
|
|
|
Assert.assertSame("Idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
|
|
|
|
|
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection = ds.getConnection();
|
|
|
|
|
Connection unwrap = connection.unwrap(Connection.class);
|
|
|
|
|
Assert.assertNotNull(connection);
|
|
|
|
|
|
|
|
|
@ -168,10 +172,12 @@ public class TestConnections
|
|
|
|
|
try (HikariDataSource ds = new HikariDataSource(config)) {
|
|
|
|
|
ds.setMaxLifetime(700);
|
|
|
|
|
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection.close();
|
|
|
|
|
Assert.assertSame("Total connections not as expected", 0, TestElf.getPool(ds).getTotalConnections());
|
|
|
|
|
Assert.assertSame("Idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
|
|
|
|
|
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection = ds.getConnection();
|
|
|
|
|
Connection unwrap = connection.unwrap(Connection.class);
|
|
|
|
|
Assert.assertNotNull(connection);
|
|
|
|
|
|
|
|
|
@ -261,11 +267,13 @@ public class TestConnections
|
|
|
|
|
|
|
|
|
|
UtilityElf.quietlySleep(500);
|
|
|
|
|
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection.close();
|
|
|
|
|
Assert.assertSame("Totals connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
|
|
|
|
|
Assert.assertSame("Idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
|
|
|
|
|
|
|
|
|
|
// This will take the pool down to zero
|
|
|
|
|
Connection connection = ds.getConnection();
|
|
|
|
|
connection = ds.getConnection();
|
|
|
|
|
Assert.assertNotNull(connection);
|
|
|
|
|
|
|
|
|
|
Assert.assertSame("Totals connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
|
|
|
|
|