use of io.grpc.rls.LbPolicyConfiguration.InvalidChildPolicyConfigException in project grpc-java by grpc.
the class LbPolicyConfigurationTest method childLoadBalancingPolicy_noPolicyProvided.
@Test
public void childLoadBalancingPolicy_noPolicyProvided() {
LoadBalancerProvider mockProvider = mock(LoadBalancerProvider.class);
when(mockProvider.getPolicyName()).thenReturn("rls");
when(mockProvider.isAvailable()).thenReturn(true);
LoadBalancerRegistry.getDefaultRegistry().register(mockProvider);
try {
ChildLoadBalancingPolicy.create("targetFieldName", ImmutableList.<Map<String, ?>>of(ImmutableMap.<String, Object>of("rls", ImmutableMap.of(), "rls2", ImmutableMap.of())));
fail("parsing exception expected");
} catch (InvalidChildPolicyConfigException e) {
assertThat(e).hasMessageThat().contains("childPolicy should have exactly one loadbalancing policy");
} finally {
LoadBalancerRegistry.getDefaultRegistry().deregister(mockProvider);
}
}
Aggregations