DynamicCompositeByteBuf { public int readableBytes() { return readableBytes; } DynamicCompositeByteBuf();  DynamicCompositeByteBuf(int capacity);  DynamicCompositeByteBuf(ByteBuf buf);  DynamicCompositeByteBuf(ByteBuf[] bufs, int offset, int len); int readableBytes(); boolean isEmpty(); boolean hasArray(); byte[] array(); int arrayOffset(); int readerIndex(); boolean isReadable(); ByteBuf nettyByteBuf(); void addBuffer(ByteBuf buffer); ByteBuf readRetainedSlice(int length); ByteBuf retainedSlice(int length); void skipBytes(int length); DynamicCompositeByteBuf readBytes(byte[] dst); DynamicCompositeByteBuf readBytes(byte[] dst, int dstIndex, int length); byte readByte(); short readUnsignedByte(); short readShort(); short readShortLE(); int readUnsignedShort(); int readUnsignedShortLE(); int readInt(); int readIntLE(); long readLong(); long readLongLE(); char readChar(); float readFloat(); float readFloatLE(); double readDouble(); double readDoubleLE(); ByteOrder order(); void release(); @Override String toString();  }
@Test public void testDynamicCompositeByteBuf2() { DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(2); Assert.assertTrue(compositeByteBuf.readableBytes() == 0); }
@Test public void testDynamicCompositeByteBuf3() { ByteBuf byteBuf1 = Unpooled.wrappedBuffer("hello".getBytes()); DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(byteBuf1); Assert.assertTrue(compositeByteBuf.readableBytes() == byteBuf1.readableBytes()); Assert.assertTrue(byteBuf1.refCnt() == 1); }
@Test public void testDynamicCompositeByteBuf4() { ByteBuf buf1 = Unpooled.wrappedBuffer("hello1".getBytes()); ByteBuf buf2 = Unpooled.wrappedBuffer("hello222".getBytes()); ByteBuf buf3 = Unpooled.wrappedBuffer("hello33333".getBytes()); ByteBuf[] bufs = new ByteBuf[] {buf1, buf2, buf3}; DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(bufs, 1, 2); Assert.assertTrue(compositeByteBuf.readableBytes() == buf2.readableBytes() + buf3.readableBytes()); }
@Test public void testReadableBytes() { ByteBuf byteBuf1 = Unpooled.wrappedBuffer("hello".getBytes()); DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(byteBuf1); Assert.assertTrue(compositeByteBuf.readableBytes() == byteBuf1.readableBytes()); }