本文整理汇总了Java中com.alibaba.dubbo.rpc.support.MockInvocation类的典型用法代码示例。如果您正苦于以下问题:Java MockInvocation类的具体用法?Java MockInvocation怎么用?Java MockInvocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MockInvocation类属于com.alibaba.dubbo.rpc.support包,在下文中一共展示了MockInvocation类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFail
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test(expected = RpcException.class)
public void testFail() 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();
for (int i = 0; i < 10; i++) {
try {
filter.invoke(invoker, invocation);
} catch (Exception e) {
assertTrue(i >= 5);
throw e;
}
}
}
示例2: testFail
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test(expected = RpcException.class)
public void testFail() 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();
for (int i = 0; i < 10; i++) {
try {
filter.invoke(invoker, invocation);
} catch (Exception e) {
assertTrue(i >= 5);
throw e;
}
}
}
示例3: testWithoutCount
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@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);
}
示例4: testWithAttachments
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@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());
}
示例5: testSetContext
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test
public void testSetContext(){
URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1");
Invoker<DemoService> invoker = new MyInvoker<DemoService>(url);
Invocation invocation = new MockInvocation();
consumerContextFilter.invoke(invoker, invocation);
assertEquals(invoker,RpcContext.getContext().getInvoker());
assertEquals(invocation,RpcContext.getContext().getInvocation());
assertEquals(NetUtils.getLocalHost() + ":0",RpcContext.getContext().getLocalAddressString());
assertEquals("test:11",RpcContext.getContext().getRemoteAddressString());
}
示例6: testInvokeNoActives
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@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);
}
示例7: testInvokeLessActives
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test
public void testInvokeLessActives() {
URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1&actives=10");
Invoker<ActiveLimitFilterTest> invoker = new MyInvoker<ActiveLimitFilterTest>(url);
Invocation invocation = new MockInvocation();
activeLimitFilter.invoke(invoker, invocation);
}
示例8: testInvokeGreaterActives
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test
public void testInvokeGreaterActives() {
URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1&actives=1&timeout=1");
final Invoker<ActiveLimitFilterTest> invoker = new MyInvoker<ActiveLimitFilterTest>(url);
final Invocation invocation = new MockInvocation();
for (int i = 0; i < 100; i++) {
Thread thread = new Thread(new Runnable() {
public void run() {
for (int i = 0; i < 100; i++) {
try {
activeLimitFilter.invoke(invoker, invocation);
} catch (RpcException expected) {
count++;
}
}
}
});
thread.start();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertNotSame(0, count);
}
示例9: testDeprecatedFilter
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test
public void testDeprecatedFilter() {
URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&echo." + Constants.DEPRECATED_KEY + "=true");
LogUtil.start();
deprecatedFilter.invoke(new MyInvoker<DemoService>(url), new MockInvocation());
assertEquals(1,
LogUtil.findMessage("The service method com.alibaba.dubbo.rpc.support.DemoService.echo(String) is DEPRECATED"));
LogUtil.stop();
}
示例10: testInvokeException
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test
public void testInvokeException() {
Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(null);
Invocation invocation = new MockInvocation();
LogUtil.start();
accessLogFilter.invoke(invoker, invocation);
assertEquals(1, LogUtil.findMessage("Exception in AcessLogFilter of service"));
LogUtil.stop();
}
示例11: testDefault
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test
public void testDefault() {
URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1");
Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(url);
Invocation invocation = new MockInvocation();
accessLogFilter.invoke(invoker, invocation);
}
示例12: testCustom
import com.alibaba.dubbo.rpc.support.MockInvocation; //导入依赖的package包/类
@Test
public void testCustom() {
URL url = URL.valueOf("test://test:11/test?accesslog=alibaba");
Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(url);
Invocation invocation = new MockInvocation();
accessLogFilter.invoke(invoker, invocation);
}