com.alibaba.dubbo.rpc.support.MyInvoker Java Examples

The following examples show how to use com.alibaba.dubbo.rpc.support.MyInvoker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TpsLimitFilterTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@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;
        }
    }
}
 
Example #2
Source File: TpsLimitFilterTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@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;
        }
    }
}
 
Example #3
Source File: TpsLimitFilterTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@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;
        }
    }
}
 
Example #4
Source File: TpsLimitFilterTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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;
        }
    }
}
 
Example #5
Source File: TpsLimitFilterTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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;
        }
    }
}
 
Example #6
Source File: TpsLimitFilterTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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;
        }
    }
}
 
Example #7
Source File: ConsumerContextFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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());
    
}
 
Example #8
Source File: AccessLogFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #9
Source File: TpsLimitFilterTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #10
Source File: AccessLogFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: AccessLogFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #12
Source File: DeprecatedFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #13
Source File: ActiveLimitFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #14
Source File: ActiveLimitFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: ActiveLimitFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #16
Source File: DeprecatedFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #17
Source File: AccessLogFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #18
Source File: ConsumerContextFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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());
    
}
 
Example #19
Source File: ActiveLimitFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #20
Source File: ConsumerContextFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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());
    
}
 
Example #21
Source File: ContextFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #22
Source File: TpsLimitFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #23
Source File: AccessLogFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #24
Source File: AccessLogFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #25
Source File: AccessLogFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #26
Source File: DeprecatedFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #27
Source File: ActiveLimitFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #28
Source File: ActiveLimitFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #29
Source File: ActiveLimitFilterTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #30
Source File: AccessLogFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}