LANG-1384: Version "11" is available.

This commit is contained in:
Gilles Sadowski 2018-03-08 13:54:31 +01:00
parent cb686673a7
commit 50ce8c44e1
4 changed files with 40 additions and 1 deletions

View File

@ -94,6 +94,13 @@ public enum JavaVersion {
*/
JAVA_10(10.0f, "10"),
/**
* Java 11
*
* @since 3.8
*/
JAVA_11(11.0f, "11"),
/**
* The most recent java version. Mainly introduced to avoid to break when a new version of Java is used.
*/
@ -180,6 +187,8 @@ public enum JavaVersion {
return JAVA_9;
} else if ("10".equals(nom)) {
return JAVA_10;
} else if ("11".equals(nom)) {
return JAVA_11;
}
if (nom == null) {
return null;

View File

@ -985,6 +985,18 @@ public class SystemUtils {
*/
public static final boolean IS_JAVA_10 = getJavaVersionMatches("10");
/**
* <p>
* Is {@code true} if this is Java version 11 (also 11.x versions).
* </p>
* <p>
* The field will return {@code false} if {@link #JAVA_VERSION} is {@code null}.
* </p>
*
* @since 3.8
*/
public static final boolean IS_JAVA_11 = getJavaVersionMatches("11");
// Operating system checks
// -----------------------------------------------------------------------
// These MUST be declared after those above as they depend on the

View File

@ -56,10 +56,11 @@ public class JavaVersionTest {
assertEquals("1.8 failed", JAVA_1_8, get("1.8"));
assertEquals("9 failed", JAVA_9, get("9"));
assertEquals("10 failed", JAVA_10, get("10"));
assertEquals("11 failed", JavaVersion.JAVA_11, get("11"));
assertEquals("1.10 failed", JAVA_RECENT, get("1.10"));
// assertNull("2.10 unexpectedly worked", get("2.10"));
assertEquals("Wrapper method failed", get("1.5"), getJavaVersion("1.5"));
assertEquals("Unhandled", JAVA_RECENT, get("11")); // LANG-1384
assertEquals("Unhandled", JAVA_RECENT, get("12")); // LANG-1384
}
@Test

View File

@ -29,6 +29,7 @@ import static org.apache.commons.lang3.JavaVersion.JAVA_1_7;
import static org.apache.commons.lang3.JavaVersion.JAVA_1_8;
import static org.apache.commons.lang3.JavaVersion.JAVA_9;
import static org.apache.commons.lang3.JavaVersion.JAVA_10;
import static org.apache.commons.lang3.JavaVersion.JAVA_11;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -408,6 +409,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_10));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_11));
} else if (SystemUtils.IS_JAVA_1_8) {
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
@ -419,6 +421,7 @@ public class SystemUtilsTest {
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_10));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_11));
} else if (SystemUtils.IS_JAVA_9) {
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
@ -430,6 +433,7 @@ public class SystemUtilsTest {
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_9));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_10));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_11));
} else if (SystemUtils.IS_JAVA_10) {
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
@ -441,6 +445,19 @@ public class SystemUtilsTest {
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_9));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_10));
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_11));
} else if (SystemUtils.IS_JAVA_11) {
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_3));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_4));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_5));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_6));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_7));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_9));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_10));
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_11));
}
}