Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed Mar 16, 2022
1 parent 7c4c64d commit a3ac990
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -20,6 +20,7 @@
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcInvocation;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -71,12 +72,16 @@ public void testGetRegistryWeight() {
url1 = url1.addParameter(REGISTRY_KEY + "." + WEIGHT_KEY, 10);
given(invoker1.getUrl()).willReturn(url1);

Invoker invoker2 = mock(Invoker.class, Mockito.withSettings().stubOnly());

ClusterInvoker invoker2 = mock(ClusterInvoker.class, Mockito.withSettings().stubOnly());
URL url2 = new URL("", "", 0, "org.apache.dubbo.registry.RegistryService", new HashMap<>());
url2 = url2.addParameter(REGISTRY_KEY + "." + WEIGHT_KEY, 20);
url2 = url2.addParameter(WEIGHT_KEY, 20);
URL registryUrl2 = new URL("", "", 0, "org.apache.dubbo.registry.RegistryService", new HashMap<>());
registryUrl2 = registryUrl2.addParameter(WEIGHT_KEY, 30);
given(invoker2.getUrl()).willReturn(url2);
given(invoker2.getRegistryUrl()).willReturn(registryUrl2);

Assertions.assertEquals(100, balance.getWeight(invoker1, invocation));
Assertions.assertEquals(20, balance.getWeight(invoker2, invocation));
Assertions.assertEquals(30, balance.getWeight(invoker2, invocation));
}
}

0 comments on commit a3ac990

Please sign in to comment.