   dubbo-rpc/dubbo-rpc-rmi
   dubbo-rpc/dubbo-rpc-thrift
   dubbo-rpc/dubbo-rpc-webservice/
protocol.writeMessageEnd();
        protocol.getTransport().flush();
        int oldIndex = messageLength = bos.size();
        try {
            bos.setWriteIndex(ThriftCodec.MESSAGE_LENGTH_INDEX);
            protocol.writeI32(messageLength);
            bos.setWriteIndex(ThriftCodec.MESSAGE_HEADER_LENGTH_INDEX);
            protocol.writeI16((short) (0xffff & headerLength));
        } finally {
            bos.setWriteIndex(oldIndex);
        }
        
        byte[] buf = new byte[4 + bos.size()];
        System.arraycopy(bos.toByteArray(), 0, buf, 4, bos.size());
        ChannelBuffer bis = ChannelBuffers.wrappedBuffer(buf);
        Object obj = codec.decode((Channel) null, bis);
        Assert.assertNotNull(obj);
        Assert.assertEquals(true, obj instanceof Response);
        Response response = (Response) obj;
        Assert.assertEquals(request.getId(), response.getId());
        Assert.assertTrue(response.getResult() instanceof RpcResult);
        RpcResult result = (RpcResult) response.getResult();
        Assert.assertTrue(result.getResult() instanceof String);
        Assert.assertEquals(methodResult.success, result.getResult());
    }
    @Test
    public void testDecodeExceptionResponse() throws Exception {
        URL url = URL.valueOf(ThriftProtocol.NAME + "://127.0.0.1:40880/" + Demo.class.getName());
        Channel channel = new MockedChannel(url);
        RandomAccessByteArrayOutputStream bos = new RandomAccessByteArrayOutputStream(128);