@Test
public void testReadLongInputByteByByte() throws Exception {

  int size = 400000;
  byte[] inputData = new byte[size];
  for (int i = 0; i < size; i++) {
    inputData[i] = (byte) (i % 253);
  }
  ReadableByteChannel baseChannel = new ByteBufferChannel(inputData);
  RewindableReadableByteChannel rewindableChannel =
      new RewindableReadableByteChannel(baseChannel);
  ByteBuffer buffer = ByteBuffer.allocate(size);
  ByteBuffer byteBuffer = ByteBuffer.allocate(1);
  while (true) {
    int s = rewindableChannel.read(byteBuffer);
    byteBuffer.flip();
    buffer.put(byteBuffer);
    if (s == -1) {
      break;
    }
    byteBuffer.clear();
  }
  assertArrayEquals(Arrays.copyOf(buffer.array(), buffer.position()), inputData);
}