Search in sources :

Example 11 with MockInvocation

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

the class ActiveLimitFilterTest method testInvokeNoActives.

@Test
public void testInvokeNoActives() {
    URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1&actives=0");
    Invoker<ActiveLimitFilterTest> invoker = new MyInvoker<ActiveLimitFilterTest>(url);
    Invocation invocation = new MockInvocation();
    activeLimitFilter.invoke(invoker, invocation);
}
Also used : Invocation(org.apache.dubbo.rpc.Invocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) BlockMyInvoker(org.apache.dubbo.rpc.support.BlockMyInvoker) MyInvoker(org.apache.dubbo.rpc.support.MyInvoker) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Example 12 with MockInvocation

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

the class AccessLogFilterTest method testCustom.

@Test
public void testCustom() {
    URL url = URL.valueOf("test://test:11/test?accesslog=custom-access.log");
    Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(url);
    Invocation invocation = new MockInvocation();
    accessLogFilter.invoke(invoker, invocation);
}
Also used : Invocation(org.apache.dubbo.rpc.Invocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) MyInvoker(org.apache.dubbo.rpc.support.MyInvoker) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Example 13 with MockInvocation

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

the class ContextFilterTest method testWithAttachments.

@Test
public void testWithAttachments() {
    URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1");
    Invoker<DemoService> invoker = new MyInvoker<DemoService>(url);
    Invocation invocation = new MockInvocation();
    Result result = contextFilter.invoke(invoker, invocation);
    assertNull(RpcContext.getContext().getInvoker());
}
Also used : Invocation(org.apache.dubbo.rpc.Invocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) DemoService(org.apache.dubbo.rpc.support.DemoService) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) MyInvoker(org.apache.dubbo.rpc.support.MyInvoker) URL(org.apache.dubbo.common.URL) Result(org.apache.dubbo.rpc.Result) Test(org.junit.jupiter.api.Test)

Example 14 with MockInvocation

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

the class DefaultTPSLimiterTest method testIsAllowable.

@Test
public void testIsAllowable() throws Exception {
    Invocation invocation = new MockInvocation();
    URL url = URL.valueOf("test://test");
    url = url.addParameter(INTERFACE_KEY, "org.apache.dubbo.rpc.file.TpsService");
    url = url.addParameter(TPS_LIMIT_RATE_KEY, TEST_LIMIT_RATE);
    url = url.addParameter(TPS_LIMIT_INTERVAL_KEY, 1000);
    for (int i = 1; i <= TEST_LIMIT_RATE; i++) {
        Assertions.assertTrue(defaultTPSLimiter.isAllowable(url, invocation));
    }
}
Also used : Invocation(org.apache.dubbo.rpc.Invocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Example 15 with MockInvocation

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

the class DefaultTPSLimiterTest method testIsNotAllowable.

@Test
public void testIsNotAllowable() throws Exception {
    Invocation invocation = new MockInvocation();
    URL url = URL.valueOf("test://test");
    url = url.addParameter(INTERFACE_KEY, "org.apache.dubbo.rpc.file.TpsService");
    url = url.addParameter(TPS_LIMIT_RATE_KEY, TEST_LIMIT_RATE);
    url = url.addParameter(TPS_LIMIT_INTERVAL_KEY, 1000);
    for (int i = 1; i <= TEST_LIMIT_RATE + 1; i++) {
        if (i == TEST_LIMIT_RATE + 1) {
            Assertions.assertFalse(defaultTPSLimiter.isAllowable(url, invocation));
        } else {
            Assertions.assertTrue(defaultTPSLimiter.isAllowable(url, invocation));
        }
    }
}
Also used : Invocation(org.apache.dubbo.rpc.Invocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) MockInvocation(org.apache.dubbo.rpc.support.MockInvocation) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Aggregations

MockInvocation (org.apache.dubbo.rpc.support.MockInvocation)17 Test (org.junit.jupiter.api.Test)17 URL (org.apache.dubbo.common.URL)16 Invocation (org.apache.dubbo.rpc.Invocation)16 MyInvoker (org.apache.dubbo.rpc.support.MyInvoker)8 BlockMyInvoker (org.apache.dubbo.rpc.support.BlockMyInvoker)5 RpcException (org.apache.dubbo.rpc.RpcException)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Result (org.apache.dubbo.rpc.Result)3 RpcStatus (org.apache.dubbo.rpc.RpcStatus)2 DemoService (org.apache.dubbo.rpc.support.DemoService)2 RuntimeExceptionInvoker (org.apache.dubbo.rpc.support.RuntimeExceptionInvoker)2 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 Queue (java.util.Queue)1 AccessLogData (org.apache.dubbo.rpc.support.AccessLogData)1