@Test
    public void testSubscribeNotify() throws InterruptedException {
        ProviderConfig<?> providerConfig = providerConfig("consul-test-1", 12200);
        registry.register(providerConfig);

        ConsumerConfig<?> consumerConfig = consumerConfig("consul-test-1");
        MockProviderInfoListener listener = new MockProviderInfoListener();
        consumerConfig.setProviderInfoListener(listener);

        assertUntil(() -> {
            List<ProviderGroup> providerGroups = registry.subscribe(consumerConfig);
            Assert.assertEquals(1, providerGroups.size());
            Assert.assertEquals(1, providerGroups.get(0).size());
        }, 10, TimeUnit.SECONDS);

        CountDownLatch latch = new CountDownLatch(1);
        listener.setCountDownLatch(latch);

        providerConfig = providerConfig("consul-test-1", 12201, 12202);
        registry.register(providerConfig);

        boolean ok = latch.await(10, TimeUnit.SECONDS);
        Assert.assertTrue(ok);

        assertUntil(() -> {
            Map<String, ProviderInfo> providers = listener.getData();
            Assert.assertEquals(3, providers.size());
        }, 10, TimeUnit.SECONDS);

        latch = new CountDownLatch(1);
        listener.setCountDownLatch(latch);

        registry.unRegister(providerConfig);

        ok = latch.await(10, TimeUnit.SECONDS);
        Assert.assertTrue(ok);

        assertUntil(() -> {
            Map<String, ProviderInfo> providers = listener.getData();
            Assert.assertEquals(1, providers.size());
        }, 10, TimeUnit.SECONDS);
    }
Consul Registry Tests

@author <a href=mailto:scienjus@gmail.com>ScienJus</a>
registry/registry-consul/src/test/java/com/alipay/sofa/rpc/registry/consul/ConsulRegistryTest.java