@Test
public void testUseProviderParams() {

    // present in both local and remote, but uses remote value.
    URL localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
            "&methods=local&tag=local&timestamp=local");
    URL remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=remote&group=remote&dubbo=remote&release=remote" +
            "&methods=remote&tag=remote&timestamp=remote");
    URL mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
    Assertions.assertEquals(remoteURL.getParameter(VERSION_KEY), mergedUrl.getParameter(VERSION_KEY));
    Assertions.assertEquals(remoteURL.getParameter(GROUP_KEY), mergedUrl.getParameter(GROUP_KEY));
    Assertions.assertEquals(remoteURL.getParameter(DUBBO_VERSION_KEY), mergedUrl.getParameter(DUBBO_VERSION_KEY));
    Assertions.assertEquals(remoteURL.getParameter(RELEASE_KEY), mergedUrl.getParameter(RELEASE_KEY));
    Assertions.assertEquals(remoteURL.getParameter(METHODS_KEY), mergedUrl.getParameter(METHODS_KEY));
    Assertions.assertEquals(remoteURL.getParameter(TIMESTAMP_KEY), mergedUrl.getParameter(TIMESTAMP_KEY));
    Assertions.assertEquals(remoteURL.getParameter(TAG_KEY), mergedUrl.getParameter(TAG_KEY));
    // present in local url but not in remote url, parameters of remote url is empty
    localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
            "&methods=local&tag=local&timestamp=local");
    remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService");
    mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
    Assertions.assertEquals(mergedUrl.getParameter(VERSION_KEY),localURL.getParameter(VERSION_KEY));
    Assertions.assertEquals(mergedUrl.getParameter(GROUP_KEY),localURL.getParameter(GROUP_KEY));
    Assertions.assertNull(mergedUrl.getParameter(DUBBO_VERSION_KEY));
    Assertions.assertNull(mergedUrl.getParameter(RELEASE_KEY));
    Assertions.assertNull(mergedUrl.getParameter(METHODS_KEY));
    Assertions.assertNull(mergedUrl.getParameter(TIMESTAMP_KEY));
    Assertions.assertNull(mergedUrl.getParameter(TAG_KEY));
    // present in local url but not in remote url
    localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
            "&methods=local&tag=local&timestamp=local");
    remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService?key=value");
    mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
    Assertions.assertEquals(mergedUrl.getParameter(VERSION_KEY),localURL.getParameter(VERSION_KEY));
    Assertions.assertEquals(mergedUrl.getParameter(GROUP_KEY),localURL.getParameter(GROUP_KEY));
    Assertions.assertNull(mergedUrl.getParameter(DUBBO_VERSION_KEY));
    Assertions.assertNull(mergedUrl.getParameter(RELEASE_KEY));
    Assertions.assertNull(mergedUrl.getParameter(METHODS_KEY));
    Assertions.assertNull(mergedUrl.getParameter(TIMESTAMP_KEY));
    Assertions.assertNull(mergedUrl.getParameter(TAG_KEY));
    // present in both local and remote, uses local url params
    localURL = URL.valueOf("dubbo://localhost:20880/DemoService?loadbalance=local&timeout=1000&cluster=local");
    remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService?loadbalance=remote&timeout=2000&cluster=remote");
    mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
    Assertions.assertEquals(localURL.getParameter(CLUSTER_KEY), mergedUrl.getParameter(CLUSTER_KEY));
    Assertions.assertEquals(localURL.getParameter(TIMEOUT_KEY), mergedUrl.getParameter(TIMEOUT_KEY));
    Assertions.assertEquals(localURL.getParameter(LOADBALANCE_KEY), mergedUrl.getParameter(LOADBALANCE_KEY));
}