@Test
public void exhaustAndClose() throws IOException {

    TestInputStream countingStream = new TestInputStream(testStream);
    CappedInputStream cappedStream = new CappedInputStream(countingStream, 50);
    cappedStream.exhaustAndClose();
    assertThat(countingStream.getSkipCount()).isEqualTo(50);
    assertThat(countingStream.getReadCount()).isEqualTo(0);
    assertThat(cappedStream.available()).isEqualTo(0);
    assertThatExceptionOfType(IOException.class).isThrownBy(cappedStream::read);
}