### Question:
EchoOutputMessageFactory implements OFSerializer<EchoOutput> { @Override public void serialize(EchoOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(EchoOutput message, ByteBuf outBuffer);  }### Answer:
@Test public void testSerialize() throws Exception { EchoOutputBuilder builder = new EchoOutputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); builder.setData(data); EchoOutput message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); byte[] readData = new byte[serializedBuffer.readableBytes()]; serializedBuffer.readBytes(readData); Assert.assertArrayEquals("Wrong data", message.getData(), readData); }
@Test public void testSerialize() { EchoOutputMessageFactory serializer = new EchoOutputMessageFactory(); SerializerRegistry registry = new NetIdeSerializerRegistryImpl(); registry.init(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); Assert.assertArrayEquals("Wrong data", message.getData(), serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); }