diff --git a/pom.xml b/pom.xml index d7ea204ef..74bcc2f5b 100644 --- a/pom.xml +++ b/pom.xml @@ -212,7 +212,7 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.11 pre-unit-test @@ -1039,7 +1039,7 @@ org.mockito mockito-junit-jupiter test - 2.27.0 + 4.11.0 diff --git a/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java b/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java index c9dd38968..986266d63 100644 --- a/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java +++ b/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java @@ -120,8 +120,8 @@ class ConsoleLoggerTest { @Test void shouldLogStackTraceToFile() throws IOException { // given - Settings settings = newSettings(true, LogLevel.INFO); - settings.getProperty(PluginSettings.LOG_LEVEL); // dummy code to avoid Mockito from complaining about the log level being stubbed + Settings settings = mock(Settings.class); + given(settings.getProperty(SecuritySettings.USE_LOGGING)).willReturn(true); ConsoleLogger.initializeSharedSettings(settings); Exception e = new IllegalStateException("Test exception message"); diff --git a/src/test/java/fr/xephi/authme/TestHelper.java b/src/test/java/fr/xephi/authme/TestHelper.java index a9daa9758..1afabe6b0 100644 --- a/src/test/java/fr/xephi/authme/TestHelper.java +++ b/src/test/java/fr/xephi/authme/TestHelper.java @@ -120,9 +120,20 @@ public final class TestHelper { .willAnswer(invocation -> ((Property) invocation.getArgument(0)).getDefaultValue()); } + /** + * Creates a file with the given name in the provided folder. Throws an exception if the file + * could not be created. + * + * @param folder the folder to create the file in + * @param filename the name of the file to create + * @return the created file + */ public static File createFile(File folder, String filename) throws IOException { File file = new File(folder, filename); - file.createNewFile(); + boolean created = file.createNewFile(); + if (!created) { + throw new IllegalStateException("Could not create file '" + filename + "' in " + folder); + } return file; } } diff --git a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java index ffac68da6..a76b35b95 100644 --- a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.mock; class PlayerUtilsTest { @BeforeAll - static void setAuthmeInstance() { + static void setUpLogger() { TestHelper.setupLogger(); }