RegistryFactoryWrapper implements RegistryFactory { @Override public Registry getRegistry(URL url) { return new ListenerRegistryWrapper(registryFactory.getRegistry(url), Collections.unmodifiableList(ExtensionLoader.getExtensionLoader(RegistryServiceListener.class) .getActivateExtension(url, "registry.listeners"))); } RegistryFactoryWrapper(RegistryFactory registryFactory); @Override Registry getRegistry(URL url);  }
@Test public void test() throws Exception { RegistryServiceListener listener1 = Mockito.mock(RegistryServiceListener.class); RegistryServiceListener1.delegate = listener1; RegistryServiceListener listener2 = Mockito.mock(RegistryServiceListener.class); RegistryServiceListener2.delegate = listener2; Registry registry = registryFactory.getRegistry(URL.valueOf("simple: URL url = URL.valueOf("dubbo: registry.register(url); Mockito.verify(listener1, Mockito.times(1)).onRegister(url); Mockito.verify(listener2, Mockito.times(1)).onRegister(url); registry.unregister(url); Mockito.verify(listener1, Mockito.times(1)).onUnregister(url); Mockito.verify(listener2, Mockito.times(1)).onUnregister(url); registry.subscribe(url, Mockito.mock(NotifyListener.class)); Mockito.verify(listener1, Mockito.times(1)).onSubscribe(url); Mockito.verify(listener2, Mockito.times(1)).onSubscribe(url); registry.unsubscribe(url, Mockito.mock(NotifyListener.class)); Mockito.verify(listener1, Mockito.times(1)).onUnsubscribe(url); Mockito.verify(listener2, Mockito.times(1)).onUnsubscribe(url); }