use of java.io.PipedInputStream in project hadoop by apache.
the class TestJMXGet method checkPrintAllValues.
private static boolean checkPrintAllValues(JMXGet jmx) throws Exception {
int size = 0;
byte[] bytes = null;
String pattern = "List of all the available keys:";
PipedOutputStream pipeOut = new PipedOutputStream();
PipedInputStream pipeIn = new PipedInputStream(pipeOut);
PrintStream oldErr = System.err;
System.setErr(new PrintStream(pipeOut));
try {
jmx.printAllValues();
if ((size = pipeIn.available()) != 0) {
bytes = new byte[size];
pipeIn.read(bytes, 0, bytes.length);
}
pipeOut.close();
pipeIn.close();
} finally {
System.setErr(oldErr);
}
return bytes != null ? new String(bytes).contains(pattern) : false;
}
use of java.io.PipedInputStream in project mongo-hadoop by mongodb.
the class MongoUpdateOutputReaderTest method inputFromBSONObject.
private DataInput inputFromBSONObject(final BSONObject object) throws IOException {
PipedOutputStream outputStream = new PipedOutputStream();
PipedInputStream inputStream = new PipedInputStream(outputStream);
bsonWritable.setDoc(object);
bsonWritable.write(new DataOutputStream(outputStream));
return new DataInputStream(inputStream);
}
use of java.io.PipedInputStream in project robovm by robovm.
the class InputStreamReaderTest method testReadDoesNotBlockUnnecessarily.
/**
* This bug claims that InputStreamReader blocks unnecessarily:
* http://code.google.com/p/android/issues/detail?id=10252
*/
public void testReadDoesNotBlockUnnecessarily() throws IOException {
PipedInputStream pin = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream(pin);
pos.write("hello".getBytes("UTF-8"));
InputStreamReader reader = new InputStreamReader(pin);
char[] buffer = new char[1024];
int count = reader.read(buffer);
assertEquals(5, count);
}
use of java.io.PipedInputStream in project robovm by robovm.
the class InterruptedStreamTest method testInterruptPipedInputStream.
public void testInterruptPipedInputStream() throws Exception {
PipedOutputStream out = new PipedOutputStream();
PipedInputStream in = new PipedInputStream(out);
testInterruptInputStream(in);
}
use of java.io.PipedInputStream in project robovm by robovm.
the class InterruptedStreamTest method testInterruptPipedOutputStream.
public void testInterruptPipedOutputStream() throws Exception {
PipedOutputStream out = new PipedOutputStream();
new PipedInputStream(out);
testInterruptOutputStream(out);
}
Aggregations