tswstarplanet commented on a change in pull request #2591: FailbackRegistry 
Test: recover method
URL: https://github.com/apache/incubator-dubbo/pull/2591#discussion_r221574034
 
 

 ##########
 File path: 
dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java
 ##########
 @@ -180,6 +181,27 @@ public void notify(List<URL> urls) {
         assertEquals(2, count.get());
     }
 
+    @Test
+    public void testRecover() throws Exception {
+        CountDownLatch countDownLatch = new CountDownLatch(2);
+        final AtomicReference<Boolean> notified = new 
AtomicReference<Boolean>(false);
+
+        NotifyListener listner = new NotifyListener() {
+            @Override
+            public void notify(List<URL> urls) {
+                notified.set(Boolean.TRUE);
+            }
+        };
+
+        MockRegistry mockRegistry = new MockRegistry(registryUrl, 
countDownLatch);
+        mockRegistry.register(serviceUrl);
+        mockRegistry.subscribe(serviceUrl, listner);
+        Assert.assertEquals(mockRegistry.getRegistered().size(), 1);
+        Assert.assertEquals(mockRegistry.getSubscribed().size(), 1);
+        mockRegistry.recover();
+        Assert.assertEquals(mockRegistry.getFailedSubscribed().size(), 1);
+        Assert.assertEquals(countDownLatch.getCount(), 0);
 
 Review comment:
   The registerUrl has set the retry period 200 millisecond. And I have used 
CountDownLatch await method to wait the retry thread to finish.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to