/** * Tests the ability to skip remaining bytes upon closing. */ @Test public void testSkipRemainingOnClose() throws Exception { for (int size = 0; size < MAX_SIZE; size++) { int bound = size / 2; val data = construct(size); @Cleanup val input = new ByteArrayInputStream(data); @Cleanup val bis = new BoundedInputStream(input, bound); Assert.assertEquals("Unexpected value for getBound().", bound, bis.getBound()); if (size % 2 == 1) { // Only read some data for every other iteration. int bytesRead = bis.read(new byte[bound / 2]); Assert.assertEquals("Unexpected number of bytes read.", bound / 2, bytesRead); } bis.close(); Assert.assertEquals("Unexpected number of bytes remaining to be read after skipRemaining().", data.length - bis.getBound(), input.available()); } }
public void testSubStream() throws Exception { val bound = MAX_SIZE / 2; val data = construct(MAX_SIZE); @Cleanup val input = new ByteArrayInputStream(data);
public void testBounds() throws Exception { val bound = MAX_SIZE / 2; val data = construct(MAX_SIZE); @Cleanup val input = new ByteArrayInputStream(data);