ConsulRegistry extends FailbackRegistry { @Override public void register(URL url) { if (isConsumerSide(url)) { return; } super.register(url); } ConsulRegistry(URL url); @Override void register(URL url); @Override void doRegister(URL url); @Override void unregister(URL url); @Override void doUnregister(URL url); @Override void subscribe(URL url, NotifyListener listener); @Override void doSubscribe(URL url, NotifyListener listener); @Override void unsubscribe(URL url, NotifyListener listener); @Override void doUnsubscribe(URL url, NotifyListener listener); @Override List<URL> lookup(URL url); @Override boolean isAvailable(); @Override void destroy();  }
@Test public void testRegister() { Set<URL> registered; for (int i = 0; i < 2; i++) { consulRegistry.register(serviceUrl); registered = consulRegistry.getRegistered(); assertThat(registered.contains(serviceUrl), is(true)); } registered = consulRegistry.getRegistered(); assertThat(registered.size(), is(1)); }
@Test public void testStatusChecker() { RegistryStatusChecker registryStatusChecker = new RegistryStatusChecker(); Status status = registryStatusChecker.check(); assertThat(status.getLevel(), is(Status.Level.UNKNOWN)); Registry registry = consulRegistryFactory.getRegistry(registryUrl); assertThat(registry, not(nullValue())); status = registryStatusChecker.check(); assertThat(status.getLevel(), is(Status.Level.OK)); registry.register(serviceUrl); status = registryStatusChecker.check(); assertThat(status.getLevel(), is(Status.Level.OK)); }