@Test
public void testDoRetry_register() throws Exception {

    final AtomicReference<Boolean> notified = new AtomicReference<Boolean>(false);
    final CountDownLatch latch = new CountDownLatch(1);//All of them are called 4 times. A successful attempt to lose 1. subscribe will not be done
    NotifyListener listner = new NotifyListener() {
        @Override
        public void notify(List<URL> urls) {
            notified.set(Boolean.TRUE);
        }
    };
    registry = new MockRegistry(registryUrl, latch);
    registry.setBad(true);
    registry.subscribe(serviceUrl.setProtocol(CONSUMER_PROTOCOL).addParameters(CollectionUtils.toStringMap("check", "false")), listner);
    //Failure can not be called to listener.
    assertEquals(false, notified.get());
    assertEquals(1, latch.getCount());
    registry.setBad(false);
    for (int i = 0; i < trytimes; i++) {
        System.out.println("failback registry retry ,times:" + i);
        //System.out.println(latch.getCount());
        if (latch.getCount() == 0)
            break;
        Thread.sleep(sleeptime);
    }
      Thread.sleep(100000);
    assertEquals(0, latch.getCount());
    //The failedsubcribe corresponding key will be cleared when unsubscribing
    assertEquals(true, notified.get());
}