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
}
}
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());
}
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
}
}
Aggregations