NettyBufferFactory implements BufferFactory<ByteBuf> { @Override public Buffer create(final ByteBuf value) { return new NettyBuffer(value); }  @Override Buffer create(final ByteBuf value); @Override Buffer wrap(final ByteBuffer value); static void readRaw(final Buffer buffer, final Consumer<ByteBuf> consumer); static void writeRaw(final Buffer buffer, final Consumer<ByteBuf> consumer);  }
@Test public void shouldReturnAWrapper() { final ByteBuf raw = getRaw(); final Buffer buffer = factory.create(raw); assertEquals(raw.refCnt(), buffer.referenceCount()); }
@Test public void shouldAdvanceWriterAndReaderIndex() { final ByteBuf raw = getRaw(); final Buffer buffer = factory.create(raw); final int intValue = 100; final long longValue = 2019L; final float floatValue = 10.9F; assertEquals(0, buffer.writerIndex()); assertEquals(0, buffer.readerIndex()); buffer.writeBoolean(true); buffer.writeInt(intValue); buffer.writeLong(longValue); buffer.writeFloat(floatValue); assertEquals(17, buffer.writerIndex()); assertEquals(0, buffer.readerIndex()); assertTrue(buffer.readBoolean()); assertEquals(intValue, buffer.readInt()); assertEquals(longValue, buffer.readLong()); assertEquals(floatValue, buffer.readFloat(), 0f); assertEquals(17, buffer.writerIndex()); assertEquals(17, buffer.readerIndex()); }