use of com.alibaba.com.caucho.hessian.HessianException in project dubbo by alibaba.
the class ExceptionFilterTest method testConvertToRunTimeException.
@SuppressWarnings("unchecked")
@Test
public void testConvertToRunTimeException() throws Exception {
ExceptionFilter exceptionFilter = new ExceptionFilter();
RpcInvocation invocation = new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[] { String.class }, new Object[] { "world" });
AppResponse mockRpcResult = new AppResponse();
mockRpcResult.setException(new HessianException("hessian"));
Result mockAsyncResult = AsyncRpcResult.newDefaultAsyncResult(mockRpcResult, invocation);
Invoker<DemoService> invoker = mock(Invoker.class);
when(invoker.invoke(invocation)).thenReturn(mockAsyncResult);
when(invoker.getInterface()).thenReturn(DemoService.class);
Result asyncResult = exceptionFilter.invoke(invoker, invocation);
AppResponse appResponse = (AppResponse) asyncResult.get();
exceptionFilter.onResponse(appResponse, invoker, invocation);
Assertions.assertFalse(appResponse.getException() instanceof HessianException);
Assertions.assertEquals(appResponse.getException().getClass(), RuntimeException.class);
}
Aggregations