Search in sources :

Example 1 with RuntimeExceptionInvoker

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

the class ActiveLimitFilterTest method testInvokeRuntimeExceptionWithActiveCountMatch.

@Test
public void testInvokeRuntimeExceptionWithActiveCountMatch() {
    URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1&actives=0");
    Invoker<ActiveLimitFilterTest> invoker = new RuntimeExceptionInvoker(url);
    Invocation invocation = new MockInvocation();
    RpcStatus count = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName());
    int beforeExceptionActiveCount = count.getActive();
    try {
        activeLimitFilter.invoke(invoker, invocation);
    } catch (RuntimeException ex) {
        activeLimitFilter.onError(ex, invoker, invocation);
        int afterExceptionActiveCount = count.getActive();
        assertEquals(beforeExceptionActiveCount, afterExceptionActiveCount, "After exception active count should be same");
    }
}
Also used : Invocation(org.apache.dubbo.rpc.Invocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) RuntimeExceptionInvoker(org.apache.dubbo.rpc.support.RuntimeExceptionInvoker) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) RpcStatus(org.apache.dubbo.rpc.RpcStatus) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Example 2 with RuntimeExceptionInvoker

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

the class ActiveLimitFilterTest method testInvokeRuntimeException.

@Test
public void testInvokeRuntimeException() {
    Assertions.assertThrows(RuntimeException.class, () -> {
        URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1&actives=0");
        Invoker<ActiveLimitFilterTest> invoker = new RuntimeExceptionInvoker(url);
        Invocation invocation = new MockInvocation();
        RpcStatus count = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName());
        int beforeExceptionActiveCount = count.getActive();
        activeLimitFilter.invoke(invoker, invocation);
        int afterExceptionActiveCount = count.getActive();
        assertEquals(beforeExceptionActiveCount, afterExceptionActiveCount, "After exception active count should be same");
    });
}
Also used : Invocation(org.apache.dubbo.rpc.Invocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) RuntimeExceptionInvoker(org.apache.dubbo.rpc.support.RuntimeExceptionInvoker) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) RpcStatus(org.apache.dubbo.rpc.RpcStatus) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Aggregations

URL (org.apache.dubbo.common.URL)2 Invocation (org.apache.dubbo.rpc.Invocation)2 RpcStatus (org.apache.dubbo.rpc.RpcStatus)2 MockInvocation (org.apache.dubbo.rpc.support.MockInvocation)2 RuntimeExceptionInvoker (org.apache.dubbo.rpc.support.RuntimeExceptionInvoker)2 Test (org.junit.jupiter.api.Test)2