Skip to content

Commit

Permalink
Add JRE.JAVA_18 constant
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Sep 14, 2021
1 parent a295157 commit c02f030
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GitHub.

==== New Features and Improvements

*
* `JAVA_18` has been added to the `JRE` enum for use with JRE-based execution conditions.


[[release-notes-5.8.1-junit-vintage]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,19 @@ public enum JRE {
@API(status = STABLE, since = "5.7.1")
JAVA_17,

/**
* Java 18.
*
* @since 5.8.1
*/
@API(status = STABLE, since = "5.8.1")
JAVA_18,

/**
* 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}, or {@link #JAVA_17}.
* {@link #JAVA_16}, {@link #JAVA_17}, or {@link #JAVA_18}.
*/
OTHER;

Expand Down Expand Up @@ -166,6 +174,8 @@ private static JRE determineCurrentVersion() {
return JAVA_16;
case 17:
return JAVA_17;
case 18:
return JAVA_18;
default:
return OTHER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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.onJava8;
import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9;

Expand Down Expand Up @@ -119,7 +120,7 @@ void javaMin10() {
void other() {
evaluateCondition();
assertDisabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13()
|| onJava14() || onJava15() || onJava16() || onJava17()));
|| onJava14() || onJava15() || onJava16() || onJava17() || onJava18()));
}

private void assertDisabledOnCurrentJreIf(boolean condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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.onJava8;
import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9;
import static org.junit.jupiter.api.condition.JRE.JAVA_10;
Expand Down Expand Up @@ -86,7 +87,7 @@ void javaMin10() {
@DisabledForJreRange(min = OTHER, max = OTHER)
void other() {
assertTrue(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14()
|| onJava15() || onJava16() || onJava17());
|| onJava15() || onJava16() || onJava17() || onJava18());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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.onJava8;
import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9;

Expand Down Expand Up @@ -166,14 +167,23 @@ void java17() {
assertDisabledOnCurrentJreIf(onJava17());
}

/**
* @see DisabledOnJreIntegrationTests#java18()
*/
@Test
void java18() {
evaluateCondition();
assertDisabledOnCurrentJreIf(onJava18());
}

/**
* @see DisabledOnJreIntegrationTests#other()
*/
@Test
void other() {
evaluateCondition();
assertDisabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13()
|| onJava14() || onJava15() || onJava16() || onJava17()));
|| onJava14() || onJava15() || onJava16() || onJava17() || onJava18()));
}

private void assertDisabledOnCurrentJreIf(boolean condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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.onJava8;
import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9;
import static org.junit.jupiter.api.condition.JRE.JAVA_10;
Expand All @@ -31,6 +32,7 @@
import static org.junit.jupiter.api.condition.JRE.JAVA_15;
import static org.junit.jupiter.api.condition.JRE.JAVA_16;
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_8;
import static org.junit.jupiter.api.condition.JRE.JAVA_9;
import static org.junit.jupiter.api.condition.JRE.OTHER;
Expand Down Expand Up @@ -58,7 +60,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,
OTHER }, disabledReason = "Disabled on every JRE")
JAVA_18, OTHER }, disabledReason = "Disabled on every JRE")
void disabledOnAllJavaVersions() {
fail("should be disabled");
}
Expand Down Expand Up @@ -123,11 +125,17 @@ void java17() {
assertFalse(onJava17());
}

@Test
@DisabledOnJre(JAVA_18)
void java18() {
assertFalse(onJava18());
}

@Test
@DisabledOnJre(OTHER)
void other() {
assertTrue(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14()
|| onJava15() || onJava16() || onJava17());
|| onJava15() || onJava16() || onJava17() || onJava18());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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.onJava8;
import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9;

Expand Down Expand Up @@ -119,7 +120,7 @@ void javaMin10() {
void other() {
evaluateCondition();
assertEnabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13()
|| onJava14() || onJava15() || onJava16() || onJava17()));
|| onJava14() || onJava15() || onJava16() || onJava17() || onJava18()));
}

private void assertEnabledOnCurrentJreIf(boolean condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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.onJava8;
import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9;
import static org.junit.jupiter.api.condition.JRE.JAVA_10;
Expand Down Expand Up @@ -83,15 +84,15 @@ void javaMax12() {
@EnabledForJreRange(min = JAVA_10)
void javaMin10() {
assertTrue(onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() || onJava16()
|| onJava17());
|| onJava17() || onJava18());
assertFalse(onJava9());
}

@Test
@EnabledForJreRange(min = OTHER, max = OTHER)
void other() {
assertFalse(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14()
|| onJava15() || onJava16() || onJava17());
|| onJava15() || onJava16() || onJava17() || onJava18());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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.onJava8;
import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9;

Expand Down Expand Up @@ -165,14 +166,23 @@ void java17() {
assertEnabledOnCurrentJreIf(onJava17());
}

/**
* @see EnabledOnJreIntegrationTests#java18()
*/
@Test
void java18() {
evaluateCondition();
assertEnabledOnCurrentJreIf(onJava18());
}

/**
* @see EnabledOnJreIntegrationTests#other()
*/
@Test
void other() {
evaluateCondition();
assertEnabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13()
|| onJava14() || onJava15() || onJava16() || onJava17()));
|| onJava14() || onJava15() || onJava16() || onJava17() || onJava18()));
assertCustomDisabledReasonIs("Disabled on almost every JRE");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.jupiter.api.condition.JRE.JAVA_15;
import static org.junit.jupiter.api.condition.JRE.JAVA_16;
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_8;
import static org.junit.jupiter.api.condition.JRE.JAVA_9;
import static org.junit.jupiter.api.condition.JRE.OTHER;
Expand Down Expand Up @@ -48,7 +49,8 @@ void missingJreDeclaration() {
}

@Test
@EnabledOnJre({ JAVA_8, JAVA_9, JAVA_10, JAVA_11, JAVA_12, JAVA_13, JAVA_14, JAVA_15, JAVA_16, JAVA_17, OTHER })
@EnabledOnJre({ JAVA_8, JAVA_9, JAVA_10, JAVA_11, JAVA_12, JAVA_13, JAVA_14, JAVA_15, JAVA_16, JAVA_17, JAVA_18,
OTHER })
void enabledOnAllJavaVersions() {
}

Expand Down Expand Up @@ -112,11 +114,17 @@ void java17() {
assertTrue(onJava17());
}

@Test
@EnabledOnJre(JAVA_18)
void java18() {
assertTrue(onJava18());
}

@Test
@EnabledOnJre(value = OTHER, disabledReason = "Disabled on almost every JRE")
void other() {
assertFalse(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14()
|| onJava15() || onJava16() || onJava17());
|| onJava15() || onJava16() || onJava17() || onJava18());
}

static boolean onJava8() {
Expand Down Expand Up @@ -159,4 +167,8 @@ static boolean onJava17() {
return JAVA_VERSION.startsWith("17");
}

static boolean onJava18() {
return JAVA_VERSION.startsWith("18");
}

}

0 comments on commit c02f030

Please sign in to comment.