@Test
public void testReadEverythingInChunks() throws Exception {

  byte[] inputData = "The quick brown fox jumps over the lazy dog.".getBytes(UTF_8);
  ReadableByteChannel baseChannel = new ByteBufferChannel(inputData, /*maxChunkSize=*/ 20);
  RewindableReadableByteChannel rewindableChannel =
      new RewindableReadableByteChannel(baseChannel);
  ByteBuffer buffer = ByteBuffer.allocate(1000);
  assertEquals(20, rewindableChannel.read(buffer));
  assertEquals(20, rewindableChannel.read(buffer));
  assertEquals(inputData.length - 40, rewindableChannel.read(buffer));
  assertEquals(-1, rewindableChannel.read(buffer));
  assertArrayEquals(Arrays.copyOf(buffer.array(), inputData.length) , inputData);
}