diff options
Diffstat (limited to 'jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java')
-rw-r--r-- | jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java index 134c34641a5..0c3670dd56e 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java @@ -10,9 +10,10 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.ByteBuffer; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** @@ -70,6 +71,21 @@ public class UnsafeContentInputStreamTestCase { } @Test + public void requireThatReadAfterResetIncludesDataAfterMark() throws IOException { + ReadableContentChannel content = new ReadableContentChannel(); + UnsafeContentInputStream in = new UnsafeContentInputStream(content); + byte[] outBuf = new byte[] {1, 2, 3}; + content.write(ByteBuffer.wrap(outBuf), null); + in.mark(4); + assertEquals(3, in.read(new byte[] {101, 102, 103, 104})); + in.reset(); + byte[] inBuf = new byte[4]; + int read = in.read(inBuf); + assertEquals(3, read); + assertArrayEquals(new byte[]{1, 2, 3, 0}, inBuf); + } + + @Test public void requireThatCompletionsAreCalledWithDeprecatedContentWriter() throws IOException { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); |