Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 17 package org.apache.tools.ant.taskdefs; 18 19 import org.apache.tools.ant.*; 20 import org.apache.tools.ant.BuildFileTest; 21 import java.util.Random ; 22 23 31 public class DemuxOutputTask extends Task { 32 private String randomOutValue; 33 private String randomErrValue; 34 private boolean outputReceived = false; 35 private boolean errorReceived = false; 36 37 public void execute() { 38 Random generator = new Random (); 39 randomOutValue = "Output Value is " + generator.nextInt(); 40 randomErrValue = "Error Value is " + generator.nextInt(); 41 42 System.out.println(randomOutValue); 43 System.err.println(randomErrValue); 44 if (!outputReceived) { 45 throw new BuildException("Did not receive output"); 46 } 47 48 if (!errorReceived) { 49 throw new BuildException("Did not receive error"); 50 } 51 } 52 53 protected void handleOutput(String line) { 54 line = line.trim(); 55 if (line.length() != 0 && !line.equals(randomOutValue)) { 56 String message = "Received = [" + line + "], expected = [" 57 + randomOutValue + "]"; 58 throw new BuildException(message); 59 } 60 outputReceived = true; 61 } 62 63 protected void handleErrorOutput(String line) { 64 line = line.trim(); 65 if (line.length() != 0 && !line.equals(randomErrValue)) { 66 String message = "Received = [" + line + "], expected = [" 67 + randomErrValue + "]"; 68 throw new BuildException(message); 69 } 70 errorReceived = true; 71 } 72 } 73 74
| Popular Tags
|