Add checks for JDK1.6

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@389912 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2006-03-29 22:27:48 +00:00
parent d7db8448a1
commit 756cdad67c
2 changed files with 46 additions and 5 deletions

View File

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

View File

@ -245,16 +245,49 @@ public class SystemUtilsTest extends TestCase {
assertEquals(false, SystemUtils.IS_JAVA_1_3);
assertEquals(false, SystemUtils.IS_JAVA_1_4);
assertEquals(false, SystemUtils.IS_JAVA_1_5);
assertEquals(false, SystemUtils.IS_JAVA_1_6);
} else if (javaVersion.startsWith("1.1")) {
assertTrue(SystemUtils.IS_JAVA_1_1);
assertEquals(true, SystemUtils.IS_JAVA_1_1);
assertEquals(false, SystemUtils.IS_JAVA_1_2);
assertEquals(false, SystemUtils.IS_JAVA_1_3);
assertEquals(false, SystemUtils.IS_JAVA_1_4);
assertEquals(false, SystemUtils.IS_JAVA_1_5);
assertEquals(false, SystemUtils.IS_JAVA_1_6);
} else if (javaVersion.startsWith("1.2")) {
assertTrue(SystemUtils.IS_JAVA_1_2);
assertEquals(false, SystemUtils.IS_JAVA_1_1);
assertEquals(true, SystemUtils.IS_JAVA_1_2);
assertEquals(false, SystemUtils.IS_JAVA_1_3);
assertEquals(false, SystemUtils.IS_JAVA_1_4);
assertEquals(false, SystemUtils.IS_JAVA_1_5);
assertEquals(false, SystemUtils.IS_JAVA_1_6);
} else if (javaVersion.startsWith("1.3")) {
assertTrue(SystemUtils.IS_JAVA_1_3);
assertEquals(false, SystemUtils.IS_JAVA_1_1);
assertEquals(false, SystemUtils.IS_JAVA_1_2);
assertEquals(true, SystemUtils.IS_JAVA_1_3);
assertEquals(false, SystemUtils.IS_JAVA_1_4);
assertEquals(false, SystemUtils.IS_JAVA_1_5);
assertEquals(false, SystemUtils.IS_JAVA_1_6);
} else if (javaVersion.startsWith("1.4")) {
assertTrue(SystemUtils.IS_JAVA_1_4);
assertEquals(false, SystemUtils.IS_JAVA_1_1);
assertEquals(false, SystemUtils.IS_JAVA_1_2);
assertEquals(false, SystemUtils.IS_JAVA_1_3);
assertEquals(true, SystemUtils.IS_JAVA_1_4);
assertEquals(false, SystemUtils.IS_JAVA_1_5);
assertEquals(false, SystemUtils.IS_JAVA_1_6);
} else if (javaVersion.startsWith("1.5")) {
assertTrue(SystemUtils.IS_JAVA_1_5);
assertEquals(false, SystemUtils.IS_JAVA_1_1);
assertEquals(false, SystemUtils.IS_JAVA_1_2);
assertEquals(false, SystemUtils.IS_JAVA_1_3);
assertEquals(false, SystemUtils.IS_JAVA_1_4);
assertEquals(true, SystemUtils.IS_JAVA_1_5);
assertEquals(false, SystemUtils.IS_JAVA_1_6);
} else if (javaVersion.startsWith("1.6")) {
assertEquals(false, SystemUtils.IS_JAVA_1_1);
assertEquals(false, SystemUtils.IS_JAVA_1_2);
assertEquals(false, SystemUtils.IS_JAVA_1_3);
assertEquals(false, SystemUtils.IS_JAVA_1_4);
assertEquals(false, SystemUtils.IS_JAVA_1_5);
assertEquals(true, SystemUtils.IS_JAVA_1_6);
} else {
System.out.println("Can't test IS_JAVA value");
}