diff --git a/.github/workflows/cross-version.yml b/.github/workflows/cross-version.yml index 13c93692b87a..8480a68a49c7 100644 --- a/.github/workflows/cross-version.yml +++ b/.github/workflows/cross-version.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - jdk: [19, 20, 21] + jdk: [20, 21, 22] name: "OpenJDK ${{ matrix.jdk }}" runs-on: ubuntu-latest steps: diff --git a/documentation/src/docs/asciidoc/release-notes/release-notes-5.10.0-RC1.adoc b/documentation/src/docs/asciidoc/release-notes/release-notes-5.10.0-RC1.adoc index a27df6037dd6..a9ab80ed4da8 100644 --- a/documentation/src/docs/asciidoc/release-notes/release-notes-5.10.0-RC1.adoc +++ b/documentation/src/docs/asciidoc/release-notes/release-notes-5.10.0-RC1.adoc @@ -62,6 +62,7 @@ JUnit repository on GitHub. * Lifecycle and thread-safety semantics are now documented for the `TempDirFactory` SPI. * The scope of applicability for `TestWatcher` implementations is now more extensively documented in the User Guide and Javadoc. +* `JAVA_22` has been added to the `JRE` enum for use with JRE-based execution conditions. [[release-notes-5.10.0-RC1-junit-vintage]] diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java index fc6c980271b0..85e2b58ad888 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java @@ -44,6 +44,7 @@ * @see #JAVA_19 * @see #JAVA_20 * @see #JAVA_21 + * @see #JAVA_22 * @see #OTHER * @see EnabledOnJre * @see DisabledOnJre @@ -153,12 +154,21 @@ public enum JRE { @API(status = STABLE, since = "5.9.2") JAVA_21, + /** + * Java 22. + * + * @since 5.10 + */ + @API(status = STABLE, since = "5.9.2") + JAVA_22, + /** * A JRE version other than {@link #JAVA_8}, {@link #JAVA_9}, * {@link #JAVA_10}, {@link #JAVA_11}, {@link #JAVA_12}, * {@link #JAVA_13}, {@link #JAVA_14}, {@link #JAVA_15}, * {@link #JAVA_16}, {@link #JAVA_17}, {@link #JAVA_18}, - * {@link #JAVA_19}, {@link #JAVA_20}, or {@link #JAVA_21}. + * {@link #JAVA_19}, {@link #JAVA_20}, {@link #JAVA_21}, or + * {@link #JAVA_22}. */ OTHER; @@ -214,6 +224,8 @@ private static JRE determineCurrentVersion() { return JAVA_20; case 21: return JAVA_21; + case 22: + return JAVA_22; default: return OTHER; } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java index 9ccce353304a..7c4cf44ede4c 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava19; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava20; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava21; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava22; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -116,7 +117,7 @@ void other() { evaluateCondition(); assertDisabledOnCurrentJreIf( !(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() - || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21())); + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22())); } private void assertDisabledOnCurrentJreIf(boolean condition) { diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java index bcca45f99859..c1c782def80e 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava19; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava20; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava21; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava22; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; import static org.junit.jupiter.api.condition.JRE.JAVA_17; @@ -82,8 +83,9 @@ void javaMin18() { @Test @DisabledForJreRange(min = OTHER, max = OTHER) void other() { - assertTrue(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21()); + assertTrue( + onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22()); } } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java index 35fa2e52bd85..acba9ef791c7 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava19; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava20; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava21; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava22; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -206,6 +207,15 @@ void java21() { assertDisabledOnCurrentJreIf(onJava21()); } + /** + * @see DisabledOnJreIntegrationTests#java22() + */ + @Test + void java22() { + evaluateCondition(); + assertDisabledOnCurrentJreIf(onJava22()); + } + /** * @see DisabledOnJreIntegrationTests#other() */ @@ -214,7 +224,7 @@ void other() { evaluateCondition(); assertDisabledOnCurrentJreIf( !(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() - || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21())); + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22())); } private void assertDisabledOnCurrentJreIf(boolean condition) { diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java index 12ece2e580a9..2c7f922cd6b7 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava19; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava20; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava21; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava22; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; import static org.junit.jupiter.api.condition.JRE.JAVA_10; @@ -39,6 +40,7 @@ import static org.junit.jupiter.api.condition.JRE.JAVA_19; import static org.junit.jupiter.api.condition.JRE.JAVA_20; import static org.junit.jupiter.api.condition.JRE.JAVA_21; +import static org.junit.jupiter.api.condition.JRE.JAVA_22; import static org.junit.jupiter.api.condition.JRE.JAVA_8; import static org.junit.jupiter.api.condition.JRE.JAVA_9; import static org.junit.jupiter.api.condition.JRE.OTHER; @@ -66,7 +68,7 @@ void missingJreDeclaration() { @Test @DisabledOnJre(value = { JAVA_8, JAVA_9, JAVA_10, JAVA_11, JAVA_12, JAVA_13, JAVA_14, JAVA_15, JAVA_16, JAVA_17, - JAVA_18, JAVA_19, JAVA_20, JAVA_21, OTHER }, disabledReason = "Disabled on every JRE") + JAVA_18, JAVA_19, JAVA_20, JAVA_21, JAVA_22, OTHER }, disabledReason = "Disabled on every JRE") void disabledOnAllJavaVersions() { fail("should be disabled"); } @@ -155,11 +157,18 @@ void java21() { assertFalse(onJava21()); } + @Test + @DisabledOnJre(JAVA_22) + void java22() { + assertFalse(onJava22()); + } + @Test @DisabledOnJre(OTHER) void other() { - assertTrue(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21()); + assertTrue( + onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22()); } } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java index f894695285d2..3e4cf7db4b15 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava19; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava20; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava21; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava22; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -115,7 +116,7 @@ void other() { evaluateCondition(); assertEnabledOnCurrentJreIf( !(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() - || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21())); + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22())); } private void assertEnabledOnCurrentJreIf(boolean condition) { diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java index 5007240e7f2a..ccf86a08eb6a 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava19; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava20; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava21; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava22; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; import static org.junit.jupiter.api.condition.JRE.JAVA_17; @@ -78,15 +79,16 @@ void javaMax18() { @Test @EnabledForJreRange(min = JAVA_18) void javaMin18() { - assertTrue(onJava18() || onJava19() || onJava20() || onJava21()); + assertTrue(onJava18() || onJava19() || onJava20() || onJava21() || onJava22()); assertFalse(onJava17()); } @Test @EnabledForJreRange(min = OTHER, max = OTHER) void other() { - assertFalse(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21()); + assertFalse( + onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22()); } } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java index 9c4bb4c2a143..60f3cb70be1f 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava19; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava20; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava21; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava22; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -205,6 +206,15 @@ void java21() { assertEnabledOnCurrentJreIf(onJava21()); } + /** + * @see EnabledOnJreIntegrationTests#java22() + */ + @Test + void java22() { + evaluateCondition(); + assertEnabledOnCurrentJreIf(onJava22()); + } + /** * @see EnabledOnJreIntegrationTests#other() */ @@ -213,7 +223,7 @@ void other() { evaluateCondition(); assertEnabledOnCurrentJreIf( !(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() - || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21())); + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22())); assertCustomDisabledReasonIs("Disabled on almost every JRE"); } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java index a7a414486727..3ad579262415 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.condition.JRE.JAVA_19; import static org.junit.jupiter.api.condition.JRE.JAVA_20; import static org.junit.jupiter.api.condition.JRE.JAVA_21; +import static org.junit.jupiter.api.condition.JRE.JAVA_22; import static org.junit.jupiter.api.condition.JRE.JAVA_8; import static org.junit.jupiter.api.condition.JRE.JAVA_9; import static org.junit.jupiter.api.condition.JRE.OTHER; @@ -53,7 +54,7 @@ void missingJreDeclaration() { @Test @EnabledOnJre({ JAVA_8, JAVA_9, JAVA_10, JAVA_11, JAVA_12, JAVA_13, JAVA_14, JAVA_15, JAVA_16, JAVA_17, JAVA_18, - JAVA_19, JAVA_20, JAVA_21, OTHER }) + JAVA_19, JAVA_20, JAVA_21, JAVA_22, OTHER }) void enabledOnAllJavaVersions() { } @@ -141,11 +142,18 @@ void java21() { assertTrue(onJava21()); } + @Test + @EnabledOnJre(JAVA_22) + void java22() { + assertTrue(onJava22()); + } + @Test @EnabledOnJre(value = OTHER, disabledReason = "Disabled on almost every JRE") void other() { - assertFalse(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21()); + assertFalse( + onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() + || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22()); } static boolean onJava8() { @@ -204,4 +212,8 @@ static boolean onJava21() { return JAVA_VERSION.startsWith("21"); } + static boolean onJava22() { + return JAVA_VERSION.startsWith("22"); + } + } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/JRETests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/JRETests.java index f915146cfee4..7a2a2e6236ad 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/JRETests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/JRETests.java @@ -16,6 +16,7 @@ import static org.junit.jupiter.api.condition.JRE.JAVA_19; import static org.junit.jupiter.api.condition.JRE.JAVA_20; import static org.junit.jupiter.api.condition.JRE.JAVA_21; +import static org.junit.jupiter.api.condition.JRE.JAVA_22; import static org.junit.jupiter.api.condition.JRE.OTHER; import org.junit.jupiter.api.Test; @@ -57,6 +58,12 @@ void java21() { assertEquals(JAVA_21, JRE.currentVersion()); } + @Test + @EnabledOnJre(JAVA_22) + void java22() { + assertEquals(JAVA_22, JRE.currentVersion()); + } + @Test @EnabledOnJre(OTHER) void other() {