Methods Summary |
---|
private org.apache.tools.ant.types.Commandline | getCommandline(int timetorun)
Commandline cmd = new Commandline();
cmd.setExecutable(TimeProcess.class.getName());
cmd.createArgument().setValue(String.valueOf(timetorun));
return cmd;
|
private static java.lang.String | getTestClassPath()Dangerous method to obtain the classpath for the test. This is
severely tighted to the build.xml properties.
String classpath = System.getProperty("build.tests");
if (classpath == null) {
System.err.println("WARNING: 'build.tests' property is not available !");
classpath = System.getProperty("java.class.path");
}
return classpath;
|
protected void | setUp()
ej = new ExecuteJava();
ej.setTimeout(new Long(TIME_OUT));
project = new Project();
project.setBasedir(".");
project.setProperty(MagicNames.ANT_HOME, System.getProperty(MagicNames.ANT_HOME));
cp = new Path(project, getTestClassPath());
ej.setClasspath(cp);
|
public void | testNoTimeOut()
Commandline cmd = getCommandline(TIME_OUT/2);
ej.setJavaCommand(cmd);
ej.execute(project);
assertTrue("process should not have been killed", !ej.killedProcess());
|
public void | testNoTimeOutForked()
Commandline cmd = getCommandline(TIME_OUT/2);
ej.setJavaCommand(cmd);
ej.fork(cp);
assertTrue("process should not have been killed", !ej.killedProcess());
|
public void | testTimeOut()
Commandline cmd = getCommandline(TIME_OUT*2);
ej.setJavaCommand(cmd);
long now = System.currentTimeMillis();
ej.execute(project);
long elapsed = System.currentTimeMillis() - now;
assertTrue("process should have been killed", ej.killedProcess());
assertTrue("elapse time of "+elapsed
+" ms is less than timeout value of "+TIME_OUT_TEST+" ms",
elapsed >= TIME_OUT_TEST);
assertTrue("elapse time of "+elapsed
+" ms is greater than run value of "+(TIME_OUT*2)+" ms",
elapsed < TIME_OUT*2);
|
public void | testTimeOutForked()
//process doesn't die properly under this combination,
//thus test fails. No workaround?
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)
&& Os.isFamily("dos")) {
return;
}
Commandline cmd = getCommandline(TIME_OUT*2);
ej.setJavaCommand(cmd);
long now = System.currentTimeMillis();
ej.fork(cp);
long elapsed = System.currentTimeMillis() - now;
assertTrue("process should have been killed", ej.killedProcess());
assertTrue("elapse time of "+elapsed
+" ms is less than timeout value of "+TIME_OUT_TEST+" ms",
elapsed >= TIME_OUT_TEST);
assertTrue("elapse time of "+elapsed
+" ms is greater than run value of "+(TIME_OUT*2)+" ms",
elapsed < TIME_OUT*2);
|