### Question:
ByteArrayEncoder extends MessageToMessageEncoder<byte[]> { @Override protected void encode(ChannelHandlerContext ctx, byte[] msg, List<Object> out) throws Exception { out.add(Unpooled.wrappedBuffer(msg)); }    }### Answer:
@Test public void testEncode() { byte[] b = new byte[2048]; new Random().nextBytes(b); ch.writeOutbound(b); assertThat((ByteBuf) ch.readOutbound(), is(wrappedBuffer(b))); }
@Test public void testEncode() { byte[] b = new byte[2048]; new Random().nextBytes(b); ch.writeOutbound(b); ByteBuf encoded = (ByteBuf) ch.readOutbound(); assertThat(encoded, is(wrappedBuffer(b))); encoded.release(); }
@Test public void testEncode() { byte[] b = new byte[2048]; new Random().nextBytes(b); ch.writeOutbound(b); ByteBuf encoded = ch.readOutbound(); assertThat(encoded, is(wrappedBuffer(b))); encoded.release(); }