test_class.declarator: port = new PortTelnetHandler()
test_class.modifier: private static
test_class.original_string: private static TelnetHandler port = new PortTelnetHandler();
test_class.type: TelnetHandler
test_class.var_name: port
test_class.declarator: mockInvoker
test_class.modifier: private static
test_class.original_string: private static Invoker<DemoService> mockInvoker;
test_class.type: Invoker<DemoService>
test_class.var_name: mockInvoker
test_class.declarator: availablePort = NetUtils.getAvailablePort()
test_class.modifier: private static
test_class.original_string: private static int availablePort = NetUtils.getAvailablePort();
test_class.type: int
test_class.var_name: availablePort
test_class.file: dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/legacy/PortTelnetHandlerTest.java
test_class.identifier: PortTelnetHandlerTest
test_case.body: @Test
      public void testListAllPort() throws RemotingException {
          String result = port.telnet(null, "");
          assertEquals("" + availablePort + "", result);
      }
test_case.class_method_signature: PortTelnetHandlerTest.testListAllPort()
test_case.full_signature: @Test public void testListAllPort()
test_case.identifier: testListAllPort
test_case.invocations: telnet assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testListAllPort()
focal_class.file: dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/legacy/PortTelnetHandler.java
focal_class.identifier: PortTelnetHandler
focal_class.interfaces: implements TelnetHandler
focal_class.class_method_signature: PortTelnetHandler.telnet(Channel channel, String message)
focal_class.full_signature: @Override public String telnet(Channel channel, String message)
focal_class.identifier: telnet
focal_class.modifiers: @Override public
focal_class.parameters: (Channel channel, String message)
focal_class.return: String
focal_class.signature: String telnet(Channel channel, String message)
focal_method.body: @Override
      public String telnet(Channel channel, String message) {
          StringBuilder buf = new StringBuilder();
          String port = null;
          boolean detail = false;
          if (message.length() > 0) {
              String[] parts = message.split("\\s+");
              for (String part : parts) {
                  if ("-l".equals(part)) {
                      detail = true;
                  } else {
                      if (!StringUtils.isInteger(part)) {
                          return "Illegal port " + part + ", must be integer.";
                      }
                      port = part;
                  }
              }
          }
          if (port == null || port.length() == 0) {
              for (ProtocolServer server : DubboProtocol.getDubboProtocol().getServers()) {
                  if (buf.length() > 0) {
                      buf.append("\r\n");
                  }
                  if (detail) {
                      buf.append(server.getUrl().getProtocol()).append("://").append(server.getUrl().getAddress());
                  } else {
                      buf.append(server.getUrl().getPort());
                  }
              }
          } else {
              int p = Integer.parseInt(port);
              ProtocolServer protocolServer = null;
              for (ProtocolServer s : DubboProtocol.getDubboProtocol().getServers()) {
                  if (p == s.getUrl().getPort()) {
                      protocolServer = s;
                      break;
                  }
              }
              if (protocolServer != null) {
                  ExchangeServer server = (ExchangeServer) protocolServer.getRemotingServer();
                  Collection<ExchangeChannel> channels = server.getExchangeChannels();
                  for (ExchangeChannel c : channels) {
                      if (buf.length() > 0) {
                          buf.append("\r\n");
                      }
                      if (detail) {
                          buf.append(c.getRemoteAddress()).append(" -> ").append(c.getLocalAddress());
                      } else {
                          buf.append(c.getRemoteAddress());
                      }
                  }
              } else {
                  buf.append("No such port ").append(port);
              }
          }
          return buf.toString();
      }
focal_method.class_method_signature: PortTelnetHandler.telnet(Channel channel, String message)
focal_method.full_signature: @Override public String telnet(Channel channel, String message)
focal_method.identifier: telnet
focal_method.invocations: length split equals isInteger length getServers getDubboProtocol length append append append append getProtocol getUrl getAddress getUrl append getPort getUrl parseInt getServers getDubboProtocol getPort getUrl getRemotingServer getExchangeChannels length append append append append getRemoteAddress getLocalAddress append getRemoteAddress append append toString
focal_method.modifiers: @Override public
focal_method.parameters: (Channel channel, String message)
focal_method.return: String
focal_method.signature: String telnet(Channel channel, String message)