Fix unit test breakage.

pull/1271/head
Brett Wooldridge 6 years ago
parent f005a4769f
commit 239919c33d

@ -443,7 +443,8 @@ abstract class PoolBase
* @param connection a Connection to check
* @throws SQLException rethrown from the driver
*/
private void checkValidationSupport(final Connection connection) throws SQLException {
private void checkValidationSupport(final Connection connection) throws SQLException
{
try {
if (isUseJdbc4Validation) {
connection.isValid(1);
@ -452,7 +453,7 @@ abstract class PoolBase
executeSql(connection, config.getConnectionTestQuery(), false);
}
}
catch (Exception e) {
catch (Exception | AbstractMethodError e) {
logger.error("{} - Failed to execute{} connection test query ({}).", poolName, (isUseJdbc4Validation ? " isValid() for connection, configure" : ""), e.getMessage());
throw e;
}
@ -464,7 +465,8 @@ abstract class PoolBase
* @param connection a Connection to check
* @throws SQLException rethrown from the driver
*/
private void checkDefaultIsolation(final Connection connection) throws SQLException {
private void checkDefaultIsolation(final Connection connection) throws SQLException
{
try {
defaultTransactionIsolation = connection.getTransactionIsolation();
if (transactionIsolation == -1) {

@ -109,7 +109,8 @@ public final class JavassistProxyFactory
/**
* Generate Javassist Proxy Classes
*/
private static <T> void generateProxyClass(Class<T> primaryInterface, String superClassName, String methodBody) throws Exception {
private static <T> void generateProxyClass(Class<T> primaryInterface, String superClassName, String methodBody) throws Exception
{
String newClassName = superClassName.replaceAll("(.+)\\.(\\w+)", "$1.Hikari$2");
CtClass superCt = classPool.getCtClass(superClassName);
@ -200,7 +201,8 @@ public final class JavassistProxyFactory
return false;
}
private static boolean isDefaultMethod(Class<?> intf, CtMethod intfMethod) throws Exception {
private static boolean isDefaultMethod(Class<?> intf, CtMethod intfMethod) throws Exception
{
List<Class<?>> paramTypes = new ArrayList<>();
for (CtClass pt : intfMethod.getParameterTypes()) {

@ -2,6 +2,7 @@ package com.zaxxer.hikari.metrics.dropwizard;
import static org.mockito.Mockito.verify;
import com.zaxxer.hikari.metrics.PoolStats;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -19,8 +20,8 @@ public class CodaHaleMetricsTrackerTest {
private CodaHaleMetricsTracker testee;
@Before
public void setup(){
testee = new CodaHaleMetricsTracker("mypool", null, mockMetricRegistry);
public void setup() {
testee = new CodaHaleMetricsTracker("mypool", poolStats(), mockMetricRegistry);
}
@Test
@ -38,4 +39,13 @@ public class CodaHaleMetricsTrackerTest {
verify(mockMetricRegistry).remove("mypool.pool.MaxConnections");
verify(mockMetricRegistry).remove("mypool.pool.MinConnections");
}
private PoolStats poolStats() {
return new PoolStats(0) {
@Override
protected void update() {
// do nothing
}
};
}
}

@ -745,7 +745,7 @@ public class TestConnections
return new StubConnection();
}
throw new Error("Bad thing happens on datasource.");
throw new RuntimeException("Bad thing happens on datasource.");
}
public void setErrorOnConnection(boolean errorOnConnection) {

Loading…
Cancel
Save