You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by il...@apache.org on 2018/10/30 09:22:17 UTC
[incubator-dubbo] branch master updated: 【Unit Test】FailbackRegistry Test: recover method (#2591)
This is an automated email from the ASF dual-hosted git repository.
iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 0a116aa 【Unit Test】FailbackRegistry Test: recover method (#2591)
0a116aa is described below
commit 0a116aa957a81478234076997426cfb6296c2040
Author: tswstarplanet <ts...@163.com>
AuthorDate: Tue Oct 30 17:22:10 2018 +0800
【Unit Test】FailbackRegistry Test: recover method (#2591)
* FailbackRegistry Test: recover method
* fix the type error, and use CountDownLatch await method to fix the unstable problom
* trigger the travis ci test retry
* trigger the code static check again
---
.../registry/support/FailbackRegistryTest.java | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java
index 5e50c31..7f3ac3a 100644
--- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java
@@ -21,6 +21,7 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.registry.NotifyListener;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -180,6 +181,28 @@ public class FailbackRegistryTest {
assertEquals(2, count.get());
}
+ @Test
+ public void testRecover() throws Exception {
+ CountDownLatch countDownLatch = new CountDownLatch(4);
+ final AtomicReference<Boolean> notified = new AtomicReference<Boolean>(false);
+ NotifyListener listener = 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, listener);
+ Assert.assertEquals(1, mockRegistry.getRegistered().size());
+ Assert.assertEquals(1, mockRegistry.getSubscribed().size());
+ mockRegistry.recover();
+ countDownLatch.await();
+ Assert.assertEquals(0, mockRegistry.getFailedRegistered().size());
+ Assert.assertEquals(null, mockRegistry.getFailedSubscribed().get(registryUrl));
+ Assert.assertEquals(countDownLatch.getCount(), 0);
+ }
private static class MockRegistry extends FailbackRegistry {
CountDownLatch latch;