Search in sources :

Example 36 with Invocation

use of com.alibaba.dubbo.rpc.Invocation in project dubbo by alibaba.

the class TpsLimitFilterTest method testWithoutCount.

@Test
public void testWithoutCount() throws Exception {
    URL url = URL.valueOf("test://test");
    url = url.addParameter(Constants.INTERFACE_KEY, "com.alibaba.dubbo.rpc.file.TpsService");
    url = url.addParameter(Constants.TPS_LIMIT_RATE_KEY, 5);
    Invoker<TpsLimitFilterTest> invoker = new MyInvoker<TpsLimitFilterTest>(url);
    Invocation invocation = new MockInvocation();
    filter.invoke(invoker, invocation);
}
Also used : MockInvocation(com.alibaba.dubbo.rpc.support.MockInvocation) Invocation(com.alibaba.dubbo.rpc.Invocation) MockInvocation(com.alibaba.dubbo.rpc.support.MockInvocation) MyInvoker(com.alibaba.dubbo.rpc.support.MyInvoker) URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Example 37 with Invocation

use of com.alibaba.dubbo.rpc.Invocation in project dubbo by alibaba.

the class RpcUtilsTest method testAttachInvocationIdIfAsync_normal.

/**
	 * 正常场景:url中表示了方法异步调用
	 * 验证:1. invocationId是否正常设置,2.幂等测试
	 */
@Test
public void testAttachInvocationIdIfAsync_normal() {
    URL url = URL.valueOf("dubbo://localhost/?test.async=true");
    Map<String, String> attachments = new HashMap<String, String>();
    attachments.put("aa", "bb");
    Invocation inv = new RpcInvocation("test", new Class[] {}, new String[] {}, attachments);
    RpcUtils.attachInvocationIdIfAsync(url, inv);
    long id1 = RpcUtils.getInvocationId(inv);
    RpcUtils.attachInvocationIdIfAsync(url, inv);
    long id2 = RpcUtils.getInvocationId(inv);
    //幂等操作验证
    Assert.assertTrue(id1 == id2);
    Assert.assertTrue(id1 >= 0);
    Assert.assertEquals("bb", attachments.get("aa"));
}
Also used : RpcInvocation(com.alibaba.dubbo.rpc.RpcInvocation) RpcInvocation(com.alibaba.dubbo.rpc.RpcInvocation) Invocation(com.alibaba.dubbo.rpc.Invocation) HashMap(java.util.HashMap) URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Aggregations

Invocation (com.alibaba.dubbo.rpc.Invocation)37 URL (com.alibaba.dubbo.common.URL)28 Test (org.junit.Test)27 Result (com.alibaba.dubbo.rpc.Result)13 RpcResult (com.alibaba.dubbo.rpc.RpcResult)12 Invoker (com.alibaba.dubbo.rpc.Invoker)11 RpcInvocation (com.alibaba.dubbo.rpc.RpcInvocation)11 DemoService (com.alibaba.dubbo.rpc.support.DemoService)11 MockInvocation (com.alibaba.dubbo.rpc.support.MockInvocation)11 MyInvoker (com.alibaba.dubbo.rpc.support.MyInvoker)11 RpcException (com.alibaba.dubbo.rpc.RpcException)9 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 MonitorService (com.alibaba.dubbo.monitor.MonitorService)2 MonitorFilter (com.alibaba.dubbo.monitor.support.MonitorFilter)2 LoadBalance (com.alibaba.dubbo.rpc.cluster.LoadBalance)2 StaticDirectory (com.alibaba.dubbo.rpc.cluster.directory.StaticDirectory)2 AbstractInvoker (com.alibaba.dubbo.rpc.protocol.AbstractInvoker)2 SocketTimeoutException (java.net.SocketTimeoutException)2 HashMap (java.util.HashMap)2