Skip to content

Commit

Permalink
Enhance unit test (apache#2920)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiaojiee authored and khanimteyaz committed Dec 17, 2018
1 parent 0f27705 commit d84abb7
Showing 1 changed file with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance;
import org.apache.dubbo.rpc.cluster.router.script.ScriptRouter;
import org.apache.dubbo.rpc.cluster.router.script.ScriptRouterFactory;

import org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -1014,6 +1014,37 @@ public void test_Notified_acceptProtocol2() {
List<Invoker<DemoService>> invokers = registryDirectory.list(invocation);
Assert.assertEquals(2, invokers.size());
}

@Test
public void test_Notified_withGroupFilter() {
URL directoryUrl = noMeaningUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface" + service + "&group=group1,group2");
RegistryDirectory directory = this.getRegistryDirectory(directoryUrl);
URL provider1 = URL.valueOf("dubbo://10.134.108.1:20880?methods=getXXX&group=group1&mock=false");
URL provider2 = URL.valueOf("dubbo://10.134.108.1:20880?methods=getXXX&group=group2&mock=false");

List<URL> providers = new ArrayList<>();
providers.add(provider1);
providers.add(provider2);
directory.notify(providers);

invocation = new RpcInvocation();
invocation.setMethodName("getXXX");
List<Invoker<DemoService>> invokers = directory.list(invocation);

Assert.assertEquals(2, invokers.size());
Assert.assertTrue(invokers.get(0) instanceof MockClusterInvoker);
Assert.assertTrue(invokers.get(1) instanceof MockClusterInvoker);

directoryUrl = noMeaningUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface" + service + "&group=group1");
directory = this.getRegistryDirectory(directoryUrl);
directory.notify(providers);

invokers = directory.list(invocation);

Assert.assertEquals(2, invokers.size());
Assert.assertFalse(invokers.get(0) instanceof MockClusterInvoker);
Assert.assertFalse(invokers.get(1) instanceof MockClusterInvoker);
}

enum Param {
MORGAN,
Expand Down

0 comments on commit d84abb7

Please sign in to comment.