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


Java RpcInvocation.setMethodName方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.rpc.RpcInvocation.setMethodName方法的典型用法代码示例。如果您正苦于以下问题:Java RpcInvocation.setMethodName方法的具体用法?Java RpcInvocation.setMethodName怎么用?Java RpcInvocation.setMethodName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.rpc.RpcInvocation的用法示例。


在下文中一共展示了RpcInvocation.setMethodName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMockInvokerFromOverride_Invoke_check_ListPojo

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListPojo(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getUsers.mock","force:return [{id:1, name:\"hi1\"}, {id:2, name:\"hi2\"}]")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getUsers");
       Result ret = cluster.invoke(invocation);
       List<User> rl = (List<User>)ret.getValue();
       System.out.println(rl);
       Assert.assertEquals(2, rl.size());
       Assert.assertEquals("hi1", ((User)rl.get(0)).getName());
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:17,代码来源:MockClusterInvokerTest.java

示例2: test_NotifiedDubbo1

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@Test
public void test_NotifiedDubbo1() {
    URL errorPathUrl = URL.valueOf("notsupport:/" + "xxx" + "?refer=" + URL.encode("interface=" + service));
    RegistryDirectory registryDirectory = getRegistryDirectory(errorPathUrl);
    List<URL> serviceUrls = new ArrayList<URL>();
    URL Dubbo1URL = URL.valueOf("dubbo://127.0.0.1:9098?lazy=true");
    serviceUrls.add(Dubbo1URL.addParameter("methods", "getXXX"));
    registryDirectory.notify(serviceUrls);
    Assert.assertEquals(true, registryDirectory.isAvailable());

    invocation = new RpcInvocation();

    List<Invoker<DemoService>> invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());

    invocation.setMethodName("getXXX");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());
    Assert.assertEquals(DemoService.class.getName(), invokers.get(0).getUrl().getPath());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:21,代码来源:RegistryDirectoryTest.java

示例3: testMockInvokerFromOverride_Invoke_force_throw

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@Test
public void testMockInvokerFromOverride_Invoke_force_throw(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getBoolean2.mock","force:throw ")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getBoolean2");
	try {
		cluster.invoke(invocation);
		Assert.fail();
	} catch (RpcException e) {
		Assert.assertFalse("not custem exception", e.isBiz());
	}
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:17,代码来源:MockClusterInvokerTest.java

示例4: test_Notified1invokers

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
private void test_Notified1invokers(RegistryDirectory registryDirectory) {

        List<URL> serviceUrls = new ArrayList<URL>();
        serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));// .addParameter("refer.autodestroy", "true")
        registryDirectory.notify(serviceUrls);
        Assert.assertEquals(true, registryDirectory.isAvailable());

        invocation = new RpcInvocation();

        List invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());

        invocation.setMethodName("getXXX");
        invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());

        invocation.setMethodName("getXXX1");
        invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());

        invocation.setMethodName("getXXX2");
        invokers = registryDirectory.list(invocation);
        Assert.assertEquals(1, invokers.size());
    }
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:25,代码来源:RegistryDirectoryTest.java

