org.apache.dubbo.rpc.RpcResult Java Examples

The following examples show how to use org.apache.dubbo.rpc.RpcResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DubboFallbackRegistryTest.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomFallback() {
    BlockException ex = new FlowException("xxx");
    DubboFallbackRegistry.setConsumerFallback(
        (invoker, invocation, e) -> new RpcResult("Error: " + e.getClass().getName()));
    Result result = DubboFallbackRegistry.getConsumerFallback()
        .handle(null, null, ex);
    Assert.assertFalse("The invocation should not fail", result.hasException());
    Assert.assertEquals("Error: " + ex.getClass().getName(), result.getValue());
}
 
Example #2
Source File: DubboFallbackRegistryTest.java    From dubbo-sentinel-support with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomFallback() {
    BlockException ex = new FlowException("xxx");
    DubboFallbackRegistry.setConsumerFallback(
        (invoker, invocation, e) -> new RpcResult("Error: " + e.getClass().getName()));
    Result result = DubboFallbackRegistry.getConsumerFallback()
        .handle(null, null, ex);
    Assert.assertFalse("The invocation should not fail", result.hasException());
    Assert.assertEquals("Error: " + ex.getClass().getName(), result.getValue());
}