Search in sources :

Example 1 with MockClusterInvoker

use of org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker in project dubbo by alibaba.

the class RegistryDirectoryTest method test_Notified_withGroupFilter.

@Test
public void test_Notified_withGroupFilter() {
    URL directoryUrl = noMeaningUrl.addParameterAndEncoded(REFER_KEY, "interface" + service + "&group=group1,group2");
    RegistryDirectory directory = this.getRegistryDirectory(directoryUrl);
    URL provider1 = URL.valueOf("dubbo://10.134.108.1:20880/" + service + "?methods=getXXX&group=group1&mock=false&application=mockApplication");
    URL provider2 = URL.valueOf("dubbo://10.134.108.1:20880/" + service + "?methods=getXXX&group=group2&mock=false&application=mockApplication");
    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);
    Assertions.assertEquals(2, invokers.size());
    Assertions.assertTrue(invokers.get(0) instanceof MockClusterInvoker);
    Assertions.assertTrue(invokers.get(1) instanceof MockClusterInvoker);
    directoryUrl = noMeaningUrl.addParameterAndEncoded(REFER_KEY, "interface" + service + "&group=group1");
    directory = this.getRegistryDirectory(directoryUrl);
    directory.notify(providers);
    invokers = directory.list(invocation);
    Assertions.assertEquals(2, invokers.size());
    Assertions.assertFalse(invokers.get(0) instanceof MockClusterInvoker);
    Assertions.assertFalse(invokers.get(1) instanceof MockClusterInvoker);
}
Also used : RegistryDirectory(org.apache.dubbo.registry.integration.RegistryDirectory) RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) MockClusterInvoker(org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker) Invoker(org.apache.dubbo.rpc.Invoker) ArrayList(java.util.ArrayList) MockClusterInvoker(org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)1 URL (org.apache.dubbo.common.URL)1 RegistryDirectory (org.apache.dubbo.registry.integration.RegistryDirectory)1 Invoker (org.apache.dubbo.rpc.Invoker)1 RpcInvocation (org.apache.dubbo.rpc.RpcInvocation)1 MockClusterInvoker (org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker)1 Test (org.junit.jupiter.api.Test)1