@Test
    public void testFuture() throws InterruptedException {
        NormalRequestBodyCustomSerializer s1 = new NormalRequestBodyCustomSerializer();
        NormalStringCustomSerializer s2 = new NormalStringCustomSerializer();
        CustomSerializerManager.registerCustomSerializer(RequestBody.class.getName(), s1);
        CustomSerializerManager.registerCustomSerializer(String.class.getName(), s2);

        RequestBody req = new RequestBody(2, "hello world future");
        for (int i = 0; i < invokeTimes; i++) {
            try {
                byte testCodec = (byte) i;
                InvokeContext invokeContext = new InvokeContext();
                invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, testCodec);

                RpcResponseFuture future = client.invokeWithFuture(addr, req, invokeContext, 3000);
                String res = (String) future.get();
                Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM", res);

                Assert.assertEquals(testCodec, s1.getContentSerializer());
                Assert.assertEquals(testCodec, s2.getContentSerializer());
            } catch (RemotingException e) {
                String errMsg = "RemotingException caught in future!";
                logger.error(errMsg, e);
                Assert.fail(errMsg);
            } catch (InterruptedException e) {
                String errMsg = "InterruptedException caught in future!";
                logger.error(errMsg, e);
                Assert.fail(errMsg);
            }
        }

        Assert.assertTrue(serverConnectProcessor.isConnected());
        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
    }
test custom serializer codec

@author tsui
@version $Id: CustomSerializerCodecTest.java, v 0.1 2017-03-13 17:14 tsui Exp $
src/test/java/com/alipay/remoting/rpc/serializer/CustomSerializerCodecTest.java