use of org.apache.dubbo.rpc.RpcInvocation in project dubbo by alibaba.
the class RpcUtilsTest method testGet_$invoke_Arguments.
@Test
public void testGet_$invoke_Arguments() {
Object[] args = new Object[] { "hello", "dubbo", 520 };
Class<?> demoServiceClass = DemoService.class;
String serviceName = demoServiceClass.getName();
Invoker invoker = mock(Invoker.class);
RpcInvocation inv = new RpcInvocation("$invoke", serviceName, "", new Class<?>[] { String.class, String[].class, Object[].class }, new Object[] { "method", new String[] {}, args }, null, invoker, null);
Object[] arguments = RpcUtils.getArguments(inv);
for (int i = 0; i < args.length; i++) {
Assertions.assertNotNull(arguments[i]);
Assertions.assertEquals(args[i].getClass().getName(), arguments[i].getClass().getName());
Assertions.assertEquals(args[i], arguments[i]);
}
}
use of org.apache.dubbo.rpc.RpcInvocation in project dubbo by alibaba.
the class RpcUtilsTest method testAttachInvocationIdIfAsync_sync.
/**
* scenario: sync invocation, no attachment added by default
* verify: no id attribute added in attachment
*/
@Test
public void testAttachInvocationIdIfAsync_sync() {
URL url = URL.valueOf("dubbo://localhost/");
Invocation inv = new RpcInvocation("test", "DemoService", "", new Class[] {}, new String[] {});
RpcUtils.attachInvocationIdIfAsync(url, inv);
assertNull(RpcUtils.getInvocationId(inv));
}
use of org.apache.dubbo.rpc.RpcInvocation in project dubbo by alibaba.
the class FutureFilterTest method setUp.
@BeforeAll
public static void setUp() {
invocation = new RpcInvocation();
invocation.setMethodName("echo");
invocation.setParameterTypes(new Class<?>[] { Enum.class });
invocation.setArguments(new Object[] { "hello" });
}
use of org.apache.dubbo.rpc.RpcInvocation in project dubbo by alibaba.
the class DubboRegistryTest method setUp.
@BeforeEach
public void setUp() {
registryURL = new URL(REGISTRY_PROTOCOL, NetUtils.getLocalHost(), NetUtils.getAvailablePort()).addParameter(Constants.CHECK_KEY, false).setServiceInterface(RegistryService.class.getName());
serviceURL = new URL(DubboProtocol.NAME, NetUtils.getLocalHost(), NetUtils.getAvailablePort()).addParameter(Constants.CHECK_KEY, false).setServiceInterface(RegistryService.class.getName());
registryService = new MockDubboRegistry(registryURL);
invoker = mock(Invoker.class);
given(invoker.getUrl()).willReturn(serviceURL);
given(invoker.getInterface()).willReturn(RegistryService.class);
given(invoker.invoke(new RpcInvocation())).willReturn(null);
dubboRegistry = new DubboRegistry(invoker, registryService);
notifyListener = mock(NotifyListener.class);
}
use of org.apache.dubbo.rpc.RpcInvocation in project dubbo by alibaba.
the class RegistryDirectoryTest method test_Notified3invokers.
// 3 invoker notifications===================================
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);
Assertions.assertTrue(registryDirectory.isAvailable());
invocation = new RpcInvocation();
List invokers = registryDirectory.list(invocation);
Assertions.assertEquals(3, invokers.size());
invocation.setMethodName("getXXX");
invokers = registryDirectory.list(invocation);
Assertions.assertEquals(3, invokers.size());
invocation.setMethodName("getXXX1");
invokers = registryDirectory.list(invocation);
Assertions.assertEquals(3, invokers.size());
invocation.setMethodName("getXXX2");
invokers = registryDirectory.list(invocation);
Assertions.assertEquals(3, invokers.size());
invocation.setMethodName("getXXX3");
invokers = registryDirectory.list(invocation);
Assertions.assertEquals(3, invokers.size());
}
Aggregations