示例5: testMockInvokerFromOverride_Invoke_force_throw

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@Test
public void testMockInvokerFromOverride_Invoke_force_throw() {
    URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
            .addParameter("getBoolean2.mock", "force:throw ")
            .addParameter("invoke_return_error", "true");
    Invoker<IHelloService> cluster = getClusterInvoker(url);
    //方法配置了mock
    RpcInvocation invocation = new RpcInvocation();
    invocation.setMethodName("getBoolean2");
    try {
        cluster.invoke(invocation);
        Assert.fail();
    } catch (RpcException e) {
        Assert.assertFalse("not custem exception", e.isBiz());
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:17,代码来源:MockClusterInvokerTest.java

示例6: testMockInvokerFromOverride_Invoke_force_throwCustemExceptionNotFound

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@Test
public void testMockInvokerFromOverride_Invoke_force_throwCustemExceptionNotFound(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getBoolean2.mock","force:throw java.lang.RuntimeException2")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getBoolean2");
	try {
		cluster.invoke(invocation);
		Assert.fail();
	} catch (Exception e) {
		Assert.assertTrue(e.getCause() instanceof IllegalStateException);
	}
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:17,代码来源:MockClusterInvokerTest.java

示例7: testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
/**
 * 测试mock策略是否正常-fail-mock
 */
@Test
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("mock","true")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getSomething");
       Result ret = cluster.invoke(invocation);
       Assert.assertEquals("somethingmock", ret.getValue());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:MockClusterInvokerTest.java

示例8: testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock2

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
/**
 * 测试mock策略是否正常-fail-mock
 */
@Test
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock2(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("mock","fail")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getSomething");
       Result ret = cluster.invoke(invocation);
       Assert.assertEquals("somethingmock", ret.getValue());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:MockClusterInvokerTest.java

示例9: testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock3

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
/**
 * 测试mock策略是否正常-fail-mock
 */
@Test
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock3(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("mock","force");
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getSomething");
       Result ret = cluster.invoke(invocation);
       Assert.assertEquals("somethingmock", ret.getValue());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:15,代码来源:MockClusterInvokerTest.java

示例10: testMockInvokerFromOverride_Invoke_check_ListString_empty

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListString_empty() {
    URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
            .addParameter("getListString.mock", "force:return empty")
            .addParameter("invoke_return_error", "true");
    Invoker<IHelloService> cluster = getClusterInvoker(url);
    //方法配置了mock
    RpcInvocation invocation = new RpcInvocation();
    invocation.setMethodName("getListString");
    Result ret = cluster.invoke(invocation);
    Assert.assertEquals(0, ((List<String>) ret.getValue()).size());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:14,代码来源:MockClusterInvokerTest.java

示例11: test_Notified3invokers

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
private void test_Notified3invokers(RegistryDirectory registryDirectory) {
    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL3.addParameter("methods", "getXXX1,getXXX2,getXXX3"));

    registryDirectory.notify(serviceUrls);
    Assert.assertEquals(true, registryDirectory.isAvailable());

    invocation = new RpcInvocation();

    List invokers = registryDirectory.list(invocation);
    Assert.assertEquals(3, invokers.size());

    invocation.setMethodName("getXXX");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(3, invokers.size());

    invocation.setMethodName("getXXX1");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(3, invokers.size());

    invocation.setMethodName("getXXX2");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());

    invocation.setMethodName("getXXX3");
    invokers = registryDirectory.list(invocation);
    Assert.assertEquals(1, invokers.size());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:31,代码来源:RegistryDirectoryTest.java

示例12: testMockInvokerFromOverride_Invoke_check_boolean

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@Test
public void testMockInvokerFromOverride_Invoke_check_boolean(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getBoolean1.mock","force:return true")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getBoolean1");
       Result ret = cluster.invoke(invocation);
       Assert.assertTrue("result type must be Boolean but was : " + ret.getValue().getClass(), ret.getValue() instanceof Boolean);
       Assert.assertEquals(true, Boolean.parseBoolean(ret.getValue().toString()));
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:14,代码来源:MockClusterInvokerTest.java

示例13: testMockInvokerFromOverride_Invoke_check_ListPojo_error

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@Test
public void testMockInvokerFromOverride_Invoke_check_ListPojo_error(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getUsers.mock","force:return [{id:x, name:\"hi1\"}]")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getUsers");
	try{
		cluster.invoke(invocation);
	}catch (RpcException e) {
	}
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:15,代码来源:MockClusterInvokerTest.java

示例14: testMockInvokerFromOverride_Invoke_check_ListPojo_empty

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListPojo_empty() {
    URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
            .addParameter("getUsers.mock", "force:return empty")
            .addParameter("invoke_return_error", "true");
    Invoker<IHelloService> cluster = getClusterInvoker(url);
    //方法配置了mock
    RpcInvocation invocation = new RpcInvocation();
    invocation.setMethodName("getUsers");
    Result ret = cluster.invoke(invocation);
    Assert.assertEquals(0, ((List<User>) ret.getValue()).size());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:14,代码来源:MockClusterInvokerTest.java

示例15: testMockInvokerFromOverride_Invoke_check_ListString

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListString(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getListString.mock","force:return [\"hi\",\"hi2\"]")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getListString");
       Result ret = cluster.invoke(invocation);
       List<String> rl = (List<String>)ret.getValue();
       Assert.assertEquals(2, rl.size());
       Assert.assertEquals("hi", rl.get(0));
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:16,代码来源:MockClusterInvokerTest.java


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