@Test
    public void testConnClose() throws InterruptedException, RemotingException {
        client.getConnection(addr, 1000);

        RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
        for (int i = 0; i < invokeTimes; i++) {
            try {
                // only when client invoked, the remote address can be get by UserProcessor
                // otherwise, please use ConnectionEventProcessor
                String remoteAddr = serverUserProcessor.getRemoteAddr();
                Assert.assertNull(remoteAddr);
                remoteAddr = serverConnectProcessor.getRemoteAddr();
                Assert.assertNotNull(remoteAddr);
                Connection serverConn = serverConnectProcessor.getConnection();
                String clientres = (String) server.getRpcServer().invokeSync(remoteAddr, req, 1000);
                Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);
                Assert.assertTrue(server.getRpcServer().isConnected(remoteAddr));
                serverConn.close();
                Thread.sleep(100);
                Assert.assertFalse(server.getRpcServer().isConnected(remoteAddr));
                clientres = (String) server.getRpcServer().invokeSync(remoteAddr, req, 1000);
                Assert.fail("Connection removed! Should throw exception here.");
            } catch (RemotingException e) {
                logger.error(e.getMessage());
                Assert.assertTrue(e.getMessage().contains("not connected yet!"));
            }
        }

        Assert.assertTrue(serverConnectProcessor.isConnected());
        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
        Assert.assertEquals(0, serverUserProcessor.getInvokeTimes());
        Assert.assertEquals(invokeTimes, clientUserProcessor.getInvokeTimes());
    }
Test rpc server invoke exception

@author xiaomin.cxm
@version $Id: ServerInvokeExceptionTest.java, v 0.1 Apr 14, 2016 10:00:48 AM xiaomin.cxm Exp $
src/test/java/com/alipay/remoting/rpc/exception/ServerInvokeExceptionTest.java