package com.yuzhouwan.site.service.rpc.core;

import com.yuzhouwan.site.api.rpc.service.IRPCService;
import com.yuzhouwan.site.api.rpc.service.Server;
import com.yuzhouwan.site.service.rpc.service.RPCServiceImpl;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Copyright @ 2018 yuzhouwan.com
 * All right reserved.
 * Function: RPC Tester
 *
 * @author Benedict Jin
 * @since 2016/9/1
 */
public class RPCTest {

    @Test
    public void rpc() throws Exception {

        Server server = new RPC.RPCServer();
        server.register(IRPCService.class, RPCServiceImpl.class);
        server.start();

        int count = 0, max = 5;
        while (!server.isRunning() && count < max) {
            Thread.sleep(10);
            count++;
        }
        IRPCService testServiceImpl = RPC.getProxy(IRPCService.class, "localhost", server.getPort());
        assertEquals("Hello, Benedict!", testServiceImpl.printHello("Benedict"));
        server.stop();  // System.exit(0);
    }
}

@@ -486,17 +486,16 @@
 ption %7B%0A
-%0A
         
@@ -509,16 +509,57 @@
 server =
+ null;%0A        try %7B%0A            server =
  new RPC
@@ -572,16 +572,20 @@
 rver();%0A
+    
         
@@ -642,32 +642,36 @@
 class);%0A        
+    
 server.start();%0A
@@ -679,16 +679,20 @@
         
+  
+  
 int coun
@@ -708,11 +708,16 @@
 x = 
-5;%0A
+20;%0A    
     
@@ -777,16 +777,20 @@
         
+    
 Thread.s
@@ -798,10 +798,9 @@
 eep(
-10
+5
 );%0A 
@@ -810,16 +810,20 @@
         
+ 
+   
 count++;
@@ -831,18 +831,26 @@
         
-%7D%0A
+    %7D%0A    
         
@@ -951,16 +951,20 @@
         
+    
 assertEq
@@ -1032,24 +1032,68 @@
 %22));%0A       
+ %7D finally %7B%0A            if (server != null)
  server.stop
@@ -1116,16 +1116,26 @@
 xit(0);%0A
+        %7D%0A
     %7D%0A%7D%0A

Improve RPT testcase