diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java index 12276bc5910..5f4f89b6e6f 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/AutowiredConstructorTest.java @@ -4,7 +4,10 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class AutowiredConstructorTest { @Test void identification() { diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java index b77767af845..47267ecfdc3 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ImmutablesSortedSetComparatorTest.java @@ -4,6 +4,8 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; final class ImmutablesSortedSetComparatorTest { @Test @@ -140,6 +142,7 @@ void replacement() { .doTest(TestMode.TEXT_MATCH); } + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void replacementWithImportClash() { BugCheckerRefactoringTestHelper.newInstance(ImmutablesSortedSetComparator.class, getClass()) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java index 7d2ab285370..5ead6045cde 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitClassModifiersTest.java @@ -4,7 +4,10 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class JUnitClassModifiersTest { @Test void identification() { diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java index da842fd92a8..e2c2039de02 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java @@ -5,8 +5,11 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; final class LexicographicalAnnotationAttributeListingTest { + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void identification() { CompilationTestHelper.newInstance(LexicographicalAnnotationAttributeListing.class, getClass()) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java index baa62651dbb..12e3c7f9563 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestMappingAnnotationTest.java @@ -2,7 +2,10 @@ import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class RequestMappingAnnotationTest { @Test void identification() { diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java index 38616e4ea0f..cc8e8d55b88 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RequestParamTypeTest.java @@ -2,7 +2,10 @@ import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class RequestParamTypeTest { @Test void identification() { diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java index c61a99a8ca3..f420f2c9e3f 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ScheduledTransactionTraceTest.java @@ -4,8 +4,11 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; import org.springframework.scheduling.annotation.Scheduled; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class ScheduledTransactionTraceTest { @Test void identification() { diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java index d0ae0c49ca9..4c4b7ee8f1f 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/SpringMvcAnnotationTest.java @@ -4,7 +4,10 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +@DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) final class SpringMvcAnnotationTest { @Test void identification() { diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java index d876f410825..86884cc7d10 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java @@ -6,6 +6,8 @@ import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode; import com.google.errorprone.CompilationTestHelper; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; final class StaticImportTest { @Test @@ -26,6 +28,7 @@ void exemptedMembersAreNotRedundant() { .doesNotContainAnyElementsOf(StaticImport.STATIC_IMPORT_EXEMPTED_IDENTIFIERS); } + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void identification() { CompilationTestHelper.newInstance(StaticImport.class, getClass()) @@ -111,6 +114,7 @@ void identification() { .doTest(); } + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) @Test void replacement() { BugCheckerRefactoringTestHelper.newInstance(StaticImport.class, getClass()) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java index 0dc5d220495..8b42f880fa6 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/RefasterRulesTest.java @@ -4,6 +4,8 @@ import com.google.common.collect.ImmutableSet; import java.util.stream.Stream; +import org.junit.jupiter.api.condition.DisabledForJreRange; +import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -69,6 +71,10 @@ final class RefasterRulesTest { TestNGToAssertJRules.class, TimeRules.class, WebClientRules.class); + // XXX: Drop all logic related to this collection once we drop support for + // JDKs prior to version 17. + private static final ImmutableSet> JDK_17_PLUS_RULE_COLLECTIONS = + ImmutableSet.of(WebClientRules.class); // XXX: Create a JUnit extension to automatically discover the rule collections in a given context // to make sure the list is exhaustive. @@ -77,12 +83,24 @@ private static Stream validateRuleCollectionTestCases() { // method with `@ValueSource(classes = {...})`. return RULE_COLLECTIONS.stream() .filter(not(AssertJRules.class::equals)) + .filter(not(WebClientRules.class::equals)) .map(Arguments::arguments); } @MethodSource("validateRuleCollectionTestCases") @ParameterizedTest void validateRuleCollection(Class clazz) { - RefasterRuleCollection.validate(clazz); + if (!JDK_17_PLUS_RULE_COLLECTIONS.contains(clazz)) { + RefasterRuleCollection.validate(clazz); + } + } + + @DisabledForJreRange(max = JRE.JAVA_16 /* Spring targets JDK 17. */) + @MethodSource("validateRuleCollectionTestCases") + @ParameterizedTest + void validateRuleCollectionWithJdk17AndAbove(Class clazz) { + if (JDK_17_PLUS_RULE_COLLECTIONS.contains(clazz)) { + RefasterRuleCollection.validate(clazz); + } } } diff --git a/pom.xml b/pom.xml index 8f4354913c1..1100dfd800a 100644 --- a/pom.xml +++ b/pom.xml @@ -1034,6 +1034,10 @@ + + provided + test + ${version.jdk.target}