当前位置: 首页>>代码示例>>Java>>正文


Java MockInvocation类代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:TpsLimitFilterTest.java

示例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;
        }
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:18,代码来源:TpsLimitFilterTest.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:11,代码来源:TpsLimitFilterTest.java

示例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());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:9,代码来源:ContextFilterTest.java

示例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());
    
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:13,代码来源:ConsumerContextFilterTest.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:ActiveLimitFilterTest.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:ActiveLimitFilterTest.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:28,代码来源:ActiveLimitFilterTest.java

示例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();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:DeprecatedFilterTest.java

示例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();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:AccessLogFilterTest.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:AccessLogFilterTest.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:AccessLogFilterTest.java


注:本文中的com.alibaba.dubbo.rpc.support.MockInvocation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。