diff options
| author | Jesse Wilson <jessewilson@google.com> | 2010-04-13 18:02:47 -0700 |
|---|---|---|
| committer | Jesse Wilson <jessewilson@google.com> | 2010-04-13 18:02:47 -0700 |
| commit | e09ba12220c2cbbe9d91514da4d0f8fd8543b239 (patch) | |
| tree | 0aa9a8fc34f968d8696badc64d7181fdbb713172 | |
| parent | 5fdfbeffbba55999b0122da12334bc26434ce815 (diff) | |
| download | android_dalvik-e09ba12220c2cbbe9d91514da4d0f8fd8543b239.tar.gz android_dalvik-e09ba12220c2cbbe9d91514da4d0f8fd8543b239.tar.bz2 android_dalvik-e09ba12220c2cbbe9d91514da4d0f8fd8543b239.zip | |
Fixing PipedInputStreamTest to fill the buffer before dying on a dead reader.
Change-Id: Ie34a8bec7b2a34d2933225d6d4e04e0643dbcf99
| -rw-r--r-- | libcore/luni/src/test/java/tests/api/java/io/PipedInputStreamTest.java | 12 |
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; |
