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 1549909ca300..943b74475f36 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 @@ -45,6 +45,8 @@ * @see #JAVA_20 * @see #JAVA_21 * @see #JAVA_22 + * @see #JAVA_23 + * @see #JAVA_24 * @see #OTHER * @see EnabledOnJre * @see DisabledOnJre @@ -162,13 +164,29 @@ public enum JRE { @API(status = STABLE, since = "5.10") JAVA_22, + /** + * Java 23. + * + * @since 5.11 + */ + @API(status = STABLE, since = "5.11") + JAVA_23, + + /** + * Java 24. + * + * @since 5.11 + */ + @API(status = STABLE, since = "5.11") + JAVA_24, + /** * 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}, {@link #JAVA_21}, or - * {@link #JAVA_22}. + * {@link #JAVA_19}, {@link #JAVA_20}, {@link #JAVA_21}, + * {@link #JAVA_22}, {@link #JAVA_23}, or {@link #JAVA_24}. */ OTHER; @@ -226,6 +244,10 @@ private static JRE determineCurrentVersion() { return JAVA_21; case 22: return JAVA_22; + case 23: + return JAVA_23; + case 24: + return JAVA_24; default: return OTHER; } diff --git a/junit-jupiter-api/src/testFixtures/java/org/junit/jupiter/api/condition/JavaVersionPredicates.java b/junit-jupiter-api/src/testFixtures/java/org/junit/jupiter/api/condition/JavaVersionPredicates.java new file mode 100644 index 000000000000..d0b7114931e1 --- /dev/null +++ b/junit-jupiter-api/src/testFixtures/java/org/junit/jupiter/api/condition/JavaVersionPredicates.java @@ -0,0 +1,104 @@ +/* + * Copyright 2015-2024 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 + */ + +package org.junit.jupiter.api.condition; + +public class JavaVersionPredicates { + + private static final String JAVA_VERSION = System.getProperty("java.version"); + + static boolean onJava8() { + return JAVA_VERSION.startsWith("1.8"); + } + + static boolean onJava9() { + return JAVA_VERSION.startsWith("9"); + } + + static boolean onJava10() { + return JAVA_VERSION.startsWith("10"); + } + + static boolean onJava11() { + return JAVA_VERSION.startsWith("11"); + } + + static boolean onJava12() { + return JAVA_VERSION.startsWith("12"); + } + + static boolean onJava13() { + return JAVA_VERSION.startsWith("13"); + } + + static boolean onJava14() { + return JAVA_VERSION.startsWith("14"); + } + + static boolean onJava15() { + return JAVA_VERSION.startsWith("15"); + } + + static boolean onJava16() { + return JAVA_VERSION.startsWith("16"); + } + + static boolean onJava17() { + return JAVA_VERSION.startsWith("17"); + } + + static boolean onJava18() { + return JAVA_VERSION.startsWith("18"); + } + + static boolean onJava19() { + return JAVA_VERSION.startsWith("19"); + } + + static boolean onJava20() { + return JAVA_VERSION.startsWith("20"); + } + + static boolean onJava21() { + return JAVA_VERSION.startsWith("21"); + } + + static boolean onJava22() { + return JAVA_VERSION.startsWith("22"); + } + + static boolean onJava23() { + return JAVA_VERSION.startsWith("23"); + } + + static boolean onJava24() { + return JAVA_VERSION.startsWith("24"); + } + + static boolean onKnownVersion() { + return onJava8() // + || onJava9() // + || onJava10() // + || onJava11() // + || onJava12() // + || onJava13() // + || onJava14() // + || onJava15() // + || onJava16() // + || onJava17() // + || onJava18() // + || onJava19() // + || onJava20() // + || onJava21() // + || onJava22() // + || onJava23() // + || onJava24(); + } +} 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 244448525084..1d308013b26c 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 @@ -11,21 +11,21 @@ package org.junit.jupiter.api.condition; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava10; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava11; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava12; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava13; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava14; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; -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.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExecutionCondition; 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 d9e11d375a5e..7319d4437f47 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 @@ -13,25 +13,25 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava10; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava11; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava12; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava13; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava14; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; -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; import static org.junit.jupiter.api.condition.JRE.JAVA_18; import static org.junit.jupiter.api.condition.JRE.JAVA_19; import static org.junit.jupiter.api.condition.JRE.OTHER; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; 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 cb323e87df75..593a202f3766 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 @@ -12,21 +12,24 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava10; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava11; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava12; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava13; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava14; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; -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.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava23; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava24; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onKnownVersion; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExecutionCondition; @@ -216,15 +219,31 @@ void java22() { assertDisabledOnCurrentJreIf(onJava22()); } + /** + * @see DisabledOnJreIntegrationTests#java23() + */ + @Test + void java23() { + evaluateCondition(); + assertDisabledOnCurrentJreIf(onJava23()); + } + + /** + * @see DisabledOnJreIntegrationTests#java24() + */ + @Test + void java24() { + evaluateCondition(); + assertDisabledOnCurrentJreIf(onJava24()); + } + /** * @see DisabledOnJreIntegrationTests#other() */ @Test void other() { evaluateCondition(); - assertDisabledOnCurrentJreIf( - !(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() - || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22())); + assertDisabledOnCurrentJreIf(!onKnownVersion()); } 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 564a89c4f24b..767bc1ebed8d 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 @@ -13,21 +13,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava10; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava11; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava12; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava13; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava14; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; -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; import static org.junit.jupiter.api.condition.JRE.JAVA_11; import static org.junit.jupiter.api.condition.JRE.JAVA_12; @@ -41,9 +26,29 @@ 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_23; +import static org.junit.jupiter.api.condition.JRE.JAVA_24; 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; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava23; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava24; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onKnownVersion; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -67,8 +72,26 @@ 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, JAVA_22, OTHER }, disabledReason = "Disabled on every JRE") + @DisabledOnJre(disabledReason = "Disabled on every JRE", 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, // + JAVA_22, // + JAVA_23, // + JAVA_24, // + OTHER // + }) void disabledOnAllJavaVersions() { fail("should be disabled"); } @@ -163,12 +186,22 @@ void java22() { assertFalse(onJava22()); } + @Test + @DisabledOnJre(JAVA_23) + void java23() { + assertFalse(onJava23()); + } + + @Test + @DisabledOnJre(JAVA_24) + void java24() { + assertFalse(onJava24()); + } + @Test @DisabledOnJre(OTHER) void other() { - assertTrue( - onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() - || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22()); + assertTrue(onKnownVersion()); } } 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 e274641a12b6..24a4ad76c849 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 @@ -11,21 +11,21 @@ package org.junit.jupiter.api.condition; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava10; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava11; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava12; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava13; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava14; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; -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.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExecutionCondition; 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 7d1deef5f72a..dcaf7d73006b 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 @@ -13,25 +13,25 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava10; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava11; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava12; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava13; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava14; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; -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; import static org.junit.jupiter.api.condition.JRE.JAVA_18; import static org.junit.jupiter.api.condition.JRE.JAVA_19; import static org.junit.jupiter.api.condition.JRE.OTHER; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; 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 ea6ae7b72a75..483dab693e9b 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 @@ -12,21 +12,24 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava10; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava11; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava12; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava13; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava14; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; -import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; -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.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava23; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava24; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onKnownVersion; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExecutionCondition; @@ -215,15 +218,31 @@ void java22() { assertEnabledOnCurrentJreIf(onJava22()); } + /** + * @see EnabledOnJreIntegrationTests#java23() + */ + @Test + void java23() { + evaluateCondition(); + assertEnabledOnCurrentJreIf(onJava23()); + } + + /** + * @see EnabledOnJreIntegrationTests#java24() + */ + @Test + void java24() { + evaluateCondition(); + assertEnabledOnCurrentJreIf(onJava24()); + } + /** * @see EnabledOnJreIntegrationTests#other() */ @Test void other() { evaluateCondition(); - assertEnabledOnCurrentJreIf( - !(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() - || onJava16() || onJava17() || onJava18() || onJava19() || onJava20() || onJava21() || onJava22())); + assertEnabledOnCurrentJreIf(!onKnownVersion()); 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 d56c60b7325d..d30a8f970551 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 @@ -25,9 +25,29 @@ 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_23; +import static org.junit.jupiter.api.condition.JRE.JAVA_24; 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; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava10; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava11; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava12; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava13; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava14; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava15; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava16; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava17; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava18; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava19; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava20; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava21; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava22; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava23; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava24; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava8; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onJava9; +import static org.junit.jupiter.api.condition.JavaVersionPredicates.onKnownVersion; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -39,8 +59,6 @@ */ class EnabledOnJreIntegrationTests { - private static final String JAVA_VERSION = System.getProperty("java.version"); - @Test @Disabled("Only used in a unit test via reflection") void enabledBecauseAnnotationIsNotPresent() { @@ -53,8 +71,26 @@ 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, JAVA_22, OTHER }) + @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, // + JAVA_22, // + JAVA_23, // + JAVA_24, // + OTHER // + }) void enabledOnAllJavaVersions() { } @@ -149,71 +185,21 @@ void java22() { } @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() || onJava22()); - } - - static boolean onJava8() { - return JAVA_VERSION.startsWith("1.8"); - } - - static boolean onJava9() { - return JAVA_VERSION.startsWith("9"); - } - - static boolean onJava10() { - return JAVA_VERSION.startsWith("10"); - } - - static boolean onJava11() { - return JAVA_VERSION.startsWith("11"); - } - - static boolean onJava12() { - return JAVA_VERSION.startsWith("12"); - } - - static boolean onJava13() { - return JAVA_VERSION.startsWith("13"); - } - - static boolean onJava14() { - return JAVA_VERSION.startsWith("14"); + @EnabledOnJre(JAVA_23) + void java23() { + assertTrue(onJava23()); } - static boolean onJava15() { - return JAVA_VERSION.startsWith("15"); - } - - static boolean onJava16() { - return JAVA_VERSION.startsWith("16"); - } - - static boolean onJava17() { - return JAVA_VERSION.startsWith("17"); - } - - static boolean onJava18() { - return JAVA_VERSION.startsWith("18"); - } - - static boolean onJava19() { - return JAVA_VERSION.startsWith("19"); - } - - static boolean onJava20() { - return JAVA_VERSION.startsWith("20"); - } - - static boolean onJava21() { - return JAVA_VERSION.startsWith("21"); + @Test + @EnabledOnJre(JAVA_24) + void java24() { + assertTrue(onJava24()); } - static boolean onJava22() { - return JAVA_VERSION.startsWith("22"); + @Test + @EnabledOnJre(value = OTHER, disabledReason = "Disabled on almost every JRE") + void other() { + assertFalse(onKnownVersion()); } }