diff --git a/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/AvoidBrandInMethodNamesRuleTest.java b/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/AvoidBrandInMethodNamesRuleTest.java index 66444b73e69..3fb4f5766c1 100644 --- a/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/AvoidBrandInMethodNamesRuleTest.java +++ b/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/AvoidBrandInMethodNamesRuleTest.java @@ -5,17 +5,10 @@ package org.sonar.samples.java.checks; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.slf4j.event.Level; -import org.sonar.api.testfixtures.log.LogTesterJUnit5; import org.sonar.java.checks.verifier.CheckVerifier; class AvoidBrandInMethodNamesRuleTest { - // Set a LogTester to see the Syntax Tree when running tests and executing the rule - @RegisterExtension - public LogTesterJUnit5 logTester = new LogTesterJUnit5().setLevel(Level.DEBUG); - @Test void detected() { // Verifies that the check will raise the adequate issues with the expected message. diff --git a/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/SecurityAnnotationMandatoryRuleTest.java b/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/SecurityAnnotationMandatoryRuleTest.java index 65777342af6..40bd9574119 100644 --- a/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/SecurityAnnotationMandatoryRuleTest.java +++ b/docs/java-custom-rules-example/src/test/java/org/sonar/samples/java/checks/SecurityAnnotationMandatoryRuleTest.java @@ -5,17 +5,10 @@ package org.sonar.samples.java.checks; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.slf4j.event.Level; -import org.sonar.api.testfixtures.log.LogTesterJUnit5; import org.sonar.java.checks.verifier.CheckVerifier; class SecurityAnnotationMandatoryRuleTest { - // Set a LogTester to see the Syntax Tree when running tests and executing the rule - @RegisterExtension - public LogTesterJUnit5 logTester = new LogTesterJUnit5().setLevel(Level.DEBUG); - @Test void detected() { // Use an instance of the check under test to raise the issue. diff --git a/external-reports/src/test/java/org/sonar/java/externalreport/CheckstyleSensorTest.java b/external-reports/src/test/java/org/sonar/java/externalreport/CheckstyleSensorTest.java index a5a2aecfa00..852915eeb34 100644 --- a/external-reports/src/test/java/org/sonar/java/externalreport/CheckstyleSensorTest.java +++ b/external-reports/src/test/java/org/sonar/java/externalreport/CheckstyleSensorTest.java @@ -19,7 +19,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; @@ -42,7 +41,7 @@ class CheckstyleSensorTest { - private static final Path PROJECT_DIR = Paths.get("src", "test", "resources", "checkstyle") + private static final Path PROJECT_DIR = Path.of("src", "test", "resources", "checkstyle") .toAbsolutePath().normalize(); private static SensorContextTester sensorContext = SensorContextTester.create(PROJECT_DIR); diff --git a/external-reports/src/test/java/org/sonar/java/externalreport/SpotBugsSensorTest.java b/external-reports/src/test/java/org/sonar/java/externalreport/SpotBugsSensorTest.java index af7f3db9f36..741649cb53b 100644 --- a/external-reports/src/test/java/org/sonar/java/externalreport/SpotBugsSensorTest.java +++ b/external-reports/src/test/java/org/sonar/java/externalreport/SpotBugsSensorTest.java @@ -19,7 +19,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; @@ -43,7 +42,7 @@ class SpotBugsSensorTest { - private static final Path PROJECT_DIR = Paths.get("src", "test", "resources", "spotbugs") + private static final Path PROJECT_DIR = Path.of("src", "test", "resources", "spotbugs") .toAbsolutePath().normalize(); private static SensorContextTester sensorContext = SensorContextTester.create(PROJECT_DIR); diff --git a/java-checks-testkit/src/test/java/org/sonar/java/checks/verifier/FilesUtilsTest.java b/java-checks-testkit/src/test/java/org/sonar/java/checks/verifier/FilesUtilsTest.java index 8c3104f1107..a4476c336b5 100644 --- a/java-checks-testkit/src/test/java/org/sonar/java/checks/verifier/FilesUtilsTest.java +++ b/java-checks-testkit/src/test/java/org/sonar/java/checks/verifier/FilesUtilsTest.java @@ -27,11 +27,9 @@ import static org.assertj.core.api.Assertions.assertThat; class FilesUtilsTest { - @TempDir - public Path temp; @Test - void verify_get_classpath_files() throws IOException { + void verify_get_classpath_files(@TempDir Path temp) throws IOException { Path tmp = Files.createDirectory(temp.resolve("tmp")); Path jar = tmp.resolve("test.jar"); Path zip = tmp.resolve("test.zip");