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

        Connection clientConn = client.createStandaloneConnection(ip, port, 1000);
        String remote = RemotingUtil.parseRemoteAddress(clientConn.getChannel());
        String local = RemotingUtil.parseLocalAddress(clientConn.getChannel());
        logger.warn("Client say local:" + local);
        logger.warn("Client say remote:" + remote);

        for (int i = 0; i < invokeTimes; i++) {
            byte testCodec = (byte) i;
            InvokeContext invokeContext = new InvokeContext();
            invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, testCodec);

            RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR);
            String serverres = (String) client.invokeSync(clientConn, req1, invokeContext, 1000);
            Assert.assertEquals(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM");

            Assert.assertEquals(testCodec, s1.getContentSerializer());
            Assert.assertEquals(testCodec, s2.getContentSerializer());

            invokeContext.clear();
            invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, (byte) (testCodec + 1));
            s1.reset();
            s2.reset();

            Assert.assertNotNull(serverConnectProcessor.getConnection());
            // only when client invoked, the remote address can be get by UserProcessor
            // otherwise, please use ConnectionEventProcessor
            String remoteAddr = serverUserProcessor.getRemoteAddr();
            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
            String clientres = (String) server.getRpcServer().invokeSync(remoteAddr, req,
                invokeContext, 1000);
            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR + "RANDOM");

            Assert.assertEquals(testCodec + 1, s1.getContentSerializer());
            Assert.assertEquals(testCodec + 1, s2.getContentSerializer());
        }

        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