git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@476230 13f79535-47bb-0310-9956-ffa450edef68master
@@ -154,6 +154,21 @@ public final class JavaEnvUtils { | |||||
return javaVersion.equals(version); | return javaVersion.equals(version); | ||||
} | } | ||||
/** | |||||
* Compares the current Java version to the passed in String - | |||||
* assumes the argument is one of the constants defined in this | |||||
* class. | |||||
* Note that Ant now requires JDK 1.2+ so {@link #JAVA_1_0} and | |||||
* {@link #JAVA_1_1} need no longer be tested for. | |||||
* @param version the version to check against the current version. | |||||
* @return true if the version of Java is the same or higher than the | |||||
* given version. | |||||
* @since Ant 1.7 | |||||
*/ | |||||
public static boolean isAtLeastJavaVersion(String version) { | |||||
return javaVersion.compareTo(version) >= 0; | |||||
} | |||||
/** | /** | ||||
* Checks whether the current Java VM is Kaffe. | * Checks whether the current Java VM is Kaffe. | ||||
* @return true if the current Java VM is Kaffe. | * @return true if the current Java VM is Kaffe. | ||||
@@ -19,6 +19,7 @@ package org.apache.tools.ant.taskdefs; | |||||
import org.apache.tools.ant.taskdefs.condition.Os; | import org.apache.tools.ant.taskdefs.condition.Os; | ||||
import org.apache.tools.ant.util.JavaEnvUtils; | |||||
import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
/** | /** | ||||
@@ -133,7 +134,7 @@ public class ManifestClassPathTest | |||||
"../../resources/dsp-void/"); | "../../resources/dsp-void/"); | ||||
} | } | ||||
public void testInternationalGerman() { | public void testInternationalGerman() { | ||||
if (System.getProperty("java.vm.version").compareTo("1.4") < 0) | |||||
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) | |||||
{ | { | ||||
System.out.println("Test with international characters skipped under pre 1.4 jvm."); | System.out.println("Test with international characters skipped under pre 1.4 jvm."); | ||||
return; | return; | ||||
@@ -143,8 +144,7 @@ public class ManifestClassPathTest | |||||
} | } | ||||
public void testInternationalHebrew() { | public void testInternationalHebrew() { | ||||
if (System.getProperty("java.vm.version").compareTo("1.4") < 0) | |||||
{ | |||||
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) { | |||||
System.out.println("Test with international characters skipped under pre 1.4 jvm."); | System.out.println("Test with international characters skipped under pre 1.4 jvm."); | ||||
return; | return; | ||||
} | } | ||||
@@ -127,4 +127,14 @@ public class JavaEnvUtilsTest extends TestCase { | |||||
} | } | ||||
public void testIsAtLeastJavaVersion() | |||||
{ | |||||
assertTrue( | |||||
"Current java version is not at least the current java version...", | |||||
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.getJavaVersion())); | |||||
assertFalse( | |||||
"In case the current java version is higher than 9.0 definitely a new algorithem will be needed", | |||||
JavaEnvUtils.isAtLeastJavaVersion("9.0")); | |||||
} | |||||
} | } |