You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/08/15 03:11:07 UTC
[GitHub] beiwei30 closed pull request #2263: [Dubbo-2177]modified
abstract-registry-test Team 8
beiwei30 closed pull request #2263: [Dubbo-2177]modified abstract-registry-test Team 8
URL: https://github.com/apache/incubator-dubbo/pull/2263
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java
index e3bdd8cac0..61d903bf4b 100644
--- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java
+++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java
@@ -21,6 +21,7 @@
import org.apache.dubbo.registry.NotifyListener;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.After;
import org.junit.Test;
import java.util.ArrayList;
@@ -41,6 +42,18 @@ public void init() {
URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":2233");
testUrl = URL.valueOf("http://1.2.3.4:9090/registry?check=false&file=N/A&interface=com.test");
+ // try null url
+ try {
+ abstractRegistry = new AbstractRegistry(null) {
+ @Override
+ public boolean isAvailable() {
+ return false;
+ }
+ };
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IllegalArgumentException);
+ }
+
//init the object
abstractRegistry = new AbstractRegistry(url) {
@Override
@@ -54,6 +67,11 @@ public boolean isAvailable() {
notifySuccess = false;
}
+ @After
+ public void after() {
+ abstractRegistry.destroy();
+ }
+
@Test
public void registerTest() {
//check parameters
@@ -70,6 +88,10 @@ public void registerTest() {
//check register when the url is the same
abstractRegistry.register(testUrl);
Assert.assertEquals(beginSize + 1, abstractRegistry.getRegistered().size());
+
+ URL secondUrl = URL.valueOf("http://1.2.3.4:9091/registry?check=false&file=N/A&interface=com.test1");
+ abstractRegistry.register(secondUrl);
+ Assert.assertEquals(beginSize + 2, abstractRegistry.getRegistered().size());
}
@Test
@@ -81,6 +103,11 @@ public void unregisterTest() {
} catch (Exception e) {
Assert.assertTrue(e instanceof IllegalArgumentException);
}
+
+ // check unregister empty
+ abstractRegistry.unregister(testUrl);
+ Assert.assertEquals(0, abstractRegistry.getRegistered().size());
+
// check if unregister url successfully
abstractRegistry.register(testUrl);
int beginSize = abstractRegistry.getRegistered().size();
@@ -147,6 +174,7 @@ public void unsubscribeTest() {
abstractRegistry.subscribe(testUrl, listener);
abstractRegistry.unsubscribe(testUrl, listener);
Assert.assertFalse(abstractRegistry.getSubscribed().get(testUrl).contains(listener));
+ Assert.assertEquals(0, abstractRegistry.getSubscribed().get(testUrl).size());
}
@Test
@@ -162,9 +190,19 @@ public void recoverTest() throws Exception {
@Test
public void notifyTest() {
- abstractRegistry.subscribe(testUrl, listener);
List<URL> urls = new ArrayList<>();
+
+ // check empty urls
+ abstractRegistry.notify(urls);
+
+ abstractRegistry.subscribe(testUrl, listener);
urls.add(testUrl);
+
+ // add second test url
+ URL secondUrl = URL.valueOf("http://1.2.3.4:9091/registry?check=false&file=N/A&interface=com.test1");
+ abstractRegistry.subscribe(secondUrl, listener);
+ urls.add(secondUrl);
+
// check if notify successfully
Assert.assertFalse(notifySuccess);
abstractRegistry.notify(urls);
@@ -189,6 +227,10 @@ public void notify2Test() {
}
List<URL> urls = new ArrayList<>();
+
+ // check empty urls
+ abstractRegistry.notify(testUrl, listener, urls);
+
urls.add(testUrl);
// check if notify successfully
Assert.assertFalse(notifySuccess);
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org