Browse Source

Make the tests runnable on systems without regexp matchers (e.g. JDK 1.2 without ORO).

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@489089 13f79535-47bb-0310-9956-ffa450edef68
master
Jan Materne 18 years ago
parent
commit
399a8a6d55
2 changed files with 30 additions and 6 deletions
  1. +16
    -0
      src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
  2. +14
    -6
      src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java

+ 16
- 0
src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java View File

@@ -133,4 +133,20 @@ public class RegexpMatcherFactory {
throw new BuildException(t);
}
}

/**
* Checks if a RegExp-Matcher is available.
* @param project The project to check for (may be <code>null</code>)
* @return <code>true</code> if available otherwise <code>false</code>
*/
public static boolean regexpMatcherPresent(Project project) {
try {
// The factory throws a BuildException if no usable matcher
// cant be instantiated. We dont need the matcher itself here.
(new RegexpMatcherFactory()).newRegexpMatcher(project);
return true;
} catch (Throwable ex) {
return false;
}
}
}

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

@@ -18,9 +18,12 @@
package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileTest;
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.util.regexp.RegexpMatcher;
import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;

/**
* Tests &lt;bm:manifestclasspath&gt;.
@@ -97,8 +100,11 @@ public class ManifestClassPathTest
}

public void testPseudoTahoeRefid() {
if (!RegexpMatcherFactory.regexpMatcherPresent(project)) {
System.out.println("Test 'testPseudoTahoeRefid' skipped because no regexp matcher is present.");
return;
}
executeTarget("test-pseudo-tahoe-refid");

assertPropertyEquals("jar.classpath", "classes/dsp-core/ " +
"classes/dsp-pres/ " +
"classes/dsp-void/ " +
@@ -108,8 +114,11 @@ public class ManifestClassPathTest
}

public void testPseudoTahoeNested() {
if (!RegexpMatcherFactory.regexpMatcherPresent(project)) {
System.out.println("Test 'testPseudoTahoeNested' skipped because no regexp matcher is present.");
return;
}
executeTarget("test-pseudo-tahoe-nested");

assertPropertyEquals("jar.classpath", "classes/dsp-core/ " +
"classes/dsp-pres/ " +
"classes/dsp-void/ " +
@@ -134,8 +143,7 @@ public class ManifestClassPathTest
"../../resources/dsp-void/");
}
public void testInternationalGerman() {
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4))
{
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
System.out.println("Test with international characters skipped under pre 1.4 jvm.");
return;
}
@@ -144,7 +152,7 @@ public class ManifestClassPathTest
}
public void testInternationalHebrew() {
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
System.out.println("Test with international characters skipped under pre 1.4 jvm.");
return;
}


Loading…
Cancel
Save