Remove staggling nanoTime() calls.

pull/316/merge
Brett Wooldridge 10 years ago
parent a79b4dd98a
commit acc322ee1b

@ -38,20 +38,20 @@ public class TestConnectionCloseBlocking {
HikariDataSource ds = new HikariDataSource(config);
long startNanos = System.nanoTime();
long start = System.currentTimeMillis();
try {
Connection connection = ds.getConnection();
connection.close();
// Hikari only checks for validity for connections with lastAccess > 1000 ms so we sleep for 1001 ms to force
// Hikari to do a connection validation which will fail and will trigger the connection to be closed
UtilityElf.quietlySleep(1001);
startNanos = System.nanoTime();
start = System.currentTimeMillis();
connection = ds.getConnection(); // on physical connection close we sleep 2 seconds
Assert.assertTrue("Waited longer than timeout",
(UtilityElf.elapsedNanos(startNanos) < config.getConnectionTimeout()));
(UtilityElf.elapsedTimeMs(start) < config.getConnectionTimeout()));
} catch (SQLException e) {
Assert.assertTrue("getConnection failed because close connection took longer than timeout",
(UtilityElf.elapsedNanos(startNanos) < config.getConnectionTimeout()));
(UtilityElf.elapsedNanos(start) < config.getConnectionTimeout()));
} finally {
shouldSleep = false;
ds.close();

Loading…
Cancel
Save