/**
* @tests java.io.PipedInputStream#available()
*/
public void test_available() throws Exception {
pis = new PipedInputStream();
pos = new PipedOutputStream();
pis.connect(pos);
t = new Thread(pw = new PWriter(pos, 1000));
t.start();
synchronized (pw) {
pw.wait(10000);
}
assertTrue("Available returned incorrect number of bytes: "
+ pis.available(), pis.available() == 1000);
PipedInputStream pin = new PipedInputStream();
PipedOutputStream pout = new PipedOutputStream(pin);
// We know the PipedInputStream buffer size is 1024.
// Writing another byte would cause the write to wait
// for a read before returning
for (int i = 0; i < 1024; i++) {
pout.write(i);
}
assertEquals("Incorrect available count", 1024, pin.available());
}