### Question:
FixLengthDecoder extends ByteToMessageDecoder { @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { while (in.readableBytes() >= length){ ByteBuf byt = in.readBytes(length) ; out.add(byt) ; } } FixLengthDecoder(int length);   }### Answer:
@Test public void decode() throws Exception { ByteBuf buf = Unpooled.buffer(); for (int i = 0; i < 9; i++) { buf.writeByte(i); } ByteBuf duplicate = buf.duplicate(); EmbeddedChannel channel = new EmbeddedChannel(new FixLengthDecoder(3)); channel.writeInbound(buf.retain()); channel.finish(); ByteBuf read = channel.readInbound(); Assert.assertEquals(duplicate.readSlice(3), read); read = channel.readInbound(); Assert.assertEquals(duplicate.readSlice(3), read); read = channel.readInbound(); Assert.assertEquals(duplicate.readSlice(3), read); read.release(); }