### Question:
ByteArrayChunkedEncoder implements ChunkedInput<ByteBuf> { @Override public ByteBuf readChunk( ChannelHandlerContext ctx ) { return readChunk( ctx.alloc() ); } ByteArrayChunkedEncoder( byte[] content, int chunkSize );  ByteArrayChunkedEncoder( byte[] content ); @Override boolean isEndOfInput(); @Override void close(); @Override ByteBuf readChunk( ChannelHandlerContext ctx ); @Override ByteBuf readChunk( ByteBufAllocator allocator ); @Override long length(); @Override long progress();  }### Answer:
@Test public void shouldWriteToBufferInChunks() { int chunkSize = 5; byte[] data = new byte[]{1, 2, 3, 4, 5, 6}; byte[] readData = new byte[6]; ByteArrayChunkedEncoder byteArraySerializer = new ByteArrayChunkedEncoder( data, chunkSize ); ByteBuf buffer = byteArraySerializer.readChunk( buffers ); buffer.readBytes( readData, 0, chunkSize ); assertEquals( 0, buffer.readableBytes() ); buffer = byteArraySerializer.readChunk( buffers ); buffer.readBytes( readData, chunkSize, 1 ); assertArrayEquals( data, readData ); assertEquals( 0, buffer.readableBytes() ); assertNull( byteArraySerializer.readChunk( buffers ) ); }