Search in sources :

Example 1 with LocalException

use of org.apache.dubbo.rpc.support.LocalException in project dubbo by alibaba.

the class ExceptionFilterTest method testRuntimeException.

@SuppressWarnings("unchecked")
@Test
public void testRuntimeException() {
    ExceptionFilter exceptionFilter = new ExceptionFilter();
    RpcInvocation invocation = new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[] { String.class }, new Object[] { "world" });
    AppResponse appResponse = new AppResponse();
    appResponse.setException(new LocalException("localException"));
    Invoker<DemoService> invoker = mock(Invoker.class);
    when(invoker.invoke(invocation)).thenReturn(appResponse);
    when(invoker.getInterface()).thenReturn(DemoService.class);
    Result newResult = exceptionFilter.invoke(invoker, invocation);
    Assertions.assertEquals(appResponse.getException(), newResult.getException());
}
Also used : RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) LocalException(org.apache.dubbo.rpc.support.LocalException) AppResponse(org.apache.dubbo.rpc.AppResponse) DemoService(org.apache.dubbo.rpc.support.DemoService) AsyncRpcResult(org.apache.dubbo.rpc.AsyncRpcResult) Result(org.apache.dubbo.rpc.Result) Test(org.junit.jupiter.api.Test)

Aggregations

AppResponse (org.apache.dubbo.rpc.AppResponse)1 AsyncRpcResult (org.apache.dubbo.rpc.AsyncRpcResult)1 Result (org.apache.dubbo.rpc.Result)1 RpcInvocation (org.apache.dubbo.rpc.RpcInvocation)1 DemoService (org.apache.dubbo.rpc.support.DemoService)1 LocalException (org.apache.dubbo.rpc.support.LocalException)1 Test (org.junit.jupiter.api.Test)1