### Question:
NettyProtocolEncoder extends OneToOneEncoder { @Override protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { RpcDataPack dataPack = (RpcDataPack) msg; List<ByteBuffer> origs = dataPack.getDataLst(); List<ByteBuffer> bbs = new ArrayList<>(origs.size() * 2 + 1); bbs.add(getPackHeader(dataPack)); for (ByteBuffer b : origs) { bbs.add(getLengthHeader(b)); bbs.add(b); } return ChannelBuffers.wrappedBuffer(bbs.toArray(new ByteBuffer[bbs.size()])); }    }### Answer:
@Test public void encode() { NettyProtocolEncoder nettyProtocolEncoder = new NettyProtocolEncoder(); RpcDataPack obj = new RpcDataPack(); obj.setSerialNo(123); List<ByteBuffer> dataList = new LinkedList<>(); dataList.add(ByteBuffer.wrap("abc".getBytes())); dataList.add(ByteBuffer.wrap("def".getBytes())); obj.setDataLst(dataList); try { Object result = nettyProtocolEncoder.encode(null, null, obj); ChannelBuffer buf = (ChannelBuffer) result; int i = buf.readInt(); i = buf.readInt(); Assert.assertEquals(123, i); } catch (Exception e) { e.printStackTrace(); } }