This is an automated email from the ASF dual-hosted git repository.

carryxyh 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 cd60e58  [Dubbo-2348 ] AbstractRegistry util test enhancement (#2409)
cd60e58 is described below

commit cd60e58e1a579749c89c6ac8ddb39f8e8e894ef5
Author: lichen <11263332+lllic...@users.noreply.github.com>
AuthorDate: Wed Sep 19 17:28:43 2018 +0800

    [Dubbo-2348 ] AbstractRegistry util test enhancement (#2409)
    
    * add AbstractRegistryTest getCacheUrlsTest method
    * enhance unit test
---
 .../dubbo/registry/support/AbstractRegistryTest.java   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

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 16ffd85..a6b688f 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
@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -48,6 +49,8 @@ public class AbstractRegistryTest {
     @Before
     public void init() {
         URL url = URL.valueOf("dubbo://192.168.0.2:2233");
+        //sync update cache file
+        url = url.addParameter("save.file",true);
         testUrl = 
URL.valueOf("http://192.168.0.3:9090/registry?check=false&file=N/A&interface=com.test";);
         mockUrl = new URL("dubbo", "192.168.0.1", 2200);
 
@@ -515,4 +518,19 @@ public class AbstractRegistryTest {
         list.add(url3);
         return list;
     }
+
+    @Test
+    public void getCacheUrlsTest(){
+        List<URL> urls = new ArrayList<>();
+        urls.add(testUrl);
+        // check if notify successfully
+        Assert.assertFalse(notifySuccess);
+        abstractRegistry.notify(testUrl, listener, urls);
+        Assert.assertTrue(notifySuccess);
+        List<URL> cacheUrl = abstractRegistry.getCacheUrls(testUrl);
+        Assert.assertTrue(cacheUrl.size() == 1);
+        URL nullUrl = 
URL.valueOf("http://1.2.3.4:9090/registry?check=false&file=N/A&interface=com.testa";);
+        cacheUrl = abstractRegistry.getCacheUrls(nullUrl);
+        Assert.assertTrue(Objects.isNull(cacheUrl));
+    }
 }

Reply via email to