AbstractAcceptance implements Acceptance { @Override public Response handle(Request request) { Result result = null; Call call = request.getCall(); try { Object resObj = serviceInvoker.invoke(call.getService(), call.getGroup(), call.getMethod(), call.getTimeout(), call.getParams(), call.getParamTypes()); result = new Result(200, resObj); } catch (RpcException e) { result = new Result(e.getCode(), e.getMessage()); } catch (NoSuchMethodException e) { result = new Result(405, "unkown method: [" + call.getGroup() + "]" + e.getMessage()); } catch (IllegalArgumentException | IllegalAccessException e) { String message = "illegal access: [" + call.getGroup() + "]" + call.getService() + "." + call.getMethod() + "(): " + e.getMessage(); result = new Result(502, message); } catch (InvocationTargetException e) { Throwable t = getTargetException(e); String message = "service exception: " + call.getGroup() + "]" + call.getService() + "." + call.getMethod() + "(): " + t.getMessage(); result = new Result(500, message); } catch (Throwable e) { String message = "service exception: " + call.getGroup() + "]" + call.getService() + "." + call.getMethod() + "(): " + e.getMessage(); result = new Result(509, message); } return new Response(request.getMessageId(), request.getSerializeType(), result); } AbstractAcceptance(ServiceInvoker serviceInvoker, TransportConfig transportConfig,
            InetSocketAddress serviceAddress); @Override Response handle(Request request);  }
@Test public void testHandle() { Request request = new Request(1234, SerializeType.JACKSON, new Call(DemoService.class.getName(), "", 3000, "hello", new Object[] { "dinstone" }, new Class<?>[] { String.class })); Response response = acceptance.handle(request); System.out.println(response); assertEquals(response.getResult().getCode(), 200); }
@Test public void testHandle1() { Request request = new Request(12345, SerializeType.JACKSON, new Call(DemoService.class.getName(), "", 3000, "hello", new Object[] { "guojinfei", 34 }, new Class<?>[] { String.class, int.class })); Response response = acceptance.handle(request); System.out.println(response); assertEquals(response.getResult().getCode(), 200); }
@Test public void testHandle2() { Request request = new Request(12345, SerializeType.JACKSON, new Call(DemoService.class.getName(), "", 3000, "hello", new Object[] { "guojinfei", (int) 34 }, null)); Response response = acceptance.handle(request); System.out.println(response); assertEquals(response.getResult().getCode(), 405); }
@Test public void testHandle3() { Request request = new Request(12345, SerializeType.JACKSON, new Call(DemoService.class.getName(), "", 3000, "hello", null, null)); Response response = acceptance.handle(request); System.out.println(response); assertEquals(response.getResult().getCode(), 405); }