Disable regular Hikari log statements during test execution

- Also use mock logger instead of a real one in a few select tests to reduce the log output during tests
This commit is contained in:
ljacqu 2019-11-03 17:38:14 +01:00
parent 901b9adb8a
commit 51260fd22d
4 changed files with 10 additions and 10 deletions

View File

@ -9,9 +9,11 @@ import org.junit.runners.Parameterized;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static org.mockito.Mockito.mock;
@ -21,7 +23,7 @@ import static org.mockito.Mockito.mock;
public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractResourceClosingTest {
/** List of DataSource method names not to test. */
private static final Set<String> IGNORED_METHODS = ImmutableSet.of("reload", "getType");
private static final Set<String> IGNORED_METHODS = ImmutableSet.of("reload", "getType", "isCached");
private static Settings settings;
@ -64,12 +66,8 @@ public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractR
/* Get all methods of the DataSource interface, minus the ones in the ignored list. */
private static List<Method> getDataSourceMethods() {
List<Method> publicMethods = new ArrayList<>();
for (Method method : DataSource.class.getDeclaredMethods()) {
if (!IGNORED_METHODS.contains(method.getName()) && !method.isSynthetic()) {
publicMethods.add(method);
}
}
return publicMethods;
return Arrays.stream(DataSource.class.getDeclaredMethods())
.filter(method -> !IGNORED_METHODS.contains(method.getName()) && !method.isSynthetic())
.collect(Collectors.toList());
}
}

View File

@ -47,7 +47,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
TestHelper.returnDefaultsForAllProperties(settings);
set(DatabaseSettings.MYSQL_DATABASE, "sqlite-test");
set(DatabaseSettings.MYSQL_TABLE, "authme");
TestHelper.setRealLogger();
TestHelper.setupLogger();
Path sqlInitFile = TestHelper.getJarPath(TestHelper.PROJECT_ROOT + "datasource/sql-initialize.sql");
// Note ljacqu 20160221: It appears that we can only run one statement per Statement.execute() so we split

View File

@ -64,7 +64,7 @@ public class PermissionsManagerInitializationTest {
@BeforeClass
public static void setUpLogger() {
TestHelper.setRealLogger();
TestHelper.setupLogger();
}
@Before

View File

@ -0,0 +1,2 @@
# Suppress INFO statements when a new Hikari pool is being created
org.slf4j.simpleLogger.log.com.zaxxer.hikari=WARN