@Test
    public void testSync() throws InterruptedException {
        MultiInterestBaseRequestBody req = new RequestBodyC1(1, "hello world sync--c1");
        MultiInterestBaseRequestBody req2 = new RequestBodyC2(4, "hello world sync--c2");
        for (int i = 0; i < invokeTimes; i++) {
            try {
                String res = (String) client.invokeSync(addr, req, 3000);
                logger.warn("Result received in sync: " + res);
                Assert.assertEquals(RequestBodyC1.DEFAULT_SERVER_RETURN_STR, res);
            } catch (RemotingException e) {
                String errMsg = "RemotingException caught in sync!";
                logger.error(errMsg, e);
                Assert.fail(errMsg);
            } catch (InterruptedException e) {
                String errMsg = "InterruptedException caught in sync!";
                logger.error(errMsg, e);
                Assert.fail(errMsg);
            }
        }
        for (int i = 0; i < invokeTimes; i++) {
            try {
                String res = (String) client.invokeSync(addr, req2, 3000);
                logger.warn("Result received in sync: " + res);
                Assert.assertEquals(RequestBodyC2.DEFAULT_SERVER_RETURN_STR, res);
            } catch (RemotingException e) {
                String errMsg = "RemotingException caught in sync!";
                logger.error(errMsg, e);
                Assert.fail(errMsg);
            } catch (InterruptedException e) {
                String errMsg = "InterruptedException caught in sync!";
                logger.error(errMsg, e);
                Assert.fail(errMsg);
            }
        }

        Assert.assertTrue(serverConnectProcessor.isConnected());
        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimesC1());
        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimesC2());
    }
@antuor muyun.cyt (muyun.cyt@antfin.com)  2018/7/5   11:20 AM
src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/BasicUsage_MultiInterestUserProcessorTest.java