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);
}
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"));
}
Aggregations