diff --git a/src/test/java/org/takes/rq/CapInputStreamTest.java b/src/test/java/org/takes/rq/CapInputStreamTest.java index e501ff5dd..557bdfb44 100644 --- a/src/test/java/org/takes/rq/CapInputStreamTest.java +++ b/src/test/java/org/takes/rq/CapInputStreamTest.java @@ -25,9 +25,11 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.mockito.Mockito; /** * Test case for {@link CapInputStream}. @@ -54,4 +56,35 @@ public void putsCapOnStream() throws IOException { ); } + /** + * CapInputStream can close a stream. + * @throws IOException If some problem inside + */ + @Test + public void closesStream() throws IOException { + final InputStream stream = Mockito.mock(InputStream.class); + final CapInputStream wrapper = new CapInputStream( + stream, + 0L + ); + wrapper.close(); + Mockito.verify(stream, Mockito.times(1)).close(); + } + + /** + * CapInputStream can skip on a stream. + * @throws IOException If some problem inside + */ + @Test + public void skipsOnStream() throws IOException { + final long skip = 25L; + final InputStream stream = Mockito.mock(InputStream.class); + final CapInputStream wrapper = new CapInputStream( + stream, + 50L + ); + wrapper.skip(skip); + Mockito.verify(stream, Mockito.times(1)).skip(skip); + } + }