use of java.io.PipedWriter in project j2objc by google.
the class OldPipedWriterTest method test_connectLjava_io_PipedReader.
public void test_connectLjava_io_PipedReader() throws Exception {
PipedReader rd = new PipedReader();
pw = new PipedWriter();
try {
pw.connect(rd);
} catch (Exception e) {
fail("Test 1: Unexpected exception when connecting: " + e.getLocalizedMessage());
}
readerThread = new Thread(reader = new PReader(rd), "connect");
readerThread.start();
try {
pw.write(testBuf);
} catch (IOException e) {
fail("Test 2: Unexpected IOException when writing after connecting.");
}
assertEquals("Test 3: Incorrect character string received.", testString, reader.read(testLength));
try {
pw.connect(new PipedReader());
fail("Test 4: IOException expected when reconnecting the writer.");
} catch (IOException e) {
// Expected.
}
}
use of java.io.PipedWriter in project j2objc by google.
the class OldPipedWriterTest method test_write$CII.
public void test_write$CII() throws Exception {
pw = new PipedWriter();
try {
pw.write(testBuf, 0, 5);
fail("Test 1: IOException expected.");
} catch (IOException e) {
// Expected.
}
pw = new PipedWriter(new PipedReader());
try {
pw.write(testBuf, -1, 1);
fail("Test 2: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
pw.write(testBuf, 0, -1);
fail("Test 3: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
pw.write(testBuf, 5, testString.length());
fail("Test 4: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
pw.close();
pw = new PipedWriter();
try {
readerThread = new Thread(reader = new PReader(pw), "writeCII");
readerThread.start();
pw.write(testBuf, 0, testLength);
pw.close();
reader.read(testLength);
assertTrue("Test 5: Characters read do not match the characters written.", Arrays.equals(testBuf, reader.buf));
} catch (IOException e) {
fail("Test 5: Unexpected IOException: " + e.getMessage());
}
readerThread.interrupt();
try {
pw.write(testBuf, 0, 5);
fail("Test 6: IOException expected.");
} catch (IOException e) {
// Expected.
}
reader.pr.close();
try {
pw.write(testBuf, 0, 5);
fail("Test 7: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of java.io.PipedWriter in project robovm by robovm.
the class InterruptedStreamTest method testInterruptPipedReader.
public void testInterruptPipedReader() throws Exception {
PipedWriter writer = new PipedWriter();
PipedReader reader = new PipedReader(writer);
testInterruptReader(reader);
}
use of java.io.PipedWriter in project robovm by robovm.
the class InterruptedStreamTest method testInterruptPipedWriter.
public void testInterruptPipedWriter() throws Exception {
final PipedWriter writer = new PipedWriter();
new PipedReader(writer);
testInterruptWriter(writer);
}
use of java.io.PipedWriter in project robovm by robovm.
the class OldPipedWriterTest method test_flush.
public void test_flush() throws Exception {
// Test for method void java.io.PipedWriter.flush()
pw = new PipedWriter();
readerThread = new Thread(reader = new PReader(pw), "flush");
readerThread.start();
pw.write(testBuf);
pw.flush();
assertEquals("Test 1: Flush failed. ", testString, reader.read(testLength));
}
Aggregations