Browse Source

added at least check to JavaEnvUtils (and make use of it)

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@476230 13f79535-47bb-0310-9956-ffa450edef68
master
Jacobus Martinus Kruithof 18 years ago
parent
commit
fba52dd8fa
3 changed files with 28 additions and 3 deletions
  1. +15
    -0
      src/main/org/apache/tools/ant/util/JavaEnvUtils.java
  2. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
  3. +10
    -0
      src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java

+ 15
- 0
src/main/org/apache/tools/ant/util/JavaEnvUtils.java View File

@@ -154,6 +154,21 @@ public final class JavaEnvUtils {
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.
* @return true if the current Java VM is Kaffe.


+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java View File

@@ -19,6 +19,7 @@ package org.apache.tools.ant.taskdefs;
import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.BuildFileTest;
/**
@@ -133,7 +134,7 @@ public class ManifestClassPathTest
"../../resources/dsp-void/");
}
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.");
return;
@@ -143,8 +144,7 @@ public class ManifestClassPathTest
}
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.");
return;
}


+ 10
- 0
src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java View File

@@ -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"));
}

}

Loading…
Cancel
Save