### Question:
CrcInputStream extends FilterInputStream { public long getValue() { return crc.getValue(); } CrcInputStream(InputStream inputStream, Checksum crc); long getValue(); void reset(); @Override int read(); @Override int read(byte[] b, int off, int len);  }### Answer:
@Test public void calculatesACrcCorrectlyWhenReading() throws Exception { final byte[] data = getUtf8Bytes("The quick brown fox jumps over the \000\001\002\003"); final long expectedCrc = computeCrcDirectly(data); final CrcInputStream crcInputStream = createCrcInputStreamReadingFromByteArray(data); readEntireInputStream(crcInputStream); assertThat(crcInputStream.getValue(), is(equalTo(expectedCrc))); }