Skip to content

Commit

Permalink
Keep Mockito versions in sync; small fixes after JUnit 5 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacqu committed Dec 21, 2023
1 parent 13087f7 commit 6161d95
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.11</version>
<executions>
<execution>
<id>pre-unit-test</id>
Expand Down Expand Up @@ -1039,7 +1039,7 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
<version>2.27.0</version>
<version>4.11.0</version>
</dependency>

<!-- Required to mock the LuckPerms API-->
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/fr/xephi/authme/ConsoleLoggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ void shouldNotLogToFile() {
@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");

Expand Down
13 changes: 12 additions & 1 deletion src/test/java/fr/xephi/authme/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,20 @@ public static void returnDefaultsForAllProperties(Settings settings) {
.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;
}
}
2 changes: 1 addition & 1 deletion src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class PlayerUtilsTest {

@BeforeAll
static void setAuthmeInstance() {
static void setUpLogger() {
TestHelper.setupLogger();
}

Expand Down

0 comments on commit 6161d95

Please sign in to comment.