org.apache.tools.ant.taskdefs
public class: DemuxOutputTask [javadoc |
source]
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.DemuxOutputTask
All Implemented Interfaces:
Cloneable
A simple task that prints to System.out and System.err and then catches
the output which it then checks. If the output does not match, an
exception is thrown
- since:
1.5 -
- created:
21 - February 2002
| Methods from org.apache.tools.ant.Task: |
|---|
|
bindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, markInvalid, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
| Method from org.apache.tools.ant.taskdefs.DemuxOutputTask Detail: |
public void execute() {
Random generator = new Random();
randomOutValue = "Output Value is " + generator.nextInt();
randomErrValue = "Error Value is " + generator.nextInt();
System.out.println(randomOutValue);
System.err.println(randomErrValue);
if (!outputReceived) {
throw new BuildException("Did not receive output");
}
if (!errorReceived) {
throw new BuildException("Did not receive error");
}
}
|
protected void handleErrorOutput(String line) {
line = line.trim();
if (line.length() != 0 && !line.equals(randomErrValue)) {
String message = "Received = [" + line + "], expected = ["
+ randomErrValue + "]";
throw new BuildException(message);
}
errorReceived = true;
}
|
protected void handleOutput(String line) {
line = line.trim();
if (line.length() != 0 && !line.equals(randomOutValue)) {
String message = "Received = [" + line + "], expected = ["
+ randomOutValue + "]";
throw new BuildException(message);
}
outputReceived = true;
}
|