|
|
@ -31,6 +31,7 @@ import com.zaxxer.hikari.HikariDataSource;
|
|
|
|
import com.zaxxer.hikari.mocks.StubConnection;
|
|
|
|
import com.zaxxer.hikari.mocks.StubConnection;
|
|
|
|
import com.zaxxer.hikari.util.ClockSource;
|
|
|
|
import com.zaxxer.hikari.util.ClockSource;
|
|
|
|
import com.zaxxer.hikari.util.UtilityElf;
|
|
|
|
import com.zaxxer.hikari.util.UtilityElf;
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.Level;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author Brett Wooldridge
|
|
|
|
* @author Brett Wooldridge
|
|
|
@ -40,6 +41,7 @@ public class ShutdownTest
|
|
|
|
@Before
|
|
|
|
@Before
|
|
|
|
public void beforeTest()
|
|
|
|
public void beforeTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TestElf.setSlf4jLogLevel(ShutdownTest.class, Level.DEBUG);
|
|
|
|
StubConnection.count.set(0);
|
|
|
|
StubConnection.count.set(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -87,13 +89,13 @@ public class ShutdownTest
|
|
|
|
|
|
|
|
|
|
|
|
UtilityElf.quietlySleep(1200L);
|
|
|
|
UtilityElf.quietlySleep(1200L);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue("Totals connection count not as expected, ", pool.getTotalConnections() > 0);
|
|
|
|
Assert.assertTrue("Total connection count not as expected, ", pool.getTotalConnections() > 0);
|
|
|
|
|
|
|
|
|
|
|
|
ds.close();
|
|
|
|
ds.close();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected", 0, pool.getTotalConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected, ", 0, pool.getTotalConnections());
|
|
|
|
Assert.assertTrue(ds.isClosed());
|
|
|
|
Assert.assertTrue(ds.isClosed());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -116,13 +118,13 @@ public class ShutdownTest
|
|
|
|
|
|
|
|
|
|
|
|
UtilityElf.quietlySleep(1200L);
|
|
|
|
UtilityElf.quietlySleep(1200L);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue("Totals connection count not as expected, ", pool.getTotalConnections() > 0);
|
|
|
|
Assert.assertTrue("Total connection count not as expected, ", pool.getTotalConnections() > 0);
|
|
|
|
|
|
|
|
|
|
|
|
ds.close();
|
|
|
|
ds.close();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected", 0, pool.getTotalConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected, ", 0, pool.getTotalConnections());
|
|
|
|
Assert.assertTrue(ds.toString().startsWith("HikariDataSource (") && ds.toString().endsWith(")"));
|
|
|
|
Assert.assertTrue(ds.toString().startsWith("HikariDataSource (") && ds.toString().endsWith(")"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -145,13 +147,13 @@ public class ShutdownTest
|
|
|
|
|
|
|
|
|
|
|
|
UtilityElf.quietlySleep(1200L);
|
|
|
|
UtilityElf.quietlySleep(1200L);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue("Totals connection count not as expected, ", pool.getTotalConnections() == 5);
|
|
|
|
Assert.assertTrue("Total connection count not as expected, ", pool.getTotalConnections() == 5);
|
|
|
|
|
|
|
|
|
|
|
|
ds.close();
|
|
|
|
ds.close();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected", 0, pool.getTotalConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected, ", 0, pool.getTotalConnections());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -200,13 +202,13 @@ public class ShutdownTest
|
|
|
|
connections[i] = ds.getConnection();
|
|
|
|
connections[i] = ds.getConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue("Totals connection count not as expected, ", pool.getTotalConnections() == 5);
|
|
|
|
Assert.assertTrue("Total connection count not as expected, ", pool.getTotalConnections() == 5);
|
|
|
|
|
|
|
|
|
|
|
|
ds.close();
|
|
|
|
ds.close();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Active connection count not as expected, ", 0, pool.getActiveConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Idle connection count not as expected, ", 0, pool.getIdleConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected", 0, pool.getTotalConnections());
|
|
|
|
Assert.assertSame("Total connection count not as expected, ", 0, pool.getTotalConnections());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|