aboutsummaryrefslogtreecommitdiff
path: root/gnu/testlet/java/io/PipedStream/close.java
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/testlet/java/io/PipedStream/close.java')
-rw-r--r--gnu/testlet/java/io/PipedStream/close.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/gnu/testlet/java/io/PipedStream/close.java b/gnu/testlet/java/io/PipedStream/close.java
new file mode 100644
index 00000000..63170ea7
--- /dev/null
+++ b/gnu/testlet/java/io/PipedStream/close.java
@@ -0,0 +1,51 @@
+// Tags: JDK1.0
+
+// This test is from Jeff Sturm.
+// It tests whether close() on a PipedInputStream will correctly
+// notify the writer.
+
+package gnu.testlet.java.io.PipedStream;
+
+import gnu.testlet.Testlet;
+import gnu.testlet.TestHarness;
+import java.io.*;
+
+public class close implements Runnable, Testlet {
+ Thread main;
+ PipedInputStream in;
+ PipedOutputStream out;
+ TestHarness harness;
+
+ public void run() {
+ try {
+ Thread.sleep(1000);
+ harness.debug("Closing pipe input stream:");
+ in.close();
+ Thread.sleep(1000);
+ harness.debug("Interrupting pipe reader:");
+ main.interrupt();
+ } catch (Throwable t) {
+ harness.debug(t);
+ }
+ }
+
+ public void test (TestHarness harness) {
+ int val = 23;
+ try {
+ close test = new close();
+ test.harness = harness;
+
+ test.main = Thread.currentThread();
+ test.out = new PipedOutputStream();
+ test.in = new PipedInputStream(test.out);
+
+ (new Thread(test)).start();
+
+ val = test.in.read();
+ } catch (InterruptedIOException t) {
+ harness.check(true,"read() interrupted okay");
+ } catch (IOException t) {
+ harness.fail("Unexpected IOException thrown");
+ }
+ }
+}