@Override
    public void init(final DiscoveryConfig config) {
        if (this.namingService != null) {
            LOGGER.info("Nacos naming service already registered");
            return;
        }
        Properties properties = config.getProps();
        Properties nacosProperties = new Properties();
        this.groupName = properties.getProperty("groupName", "SHENYU_GROUP");
        String serverAddr = config.getServerList();
        nacosProperties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
        nacosProperties.put(PropertyKeyConst.NAMESPACE, properties.getProperty(NAMESPACE, ""));
        nacosProperties.put(PropertyKeyConst.USERNAME, properties.getProperty(PropertyKeyConst.USERNAME, ""));
        nacosProperties.put(PropertyKeyConst.PASSWORD, properties.getProperty(PropertyKeyConst.PASSWORD, ""));
        nacosProperties.put(PropertyKeyConst.ACCESS_KEY, properties.getProperty(PropertyKeyConst.ACCESS_KEY, ""));
        nacosProperties.put(PropertyKeyConst.SECRET_KEY, properties.getProperty(PropertyKeyConst.SECRET_KEY, ""));
        try {
            this.namingService = NamingFactory.createNamingService(nacosProperties);
            LOGGER.info("Nacos naming service initialized success");
        } catch (NacosException e) {
            LOGGER.error("Error initializing Nacos naming service", e);
            throw new ShenyuException(e);
        }
    }
@Test
    void testInit() throws NoSuchFieldException, IllegalAccessException {
        // Set the discovery config
        setField(nacosDiscoveryServiceUnderTest.getClass(), "namingService", null);
        DiscoveryConfig config = new DiscoveryConfig();
        Properties properties = new Properties();
        config.setServerList("127.0.0.1:8848");
        properties.setProperty("groupName", "SHENYU_GROUP");
        config.setProps(properties);

        try (MockedStatic<NamingFactory> mockedNamingFactory = mockStatic(NamingFactory.class)) {
            // Mock the successful creation of NamingService
            mockedNamingFactory.when(() -> NamingFactory.createNamingService(any(Properties.class)))
                    .thenReturn(namingService);
            nacosDiscoveryServiceUnderTest.init(config);
            mockedNamingFactory.verify(() -> NamingFactory.createNamingService(any(Properties.class)));
            assertEquals(namingService, getField(nacosDiscoveryServiceUnderTest, "namingService"));
            // Mock the situation where NamingService fails to be created and throws an exception
            mockedNamingFactory.when(() -> NamingFactory.createNamingService(any(Properties.class)))
                    .thenThrow(new NacosException());
            assertDoesNotThrow(() -> nacosDiscoveryServiceUnderTest.init(config));
        }
    }