@Test
  public void commonCaseTest() throws Exception {
    ByteBuffer content = ByteBuffer.wrap(fillRandomBytes(new byte[1024]));
    ByteBufferReadableStreamChannel readableStreamChannel = new ByteBufferReadableStreamChannel(content);
    assertTrue("ByteBufferReadableStreamChannel is not open", readableStreamChannel.isOpen());
    assertEquals("Size returned by ByteBufferReadableStreamChannel did not match source array size", content.capacity(),
        readableStreamChannel.getSize());
    ByteBufferAsyncWritableChannel writeChannel = new ByteBufferAsyncWritableChannel();
    ReadIntoCallback callback = new ReadIntoCallback();
    Future<Long> future = readableStreamChannel.readInto(writeChannel, callback);
    ByteBuffer contentWrapper = ByteBuffer.wrap(content.array());
    while (contentWrapper.hasRemaining()) {
      ByteBuffer recvdContent = writeChannel.getNextChunk();
      assertNotNull("Written content lesser than original content", recvdContent);
      while (recvdContent.hasRemaining()) {
        assertTrue("Written content is more than original content", contentWrapper.hasRemaining());
        assertEquals("Unexpected byte", contentWrapper.get(), recvdContent.get());
      }
      writeChannel.resolveOldestChunk(null);
    }
    assertNull("There should have been no more data in the channel", writeChannel.getNextChunk(0));
    writeChannel.close();
    callback.awaitCallback();
    if (callback.exception != null) {
      throw callback.exception;
    }
    long futureBytesRead = future.get();
    assertEquals("Total bytes written does not match (callback)", content.limit(), callback.bytesRead);
    assertEquals("Total bytes written does not match (future)", content.limit(), futureBytesRead);
  }
Tests the common case read operations i.e
1. Create {@link ByteBufferReadableStreamChannel} with random bytes.
2. Calls the different read operations of {@link ByteBufferReadableStreamChannel} and checks that the data read
matches the data used to create the {@link ByteBufferReadableStreamChannel}.
@throws Exception
ambry-commons/src/test/java/com/github/ambry/commons/ByteBufferReadableStreamChannelTest.java