ByteArrayOutputStreamPayload extends AbstractInOutPayload { @Override public int doIn(ByteBuf byteBuf) throws IOException { int size = byteBuf.readableBytes(); makeSureSize(size); byteBuf.readBytes(data, pos.get(), size); int read = size - byteBuf.readableBytes(); pos.addAndGet(read); return read; } ByteArrayOutputStreamPayload();  ByteArrayOutputStreamPayload(int INIT_SIZE);  ByteArrayOutputStreamPayload(String message); @Override void doStartInput(); @Override int doIn(ByteBuf byteBuf); @Override long doOut(WritableByteChannel writableByteChannel); byte[] getBytes(); @Override String toString();  }
@Test public void testDoIn() throws IOException { ByteArrayOutputStreamPayload payload = new ByteArrayOutputStreamPayload(); String randomStr = randomString(); ByteBuf byteBuf = directByteBuf(randomStr.length()); byteBuf.writeBytes(randomStr.getBytes()); payload.startInput(); int size = payload.in(byteBuf); Assert.assertEquals(size, randomStr.length()); }