@Test
public void testRetainedSlice() {

    ByteBuf buf1 = Unpooled.buffer(8);
    buf1.writeInt(1);
    buf1.writeInt(2);
    ByteBuf buf2 = Unpooled.buffer(16);
    buf2.writeLong(10);
    buf2.writeLong(20);
    ByteBuf[] bufs = new ByteBuf[2];
    bufs[0] = buf1;
    bufs[1] = buf2;
    DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(bufs, 0, 2);
    Assert.assertTrue(compositeByteBuf.readableBytes() == 24);
    ByteBuf compositeByteBuf2 = compositeByteBuf.retainedSlice(12);
    Assert.assertTrue(compositeByteBuf.readableBytes() == 24);
    Assert.assertTrue(compositeByteBuf2.readInt() == 1);
    Assert.assertTrue(buf1.refCnt() == 2);
    Assert.assertTrue(buf2.refCnt() == 2);
    compositeByteBuf2.release();
    Assert.assertTrue(buf1.refCnt() == 1);
    Assert.assertTrue(buf2.refCnt() == 1);
}