### Question:
EchoInputMessageFactory implements OFSerializer<EchoInput> { @Override public void serialize(EchoInput 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(EchoInput message, ByteBuf outBuffer);  }### Answer:
@Test public void testV13() throws Exception { EchoInputBuilder eib = new EchoInputBuilder(); BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID); EchoInput ei = eib.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); echoFactory.serialize(ei, out); BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8); }
@Test public void testV10() throws Exception { EchoInputBuilder eib = new EchoInputBuilder(); BufferHelper.setupHeader(eib, EncodeConstants.OF10_VERSION_ID); EchoInput ei = eib.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); echoFactory.serialize(ei, out); BufferHelper.checkHeaderV10(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8); }
@Test public void testData() throws Exception{ byte[] dataToTest = new byte[]{91,92,93,94,95,96,97,98}; EchoInputBuilder eib = new EchoInputBuilder(); BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID); eib.setData(dataToTest); EchoInput ei = eib.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); echoFactory.serialize(ei, out); BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8+dataToTest.length); byte[] outData = new byte[dataToTest.length]; out.readBytes(outData); Assert.assertArrayEquals("Wrong - different output data.", dataToTest, outData); out.release(); }