protected final void encode(ChannelHandlerContext ctx,
                          Iterable<OFMessage> msgs,
                          ByteBuf out) {

        msgs.forEach(msg -> msg.writeTo(out));
    }
@Test
    public void testEncode() throws Exception {
        OFMessageEncoder encoder = OFMessageEncoder.getInstance();
        MockOfMessage message1 = new MockOfMessage();
        encoder.encode(null, Collections.singletonList(message1), buf);

        assertThat(buf.isReadable(), Matchers.is(true));
        byte[] channelBytes = new byte[buf.readableBytes()];
        buf.readBytes(channelBytes);
        String expectedListMessage = "message1 ";
        assertThat(channelBytes, is(expectedListMessage.getBytes()));
    }