use of com.zaxxer.hikari.HikariDataSource in project HikariCP by brettwooldridge.
the class TestElf method newHikariDataSource.
static HikariDataSource newHikariDataSource() {
final StackTraceElement callerStackTrace = Thread.currentThread().getStackTrace()[2];
String poolName = callerStackTrace.getMethodName();
if ("setup".equals(poolName)) {
poolName = callerStackTrace.getClassName();
}
final HikariDataSource ds = new HikariDataSource();
ds.setPoolName(poolName);
return ds;
}
use of com.zaxxer.hikari.HikariDataSource in project HikariCP by brettwooldridge.
the class ExceptionTest 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.HikariDataSource in project HikariCP by brettwooldridge.
the class HouseKeeperCleanupTest method testHouseKeeperCleanupWithCustomExecutor.
@Test
public void testHouseKeeperCleanupWithCustomExecutor() throws Exception {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(10);
config.setInitializationFailTimeout(Long.MAX_VALUE);
config.setConnectionTimeout(2500);
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
config.setScheduledExecutor(executor);
HikariConfig config2 = newHikariConfig();
config.copyState(config2);
try (final HikariDataSource ds1 = new HikariDataSource(config);
final HikariDataSource ds2 = new HikariDataSource(config2)) {
assertEquals("Scheduled tasks count not as expected, ", 2, executor.getQueue().size());
}
assertEquals("Scheduled tasks count not as expected, ", 0, executor.getQueue().size());
}
use of com.zaxxer.hikari.HikariDataSource in project HikariCP by brettwooldridge.
the class JdbcDriverTest method driverTest2.
@Test
public void driverTest2() throws SQLException {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(1);
config.setMaximumPoolSize(1);
config.setConnectionTestQuery("VALUES 1");
config.setDriverClassName("com.zaxxer.hikari.mocks.StubDriver");
config.setJdbcUrl("jdbc:invalid");
try {
ds = new HikariDataSource(config);
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("claims to not accept"));
}
}
use of com.zaxxer.hikari.HikariDataSource in project HikariCP by brettwooldridge.
the class MiscTest method testLogWriter.
@Test
public void testLogWriter() throws SQLException {
HikariConfig config = newHikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(4);
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
setConfigUnitTest(true);
try (HikariDataSource ds = new HikariDataSource(config)) {
PrintWriter writer = new PrintWriter(System.out);
ds.setLogWriter(writer);
assertSame(writer, ds.getLogWriter());
assertEquals("testLogWriter", config.getPoolName());
} finally {
setConfigUnitTest(false);
}
}
Aggregations