@Test
  public void basicsTestWithNettyByteBuf() throws Exception {
    for (boolean useCompositeByteBuf : Arrays.asList(false, true)) {
      List<byte[]> inputBuffers = getBuffers(1000, 20, 201, 0, 79, 1005);
      RetainingAsyncWritableChannel channel = new RetainingAsyncWritableChannel();
      for (int i = 0; i < inputBuffers.size(); i++) {
        byte[] data = inputBuffers.get(i);
        ByteBuf chunk;
        if (data.length == 0) {
          chunk = Unpooled.wrappedBuffer(data);
        } else if (!useCompositeByteBuf) {
          chunk = ByteBufAllocator.DEFAULT.heapBuffer(data.length);
          chunk.writeBytes(data);
        } else {
          CompositeByteBuf composite = ByteBufAllocator.DEFAULT.compositeHeapBuffer(100);
          ByteBuf c = ByteBufAllocator.DEFAULT.heapBuffer(data.length / 2);
          c.writeBytes(data, 0, data.length / 2);
          composite.addComponent(true, c);
          c = ByteBufAllocator.DEFAULT.heapBuffer(data.length - data.length / 2);
          c.writeBytes(data, data.length / 2, data.length - data.length / 2);
          composite.addComponent(true, c);
          chunk = composite;
        }
        writeAndCheckCallback(chunk, channel, chunk.readableBytes(), null, null);
      }
      checkStream(inputBuffers, channel);
      channel.close();
      writeAndCheckCallback(ByteBuffer.allocate(0), channel, 0, ClosedChannelException.class, null);
    }
  }
Test that {@link RetainingAsyncWritableChannel} behaves as expected: chunks are copied, callback completed
immediately after {@link RetainingAsyncWritableChannel#write} method completes.
ambry-commons/src/test/java/com/github/ambry/commons/RetainingAsyncWritableChannelTest.java