bodewig 2003/04/01 05:29:03
Modified: src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTestRunner.java src/main/org/apache/tools/ant/taskdefs/optional/ssh SSHExec.java Log: Remove redundant classes Revision Changes Path 1.34 +4 -29 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java Index: JUnitTestRunner.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- JUnitTestRunner.java 7 Mar 2003 11:23:06 -0000 1.33 +++ JUnitTestRunner.java 1 Apr 2003 13:29:01 -0000 1.34 @@ -78,6 +78,7 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.util.StringUtils; +import org.apache.tools.ant.util.TeeOutputStream; /** * Simple Testrunner for JUnit that runs all tests of a testsuite. @@ -302,17 +303,12 @@ System.setErr(systemError); } else { System.setOut(new PrintStream( - new TeeOutputStream( - new OutputStream[] {savedOut, - systemOut} - ) + new TeeOutputStream(savedOut, systemOut) ) ); System.setErr(new PrintStream( - new TeeOutputStream( - new OutputStream[] {savedErr, - systemError} - ) + new TeeOutputStream(savedErr, + systemError) ) ); } @@ -613,25 +609,4 @@ return false; } - /** - * Helper class that sends output sent to multiple streams. - * - * @since Ant 1.5 - */ - private class TeeOutputStream extends OutputStream { - - private OutputStream[] outs; - - private TeeOutputStream(OutputStream[] outs) { - this.outs = outs; - } - - public void write(int b) throws IOException { - for (int i = 0; i < outs.length; i++) { - outs[i].write(b); - } - } - - } - } // JUnitTestRunner 1.5 +2 -62 ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java Index: SSHExec.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SSHExec.java 1 Apr 2003 13:09:28 -0000 1.4 +++ SSHExec.java 1 Apr 2003 13:29:03 -0000 1.5 @@ -56,6 +56,7 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.apache.tools.ant.util.TeeOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -165,7 +166,7 @@ } ByteArrayOutputStream out = new ByteArrayOutputStream(); - Tee tee = new Tee(out, System.out); + TeeOutputStream tee = new TeeOutputStream(out, System.out); try { // execute the command @@ -249,67 +250,6 @@ if (out != null) { out.close(); } - } - } - - /** - * Similar to standard unix "tee" utility, sends output to two streams. - * - * @author Dale Anson, [EMAIL PROTECTED] - * @version $Revision$ - */ - public class Tee extends OutputStream { - - private OutputStream left = null; - private OutputStream right = null; - - /** - * Constructor for Tee, sends output to both of the given - * streams, which are referred to as the "teed" streams. - * - * @param left one stream to write to - * @param right the other stream to write to - */ - public Tee(OutputStream left, OutputStream right) { - if (left == null || right == null) { - throw new IllegalArgumentException("Both streams are required."); - } - this.left = left; - this.right = right; - } - - /** - * Writes the specified byte to both of the teed streams. Per java api, - * the general contract for write is that one byte is written to the - * output stream. The byte to be written is the eight low-order bits of - * the argument b. The 24 high-order bits of b are ignored. - * - * @param b - * @exception IOException If an IO error occurs - */ - public void write( int b ) throws IOException { - left.write( b ); - right.write( b ); - } - - /** - * Closes both of the teed streams. - * - * @exception IOException If an IO error occurs - */ - public void close() throws IOException { - left.close(); - right.close(); - } - - /** - * Flushes both of the teed streams. - * - * @exception IOException If an IO error occurs - */ - public void flush() throws IOException { - left.flush(); - right.flush(); } }