### Question:
AbstractRegistryFactory implements RegistryFactory { @Override public Registry getRegistry(URL url) { url = url.setPath(RegistryService.class.getName()) .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()) .removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY); String key = url.toServiceStringWithoutResolving(); LOCK.lock(); try { Registry registry = REGISTRIES.get(key); if (registry != null) { return registry; } registry = createRegistry(url); if (registry == null) { throw new IllegalStateException("Can not create registry " + url); } REGISTRIES.put(key, registry); return registry; } finally { LOCK.unlock(); } }  static Collection<Registry> getRegistries(); static void destroyAll(); @Override Registry getRegistry(URL url);  }### Answer:
@Test public void testRegistryFactoryCache() throws Exception { URL url = URL.valueOf("dubbo: Registry registry1 = registryFactory.getRegistry(url); Registry registry2 = registryFactory.getRegistry(url); Assertions.assertEquals(registry1, registry2); }
@Test public void testRegistryFactoryGroupCache() throws Exception { Registry registry1 = registryFactory.getRegistry(URL.valueOf("dubbo: Registry registry2 = registryFactory.getRegistry(URL.valueOf("dubbo: Assertions.assertNotSame(registry1, registry2); }