|
|
|
@ -22,6 +22,7 @@ import java.sql.Connection;
|
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.sql.SQLTransientConnectionException;
|
|
|
|
|
import java.sql.Statement;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
@ -62,6 +63,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testCreate() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -107,6 +109,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testMaxLifetime() throws Exception
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -165,6 +168,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testMaxLifetime2() throws Exception
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -219,6 +223,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testDoubleClose() throws Exception
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -262,6 +267,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testBackfill() throws Exception
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -322,6 +328,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testMaximumPoolLimit() throws Exception
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -375,6 +382,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testOldDriver() throws Exception
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -405,6 +413,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testSuspendResume() throws Exception
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -544,6 +553,7 @@ public class TestConnections
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public void testPopulationSlowAcquisition() throws InterruptedException, SQLException
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
@ -586,4 +596,24 @@ public class TestConnections
|
|
|
|
|
StubConnection.slowCreate = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testMinimumIdleZero() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
HikariConfig config = new HikariConfig();
|
|
|
|
|
config.setPoolName("minimumIdleZero");
|
|
|
|
|
config.setMinimumIdle(0);
|
|
|
|
|
config.setMaximumPoolSize(5);
|
|
|
|
|
config.setConnectionTimeout(1000L);
|
|
|
|
|
config.setConnectionTestQuery("VALUES 1");
|
|
|
|
|
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
|
|
|
|
|
|
|
|
|
|
try (HikariDataSource ds = new HikariDataSource(config);
|
|
|
|
|
Connection connection = ds.getConnection()) {
|
|
|
|
|
// passed
|
|
|
|
|
}
|
|
|
|
|
catch (SQLTransientConnectionException sqle) {
|
|
|
|
|
Assert.fail("Failed to obtain connection");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|