Add test for SystemUtils.isJavaVersionAtLeast to make sure it works with Java 9 EA
This commit is contained in:
parent
10d2363fcd
commit
5f4249e2ec
|
@ -19,7 +19,15 @@
|
||||||
|
|
||||||
package org.apache.commons.lang3;
|
package org.apache.commons.lang3;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.JavaVersion.JAVA_1_1;
|
||||||
|
import static org.apache.commons.lang3.JavaVersion.JAVA_1_2;
|
||||||
|
import static org.apache.commons.lang3.JavaVersion.JAVA_1_3;
|
||||||
import static org.apache.commons.lang3.JavaVersion.JAVA_1_4;
|
import static org.apache.commons.lang3.JavaVersion.JAVA_1_4;
|
||||||
|
import static org.apache.commons.lang3.JavaVersion.JAVA_1_5;
|
||||||
|
import static org.apache.commons.lang3.JavaVersion.JAVA_1_6;
|
||||||
|
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.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -431,6 +439,101 @@ public class SystemUtilsTest {
|
||||||
assertTrue(SystemUtils.isJavaVersionMatch(javaVersion, "9"));
|
assertTrue(SystemUtils.isJavaVersionMatch(javaVersion, "9"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsJavaVersionAtLeat() throws Exception {
|
||||||
|
if (SystemUtils.IS_JAVA_1_1) {
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_3));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_4));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_5));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_6));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_7));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_1_2) {
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_3));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_4));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_5));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_6));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_7));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_1_3) {
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_3));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_4));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_5));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_6));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_7));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_1_4) {
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_1));
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_2));
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_3));
|
||||||
|
assertTrue(SystemUtils.isJavaVersionAtLeast(JAVA_1_4));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_5));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_6));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_7));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_1_5) {
|
||||||
|
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));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_6));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_7));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_1_6) {
|
||||||
|
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));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_7));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_1_7) {
|
||||||
|
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));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_1_8));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_1_8) {
|
||||||
|
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));
|
||||||
|
assertFalse(SystemUtils.isJavaVersionAtLeast(JAVA_9));
|
||||||
|
} else if (SystemUtils.IS_JAVA_9) {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOSMatchesName() {
|
public void testOSMatchesName() {
|
||||||
String osName = null;
|
String osName = null;
|
||||||
|
|
Loading…
Reference in New Issue