Package com.alibaba.dubbo.rpc

Examples of com.alibaba.dubbo.rpc.Invocation


   * 验证:当原始acctachment为null时,不能报错.
   */
  @Test
  public void testAttachInvocationIdIfAsync_nullAttachments() {
    URL url = URL.valueOf("dubbo://localhost/?test.async=true");
    Invocation inv = new RpcInvocation("test", new Class[]{}, new String[]{});
    RpcUtils.attachInvocationIdIfAsync(url, inv);
    Assert.assertTrue(RpcUtils.getInvocationId(inv) >= 0l);
  }
View Full Code Here


    Filter echoFilter = new EchoFilter();

    @SuppressWarnings("unchecked")
    @Test
    public void testEcho() {
        Invocation invocation = EasyMock.createMock(Invocation.class);
        EasyMock.expect(invocation.getMethodName()).andReturn("$echo").anyTimes();
        EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Enum.class }).anyTimes();
        EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes();
        EasyMock.expect(invocation.getAttachments()).andReturn(null).anyTimes();
        EasyMock.replay(invocation);
        Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
        EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
        EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
        RpcResult result = new RpcResult();
View Full Code Here

   * 验证:acctachment中没有添加id属性
   */
  @Test
  public void testAttachInvocationIdIfAsync_forceNotAttache() {
    URL url = URL.valueOf("dubbo://localhost/?test.async=true&"+Constants.AUTO_ATTACH_INVOCATIONID_KEY+"=false");
    Invocation inv = new RpcInvocation("test", new Class[]{}, new String[]{});
    RpcUtils.attachInvocationIdIfAsync(url, inv);
    Assert.assertNull(RpcUtils.getInvocationId(inv));
  }
View Full Code Here

   * 验证:acctachment中有添加id属性
   */
  @Test
  public void testAttachInvocationIdIfAsync_forceAttache() {
    URL url = URL.valueOf("dubbo://localhost/?"+Constants.AUTO_ATTACH_INVOCATIONID_KEY+"=true");
    Invocation inv = new RpcInvocation("test", new Class[]{}, new String[]{});
    RpcUtils.attachInvocationIdIfAsync(url, inv);
    Assert.assertNotNull(RpcUtils.getInvocationId(inv));
  }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Test
    public void testNonEcho() {
        Invocation invocation = EasyMock.createMock(Invocation.class);
        EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes();
        EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Enum.class }).anyTimes();
        EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes();
        EasyMock.expect(invocation.getAttachments()).andReturn(null).anyTimes();
        EasyMock.replay(invocation);
        Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
        EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
        EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
        RpcResult result = new RpcResult();
View Full Code Here

    Filter     consumerContextFilter = new ConsumerContextFilter();
    @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());
View Full Code Here

    @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);
    }
View Full Code Here

    @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);
    }
View Full Code Here

    @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++) {
View Full Code Here

    @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());
    }
View Full Code Here

TOP

Related Classes of com.alibaba.dubbo.rpc.Invocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.