Search in sources :

Example 1 with InvokerWrapper

use of org.apache.dubbo.rpc.protocol.InvokerWrapper in project dubbo by alibaba.

the class RegistryDirectoryTest method testNofityOverrideUrls_CleanOnly.

/**
 * The test clears the override rule and only sends the override cleanup rules
 * Whether the test can be restored to the providerUrl when it is pushed
 */
@Test
public void testNofityOverrideUrls_CleanOnly() {
    RegistryDirectory registryDirectory = getRegistryDirectory();
    invocation = new RpcInvocation();
    List<URL> durls = new ArrayList<URL>();
    durls.add(SERVICEURL.setHost("10.20.30.140").addParameter("timeout", "1"));
    registryDirectory.notify(durls);
    Assertions.assertNull(((InvokerWrapper<?>) registryDirectory.getInvokers().get(0)).getUrl().getParameter("mock"));
    // override
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0?timeout=1000&mock=fail"));
    registryDirectory.notify(durls);
    List<Invoker<?>> invokers = registryDirectory.list(invocation);
    Invoker<?> aInvoker = invokers.get(0);
    Assertions.assertEquals("1000", aInvoker.getUrl().getParameter("timeout"));
    Assertions.assertEquals("fail", ((InvokerWrapper<?>) registryDirectory.getInvokers().get(0)).getUrl().getParameter("mock"));
    // override clean
    durls = new ArrayList<URL>();
    durls.add(URL.valueOf("override://0.0.0.0/dubbo.test.api.HelloService"));
    registryDirectory.notify(durls);
    invokers = registryDirectory.list(invocation);
    aInvoker = invokers.get(0);
    // Need to be restored to the original providerUrl
    Assertions.assertEquals("1", aInvoker.getUrl().getParameter("timeout"));
    Assertions.assertNull(((InvokerWrapper<?>) registryDirectory.getInvokers().get(0)).getUrl().getParameter("mock"));
}
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) InvokerWrapper(org.apache.dubbo.rpc.protocol.InvokerWrapper) 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 InvokerWrapper (org.apache.dubbo.rpc.protocol.InvokerWrapper)1 Test (org.junit.jupiter.api.Test)1