@Override
    public String telnet(Channel channel, String message) throws RemotingException {
        String prompt = channel.getUrl().getParameterAndDecoded(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT);
        boolean noprompt = message.contains("--no-prompt");
        message = message.replace("--no-prompt", "");
        StringBuilder buf = new StringBuilder();
        message = message.trim();
        String command;
        if (message.length() > 0) {
            int i = message.indexOf(' ');
            if (i > 0) {
                command = message.substring(0, i).trim();
                message = message.substring(i + 1).trim();
            } else {
                command = message;
                message = "";
            }
        } else {
            command = "";
        }
        if (command.length() > 0) {
            if (extensionLoader.hasExtension(command)) {
                if (commandEnabled(channel.getUrl(), command)) {
                    try {
                        String result = extensionLoader.getExtension(command).telnet(channel, message);
                        if (result == null) {
                            return null;
                        }
                        buf.append(result);
                    } catch (Throwable t) {
                        buf.append(t.getMessage());
                    }
                } else {
                    buf.append("Command: ");
                    buf.append(command);
                    buf.append(
                            " disabled for security reasons, please enable support by listing the commands through 'telnet'");
                }
            } else {
                buf.append("Unsupported command: ");
                buf.append(command);
            }
        }
        if (buf.length() > 0) {
            buf.append("\r\n");
        }
        if (StringUtils.isNotEmpty(prompt) && !noprompt) {
            buf.append(prompt);
        }
        return buf.toString();
    }
@Test
    void testTelnet() throws RemotingException {

        Channel channel = Mockito.mock(Channel.class);
        Map<String, String> param = new HashMap<>();
        param.put("telnet", "status");
        URL url = new URL("p1", "127.0.0.1", 12345, "path1", param);
        Mockito.when(channel.getUrl()).thenReturn(url);
        TelnetHandlerAdapter telnetHandlerAdapter = new TelnetHandlerAdapter(FrameworkModel.defaultModel());

        String message = "--no-prompt status ";
        String expectedResult = "OK\r\n";
        Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));

        message = "--no-prompt status test";
        expectedResult = "Unsupported parameter test for status.\r\n";
        Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));

        message = "--no-prompt test";
        expectedResult = "Unsupported command: test\r\n";
        Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));

        message = "--no-prompt help";
        expectedResult =
                "Command: help disabled for security reasons, please enable support by listing the commands through 'telnet'\r\n";
        Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));

        message = "--no-prompt";
        expectedResult = StringUtils.EMPTY_STRING;
        Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));

        message = "help";
        expectedResult =
                "Command: help disabled for security reasons, please enable support by listing the commands through 'telnet'\r\ndubbo>";
        Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));
    }