Example #1
0
  @Test
  public void testUnknownException() throws Throwable {

    // create client service
    Service clientService =
        ProxyUtil.createClientProxy(
            cl, Service.class, false, jsonRpcClient, clientInputStream, clientOutputStream);

    jsonRpcServer.setErrorResolver(AnnotationsErrorResolver.INSTANCE);

    mockCtx.checking(
        new Expectations() {
          {
            one(serviceMock).unresolvedExceptionThrown();
            will(throwException(new IllegalArgumentException("testing")));
            one(serviceMock).undelcaredExceptionThrown();
            will(throwException(new IllegalArgumentException("testing")));
          }
        });

    try {
      clientService.unresolvedExceptionThrown();
      fail("Expecting exception");
    } catch (Throwable t) {
      assertTrue(JsonRpcClientException.class.isInstance(t));
    }

    try {
      clientService.undelcaredExceptionThrown();
      fail("Expecting exception");
    } catch (Throwable t) {
      assertTrue(JsonRpcClientException.class.isInstance(t));
    }
  }
Example #2
0
 @Override
 public void run() {
   keepRunning.set(true);
   while (keepRunning.get()) {
     try {
       if (ips.available() > 0) {
         jsonRpcServer.handle(ips, ops);
       }
     } catch (Exception e) {
       e.printStackTrace();
       return;
     }
     synchronized (startLock) {
       startLock.notify();
     }
   }
 }