Browse Source

-env util to get an ordered version number,

-test of tsa only runs on java1.5+


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278051 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 20 years ago
parent
commit
7229e5923e
2 changed files with 19 additions and 4 deletions
  1. +12
    -1
      src/main/org/apache/tools/ant/util/JavaEnvUtils.java
  2. +7
    -3
      src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java

+ 12
- 1
src/main/org/apache/tools/ant/util/JavaEnvUtils.java View File

@@ -123,6 +123,17 @@ public final class JavaEnvUtils {
return javaVersion;
}


/**
* Returns the version of Java this class is running under.
* This number can be used for comparisions; it will always be
* @return the version of Java as a number 10x the major/minor,
* e.g Java1.5 has a value of 15
*/
public static int getJavaVersionNumber() {
return javaVersionNumber;
}

/**
* Compares the current Java version to the passed in String -
* assumes the argument is one of the constants defined in this
@@ -139,7 +150,7 @@ public final class JavaEnvUtils {
* Checks whether the current Java VM is Kaffe.
* @return true if the current Java VM is Kaffe.
* @since Ant 1.6.3
* @see http://www.kaffe.org/
* @see <a href="http://www.kaffe.org/">http://www.kaffe.org/</a>
*/
public static boolean isKaffe() {
return kaffeDetected;


+ 7
- 3
src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java View File

@@ -25,6 +25,7 @@ import java.util.Vector;
import java.util.Enumeration;
import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.JavaEnvUtils;

/**
* Testcase for the Signjar task
@@ -148,8 +149,11 @@ public class SignJarTest extends BuildFileTest {
}

public void testTsaLocalhost() {
expectBuildException("testTsaLocalhost",
"no TSA at localhost:0");
assertLogContaining("java.net.ConnectException");
//only test on java1.5+
if(JavaEnvUtils.getJavaVersionNumber()>=15) {
expectBuildException("testTsaLocalhost",
"no TSA at localhost:0");
assertLogContaining("java.net.ConnectException");
}
}
}

Loading…
Cancel
Save