@Override
    public Status check() {
        List<ProtocolServer> 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 (ProtocolServer protocolServer : servers) {
            RemotingServer server = protocolServer.getRemotingServer();
            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());
    }
@Test
    void test() {
        ServerStatusChecker serverStatusChecker = new ServerStatusChecker();
        Status status = serverStatusChecker.check();
        Assertions.assertEquals(status.getLevel(), Status.Level.UNKNOWN);

        DubboProtocol dubboProtocol = Mockito.mock(DubboProtocol.class);
        ProtocolServer protocolServer = Mockito.mock(ProtocolServer.class);
        RemotingServer remotingServer = Mockito.mock(RemotingServer.class);
        List<ProtocolServer> servers = Arrays.asList(protocolServer);
        Mockito.when(dubboProtocol.getServers()).thenReturn(servers);
        Mockito.when(protocolServer.getRemotingServer()).thenReturn(remotingServer);
        Mockito.when(remotingServer.isBound()).thenReturn(true);
        Mockito.when(remotingServer.getLocalAddress())
                .thenReturn(InetSocketAddress.createUnresolved("127.0.0.1", 9999));
        Mockito.when(remotingServer.getChannels()).thenReturn(Arrays.asList(new MockChannel()));

        try (MockedStatic<DubboProtocol> mockDubboProtocol = Mockito.mockStatic(DubboProtocol.class)) {
            mockDubboProtocol.when(() -> DubboProtocol.getDubboProtocol()).thenReturn(dubboProtocol);
            status = serverStatusChecker.check();
            Assertions.assertEquals(status.getLevel(), Status.Level.OK);
            // In JDK 17 : 127.0.0.1/<unresolved>:9999(clients:1)
            Assertions.assertTrue(status.getMessage().contains("127.0.0.1"));
            Assertions.assertTrue(status.getMessage().contains("9999(clients:1)"));

            Mockito.when(remotingServer.isBound()).thenReturn(false);
            status = serverStatusChecker.check();
            Assertions.assertEquals(status.getLevel(), Status.Level.ERROR);
            // In JDK 17 : 127.0.0.1/<unresolved>:9999
            Assertions.assertTrue(status.getMessage().contains("127.0.0.1"));
            Assertions.assertTrue(status.getMessage().contains("9999"));
        }
    }