com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol Java Examples
The following examples show how to use
com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InvokerTelnetHandlerTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: InvokerTelnetHandlerTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testInvokeAutoFindMethod() throws RemotingException { mockInvoker = mock(Invoker.class); given(mockInvoker.getInterface()).willReturn(DemoService.class); given(mockInvoker.getUrl()).willReturn(URL.valueOf("dubbo://127.0.0.1:20886/demo")); given(mockInvoker.invoke(any(Invocation.class))).willReturn(new RpcResult("ok")); mockChannel = mock(Channel.class); given(mockChannel.getAttribute("telnet.service")).willReturn(null); given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555")); given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886")); DubboProtocol.getDubboProtocol().export(mockInvoker); String result = invoke.telnet(mockChannel, "echo(\"ok\")"); assertTrue(result.contains("ok")); }
Example #3
Source File: ServerStatusChecker.java From dubbox with Apache License 2.0 | 6 votes |
public Status check() { Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); if (servers == null || servers.size() == 0) { return new Status(Status.Level.UNKNOWN); } Status.Level level = Status.Level.OK; StringBuilder buf = new StringBuilder(); for (ExchangeServer server : servers) { if (! server.isBound()) { level = Status.Level.ERROR; buf.setLength(0); buf.append(server.getLocalAddress()); break; } if (buf.length() > 0) { buf.append(","); } buf.append(server.getLocalAddress()); buf.append("(clients:"); buf.append(server.getChannels().size()); buf.append(")"); } return new Status(level, buf.toString()); }
Example #4
Source File: ListTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #5
Source File: ServersPageHandler.java From dubbox with Apache License 2.0 | 6 votes |
public Page handle(URL url) { List<List<String>> rows = new ArrayList<List<String>>(); Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); int clientCount = 0; if (servers != null && servers.size() > 0) { for (ExchangeServer s : servers) { List<String> row = new ArrayList<String>(); String address = s.getUrl().getAddress(); row.add(NetUtils.getHostName(address) + "/" + address); int clientSize = s.getExchangeChannels().size(); clientCount += clientSize; row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>"); rows.add(row); } } return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows); }
Example #6
Source File: RegistryProtocolTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[]{new MockedClient("10.20.20.20", 2222, true)}); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //The same invoker, exporter that multiple exported are different Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #7
Source File: InvokerTelnetHandlerTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testInvokeDefaultSService() throws RemotingException { mockInvoker = mock(Invoker.class); given(mockInvoker.getInterface()).willReturn(DemoService.class); given(mockInvoker.getUrl()).willReturn(URL.valueOf("dubbo://127.0.0.1:20886/demo")); given(mockInvoker.invoke(any(Invocation.class))).willReturn(new RpcResult("ok")); mockChannel = mock(Channel.class); given(mockChannel.getAttribute("telnet.service")).willReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService"); given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555")); given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886")); 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")); }
Example #8
Source File: InvokerTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #9
Source File: InvokerTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #10
Source File: ListTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #11
Source File: ListTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #12
Source File: RegistryProtocolTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //同一个invoker,多次export的exporter不同 Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #13
Source File: ServerStatusChecker.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
public Status check() { Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); if (servers == null || servers.size() == 0) { return new Status(Status.Level.UNKNOWN); } Status.Level level = Status.Level.OK; StringBuilder buf = new StringBuilder(); for (ExchangeServer server : servers) { if (! server.isBound()) { level = Status.Level.ERROR; buf.setLength(0); buf.append(server.getLocalAddress()); break; } if (buf.length() > 0) { buf.append(","); } buf.append(server.getLocalAddress()); buf.append("(clients:"); buf.append(server.getChannels().size()); buf.append(")"); } return new Status(level, buf.toString()); }
Example #14
Source File: ServerStatusChecker.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override public Status check() { Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); if (servers == null || servers.isEmpty()) { return new Status(Status.Level.UNKNOWN); } Status.Level level = Status.Level.OK; StringBuilder buf = new StringBuilder(); for (ExchangeServer server : servers) { if (!server.isBound()) { level = Status.Level.ERROR; buf.setLength(0); buf.append(server.getLocalAddress()); break; } if (buf.length() > 0) { buf.append(","); } buf.append(server.getLocalAddress()); buf.append("(clients:"); buf.append(server.getChannels().size()); buf.append(")"); } return new Status(level, buf.toString()); }
Example #15
Source File: ListTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #16
Source File: ServersPageHandler.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
public Page handle(URL url) { List<List<String>> rows = new ArrayList<List<String>>(); Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); int clientCount = 0; if (servers != null && servers.size() > 0) { for (ExchangeServer s : servers) { List<String> row = new ArrayList<String>(); String address = s.getUrl().getAddress(); row.add(NetUtils.getHostName(address) + "/" + address); int clientSize = s.getExchangeChannels().size(); clientCount += clientSize; row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>"); rows.add(row); } } return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows); }
Example #17
Source File: ListTelnetHandlerTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@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); }
Example #18
Source File: ListTelnetHandlerTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@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); }
Example #19
Source File: RegistryProtocolTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@Test public void testExport() { RegistryProtocol registryProtocol = new RegistryProtocol(); registryProtocol.setCluster(new FailfastCluster()); registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension()); Protocol dubboProtocol = DubboProtocol.getDubboProtocol(); registryProtocol.setProtocol(dubboProtocol); URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl); DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) }); Exporter<DemoService> exporter = registryProtocol.export(invoker); Exporter<DemoService> exporter2 = registryProtocol.export(invoker); //同一个invoker,多次export的exporter不同 Assert.assertNotSame(exporter, exporter2); exporter.unexport(); exporter2.unexport(); }
Example #20
Source File: ServerStatusChecker.java From dubbo3 with Apache License 2.0 | 6 votes |
public Status check() { Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); if (servers == null || servers.size() == 0) { return new Status(Status.Level.UNKNOWN); } Status.Level level = Status.Level.OK; StringBuilder buf = new StringBuilder(); for (ExchangeServer server : servers) { if (! server.isBound()) { level = Status.Level.ERROR; buf.setLength(0); buf.append(server.getLocalAddress()); break; } if (buf.length() > 0) { buf.append(","); } buf.append(server.getLocalAddress()); buf.append("(clients:"); buf.append(server.getChannels().size()); buf.append(")"); } return new Status(level, buf.toString()); }
Example #21
Source File: ServersPageHandler.java From dubbo3 with Apache License 2.0 | 6 votes |
public Page handle(URL url) { List<List<String>> rows = new ArrayList<>(); Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); int clientCount = 0; if (servers != null && servers.size() > 0) { for (ExchangeServer s : servers) { List<String> row = new ArrayList<>(); String address = s.getUrl().getAddress(); row.add(NetUtils.getHostName(address) + "/" + address); int clientSize = s.getExchangeChannels().size(); clientCount += clientSize; row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>"); rows.add(row); } } return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows); }
Example #22
Source File: ListTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #23
Source File: InvokerTelnetHandlerTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@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); }
Example #24
Source File: InvokerTelnetHandlerTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@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); }
Example #25
Source File: ServersPageHandler.java From dubbox with Apache License 2.0 | 6 votes |
public Page handle(URL url) { List<List<String>> rows = new ArrayList<List<String>>(); Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); int clientCount = 0; if (servers != null && servers.size() > 0) { for (ExchangeServer s : servers) { List<String> row = new ArrayList<String>(); String address = s.getUrl().getAddress(); row.add(NetUtils.getHostName(address) + "/" + address); int clientSize = s.getExchangeChannels().size(); clientCount += clientSize; row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>"); rows.add(row); } } return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows); }
Example #26
Source File: ListTelnetHandlerTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@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); }
Example #27
Source File: ListTelnetHandlerTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@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); }
Example #28
Source File: ServerStatusChecker.java From dubbox with Apache License 2.0 | 6 votes |
public Status check() { Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); if (servers == null || servers.size() == 0) { return new Status(Status.Level.UNKNOWN); } Status.Level level = Status.Level.OK; StringBuilder buf = new StringBuilder(); for (ExchangeServer server : servers) { if (! server.isBound()) { level = Status.Level.ERROR; buf.setLength(0); buf.append(server.getLocalAddress()); break; } if (buf.length() > 0) { buf.append(","); } buf.append(server.getLocalAddress()); buf.append("(clients:"); buf.append(server.getChannels().size()); buf.append(")"); } return new Status(level, buf.toString()); }
Example #29
Source File: ServersPageHandler.java From dubbox with Apache License 2.0 | 6 votes |
public Page handle(URL url) { List<List<String>> rows = new ArrayList<List<String>>(); Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers(); int clientCount = 0; if (servers != null && servers.size() > 0) { for (ExchangeServer s : servers) { List<String> row = new ArrayList<String>(); String address = s.getUrl().getAddress(); row.add(NetUtils.getHostName(address) + "/" + address); int clientSize = s.getExchangeChannels().size(); clientCount += clientSize; row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>"); rows.add(row); } } return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows); }
Example #30
Source File: InvokerTelnetHandlerTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }