summaryrefslogtreecommitdiffstats
path: root/libcore
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2010-04-15 06:36:55 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-04-15 06:36:55 -0700
commitda18d99558da028acdef9f1479a957146c4e314d (patch)
treebbb2df719e3554d9794379e8ee9394e1146984bf /libcore
parentd9b87a918dfe98793faa08cb59012f652b4b8561 (diff)
parente09ba12220c2cbbe9d91514da4d0f8fd8543b239 (diff)
downloadandroid_dalvik-da18d99558da028acdef9f1479a957146c4e314d.tar.gz
android_dalvik-da18d99558da028acdef9f1479a957146c4e314d.tar.bz2
android_dalvik-da18d99558da028acdef9f1479a957146c4e314d.zip
am e09ba122: Fixing PipedInputStreamTest to fill the buffer before dying on a dead reader.
Diffstat (limited to 'libcore')
-rw-r--r--libcore/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/libcore/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java b/libcore/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java
index 671bfe919..c6dd60f64 100644
--- a/libcore/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java
@@ -27,6 +27,8 @@ import dalvik.annotation.TestTargetNew;
@TestTargetClass(PipedInputStream.class)
public class PipedInputStreamTest extends junit.framework.TestCase {
+ private final int BUFFER_SIZE = 1024;
+
static class PWriter implements Runnable {
PipedOutputStream pos;
@@ -150,13 +152,12 @@ public class PipedInputStreamTest extends junit.framework.TestCase {
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++)
+ for (int i = 0; i < BUFFER_SIZE; i++)
pout.write(i);
assertEquals("Test 2: Incorrect number of bytes available. ",
- 1024 , pin.available());
+ BUFFER_SIZE, pin.available());
}
/**
@@ -433,8 +434,9 @@ public class PipedInputStreamTest extends junit.framework.TestCase {
Thread.sleep(100);
}
try {
- // should throw exception since reader thread
- // is now dead
+ pos.write(new byte[BUFFER_SIZE]);
+ // should throw exception since buffer is full and
+ // reader thread is now dead
pos.write(1);
} catch (IOException e) {
pass = true;