use of org.apache.dubbo.rpc.service.GenericService in project dubbo by alibaba.
the class EnumBak method testGenericEnum.
@Test
public void testGenericEnum() throws InterruptedException {
int port = NetUtils.getAvailablePort();
URL serviceurl = URL.valueOf("dubbo://127.0.0.1:" + port + "/test?timeout=" + Integer.MAX_VALUE);
DemoService demo = new DemoServiceImpl();
Invoker<DemoService> invoker = proxy.getInvoker(demo, DemoService.class, serviceurl);
protocol.export(invoker);
URL consumerurl = serviceurl;
Invoker<GenericService> reference = protocol.refer(GenericService.class, consumerurl);
GenericService demoProxy = (GenericService) proxy.getProxy(reference);
Object obj = demoProxy.$invoke("enumlength", new String[] { Type[].class.getName() }, new Object[] { new Type[] { Type.High, Type.High } });
System.out.println("obj---------->" + obj);
invoker.destroy();
reference.destroy();
}
use of org.apache.dubbo.rpc.service.GenericService in project dubbo by alibaba.
the class EnumBak method testGenricEnumCompat.
// verify compatibility when 2.0.5 invokes 2.0.3
@Disabled
@Test
public void testGenricEnumCompat() {
int port = NetUtils.getAvailablePort();
URL consumerurl = URL.valueOf("dubbo://127.0.0.1:" + port + "/test?timeout=" + Integer.MAX_VALUE);
Invoker<GenericService> reference = protocol.refer(GenericService.class, consumerurl);
GenericService demoProxy = (GenericService) proxy.getProxy(reference);
Object obj = demoProxy.$invoke("enumlength", new String[] { Type[].class.getName() }, new Object[] { new Type[] { Type.High, Type.High } });
System.out.println("obj---------->" + obj);
reference.destroy();
}
use of org.apache.dubbo.rpc.service.GenericService in project dubbo by alibaba.
the class ConfigTest method testReferGenericExport.
@Test
public void testReferGenericExport() throws Exception {
RegistryConfig rc = new RegistryConfig();
rc.setAddress(RegistryConfig.NO_AVAILABLE);
ServiceConfig<GenericService> sc = new ServiceConfig<GenericService>();
sc.setRegistry(rc);
sc.setInterface(DemoService.class.getName());
sc.setRef((method, parameterTypes, args) -> null);
ReferenceConfig<DemoService> ref = new ReferenceConfig<DemoService>();
ref.setRegistry(rc);
ref.setInterface(DemoService.class.getName());
DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(new ApplicationConfig("test-refer-generic-export")).service(sc).reference(ref);
try {
bootstrap.start();
Assertions.fail();
} catch (Exception e) {
e.printStackTrace();
} finally {
bootstrap.stop();
}
}
use of org.apache.dubbo.rpc.service.GenericService in project dubbo by alibaba.
the class HessianProtocolTest method testGenericInvoke.
@Test
public void testGenericInvoke() {
HessianServiceImpl server = new HessianServiceImpl();
Assertions.assertFalse(server.isCalled());
ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
int port = NetUtils.getAvailablePort();
URL url = URL.valueOf("hessian://127.0.0.1:" + port + "/" + HessianService.class.getName() + "?version=1.0.0");
Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
Invoker<GenericService> invoker = protocol.refer(GenericService.class, url);
GenericService client = proxyFactory.getProxy(invoker, true);
String result = (String) client.$invoke("sayHello", new String[] { "java.lang.String" }, new Object[] { "haha" });
Assertions.assertTrue(server.isCalled());
Assertions.assertEquals("Hello, haha", result);
invoker.destroy();
exporter.unexport();
}
use of org.apache.dubbo.rpc.service.GenericService in project dubbo by alibaba.
the class HessianProtocolTest method testGenericInvokeWithBean.
@Test
public void testGenericInvokeWithBean() {
HessianServiceImpl server = new HessianServiceImpl();
Assertions.assertFalse(server.isCalled());
ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
int port = NetUtils.getAvailablePort();
URL url = URL.valueOf("hessian://127.0.0.1:" + port + "/" + HessianService.class.getName() + "?version=1.0.0&generic=bean");
Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
Invoker<GenericService> invoker = protocol.refer(GenericService.class, url);
GenericService client = proxyFactory.getProxy(invoker);
JavaBeanDescriptor javaBeanDescriptor = JavaBeanSerializeUtil.serialize("haha");
Object result = client.$invoke("sayHello", new String[] { "java.lang.String" }, new Object[] { javaBeanDescriptor });
Assertions.assertTrue(server.isCalled());
Assertions.assertEquals("Hello, haha", JavaBeanSerializeUtil.deserialize((JavaBeanDescriptor) result));
invoker.destroy();
exporter.unexport();
}
Aggregations