### Question:
PacketDecoder extends MessageToMessageDecoder<DatagramPacket> { public DiscoveryEvent decodeMessage(ChannelHandlerContext ctx, byte[] encoded, InetSocketAddress sender) { try { PeerDiscoveryMessage msg = MessageDecoder.decode(encoded); return new DiscoveryEvent(msg, sender); } catch (Exception e) { logger.error("Exception processing inbound message from {} : {}", ctx.channel().remoteAddress(), Hex.toHexString(encoded), e); throw e; } }  @Override void decode(ChannelHandlerContext ctx, DatagramPacket packet, List<Object> out); DiscoveryEvent decodeMessage(ChannelHandlerContext ctx, byte[] encoded, InetSocketAddress sender);  }### Answer:
@Test(expected = PeerDiscoveryException.class) public void decodeInvalidMessage() throws Exception { PacketDecoder decoder = new PacketDecoder(); ChannelHandlerContext ctx = Mockito.mock(ChannelHandlerContext.class); InetSocketAddress sender = new InetSocketAddress("localhost", 44035); Channel channel = Mockito.mock(Channel.class); Mockito.when(ctx.channel()).thenReturn(channel); Mockito.when(channel.remoteAddress()).thenReturn(sender); decoder.decodeMessage(ctx, new byte[] {11}, sender); Assert.fail(); }