More test coverage.

pull/192/head
Brett Wooldridge 11 years ago
parent 3de6474f37
commit f3e474d209

@ -48,6 +48,7 @@ public class HikariConfig implements HikariConfigMBean
private static final long MAX_LIFETIME = TimeUnit.MINUTES.toMillis(30);
private static int poolNumber;
private static boolean unitTest;
// Properties changeable at runtime through the MBean
//
@ -698,7 +699,7 @@ public class HikariConfig implements HikariConfigMBean
poolName = "HikariPool-" + poolNumber++;
}
if (LOGGER.isDebugEnabled()) {
if (LOGGER.isDebugEnabled() || unitTest) {
logConfiguration();
}
}

@ -38,6 +38,7 @@ public class MiscTest
config.setMinimumIdle(1);
config.setMaximumPoolSize(4);
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
TestElf.setConfigUnitTest();
final HikariDataSource ds = new HikariDataSource(config);
try {

@ -253,7 +253,7 @@ public class TestConnectionTimeoutRetry
Connection connection6 = ds.getConnection();
Connection connection7 = ds.getConnection();
Thread.sleep(1200);
Thread.sleep(1250);
Assert.assertSame("Totals connections not as expected", 10, TestElf.getPool(ds).getTotalConnections());
Assert.assertSame("Idle connections not as expected", 3, TestElf.getPool(ds).getIdleConnections());

@ -56,4 +56,16 @@ public final class TestElf
throw new RuntimeException(e);
}
}
public static void setConfigUnitTest()
{
try {
Field field = HikariConfig.class.getDeclaredField("unitTest");
field.setAccessible(true);
field.setBoolean(null, true);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}

@ -48,6 +48,7 @@ public class HikariConfig implements HikariConfigMBean
private static final long MAX_LIFETIME = TimeUnit.MINUTES.toMillis(30);
private static int poolNumber;
private static boolean unitTest;
// Properties changeable at runtime through the MBean
//
@ -698,7 +699,7 @@ public class HikariConfig implements HikariConfigMBean
poolName = "HikariPool-" + poolNumber++;
}
if (LOGGER.isDebugEnabled()) {
if (LOGGER.isDebugEnabled() || unitTest) {
logConfiguration();
}
}

@ -38,6 +38,7 @@ public class MiscTest
config.setMinimumIdle(1);
config.setMaximumPoolSize(4);
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
TestElf.setConfigUnitTest();
final HikariDataSource ds = new HikariDataSource(config);
try {

@ -253,7 +253,7 @@ public class TestConnectionTimeoutRetry
Connection connection6 = ds.getConnection();
Connection connection7 = ds.getConnection();
Thread.sleep(1200);
Thread.sleep(1250);
Assert.assertSame("Totals connections not as expected", 10, TestElf.getPool(ds).getTotalConnections());
Assert.assertSame("Idle connections not as expected", 3, TestElf.getPool(ds).getIdleConnections());

@ -56,4 +56,16 @@ public final class TestElf
throw new RuntimeException(e);
}
}
public static void setConfigUnitTest()
{
try {
Field field = HikariConfig.class.getDeclaredField("unitTest");
field.setAccessible(true);
field.setBoolean(null, true);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}

Loading…
Cancel
Save