@Test
public void testEncode() {

    InetSocketAddress recipient = SocketUtils.socketAddress("127.0.0.1", 10000);
    InetSocketAddress sender = SocketUtils.socketAddress("127.0.0.1", 20000);
    assertTrue(channel.writeOutbound(
            new DefaultAddressedEnvelope<String, InetSocketAddress>("netty", recipient, sender)));
    DatagramPacket packet = channel.readOutbound();
    try {
        assertEquals("netty", packet.content().toString(CharsetUtil.UTF_8));
        assertEquals(recipient, packet.recipient());
        assertEquals(sender, packet.sender());
    } finally {
        packet.release();
    }
}