FileDocCategorySizeDatePackage
DemuxOutputTask.javaAPI DocApache Ant 1.702592Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs

DemuxOutputTask

public class DemuxOutputTask extends org.apache.tools.ant.Task
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

Fields Summary
private String
randomOutValue
private String
randomErrValue
private boolean
outputReceived
private boolean
errorReceived
Constructors Summary
Methods Summary
public voidexecute()


       
        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 voidhandleErrorOutput(java.lang.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 voidhandleOutput(java.lang.String line)

        line = line.trim();
        if (line.length() != 0 && !line.equals(randomOutValue)) {
            String message = "Received = [" + line + "], expected = ["
                + randomOutValue + "]";
            throw new BuildException(message);
        }
        outputReceived = true;