git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277219 13f79535-47bb-0310-9956-ffa450edef68master
@@ -574,7 +574,7 @@ public class Path extends DataType implements Cloneable { | |||
* Add the Java Runtime classes to this Path instance. | |||
*/ | |||
public void addJavaRuntime() { | |||
if ("Kaffe".equals(System.getProperty("java.vm.name"))) { | |||
if (JavaEnvUtils.isKaffe()) { | |||
// newer versions of Kaffe (1.1.1+) won't have this, | |||
// but this will be sorted by FileSet anyway. | |||
File kaffeShare = new File(System.getProperty("java.home") | |||
@@ -67,6 +67,9 @@ public class JavaEnvUtils { | |||
/** Version constant for Java 1.5 */ | |||
public static final String JAVA_1_5 = "1.5"; | |||
/** Whether this is the Kaffe VM */ | |||
private static boolean kaffeDetected; | |||
/** array of packages in the runtime */ | |||
private static Vector jrePackages; | |||
@@ -103,6 +106,13 @@ public class JavaEnvUtils { | |||
// swallow as we've hit the max class version that | |||
// we have | |||
} | |||
kaffeDetected = false; | |||
try { | |||
Class.forName("kaffe.util.NotImplemented"); | |||
kaffeDetected = true; | |||
} catch (Throwable t) { | |||
// swallow as this simply doesn't seem to be Kaffe | |||
} | |||
} | |||
/** | |||
@@ -125,6 +135,16 @@ public class JavaEnvUtils { | |||
return javaVersion.equals(version); | |||
} | |||
/** | |||
* 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/ | |||
*/ | |||
public static boolean isKaffe() { | |||
return kaffeDetected; | |||
} | |||
/** | |||
* Finds an executable that is part of a JRE installation based on | |||
* the java.home system property. | |||
@@ -142,7 +142,7 @@ public class ConcatFilterTest extends BuildFileTest { | |||
try { | |||
File file = getProject().resolveFile(filename); | |||
java.io.FileReader rdr = new java.io.FileReader(file); | |||
content = fu.readFully(rdr); | |||
content = FileUtils.readFully(rdr); | |||
rdr.close(); | |||
rdr = null; | |||
} catch (Exception e) { | |||
@@ -68,7 +68,7 @@ public class DynamicFilterTest extends BuildFileTest { | |||
Reader r = null; | |||
try { | |||
r = new FileReader(getProject().resolveFile(filename)); | |||
return FileUtils.newFileUtils().readFully(r); | |||
return FileUtils.readFully(r); | |||
} | |||
finally { | |||
try {r.close();} catch (Throwable ignore) {} | |||
@@ -248,7 +248,7 @@ public class TokenFilterTest extends BuildFileTest { | |||
Reader r = null; | |||
try { | |||
r = new FileReader(getProject().resolveFile(filename)); | |||
return FileUtils.newFileUtils().readFully(r); | |||
return FileUtils.readFully(r); | |||
} | |||
finally { | |||
try {r.close();} catch (Throwable ignore) {} | |||
@@ -27,11 +27,11 @@ import org.apache.tools.ant.BuildFileTest; | |||
*/ | |||
public class CVSPassTest extends BuildFileTest { | |||
private final String EOL = System.getProperty("line.separator"); | |||
private final String JAKARTA_URL = | |||
private static final String JAKARTA_URL = | |||
":pserver:anoncvs@jakarta.apache.org:/home/cvspublic Ay=0=h<Z"; | |||
private final String XML_URL = | |||
private static final String XML_URL = | |||
":pserver:anoncvs@xml.apache.org:/home/cvspublic Ay=0=h<Z"; | |||
private final String TIGRIS_URL = | |||
private static final String TIGRIS_URL = | |||
":pserver:guest@cvs.tigris.org:/cvs AIbdZ,"; | |||
@@ -240,7 +240,7 @@ public class ConcatTest | |||
Reader r = null; | |||
try { | |||
r = new FileReader(getProject().resolveFile(filename)); | |||
return FileUtils.newFileUtils().readFully(r); | |||
return FileUtils.readFully(r); | |||
} | |||
finally { | |||
try {r.close();} catch (Throwable ignore) {} | |||
@@ -34,10 +34,10 @@ import junit.framework.ComparisonFailure; | |||
public class ExecTaskTest extends BuildFileTest { | |||
private static final String BUILD_PATH = "src/etc/testcases/taskdefs/exec/"; | |||
private static final String BUILD_FILE = BUILD_PATH + "exec.xml"; | |||
private final int TIME_TO_WAIT = 1; | |||
private static final int TIME_TO_WAIT = 1; | |||
/** maximum time allowed for the build in milliseconds */ | |||
private final int MAX_BUILD_TIME = 4000; | |||
private final int SECURITY_MARGIN = 2000; // wait 2 second extras | |||
private static final int MAX_BUILD_TIME = 4000; | |||
private static final int SECURITY_MARGIN = 2000; // wait 2 second extras | |||
// the test failed with 100 ms of margin on cvs.apache.org on August 1st, 2003 | |||
private File logFile; | |||
private MonitoredBuild myBuild = null; | |||
@@ -465,7 +465,7 @@ public class ExecTaskTest extends BuildFileTest { | |||
FileReader reader = null; | |||
try { | |||
reader = new FileReader(getProject().resolveFile(filename)); | |||
result = FileUtils.newFileUtils().readFully(reader); | |||
result = FileUtils.readFully(reader); | |||
} catch (IOException eyeOhEx) { | |||
} finally { | |||
if (reader != null) { | |||
@@ -564,7 +564,7 @@ public class ExecuteOnTest extends BuildFileTest { | |||
FileReader reader = null; | |||
try { | |||
reader = new FileReader(getProject().resolveFile(filename)); | |||
result = FileUtils.newFileUtils().readFully(reader); | |||
result = FileUtils.readFully(reader); | |||
} finally { | |||
if (reader != null) { | |||
try { | |||
@@ -191,8 +191,8 @@ public class ManifestTest extends BuildFileTest { | |||
* Tets long line wrapping | |||
*/ | |||
public void testLongLine() throws IOException, ManifestException { | |||
Project project = getProject(); | |||
project.setUserProperty("test.longline", LONG_LINE); | |||
Project p = getProject(); | |||
p.setUserProperty("test.longline", LONG_LINE); | |||
executeTarget("testLongLine"); | |||
Manifest manifest = getManifest(EXPANDED_MANIFEST); | |||
@@ -58,9 +58,9 @@ public class ParallelTest extends BuildFileTest { | |||
/** tests basic operation of the parallel task */ | |||
public void testBasic() { | |||
// should get no output at all | |||
Project project = getProject(); | |||
project.setUserProperty("test.direct", DIRECT_MESSAGE); | |||
project.setUserProperty("test.delayed", DELAYED_MESSAGE); | |||
Project p = getProject(); | |||
p.setUserProperty("test.direct", DIRECT_MESSAGE); | |||
p.setUserProperty("test.delayed", DELAYED_MESSAGE); | |||
expectOutputAndError("testBasic", "", ""); | |||
String log = getLog(); | |||
assertEquals("parallel tasks didn't output correct data", log, | |||
@@ -71,9 +71,9 @@ public class ParallelTest extends BuildFileTest { | |||
/** tests basic operation of the parallel task */ | |||
public void testThreadCount() { | |||
// should get no output at all | |||
Project project = getProject(); | |||
project.setUserProperty("test.direct", DIRECT_MESSAGE); | |||
project.setUserProperty("test.delayed", DELAYED_MESSAGE); | |||
Project p = getProject(); | |||
p.setUserProperty("test.direct", DIRECT_MESSAGE); | |||
p.setUserProperty("test.delayed", DELAYED_MESSAGE); | |||
expectOutputAndError("testThreadCount", "", ""); | |||
String log = getLog(); | |||
int pos = 0; | |||
@@ -126,24 +126,24 @@ public class ParallelTest extends BuildFileTest { | |||
/** tests the failure of a task within a parallel construction */ | |||
public void testFail() { | |||
// should get no output at all | |||
Project project = getProject(); | |||
project.setUserProperty("test.failure", FAILURE_MESSAGE); | |||
project.setUserProperty("test.delayed", DELAYED_MESSAGE); | |||
Project p = getProject(); | |||
p.setUserProperty("test.failure", FAILURE_MESSAGE); | |||
p.setUserProperty("test.delayed", DELAYED_MESSAGE); | |||
expectBuildExceptionContaining("testFail", | |||
"fail task in one parallel branch", FAILURE_MESSAGE); | |||
} | |||
/** tests the demuxing of output streams in a multithreaded situation */ | |||
public void testDemux() { | |||
Project project = getProject(); | |||
project.addTaskDefinition("demuxtest", DemuxOutputTask.class); | |||
Project p = getProject(); | |||
p.addTaskDefinition("demuxtest", DemuxOutputTask.class); | |||
PrintStream out = System.out; | |||
PrintStream err = System.err; | |||
System.setOut(new PrintStream(new DemuxOutputStream(project, false))); | |||
System.setErr(new PrintStream(new DemuxOutputStream(project, true))); | |||
System.setOut(new PrintStream(new DemuxOutputStream(p, false))); | |||
System.setErr(new PrintStream(new DemuxOutputStream(p, true))); | |||
try { | |||
project.executeTarget("testDemux"); | |||
p.executeTarget("testDemux"); | |||
} finally { | |||
System.setOut(out); | |||
System.setErr(err); | |||
@@ -59,12 +59,12 @@ public class SQLExecTest extends TestCase { | |||
protected void setUp() throws Exception { | |||
// make sure the cache is cleared. | |||
SQLExec.getLoaderMap().clear(); | |||
JDBCTask.getLoaderMap().clear(); | |||
} | |||
// simple test to ensure that the caching does work... | |||
public void testDriverCaching(){ | |||
SQLExec sql = createTask(getProperties(NULL)); | |||
SQLExec sql = createTask(getProperties(NULL)); | |||
assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); | |||
try { | |||
sql.execute(); | |||
@@ -72,20 +72,20 @@ public class SQLExecTest extends TestCase { | |||
assertTrue(e.getException().getMessage().indexOf("No suitable Driver") != -1); | |||
} | |||
assertTrue(SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); | |||
assertSame(sql.getLoader(), SQLExec.getLoaderMap().get(NULL_DRIVER)); | |||
assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER)); | |||
ClassLoader loader1 = sql.getLoader(); | |||
// 2nd run.. | |||
sql = createTask(getProperties(NULL)); | |||
// the driver must still be cached. | |||
assertTrue(sql.getLoaderMap().containsKey(NULL_DRIVER)); | |||
assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); | |||
try { | |||
sql.execute(); | |||
} catch (BuildException e){ | |||
assertTrue(e.getException().getMessage().indexOf("No suitable Driver") != -1); | |||
} | |||
assertTrue(sql.getLoaderMap().containsKey(NULL_DRIVER)); | |||
assertSame(sql.getLoader(), sql.getLoaderMap().get(NULL_DRIVER)); | |||
assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); | |||
assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER)); | |||
assertSame(loader1, sql.getLoader()); | |||
} | |||
@@ -108,7 +108,7 @@ public class StyleTest extends BuildFileTest { | |||
Reader r = null; | |||
try { | |||
r = new FileReader(getProject().resolveFile(filename)); | |||
return FileUtils.newFileUtils().readFully(r); | |||
return FileUtils.readFully(r); | |||
} | |||
finally { | |||
try {r.close();} catch (Throwable ignore) {} | |||
@@ -141,10 +141,10 @@ public class XmlPropertyTest extends BuildFileTest { | |||
// System.out.println(msg + " (" + propertyFile.getName() + ") in (" + workingDir + ")"); | |||
Project project = new Project(); | |||
Project p = new Project(); | |||
XmlProperty xmlproperty = new XmlProperty(); | |||
xmlproperty.setProject(project); | |||
xmlproperty.setProject(p); | |||
xmlproperty.setFile(inputFile); | |||
xmlproperty.setKeeproot(keepRoot); | |||
@@ -156,17 +156,17 @@ public class XmlPropertyTest extends BuildFileTest { | |||
// Set a property on the project to make sure that loading | |||
// a property with the same name from an xml file will | |||
// *not* change it. | |||
project.setNewProperty("override.property.test", "foo"); | |||
p.setNewProperty("override.property.test", "foo"); | |||
xmlproperty.execute(); | |||
Properties props = new Properties(); | |||
props.load(new FileInputStream(propertyFile)); | |||
//printProperties(project.getProperties()); | |||
//printProperties(p.getProperties()); | |||
ensureProperties(msg, inputFile, workingDir, project, props); | |||
ensureReferences(msg, inputFile, project.getReferences()); | |||
ensureProperties(msg, inputFile, workingDir, p, props); | |||
ensureReferences(msg, inputFile, p.getReferences()); | |||
} catch (IOException ex) { | |||
fail(ex.toString()); | |||
@@ -181,9 +181,9 @@ public class XmlPropertyTest extends BuildFileTest { | |||
* to generic Project/Task configuration. | |||
*/ | |||
private static void ensureProperties (String msg, File inputFile, | |||
File workingDir, Project project, | |||
File workingDir, Project p, | |||
Properties properties) { | |||
Hashtable xmlproperties = project.getProperties(); | |||
Hashtable xmlproperties = p.getProperties(); | |||
// Every key identified by the Properties must have been loaded. | |||
Enumeration propertyKeyEnum = properties.propertyNames(); | |||
while(propertyKeyEnum.hasMoreElements()){ | |||
@@ -202,7 +202,7 @@ public class XmlPropertyTest extends BuildFileTest { | |||
// We don't have an adequate way of testing the actual | |||
// *value* of the Path object, though... | |||
String id = currentKey; | |||
Object obj = project.getReferences().get(id); | |||
Object obj = p.getReferences().get(id); | |||
if ( obj == null ) { | |||
fail(assertMsg + " Object ID does not exist."); | |||
@@ -55,7 +55,6 @@ public class DependTest extends BuildFileTest { | |||
* Test direct dependency removal | |||
*/ | |||
public void testDirect() { | |||
Project project = getProject(); | |||
executeTarget("testdirect"); | |||
Hashtable files = getResultFiles(); | |||
assertEquals("Depend did not leave correct number of files", 3, | |||
@@ -70,7 +69,6 @@ public class DependTest extends BuildFileTest { | |||
* Test dependency traversal (closure) | |||
*/ | |||
public void testClosure() { | |||
Project project = getProject(); | |||
executeTarget("testclosure"); | |||
Hashtable files = getResultFiles(); | |||
assertEquals("Depend did not leave correct number of files", 2, | |||
@@ -83,7 +81,6 @@ public class DependTest extends BuildFileTest { | |||
* Test that inner class dependencies trigger deletion of the outer class | |||
*/ | |||
public void testInner() { | |||
Project project = getProject(); | |||
executeTarget("testinner"); | |||
assertEquals("Depend did not leave correct number of files", 0, | |||
getResultFiles().size()); | |||
@@ -94,7 +91,6 @@ public class DependTest extends BuildFileTest { | |||
* the outer class | |||
*/ | |||
public void testInnerInner() { | |||
Project project = getProject(); | |||
executeTarget("testinnerinner"); | |||
assertEquals("Depend did not leave correct number of files", 0, | |||
getResultFiles().size()); | |||
@@ -123,7 +119,7 @@ public class DependTest extends BuildFileTest { | |||
* fileset | |||
*/ | |||
private Hashtable getResultFiles() { | |||
FileSet resultFileSet = (FileSet)project.getReference(RESULT_FILESET); | |||
FileSet resultFileSet = (FileSet) project.getReference(RESULT_FILESET); | |||
DirectoryScanner scanner = resultFileSet.getDirectoryScanner(project); | |||
String[] scannedFiles = scanner.getIncludedFiles(); | |||
Hashtable files = new Hashtable(); | |||
@@ -139,7 +135,6 @@ public class DependTest extends BuildFileTest { | |||
* deleted | |||
*/ | |||
public void testInnerClosure() { | |||
Project project = getProject(); | |||
executeTarget("testinnerclosure"); | |||
assertEquals("Depend did not leave correct number of files", 4, | |||
getResultFiles().size()); | |||
@@ -61,7 +61,7 @@ public class XMLFormatterWithCDATAOnSystemOut extends BuildFileTest { | |||
FileReader reader = null; | |||
try { | |||
reader = new FileReader(f); | |||
String content = FileUtils.newFileUtils().readFully(reader); | |||
String content = FileUtils.readFully(reader); | |||
assertTrue(content.indexOf("</RESPONSE>]]>" | |||
+ "</ERROR>") > 0); | |||
} finally { | |||
@@ -30,7 +30,6 @@ import org.apache.tools.ant.types.Path; | |||
*/ | |||
public class SOSTest extends BuildFileTest { | |||
private Project project; | |||
private Commandline commandline; | |||
private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini"; | |||
@@ -35,7 +35,6 @@ import org.apache.tools.ant.types.Path; | |||
*/ | |||
public class MSVSSTest extends BuildFileTest implements MSVSSConstants { | |||
private Project project; | |||
private Commandline commandline; | |||
private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini"; | |||
@@ -330,7 +330,6 @@ public class ModifiedSelectorTest extends BaseSelectorTest { | |||
/** Checks whether a cache file is created. */ | |||
public void testCreatePropertiesCacheDirect() { | |||
File basedir = getSelector().getProject().getBaseDir(); | |||
File cachefile = new File(basedir, "cachefile.properties"); | |||
PropertiesfileCache cache = new PropertiesfileCache(); | |||
@@ -348,7 +347,6 @@ public class ModifiedSelectorTest extends BaseSelectorTest { | |||
/** Checks whether a cache file is created. */ | |||
public void testCreatePropertiesCacheViaModifiedSelector() { | |||
File basedir = getSelector().getProject().getBaseDir(); | |||
File cachefile = new File(basedir, "cachefile.properties"); | |||
try { | |||
@@ -826,7 +824,6 @@ public class ModifiedSelectorTest extends BaseSelectorTest { | |||
public void doScenarioTest(String target, String cachefilename) { | |||
BFT bft = new BFT(); | |||
bft.setUp(); | |||
File basedir = bft.getProject().getBaseDir(); | |||
File cachefile = new File(basedir, cachefilename); | |||
try { | |||
// do the actions | |||