@Test
    public void testServerSyncUsingConnection() throws Exception {
        Connection clientConn = client.createStandaloneConnection(ip, port, 1000);

        for (int i = 0; i < invokeTimes; i++) {
            InvokeContext invokeContext = new InvokeContext();
            invokeContext.put(TESTKEY, "TESTVALUE");
            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);

            invokeContext.clear();
            invokeContext.put(TESTKEY, "TESTVALUE");
            Assert.assertNotNull(serverConnectProcessor.getConnection());
            Connection serverConn = serverConnectProcessor.getConnection();
            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
            String clientres = (String) server.getRpcServer().invokeSync(serverConn, req,
                invokeContext, 1000);
            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);

            Assert.assertEquals("127.0.0.1", invokeContext.get(InvokeContext.SERVER_LOCAL_IP));
            Assert.assertEquals("127.0.0.1", invokeContext.get(InvokeContext.SERVER_REMOTE_IP));
            Assert.assertNotNull(invokeContext.get(InvokeContext.SERVER_LOCAL_PORT));
            Assert.assertNotNull(invokeContext.get(InvokeContext.SERVER_REMOTE_PORT));
            Assert.assertEquals(invokeContext.get(TESTKEY), "TESTVALUE");
        }

        Assert.assertTrue(serverConnectProcessor.isConnected());
        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
    }
basic usage test with invoke context

@author xiaomin.cxm
@version $Id: BasicUsage_InvokeContext_resuable_Test.java, v 0.1 Apr 6, 2016 8:58:36 PM xiaomin.cxm Exp $
src/test/java/com/alipay/remoting/rpc/invokecontext/BasicUsage_InvokeContext_resuable_Test.java