@Test public void testCloseClosesWrappedStream() throws IOException { InputStream wrapped = mock(InputStream.class); stream = new RecyclableBufferedInputStream(wrapped, byteArrayPool); stream.close(); verify(wrapped).close(); }
@Test(expected = IOException.class) public void testCloseThrowsIfWrappedStreamThrowsOnClose() throws IOException { InputStream wrapped = mock(InputStream.class); doThrow(new IOException()).when(wrapped).close(); stream = new RecyclableBufferedInputStream(wrapped, byteArrayPool); stream.close(); }
@Test public void testCallsCloseOnWrapped() throws IOException { is.close(); verify(wrapped).close(); }
@Test(expected = IOException.class) public void testReadThrowsIfStreamIsClosed() throws IOException { stream.close(); stream.read(); }
@Test(expected = IOException.class) public void testAvailableThrowsIfStreamIsClosed() throws IOException { stream.close(); stream.available(); }
@Test(expected = IOException.class) public void testReadBulkThrowsIfStreamIsClosed() throws IOException { stream.close(); stream.read(new byte[1], 0, 1); }
@Test(expected = IOException.class) public void testResetThrowsIfStreamIsClosed() throws IOException { stream.close(); stream.reset(); }
@Test(expected = IOException.class) public void testSkipThrowsIfStreamIsClosed() throws IOException { stream.close(); stream.skip(10); }