ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r476230 - in /ant/core/trunk/src: main/org/apache/tools/ant/util/JavaEnvUtils.java tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java
Date Fri, 17 Nov 2006 17:55:30 GMT
Author: jkf
Date: Fri Nov 17 09:55:30 2006
New Revision: 476230

URL: http://svn.apache.org/viewvc?view=rev&rev=476230
Log:
added at least check to JavaEnvUtils (and make use of it)

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java?view=diff&rev=476230&r1=476229&r2=476230
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java Fri Nov 17 09:55:30
2006
@@ -155,6 +155,21 @@
     }
 
     /**
+     * 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.
      * @since Ant 1.6.3

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java?view=diff&rev=476230&r1=476229&r2=476230
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
Fri Nov 17 09:55:30 2006
@@ -19,6 +19,7 @@
 
 
 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 @@
                                               "../../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 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;
         }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java?view=diff&rev=476230&r1=476229&r2=476230
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java Fri Nov
17 09:55:30 2006
@@ -127,4 +127,14 @@
 
     }
 
+    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"));
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message