DatagramPacketDecoder extends MessageToMessageDecoder<DatagramPacket> { @Override protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) throws Exception { decoder.decode(ctx, msg.content(), out); } DatagramPacketDecoder(MessageToMessageDecoder<ByteBuf> decoder); @Override boolean acceptInboundMessage(Object msg); @Override void channelRegistered(ChannelHandlerContext ctx); @Override void channelUnregistered(ChannelHandlerContext ctx); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelHandlerContext ctx); @Override void channelReadComplete(ChannelHandlerContext ctx); @Override void userEventTriggered(ChannelHandlerContext ctx, Object evt); @Override void channelWritabilityChanged(ChannelHandlerContext ctx); @Override void exceptionCaught(ChannelHandlerContext ctx, Throwable cause); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void handlerRemoved(ChannelHandlerContext ctx); @Override boolean isSharable();  }
@Test public void testDecode() { InetSocketAddress recipient = SocketUtils.socketAddress("127.0.0.1", 10000); InetSocketAddress sender = SocketUtils.socketAddress("127.0.0.1", 20000); ByteBuf content = Unpooled.wrappedBuffer("netty".getBytes(CharsetUtil.UTF_8)); assertTrue(channel.writeInbound(new DatagramPacket(content, recipient, sender))); assertEquals("netty", channel.readInbound()); }