Search in sources :

Example 1 with InvalidChildPolicyConfigException

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);
    }
}
Also used : LoadBalancerProvider(io.grpc.LoadBalancerProvider) InvalidChildPolicyConfigException(io.grpc.rls.LbPolicyConfiguration.InvalidChildPolicyConfigException) Test(org.junit.Test)

Aggregations

LoadBalancerProvider (io.grpc.LoadBalancerProvider)1 InvalidChildPolicyConfigException (io.grpc.rls.LbPolicyConfiguration.InvalidChildPolicyConfigException)1 Test (org.junit.Test)1