@Test
public void testReadToLimit() throws Exception {

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