@Test
  public void testBoundedByteBufferReceive() throws Exception {
    int bufferSize = 2000;
    ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
    buffer.putLong(bufferSize);
    byte[] buf = new byte[bufferSize - Long.BYTES];
    new Random().nextBytes(buf);
    buffer.put(buf);
    buffer.flip();
    BoundedNettyByteBufReceive set = new BoundedNettyByteBufReceive(100000);
    Assert.assertEquals("Wrong number of bytes read", bufferSize,
        set.readFrom(Channels.newChannel(new ByteBufferInputStream(buffer))));
    buffer.clear();
    ByteBuf payload = set.content();
    for (int i = 8; i < bufferSize; i++) {
      Assert.assertEquals(buffer.array()[i], payload.readByte());
    }
    payload.release();
  }
Test basic operation of {@link BoundedNettyByteBufReceive}.
@throws Exception
ambry-network/src/test/java/com/github/ambry/network/BoundedNettyByteBufReceiveTest.java