本文整理汇总了Java中com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService类的典型用法代码示例。如果您正苦于以下问题:Java DemoService类的具体用法?Java DemoService怎么用?Java DemoService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DemoService类属于com.alibaba.dubbo.rpc.protocol.dubbo.support包,在下文中一共展示了DemoService类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDubboProtocolMultiService
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService; //导入依赖的package包/类
@Test
public void testDubboProtocolMultiService() throws Exception
{
DemoService service = new DemoServiceImpl();
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + DemoService.class.getName())));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + DemoService.class.getName())));
RemoteService remote = new RemoteServiceImpl();
protocol.export(proxy.getInvoker(remote, RemoteService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + RemoteService.class.getName())));
remote = proxy.getProxy(protocol.refer(RemoteService.class, URL.valueOf("dubbo://127.0.0.1:9010/" + RemoteService.class.getName())));
service.sayHello("world");
// test netty client
assertEquals("world", service.echo("world"));
assertEquals("hello [email protected]" + RemoteServiceImpl.class.getName(), remote.sayHello("world"));
EchoService serviceEcho = (EchoService)service;
assertEquals(serviceEcho.$echo("test"), "test");
EchoService remoteEecho = (EchoService)remote;
assertEquals(remoteEecho.$echo("ok"), "ok");
}
示例2: setUp
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setUp() {
mockChannel = EasyMock.createMock(Channel.class);
mockInvoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
mockChannel.setAttribute("telnet.service", "DemoService");
EasyMock.expectLastCall().anyTimes();
mockChannel.setAttribute("telnet.service", "com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService");
EasyMock.expectLastCall().anyTimes();
mockChannel.setAttribute("telnet.service", "demo");
EasyMock.expectLastCall().anyTimes();
mockChannel.removeAttribute("telnet.service");
EasyMock.expectLastCall().anyTimes();
EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
EasyMock.replay(mockChannel, mockInvoker);
}
示例3: testInvokeDefaultSService
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testInvokeDefaultSService() throws RemotingException {
mockInvoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
mockChannel = EasyMock.createMock(Channel.class);
EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
EasyMock.expect(mockChannel.getLocalAddress()).andReturn(NetUtils.toAddress("127.0.0.1:5555")).anyTimes();
EasyMock.expect(mockChannel.getRemoteAddress()).andReturn(NetUtils.toAddress("127.0.0.1:20883")).anyTimes();
EasyMock.replay(mockChannel, mockInvoker);
DubboProtocol.getDubboProtocol().export(mockInvoker);
String result = invoke.telnet(mockChannel, "DemoService.echo(\"ok\")");
assertTrue(result.contains("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\"ok\"\r\n"));
EasyMock.reset(mockChannel, mockInvoker);
}
示例4: testInvokeAutoFindMethod
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testInvokeAutoFindMethod() throws RemotingException {
mockInvoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
mockChannel = EasyMock.createMock(Channel.class);
EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
EasyMock.expect(mockChannel.getLocalAddress()).andReturn(NetUtils.toAddress("127.0.0.1:5555")).anyTimes();
EasyMock.expect(mockChannel.getRemoteAddress()).andReturn(NetUtils.toAddress("127.0.0.1:20883")).anyTimes();
EasyMock.replay(mockChannel, mockInvoker);
DubboProtocol.getDubboProtocol().export(mockInvoker);
String result = invoke.telnet(mockChannel, "echo(\"ok\")");
assertTrue(result.contains("ok"));
EasyMock.reset(mockChannel, mockInvoker);
}
示例5: setUp
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
StringBuilder buf = new StringBuilder();
StringBuilder buf2 = new StringBuilder();
Method[] methods = DemoService.class.getMethods();
for (Method method : methods) {
if (buf.length() > 0) {
buf.append("\r\n");
}
if (buf2.length() > 0) {
buf2.append("\r\n");
}
buf2.append(method.getName());
buf.append(ReflectUtils.getName(method));
}
detailMethods = buf.toString();
methodsName = buf2.toString();
ProtocolUtils.closeAll();
}
示例6: testListDetail
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testListDetail() throws RemotingException {
int port = NetUtils.getAvailablePort();
mockInvoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:"+port+"/demo")).anyTimes();
EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
mockChannel = EasyMock.createMock(Channel.class);
EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
EasyMock.replay(mockChannel, mockInvoker);
DubboProtocol.getDubboProtocol().export(mockInvoker);
String result = list.telnet(mockChannel, "-l");
assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService -> dubbo://127.0.0.1:"+port+"/demo", result);
EasyMock.reset(mockChannel);
}
示例7: testListDefault
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testListDefault() throws RemotingException {
mockInvoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
mockChannel = EasyMock.createMock(Channel.class);
EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
EasyMock.replay(mockChannel, mockInvoker);
DubboProtocol.getDubboProtocol().export(mockInvoker);
String result = list.telnet(mockChannel, "");
assertEquals("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\r\n"
+ methodsName, result);
EasyMock.reset(mockChannel);
}