diff --git a/documentation/src/test/java/example/ClassTemplateDemo.java b/documentation/src/test/java/example/ClassTemplateDemo.java index 93f669ab5be2..67b9395619ca 100644 --- a/documentation/src/test/java/example/ClassTemplateDemo.java +++ b/documentation/src/test/java/example/ClassTemplateDemo.java @@ -52,9 +52,9 @@ void wellKnown() { } // end::user_guide[] - static + public // tag::user_guide[] - public class MyClassTemplateInvocationContextProvider + static class MyClassTemplateInvocationContextProvider // tag::custom_line_break[] implements ClassTemplateInvocationContextProvider { diff --git a/documentation/src/test/java/example/ParameterizedMigrationDemo.java b/documentation/src/test/java/example/ParameterizedMigrationDemo.java index e5425f73412e..a6308d678e9e 100644 --- a/documentation/src/test/java/example/ParameterizedMigrationDemo.java +++ b/documentation/src/test/java/example/ParameterizedMigrationDemo.java @@ -25,9 +25,9 @@ public class ParameterizedMigrationDemo { // tag::before[] @RunWith(Parameterized.class) // end::before[] - static + public // tag::before[] - public class JUnit4ParameterizedClassTests { + static class JUnit4ParameterizedClassTests { @Parameterized.Parameters public static Iterable data() { diff --git a/documentation/src/test/java/example/ParameterizedTestDemo.java b/documentation/src/test/java/example/ParameterizedTestDemo.java index 72caa35d7ba4..e789cb5e896d 100644 --- a/documentation/src/test/java/example/ParameterizedTestDemo.java +++ b/documentation/src/test/java/example/ParameterizedTestDemo.java @@ -357,9 +357,9 @@ void testWithArgumentsSource(String argument) { } // end::ArgumentsSource_example[] - static + public // tag::ArgumentsProvider_example[] - public class MyArgumentsProvider implements ArgumentsProvider { + static class MyArgumentsProvider implements ArgumentsProvider { @Override public Stream provideArguments(ParameterDeclarations parameters, @@ -375,9 +375,9 @@ void testWithArgumentsSourceWithConstructorInjection(String argument) { assertNotNull(argument); } - static + public // tag::ArgumentsProviderWithConstructorInjection_example[] - public class MyArgumentsProviderWithConstructorInjection implements ArgumentsProvider { + static class MyArgumentsProviderWithConstructorInjection implements ArgumentsProvider { private final TestInfo testInfo; @@ -427,9 +427,9 @@ void testWithImplicitFallbackArgumentConversion(Book book) { } // end::implicit_fallback_conversion_example[] - static + public // tag::implicit_fallback_conversion_example_Book[] - public class Book { + static class Book { private final String title; @@ -458,10 +458,10 @@ void testWithExplicitArgumentConversion( } // end::explicit_conversion_example[] - static + public @SuppressWarnings({ "NullableProblems", "NullAway" }) // tag::explicit_conversion_example_ToStringArgumentConverter[] - public class ToStringArgumentConverter extends SimpleArgumentConverter { + static class ToStringArgumentConverter extends SimpleArgumentConverter { @Override protected Object convert(Object source, Class targetType) { @@ -474,10 +474,10 @@ protected Object convert(Object source, Class targetType) { } // end::explicit_conversion_example_ToStringArgumentConverter[] - static + public @SuppressWarnings({ "NullableProblems", "NullAway", "ConstantValue" }) // tag::explicit_conversion_example_TypedArgumentConverter[] - public class ToLengthArgumentConverter extends TypedArgumentConverter { + static class ToLengthArgumentConverter extends TypedArgumentConverter { protected ToLengthArgumentConverter() { super(String.class, Integer.class); @@ -516,7 +516,7 @@ void testWithArgumentsAccessor(ArgumentsAccessor arguments) { arguments.get(2, Gender.class), arguments.get(3, LocalDate.class)); - if (person.getFirstName().equals("Jane")) { + if ("Jane".equals(person.getFirstName())) { assertEquals(Gender.F, person.getGender()); } else { @@ -540,9 +540,9 @@ void testWithArgumentsAggregator(@AggregateWith(PersonAggregator.class) Person p } // end::ArgumentsAggregator_example[] - static + public // tag::ArgumentsAggregator_example_PersonAggregator[] - public class PersonAggregator extends SimpleArgumentsAggregator { + static class PersonAggregator extends SimpleArgumentsAggregator { @Override protected Person aggregateArguments(ArgumentsAccessor arguments, Class targetType, AnnotatedElementContext context, int parameterIndex) { diff --git a/documentation/src/test/java/example/TestInfoDemo.java b/documentation/src/test/java/example/TestInfoDemo.java index d6b55e0bffff..5ec6589560b6 100644 --- a/documentation/src/test/java/example/TestInfoDemo.java +++ b/documentation/src/test/java/example/TestInfoDemo.java @@ -31,13 +31,13 @@ static void beforeAll(TestInfo testInfo) { TestInfoDemo(TestInfo testInfo) { String displayName = testInfo.getDisplayName(); - assertTrue(displayName.equals("TEST 1") || displayName.equals("test2()")); + assertTrue("TEST 1".equals(displayName) || "test2()".equals(displayName)); } @BeforeEach void init(TestInfo testInfo) { String displayName = testInfo.getDisplayName(); - assertTrue(displayName.equals("TEST 1") || displayName.equals("test2()")); + assertTrue("TEST 1".equals(displayName) || "test2()".equals(displayName)); } @Test diff --git a/documentation/src/test/java/example/TestTemplateDemo.java b/documentation/src/test/java/example/TestTemplateDemo.java index 1dda57c462e5..015ea64b6131 100644 --- a/documentation/src/test/java/example/TestTemplateDemo.java +++ b/documentation/src/test/java/example/TestTemplateDemo.java @@ -38,10 +38,10 @@ void testTemplate(String fruit) { } // end::user_guide[] - static + public // @formatter:off // tag::user_guide[] - public class MyTestTemplateInvocationContextProvider + static class MyTestTemplateInvocationContextProvider implements TestTemplateInvocationContextProvider { @Override diff --git a/documentation/src/test/resources/log4j2-test.xml b/documentation/src/test/resources/log4j2-test.xml index 9fb7a4a69de1..0d7f4fe5a9fc 100644 --- a/documentation/src/test/resources/log4j2-test.xml +++ b/documentation/src/test/resources/log4j2-test.xml @@ -16,4 +16,4 @@ - \ No newline at end of file + diff --git a/gradle.properties b/gradle.properties index 000b32c34896..f2bfc00f14bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ version = 6.0.0-SNAPSHOT # We need more metaspace due to apparent memory leak in Asciidoctor/JRuby org.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError org.gradle.caching=true +# https://github.com/openrewrite/rewrite-gradle-plugin/issues/212 org.gradle.parallel=true org.gradle.configuration-cache.parallel=true org.gradle.java.installations.fromEnv=GRAALVM_HOME,JDK17,JDK21,JDK24,JDK25 diff --git a/gradle/config/rewrite.yml b/gradle/config/rewrite.yml new file mode 100644 index 000000000000..c14410ef7110 --- /dev/null +++ b/gradle/config/rewrite.yml @@ -0,0 +1,66 @@ +#type: specs.openrewrite.org/v1beta/recipe +#name: org.junit.openrewrite.recipe.CodeCleanup +#displayName: Code cleanup +#description: Automatically cleanup code, e.g. remove unnecessary parentheses, simplify expressions. +#recipeList: +# - org.openrewrite.java.RemoveUnusedImports +# - org.openrewrite.staticanalysis.EqualsAvoidsNull +# - org.openrewrite.staticanalysis.ModifierOrder +# - org.junit.openrewrite.recipe.AddLicenseHeader +# - org.junit.openrewrite.recipe.Java21ForTests +# - org.openrewrite.java.format.AutoFormat +# - org.openrewrite.java.format.BlankLines +# - org.openrewrite.java.format.NormalizeFormat +# - org.openrewrite.java.format.NormalizeLineBreaks +# - org.openrewrite.java.format.RemoveTrailingWhitespace +# - org.openrewrite.java.format.Spaces +# - org.openrewrite.java.format.TabsAndIndents +# - org.openrewrite.java.format.WrappingAndBraces +# - org.openrewrite.java.migrate.UpgradeToJava17 +# - org.openrewrite.java.testing.assertj.Assertj +# - org.openrewrite.java.testing.cleanup.AssertTrueNullToAssertNull +# - org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic +# - org.openrewrite.java.testing.junit5.JUnit5BestPractices +# - org.openrewrite.staticanalysis.CodeCleanup +# - org.openrewrite.staticanalysis.CommonStaticAnalysis +# - org.openrewrite.staticanalysis.FinalizeLocalVariables +# - org.openrewrite.staticanalysis.MissingOverrideAnnotation +# - org.openrewrite.staticanalysis.RedundantFileCreation +# - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables +# - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields +# - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods +# - org.openrewrite.staticanalysis.StringLiteralEquality +# - org.openrewrite.text.EndOfLineAtEndOfFile +#--- +type: specs.openrewrite.org/v1beta/recipe +name: org.junit.openrewrite.recipe.AddLicenseHeader +displayName: AddLicenseHeader +recipeList: + - org.openrewrite.java.AddLicenseHeader: + licenseText: """ + /* + * Copyright 2015-${CURRENT_YEAR} the original author or authors. + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v2.0 which + * accompanies this distribution and is available at + * + * https://www.eclipse.org/legal/epl-v20.html + */ + """ +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.junit.openrewrite.recipe.Java21ForTests +displayName: Java21ForTests +preconditions: + - org.openrewrite.java.search.IsLikelyTest +recipeList: + - org.openrewrite.java.migrate.UpgradeToJava21 +--- +type: specs.openrewrite.org/v1beta/style +name: org.junit.openrewrite.recipe.NoTabsNoStarImports +styleConfigs: + - org.openrewrite.java.style.TabsAndIndentsStyle: + useTabCharacter: false + - org.openrewrite.java.style.ImportLayoutStyle: + classCountToUseStarImport: 9999 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8ead394f36f6..00173a49c9ff 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -61,6 +61,7 @@ mockito-core = { module = "org.mockito:mockito-core" } mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter" } nohttp-checkstyle = { module = "io.spring.nohttp:nohttp-checkstyle", version = "0.0.11" } nullaway = { module = "com.uber.nullaway:nullaway", version = "0.12.7" } +openrewrite-recipe-bom = { module = "org.openrewrite.recipe:rewrite-recipe-bom", version = "3.11.1" } opentest4j = { module = "org.opentest4j:opentest4j", version.ref = "opentest4j" } openTestReporting-cli = { module = "org.opentest4j.reporting:open-test-reporting-cli", version.ref = "openTestReporting" } openTestReporting-events = { module = "org.opentest4j.reporting:open-test-reporting-events", version.ref = "openTestReporting" } @@ -105,6 +106,7 @@ jreleaser = { id = "org.jreleaser", version = "1.19.0" } # check if workaround in gradle.properties can be removed when updating kotlin = { id = "org.jetbrains.kotlin.jvm", version = "2.2.0" } nullaway = { id = "net.ltgt.nullaway", version = "2.2.0" } +openrewrite = { id = "org.openrewrite.rewrite", version = "7.10.0" } plantuml = { id = "io.freefair.plantuml", version = "8.14" } shadow = { id = "com.gradleup.shadow", version = "8.3.8" } spotless = { id = "com.diffplug.spotless", version = "7.1.0" } diff --git a/gradle/plugins/common/build.gradle.kts b/gradle/plugins/common/build.gradle.kts index 4b4ed22250a6..40df3d0c9ce4 100644 --- a/gradle/plugins/common/build.gradle.kts +++ b/gradle/plugins/common/build.gradle.kts @@ -16,6 +16,7 @@ dependencies { implementation(libs.plugins.foojayResolver.markerCoordinates) implementation(libs.plugins.jmh.markerCoordinates) implementation(libs.plugins.nullaway.markerCoordinates) + implementation(libs.plugins.openrewrite.markerCoordinates) implementation(libs.plugins.shadow.markerCoordinates) implementation(libs.plugins.spotless.markerCoordinates) } diff --git a/gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts b/gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts index 4b5960dafc3a..a4e6b29209de 100644 --- a/gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts +++ b/gradle/plugins/common/src/main/kotlin/junitbuild.java-library-conventions.gradle.kts @@ -1,4 +1,5 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import junitbuild.extensions.dependencyFromLibs import junitbuild.extensions.isSnapshot import org.gradle.plugins.ide.eclipse.model.Classpath import org.gradle.plugins.ide.eclipse.model.Library @@ -13,6 +14,46 @@ plugins { id("junitbuild.build-parameters") id("junitbuild.checkstyle-conventions") id("junitbuild.jacoco-java-conventions") + id("org.openrewrite.rewrite") +} + +rewrite { + activeRecipe("org.openrewrite.java.RemoveUnusedImports") + activeRecipe("org.openrewrite.java.testing.cleanup.AssertTrueNullToAssertNull") + activeRecipe("org.openrewrite.staticanalysis.EqualsAvoidsNull") + activeRecipe("org.openrewrite.staticanalysis.MissingOverrideAnnotation") + activeRecipe("org.openrewrite.staticanalysis.ModifierOrder") + activeRecipe("org.openrewrite.staticanalysis.RedundantFileCreation") + activeRecipe("org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods") + activeRecipe("org.openrewrite.text.EndOfLineAtEndOfFile") + configFile = file("config/rewrite.yml") + failOnDryRunResults = true +// activeRecipe("org.junit.openrewrite.recipe.AddLicenseHeader") +// activeRecipe("org.junit.openrewrite.recipe.Java21ForTests") +// activeRecipe("org.openrewrite.java.format.AutoFormat") +// activeRecipe("org.openrewrite.java.format.BlankLines") +// activeRecipe("org.openrewrite.java.format.NormalizeFormat") +// activeRecipe("org.openrewrite.java.format.NormalizeLineBreaks") +// activeRecipe("org.openrewrite.java.format.RemoveTrailingWhitespace") +// activeRecipe("org.openrewrite.java.format.Spaces") +// activeRecipe("org.openrewrite.java.format.TabsAndIndents") +// activeRecipe("org.openrewrite.java.format.WrappingAndBraces") +// activeRecipe("org.openrewrite.java.migrate.UpgradeToJava21") +// activeRecipe("org.openrewrite.java.testing.assertj.Assertj") +// activeRecipe("org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic") +// activeRecipe("org.openrewrite.java.testing.junit5.JUnit5BestPractices") +// activeRecipe("org.openrewrite.staticanalysis.CodeCleanup") +// activeRecipe("org.openrewrite.staticanalysis.CommonStaticAnalysis") +// activeRecipe("org.openrewrite.staticanalysis.FinalizeLocalVariables") +// activeRecipe("org.openrewrite.staticanalysis.RemoveUnusedLocalVariables") +// activeRecipe("org.openrewrite.staticanalysis.RemoveUnusedPrivateFields") +// activeRecipe("org.openrewrite.staticanalysis.StringLiteralEquality") +} + +dependencies { + rewrite(platform(dependencyFromLibs("openrewrite-recipe-bom"))) + rewrite("org.openrewrite.recipe:rewrite-migrate-java") + rewrite("org.openrewrite.recipe:rewrite-testing-frameworks") } val mavenizedProjects: List by rootProject.extra @@ -270,6 +311,9 @@ tasks { checkstyleTest { config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml")) } + check { + dependsOn(rewriteDryRun) + } } pluginManager.withPlugin("java-test-fixtures") { diff --git a/gradle/plugins/common/src/main/kotlin/junitbuild.spotless-conventions.gradle.kts b/gradle/plugins/common/src/main/kotlin/junitbuild.spotless-conventions.gradle.kts index af3d6818a029..1de9fd2d9708 100644 --- a/gradle/plugins/common/src/main/kotlin/junitbuild.spotless-conventions.gradle.kts +++ b/gradle/plugins/common/src/main/kotlin/junitbuild.spotless-conventions.gradle.kts @@ -13,13 +13,11 @@ spotless { targetExclude("gradle/plugins/**/build/**") leadingSpacesToTabs() trimTrailingWhitespace() - endWithNewline() } format("documentation") { target("*.adoc", "*.md", "src/**/*.adoc", "src/**/*.md") trimTrailingWhitespace() - endWithNewline() } pluginManager.withPlugin("java") { @@ -36,8 +34,6 @@ spotless { val majorMinorVersion = "([0-9]+\\.[0-9]+).*".toRegex().matchEntire(fullVersion)!!.let { it.groups[1]!!.value } eclipse(majorMinorVersion).configFile(javaFormatterConfigFile) trimTrailingWhitespace() - endWithNewline() - removeUnusedImports() } format("moduleDescriptor") { @@ -46,7 +42,6 @@ spotless { }) licenseHeaderFile(license.headerFile, "^$") trimTrailingWhitespace() - endWithNewline() } } @@ -56,7 +51,6 @@ spotless { ktlint(requiredVersionFromLibs("ktlint")) licenseHeaderFile(license.headerFile) trimTrailingWhitespace() - endWithNewline() } configurations.named { it.startsWith("spotless") }.configureEach { // Workaround for CVE-2024-12798 and CVE-2024-12801 @@ -74,7 +68,6 @@ spotless { groovy { licenseHeaderFile(license.headerFile) trimTrailingWhitespace() - endWithNewline() } } } diff --git a/junit-jupiter-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine b/junit-jupiter-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine index 581900d54294..f19e8767902b 100644 --- a/junit-jupiter-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine +++ b/junit-jupiter-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine @@ -1 +1 @@ -org.junit.jupiter.engine.JupiterTestEngine \ No newline at end of file +org.junit.jupiter.engine.JupiterTestEngine diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java index 536cc908dc76..45d1f1a72ab1 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java @@ -14,6 +14,7 @@ import static org.apiguardian.api.API.Status.MAINTAINED; import java.lang.reflect.Member; +import java.lang.reflect.Modifier; import org.apiguardian.api.API; import org.junit.platform.commons.util.ReflectionUtils; @@ -46,7 +47,7 @@ private ModifierSupport() { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code public} - * @see java.lang.reflect.Modifier#isPublic(int) + * @see Modifier#isPublic(int) */ public static boolean isPublic(Class clazz) { return ReflectionUtils.isPublic(clazz); @@ -57,7 +58,7 @@ public static boolean isPublic(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code public} - * @see java.lang.reflect.Modifier#isPublic(int) + * @see Modifier#isPublic(int) */ public static boolean isPublic(Member member) { return ReflectionUtils.isPublic(member); @@ -68,7 +69,7 @@ public static boolean isPublic(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code private} - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPrivate(int) */ public static boolean isPrivate(Class clazz) { return ReflectionUtils.isPrivate(clazz); @@ -79,7 +80,7 @@ public static boolean isPrivate(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code private} - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPrivate(int) */ public static boolean isPrivate(Member member) { return ReflectionUtils.isPrivate(member); @@ -95,9 +96,9 @@ public static boolean isPrivate(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code private} - * @see java.lang.reflect.Modifier#isPublic(int) - * @see java.lang.reflect.Modifier#isProtected(int) - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPublic(int) + * @see Modifier#isProtected(int) + * @see Modifier#isPrivate(int) */ public static boolean isNotPrivate(Class clazz) { return ReflectionUtils.isNotPrivate(clazz); @@ -113,9 +114,9 @@ public static boolean isNotPrivate(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is not {@code private} - * @see java.lang.reflect.Modifier#isPublic(int) - * @see java.lang.reflect.Modifier#isProtected(int) - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPublic(int) + * @see Modifier#isProtected(int) + * @see Modifier#isPrivate(int) */ public static boolean isNotPrivate(Member member) { return ReflectionUtils.isNotPrivate(member); @@ -126,7 +127,7 @@ public static boolean isNotPrivate(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code abstract} - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ public static boolean isAbstract(Class clazz) { return ReflectionUtils.isAbstract(clazz); @@ -137,7 +138,7 @@ public static boolean isAbstract(Class clazz) { * * @param member the class to check; never {@code null} * @return {@code true} if the member is {@code abstract} - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ public static boolean isAbstract(Member member) { return ReflectionUtils.isAbstract(member); @@ -149,7 +150,7 @@ public static boolean isAbstract(Member member) { * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code abstract} * @since 1.13 - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ @API(status = EXPERIMENTAL, since = "6.0") public static boolean isNotAbstract(Class clazz) { @@ -162,7 +163,7 @@ public static boolean isNotAbstract(Class clazz) { * @param member the class to check; never {@code null} * @return {@code true} if the member is not {@code abstract} * @since 1.13 - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ @API(status = EXPERIMENTAL, since = "6.0") public static boolean isNotAbstract(Member member) { @@ -174,7 +175,7 @@ public static boolean isNotAbstract(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isStatic(Class clazz) { return ReflectionUtils.isStatic(clazz); @@ -185,7 +186,7 @@ public static boolean isStatic(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isStatic(Member member) { return ReflectionUtils.isStatic(member); @@ -196,7 +197,7 @@ public static boolean isStatic(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isNotStatic(Class clazz) { return ReflectionUtils.isNotStatic(clazz); @@ -207,7 +208,7 @@ public static boolean isNotStatic(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is not {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isNotStatic(Member member) { return ReflectionUtils.isNotStatic(member); @@ -219,7 +220,7 @@ public static boolean isNotStatic(Member member) { * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isFinal(Class clazz) { @@ -232,7 +233,7 @@ public static boolean isFinal(Class clazz) { * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isNotFinal(Class clazz) { @@ -245,7 +246,7 @@ public static boolean isNotFinal(Class clazz) { * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isFinal(Member member) { @@ -258,7 +259,7 @@ public static boolean isFinal(Member member) { * @param member the member to check; never {@code null} * @return {@code true} if the member is not {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isNotFinal(Member member) { diff --git a/junit-platform-suite-api/src/main/java/org/junit/platform/suite/api/SelectModules.java b/junit-platform-suite-api/src/main/java/org/junit/platform/suite/api/SelectModules.java index 9c3ba49a4e81..76244235fdd8 100644 --- a/junit-platform-suite-api/src/main/java/org/junit/platform/suite/api/SelectModules.java +++ b/junit-platform-suite-api/src/main/java/org/junit/platform/suite/api/SelectModules.java @@ -18,7 +18,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.util.Set; import org.apiguardian.api.API; diff --git a/junit-vintage-engine/junit-vintage-engine.gradle.kts b/junit-vintage-engine/junit-vintage-engine.gradle.kts index 493ac94e0605..6fb1ccd35b28 100644 --- a/junit-vintage-engine/junit-vintage-engine.gradle.kts +++ b/junit-vintage-engine/junit-vintage-engine.gradle.kts @@ -39,7 +39,7 @@ tasks { compileTestFixturesGroovy { javaLauncher = project.javaToolchains.launcherFor { // Groovy 2.x (used for Spock tests) does not support current JDKs - languageVersion = JavaLanguageVersion.of(8) + languageVersion = JavaLanguageVersion.of(17) } } jar { diff --git a/junit-vintage-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine b/junit-vintage-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine index 97ee0b959ac4..79b0bd6d4d59 100644 --- a/junit-vintage-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine +++ b/junit-vintage-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine @@ -1 +1 @@ -org.junit.vintage.engine.VintageTestEngine \ No newline at end of file +org.junit.vintage.engine.VintageTestEngine diff --git a/junit-vintage-engine/src/test/java/org/junit/vintage/engine/discovery/IsPotentialJUnit4TestClassTests.java b/junit-vintage-engine/src/test/java/org/junit/vintage/engine/discovery/IsPotentialJUnit4TestClassTests.java index 85486d998c89..b97eaa33b5ca 100644 --- a/junit-vintage-engine/src/test/java/org/junit/vintage/engine/discovery/IsPotentialJUnit4TestClassTests.java +++ b/junit-vintage-engine/src/test/java/org/junit/vintage/engine/discovery/IsPotentialJUnit4TestClassTests.java @@ -40,7 +40,7 @@ void abstractClass() { assertFalse(isPotentialJUnit4TestClass.test(Baz.class)); } - public static abstract class Baz { + public abstract static class Baz { } @Test diff --git a/junit-vintage-engine/src/test/resources/log4j2-test.xml b/junit-vintage-engine/src/test/resources/log4j2-test.xml index 063e415913fd..c0f95992bbdf 100644 --- a/junit-vintage-engine/src/test/resources/log4j2-test.xml +++ b/junit-vintage-engine/src/test/resources/log4j2-test.xml @@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/api/DisplayNameGenerationTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/api/DisplayNameGenerationTests.java index bf356db5d3ca..22c5e901955e 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/api/DisplayNameGenerationTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/api/DisplayNameGenerationTests.java @@ -333,7 +333,7 @@ public String generateDisplayNameForMethod(List> enclosingInstanceTypes } @DisplayNameGeneration(NoNameGenerator.class) - static abstract class AbstractTestCase { + abstract static class AbstractTestCase { @Test void test() { } diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/NestedTestClassesTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/NestedTestClassesTests.java index 70a844cd2639..4331efff7fbe 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/NestedTestClassesTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/NestedTestClassesTests.java @@ -417,7 +417,7 @@ void notExecutedByImplementingClass() { } - static abstract class AbstractSuperClass implements InterfaceWithNestedClass { + abstract static class AbstractSuperClass implements InterfaceWithNestedClass { @Nested class NestedInAbstractClass { diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/SealedClassTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/SealedClassTests.java index 899cf5333280..5842685124c0 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/SealedClassTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/SealedClassTests.java @@ -23,7 +23,7 @@ void sealedTestClassesAreTestClasses() { .assertStatistics(stats -> stats.finished(2).succeeded(1).failed(1)); } - sealed abstract static class AbstractTestCase permits TestCase { + abstract static sealed class AbstractTestCase permits TestCase { @Test void succeedingTest() { diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/TestClassInheritanceTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/TestClassInheritanceTests.java index 7db63a5e3021..b39e1544b6e2 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/TestClassInheritanceTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/TestClassInheritanceTests.java @@ -136,7 +136,7 @@ void beforeAndAfterMethodsInTestClassHierarchy() { // ------------------------------------------------------------------- - private static abstract class AbstractTestCase { + private abstract static class AbstractTestCase { static int countSuperBeforeInvoked = 0; static int countSuperAfterInvoked = 0; diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/ExtensionContextTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/ExtensionContextTests.java index 2599244c739c..055f392be22c 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/ExtensionContextTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/ExtensionContextTests.java @@ -529,7 +529,7 @@ private TestMethodTestDescriptor nestedMethodDescriptor() { } } - static abstract class BaseNestedTestCase { + abstract static class BaseNestedTestCase { @Test void nestedMethod() { } diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/JupiterTestDescriptorTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/JupiterTestDescriptorTests.java index 053d03498d22..bc18c15aad66 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/JupiterTestDescriptorTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/descriptor/JupiterTestDescriptorTests.java @@ -289,7 +289,7 @@ void enclosingClassesAreDerivedFromParent() { } @Tag("inherited-class-level-tag") - private static abstract class AbstractTestCase { + private abstract static class AbstractTestCase { } @Tag("classTag1") diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/DiscoveryTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/DiscoveryTests.java index 02fa1eb5b01d..df43af4414b7 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/DiscoveryTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/DiscoveryTests.java @@ -412,7 +412,7 @@ void reportsWarningsForBlankDisplayNames() throws Exception { // ------------------------------------------------------------------- @SuppressWarnings("unused") - static abstract class AbstractTestCase { + abstract static class AbstractTestCase { @Test void test() { @@ -465,7 +465,7 @@ void testTemplate() { } - static abstract class AbstractSuperClass { + abstract static class AbstractSuperClass { @Nested class NestedInAbstractClass { @Test diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/predicates/IsTestMethodTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/predicates/IsTestMethodTests.java index 73373a4999d2..24c074a4a9f2 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/predicates/IsTestMethodTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/predicates/IsTestMethodTests.java @@ -154,7 +154,7 @@ private Method abstractMethod(String name) { } @SuppressWarnings({ "JUnitMalformedDeclaration", "unused" }) - private static abstract class AbstractClassWithAbstractTestMethod { + private abstract static class AbstractClassWithAbstractTestMethod { @Test abstract void bogusAbstractTestMethod(); diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/BeforeAndAfterEachTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/BeforeAndAfterEachTests.java index a5e6b501e1ea..1517bc464ec5 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/BeforeAndAfterEachTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/BeforeAndAfterEachTests.java @@ -231,7 +231,7 @@ void beforeEachMethodThrowsAnException() { ); // @formatter:on - List expected = beforeEachMethodCallSequence.getFirst().equals("beforeEachMethod1") ? list1 : list2; + List expected = "beforeEachMethod1".equals(beforeEachMethodCallSequence.getFirst()) ? list1 : list2; assertEquals(expected, callSequence, "wrong call sequence"); diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/OrderedClassTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/OrderedClassTests.java index dd76fa677ce9..8516bece3fcd 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/OrderedClassTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/OrderedClassTests.java @@ -245,7 +245,7 @@ private static EngineTestKit.Builder testKit(@Nullable Class testClass) { // ------------------------------------------------------------------------- - private static abstract class AbstractTestCase { + private abstract static class AbstractTestCase { @Test public void successfulTest() { @@ -322,7 +322,7 @@ static class ProblematicConstructorTestCase extends AbstractTestCase { } @TestMethodOrder(OrderAnnotation.class) - private static abstract class AbstractDisabledMethodsTestCase { + private abstract static class AbstractDisabledMethodsTestCase { @Disabled @Test diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/migrationsupport/conditions/IgnoreAnnotationIntegrationTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/migrationsupport/conditions/IgnoreAnnotationIntegrationTests.java index 20d523c6dc05..de6a0429c900 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/migrationsupport/conditions/IgnoreAnnotationIntegrationTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/migrationsupport/conditions/IgnoreAnnotationIntegrationTests.java @@ -50,7 +50,7 @@ class ImplicitIgnoreConditionRegistration extends BaseNestedTestCase { } @TestInstance(PER_CLASS) - private static abstract class BaseNestedTestCase { + private abstract static class BaseNestedTestCase { private static List tests = new ArrayList<>(); diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedClassIntegrationTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedClassIntegrationTests.java index 1eac5e4d9d01..0162576740be 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedClassIntegrationTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedClassIntegrationTests.java @@ -1178,7 +1178,7 @@ static Stream parameters() { @Test void test() { - assertTrue(value.equals("foo") || value.equals("bar")); + assertTrue("foo".equals(value) || "bar".equals(value)); } } @@ -1195,7 +1195,7 @@ static Stream parameters() { @Test void test() { - assertTrue(value.equals("foo") || value.equals("bar")); + assertTrue("foo".equals(value) || "bar".equals(value)); } } @@ -1217,7 +1217,7 @@ record FieldSourceConstructorInjectionTestCase(String value) { @Test void test() { - assertTrue(value.equals("foo") || value.equals("bar")); + assertTrue("foo".equals(value) || "bar".equals(value)); } } @@ -1232,7 +1232,7 @@ static class FieldSourceFieldInjectionTestCase { @Test void test() { - assertTrue(value.equals("foo") || value.equals("bar")); + assertTrue("foo".equals(value) || "bar".equals(value)); } } @@ -1251,7 +1251,7 @@ void test() { record ArgumentsSourceConstructorInjectionTestCase(String value) { @Test void test() { - assertTrue(value.equals("foo") || value.equals("bar")); + assertTrue("foo".equals(value) || "bar".equals(value)); } } @@ -1264,7 +1264,7 @@ static class ArgumentsSourceFieldInjectionTestCase { @Test void test() { - assertTrue(value.equals("foo") || value.equals("bar")); + assertTrue("foo".equals(value) || "bar".equals(value)); } } @@ -1851,7 +1851,7 @@ void test() { } } - static abstract class AbstractBaseLifecycleTestCase { + abstract static class AbstractBaseLifecycleTestCase { @BeforeParameterizedClassInvocation static void zzz_before(TestReporter reporter) { @@ -1884,7 +1884,7 @@ void test(TestReporter reporter) { } } - static abstract class AbstractBaseLifecycleWithErrorsTestCase { + abstract static class AbstractBaseLifecycleWithErrorsTestCase { @BeforeParameterizedClassInvocation static void zzz_before(TestReporter reporter) { diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestExtensionTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestExtensionTests.java index ff3cc6a8b0cd..4bca8776ce20 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestExtensionTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestExtensionTests.java @@ -111,7 +111,7 @@ void emptyDisplayNameIsIllegal() { void defaultDisplayNameWithEmptyStringInConfigurationIsIllegal() { AtomicInteger invocations = new AtomicInteger(); Function> configurationSupplier = key -> { - if (key.equals(ParameterizedInvocationNameFormatter.DISPLAY_NAME_PATTERN_KEY)) { + if (ParameterizedInvocationNameFormatter.DISPLAY_NAME_PATTERN_KEY.equals(key)) { invocations.incrementAndGet(); return Optional.of(""); } diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/params/aggregator/AggregatorIntegrationTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/params/aggregator/AggregatorIntegrationTests.java index 1d57fbf27f51..d786fbffab55 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/params/aggregator/AggregatorIntegrationTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/params/aggregator/AggregatorIntegrationTests.java @@ -203,13 +203,13 @@ void argumentsAccessorInvocationIndex(ArgumentsAccessor arguments) { } private void testPersonAggregator(Person person) { - if (person.firstName.equals("Jane")) { + if ("Jane".equals(person.firstName)) { assertEquals("Jane Doe", person.getFullName()); assertEquals(1980, person.dateOfBirth.getYear()); assertEquals(Gender.F, person.gender); } - if (person.firstName.equals("Jack")) { + if ("Jack".equals(person.firstName)) { assertEquals("Jack Smith", person.getFullName()); assertEquals(2000, person.dateOfBirth.getYear()); assertEquals(Gender.M, person.gender); diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/params/support/AnnotationConsumerInitializerTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/params/support/AnnotationConsumerInitializerTests.java index 0cbcceb950b5..d67a3f2ef620 100644 --- a/jupiter-tests/src/test/java/org/junit/jupiter/params/support/AnnotationConsumerInitializerTests.java +++ b/jupiter-tests/src/test/java/org/junit/jupiter/params/support/AnnotationConsumerInitializerTests.java @@ -124,7 +124,7 @@ void shouldInitializeForEachAnnotations(AbstractAnnotationBasedArgumentsProvider Named.of("deprecated", new DeprecatedAnnotationBasedArgumentsProvider()) // ); - private static abstract class AbstractAnnotationBasedArgumentsProvider + private abstract static class AbstractAnnotationBasedArgumentsProvider extends AnnotationBasedArgumentsProvider { List annotations = new ArrayList<>(); diff --git a/platform-tests/src/test/java/org/junit/platform/commons/support/scanning/DefaultClasspathScannerTests.java b/platform-tests/src/test/java/org/junit/platform/commons/support/scanning/DefaultClasspathScannerTests.java index d79540ddf728..96ded621c581 100644 --- a/platform-tests/src/test/java/org/junit/platform/commons/support/scanning/DefaultClasspathScannerTests.java +++ b/platform-tests/src/test/java/org/junit/platform/commons/support/scanning/DefaultClasspathScannerTests.java @@ -136,7 +136,7 @@ private void assertClassesScannedWhenExceptionIsThrown(Predicate> filte @Test void scanForResourcesInClasspathRootWhenGenericRuntimeExceptionOccurs(LogRecordListener listener) throws Exception { Predicate runtimeExceptionSimulationFilter = resource -> { - if (resource.getName().equals("org/junit/platform/commons/other-example.resource")) { + if ("org/junit/platform/commons/other-example.resource".equals(resource.getName())) { throw new RuntimeException("a generic exception"); } return true; diff --git a/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java b/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java index 22022c758fcc..c2916d17a2fe 100644 --- a/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java +++ b/platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsTests.java @@ -98,7 +98,7 @@ */ class ReflectionUtilsTests { - private static final Predicate isFooMethod = method -> method.getName().equals("foo"); + private static final Predicate isFooMethod = method -> "foo".equals(method.getName()); private static final Predicate methodContains1 = method -> method.getName().contains("1"); private static final Predicate methodContains2 = method -> method.getName().contains("2"); private static final Predicate methodContains4 = method -> method.getName().contains("4"); @@ -1266,7 +1266,7 @@ void isMethodPresentPreconditions() { @Test void isMethodPresent() { - Predicate isMethod1 = method -> (method.getName().equals("method1") + Predicate isMethod1 = method -> ("method1".equals(method.getName()) && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == String.class); assertThat(ReflectionUtils.isMethodPresent(MethodShadowingChild.class, isMethod1)).isTrue(); @@ -1502,7 +1502,7 @@ private static void assertOneFooMethodIn(Class clazz) { */ @Test void findMethodsFindsDistinctMethodsDeclaredInMultipleInterfaces() { - Predicate isStringsMethod = method -> method.getName().equals("strings"); + Predicate isStringsMethod = method -> "strings".equals(method.getName()); assertThat(findMethods(DoubleInheritedInterfaceMethodTestCase.class, isStringsMethod)).hasSize(1); } @@ -1549,10 +1549,10 @@ void findMethodsUsingHierarchyUpMode() throws Exception { .containsExactly(ChildClass.class.getMethod("otherMethod3"), ParentClass.class.getMethod("otherMethod2"), GrandparentClass.class.getMethod("otherMethod1")); - assertThat(findMethods(ChildClass.class, method -> method.getName().equals("method2"), BOTTOM_UP))// + assertThat(findMethods(ChildClass.class, method -> "method2".equals(method.getName()), BOTTOM_UP))// .containsExactly(ParentClass.class.getMethod("method2")); - assertThat(findMethods(ChildClass.class, method -> method.getName().equals("wrongName"), BOTTOM_UP))// + assertThat(findMethods(ChildClass.class, method -> "wrongName".equals(method.getName()), BOTTOM_UP))// .isEmpty(); assertThat(findMethods(ParentClass.class, method -> method.getName().contains("method"), BOTTOM_UP))// @@ -1571,10 +1571,10 @@ void findMethodsUsingHierarchyDownMode() throws Exception { .containsExactly(GrandparentClass.class.getMethod("otherMethod1"), ParentClass.class.getMethod("otherMethod2"), ChildClass.class.getMethod("otherMethod3")); - assertThat(findMethods(ChildClass.class, method -> method.getName().equals("method2"), TOP_DOWN))// + assertThat(findMethods(ChildClass.class, method -> "method2".equals(method.getName()), TOP_DOWN))// .containsExactly(ParentClass.class.getMethod("method2")); - assertThat(findMethods(ChildClass.class, method -> method.getName().equals("wrongName"), TOP_DOWN))// + assertThat(findMethods(ChildClass.class, method -> "wrongName".equals(method.getName()), TOP_DOWN))// .isEmpty(); assertThat(findMethods(ParentClass.class, method -> method.getName().contains("method"), TOP_DOWN))// diff --git a/platform-tests/src/test/java/org/junit/platform/engine/support/hierarchical/ParallelExecutionIntegrationTests.java b/platform-tests/src/test/java/org/junit/platform/engine/support/hierarchical/ParallelExecutionIntegrationTests.java index a311559c9cea..212cc49147be 100644 --- a/platform-tests/src/test/java/org/junit/platform/engine/support/hierarchical/ParallelExecutionIntegrationTests.java +++ b/platform-tests/src/test/java/org/junit/platform/engine/support/hierarchical/ParallelExecutionIntegrationTests.java @@ -886,7 +886,7 @@ void repeatedTest() throws Exception { } @ExtendWith(ThreadReporter.class) - static abstract class BarrierTestCase { + abstract static class BarrierTestCase { @Test void test1() throws Exception { diff --git a/platform-tests/src/test/java/org/junit/platform/launcher/core/DefaultLauncherTests.java b/platform-tests/src/test/java/org/junit/platform/launcher/core/DefaultLauncherTests.java index 33bb887bd4e2..da83caa648a2 100644 --- a/platform-tests/src/test/java/org/junit/platform/launcher/core/DefaultLauncherTests.java +++ b/platform-tests/src/test/java/org/junit/platform/launcher/core/DefaultLauncherTests.java @@ -1019,7 +1019,7 @@ public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId inOrder.verify(executionListener).executionStarted( argThat(d -> d.getUniqueIdObject().equals(UniqueId.forEngine("engine-id")))); inOrder.verify(executionListener).executionSkipped( - argThat(d -> d.getUniqueIdObject().getLastSegment().getType().equals("container")), + argThat(d -> "container".equals(d.getUniqueIdObject().getLastSegment().getType())), eq("Execution cancelled")); inOrder.verify(executionListener).executionFinished( argThat(d -> d.getUniqueIdObject().equals(UniqueId.forEngine("engine-id"))), diff --git a/platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteEngineTests.java b/platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteEngineTests.java index 12cb46e6d928..851ff5da88ff 100644 --- a/platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteEngineTests.java +++ b/platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteEngineTests.java @@ -726,7 +726,7 @@ static void afterSuite() { @Suite @SelectClasses(SingleTestTestCase.class) - abstract private static class AbstractPrivateSuite { + private abstract static class AbstractPrivateSuite { } @Suite diff --git a/platform-tests/src/test/resources/do_not_delete_me.txt b/platform-tests/src/test/resources/do_not_delete_me.txt index 91c5d9e7c55b..0db3b13a83b1 100644 --- a/platform-tests/src/test/resources/do_not_delete_me.txt +++ b/platform-tests/src/test/resources/do_not_delete_me.txt @@ -1,3 +1,3 @@ I am used by tests, so... -Do NOT delete me! \ No newline at end of file +Do NOT delete me! diff --git a/platform-tests/src/test/resources/testservices/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/platform-tests/src/test/resources/testservices/META-INF/services/org.junit.platform.launcher.TestExecutionListener index 4bb9bbe72066..402a62451836 100644 --- a/platform-tests/src/test/resources/testservices/META-INF/services/org.junit.platform.launcher.TestExecutionListener +++ b/platform-tests/src/test/resources/testservices/META-INF/services/org.junit.platform.launcher.TestExecutionListener @@ -1,3 +1,3 @@ org.junit.platform.launcher.listeners.NoopTestExecutionListener org.junit.platform.launcher.listeners.UnusedTestExecutionListener -org.junit.platform.launcher.listeners.AnotherUnusedTestExecutionListener \ No newline at end of file +org.junit.platform.launcher.listeners.AnotherUnusedTestExecutionListener diff --git a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ManifestTests.java b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ManifestTests.java index f71b3f14eb12..6b7384ab4770 100644 --- a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ManifestTests.java +++ b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ManifestTests.java @@ -56,7 +56,7 @@ void manifestEntriesAdhereToConventions(String module) throws Exception { assertValue(attributes, "Bundle-SymbolicName", module); assertValue(attributes, "Bundle-Version", MavenVersion.parseMavenString(version).getOSGiVersion().toString()); - if (module.equals("junit-platform-console")) { + if ("junit-platform-console".equals(module)) { assertValue(attributes, "Main-Class", "org.junit.platform.console.ConsoleLauncher"); } var domain = Domain.domain(manifest); diff --git a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java index d018c629fc7a..75dc1b330b8c 100644 --- a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java +++ b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java @@ -90,7 +90,7 @@ static void triggerReleaseOfFileHandlesOnWindows() throws Exception { void findAndRunJUnitOnTheClassPath() { try (var loader = new URLClassLoader("junit", urls(lib), ClassLoader.getPlatformClassLoader())) { var sl = ServiceLoader.load(ToolProvider.class, loader); - var junit = StreamSupport.stream(sl.spliterator(), false).filter(p -> p.name().equals("junit")).findFirst(); + var junit = StreamSupport.stream(sl.spliterator(), false).filter(p -> "junit".equals(p.name())).findFirst(); assertTrue(junit.isPresent(), "Tool 'junit' not found in: " + lib); assertJUnitPrintsHelpMessage(junit.get()); @@ -116,7 +116,7 @@ void findAndRunJUnitOnTheModulePath() { var layer = bootLayer.defineModulesWithOneLoader(configuration, ClassLoader.getPlatformClassLoader()); var sl = ServiceLoader.load(layer, ToolProvider.class); - var junit = StreamSupport.stream(sl.spliterator(), false).filter(p -> p.name().equals("junit")).findFirst(); + var junit = StreamSupport.stream(sl.spliterator(), false).filter(p -> "junit".equals(p.name())).findFirst(); assertTrue(junit.isPresent(), "Tool 'junit' not found in modules: " + modules); assertJUnitPrintsHelpMessage(junit.get());