CacheableEventPublishingNacosServiceFactory implements NacosServiceFactory { @Override public Collection<NamingService> getNamingServices() { return namingServicesCache.values(); } CacheableEventPublishingNacosServiceFactory(); static CacheableEventPublishingNacosServiceFactory getSingleton(); @Override ConfigService createConfigService(Properties properties); @Override NamingService createNamingService(Properties properties); @Override NamingMaintainService createNamingMaintainService(Properties properties); T deferCreateService(T service, Properties properties); @SuppressWarnings("unchecked") void publishDeferService(ApplicationContext context); void setApplicationContext(ApplicationContext applicationContext); @Override Collection<ConfigService> getConfigServices(); @Override Collection<NamingService> getNamingServices(); @Override Collection<NamingMaintainService> getNamingMaintainService();  }
@Test public void testGetNamingServices() throws NacosException { NamingService namingService = nacosServiceFactory.createNamingService(properties); NamingService namingService2 = nacosServiceFactory .createNamingService(properties); Assert.assertTrue(namingService == namingService2); Assert.assertEquals(1, nacosServiceFactory.getNamingServices().size()); Assert.assertEquals(namingService, nacosServiceFactory.getNamingServices().iterator().next()); }