@Test
  public void commonCaseTest() throws ClosedChannelException {
    byte[] in = new byte[1024];
    byte[] out = new byte[1024];
    ByteBuffer inBuf = ByteBuffer.wrap(in);
    ByteBufferChannel channel = new ByteBufferChannel(ByteBuffer.wrap(out));
    ByteBuffer outBuf = channel.getBuffer();

    new Random().nextBytes(in);
    assertEquals("Bytes written is not as expected", inBuf.capacity(), channel.write(inBuf));
    assertArrayEquals("Bytes read from channel not equal to bytes written into channel", inBuf.array(), outBuf.array());
  }
Tests the common case usage.
1. Creates an input {@link ByteBuffer} with random data.
2. Creates a {@link ByteBufferChannel} of capacity equal to the input buffer.
3. Writes the data in the input buffer into the channel.
4. Checks the bytes written (both number and data) match.
@throws ClosedChannelException
ambry-utils/src/test/java/com/github/ambry/utils/ByteBufferChannelTest.java