public void testMarkNotSet() { try { counter.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessageThat().isEqualTo("Mark not set"); } }
public void testMarkNotSupported() { counter = new CountingInputStream(new UnmarkableInputStream()); try { counter.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessageThat().isEqualTo("Mark not supported"); } }
@SuppressWarnings("CheckReturnValue") // calling read() to skip a byte public void testMark() throws Exception { assertTrue(counter.markSupported()); assertEquals(10, counter.read(new byte[10])); assertEquals(10, counter.getCount()); counter.mark(5); counter.read(); assertEquals(11, counter.getCount()); counter.reset(); assertEquals(10, counter.getCount()); assertEquals(10, counter.skip(100)); assertEquals(20, counter.getCount()); }
private byte[] readSignableBytesAgainForLaterValidation(final CountingInputStream bufferedInputStream) throws IOException { final int position = (int)bufferedInputStream.getCount(); bufferedInputStream.reset(); final byte[] bytes = new byte[position]; IOUtils.read(bufferedInputStream, bytes, 0, position); return bytes; } }
public void testMarkNotSet() { try { counter.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessage("Mark not set"); } }
public void testMarkNotSupported() { counter = new CountingInputStream(new UnmarkableInputStream()); try { counter.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessage("Mark not supported"); } }
@SuppressWarnings("CheckReturnValue") // calling read() to skip a byte public void testMark() throws Exception { assertTrue(counter.markSupported()); assertEquals(10, counter.read(new byte[10])); assertEquals(10, counter.getCount()); counter.mark(5); counter.read(); assertEquals(11, counter.getCount()); counter.reset(); assertEquals(10, counter.getCount()); assertEquals(10, counter.skip(100)); assertEquals(20, counter.getCount()); }