Browse Source

Remove redundant classes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274361 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
c26280a07e
2 changed files with 6 additions and 91 deletions
  1. +4
    -29
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  2. +2
    -62
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java

+ 4
- 29
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java View File

@@ -78,6 +78,7 @@ import org.apache.tools.ant.AntClassLoader;
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 @@ public class JUnitTestRunner implements TestListener {
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 @@ public class JUnitTestRunner implements TestListener {
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

+ 2
- 62
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java View File

@@ -56,6 +56,7 @@ package org.apache.tools.ant.taskdefs.optional.ssh;

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 @@ public class SSHExec extends SSHBase {
}

ByteArrayOutputStream out = new ByteArrayOutputStream();
Tee tee = new Tee(out, System.out);
TeeOutputStream tee = new TeeOutputStream(out, System.out);

try {
// execute the command
@@ -252,66 +253,5 @@ public class SSHExec extends SSHBase {
}
}

/**
* Similar to standard unix "tee" utility, sends output to two streams.
*
* @author Dale Anson, danson@germane-software.com
* @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();
}
}

}


Loading…
Cancel
Save