Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Unit Test】FailbackRegistry Test: recover method #2591

Merged
merged 5 commits into from
Oct 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;

Expand Down Expand Up @@ -180,6 +181,28 @@ public void notify(List<URL> urls) {
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);
tswstarplanet marked this conversation as resolved.
Show resolved Hide resolved
}

private static class MockRegistry extends FailbackRegistry {
CountDownLatch latch;
Expand Down