Search in sources :

Example 1 with Factory

use of io.grpc.NameResolver.Factory in project grpc-java by grpc.

the class ManagedChannelImplGetNameResolverTest method testInvalidTarget.

private void testInvalidTarget(String target) {
    Factory nameResolverFactory = new FakeNameResolverFactory("dns");
    try {
        FakeNameResolver nameResolver = (FakeNameResolver) ManagedChannelImpl.getNameResolver(target, nameResolverFactory, NAME_RESOLVER_PARAMS);
        fail("Should have failed, but got resolver with " + nameResolver.uri);
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : Factory(io.grpc.NameResolver.Factory)

Example 2 with Factory

use of io.grpc.NameResolver.Factory in project grpc-java by grpc.

the class ManagedChannelImplGetNameResolverTest method testValidTarget.

private void testValidTarget(String target, String expectedUriString, URI expectedUri) {
    Factory nameResolverFactory = new FakeNameResolverFactory(expectedUri.getScheme());
    FakeNameResolver nameResolver = (FakeNameResolver) ManagedChannelImpl.getNameResolver(target, nameResolverFactory, NAME_RESOLVER_PARAMS);
    assertNotNull(nameResolver);
    assertEquals(expectedUri, nameResolver.uri);
    assertEquals(expectedUriString, nameResolver.uri.toString());
}
Also used : Factory(io.grpc.NameResolver.Factory)

Example 3 with Factory

use of io.grpc.NameResolver.Factory in project grpc-java by grpc.

the class ManagedChannelImplGetNameResolverTest method validTargetNoResovler.

@Test
public void validTargetNoResovler() {
    Factory nameResolverFactory = new NameResolver.Factory() {

        @Override
        public NameResolver newNameResolver(URI targetUri, Attributes params) {
            return null;
        }

        @Override
        public String getDefaultScheme() {
            return "defaultscheme";
        }
    };
    try {
        ManagedChannelImpl.getNameResolver("foo.googleapis.com:8080", nameResolverFactory, NAME_RESOLVER_PARAMS);
        fail("Should fail");
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : Attributes(io.grpc.Attributes) Factory(io.grpc.NameResolver.Factory) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Factory (io.grpc.NameResolver.Factory)3 Attributes (io.grpc.Attributes)1 URI (java.net.URI)1 Test (org.junit.Test)1