use of io.grpc.NameResolver in project grpc-java by grpc.
the class ManagedChannelImplGetNameResolverTest method validAuthorityTarget_overrideAuthority.
@Test
public void validAuthorityTarget_overrideAuthority() throws Exception {
String target = "foo.googleapis.com:8080";
String overrideAuthority = "override.authority";
URI expectedUri = new URI("defaultscheme", "", "/foo.googleapis.com:8080", null);
NameResolver.Factory nameResolverFactory = new FakeNameResolverFactory(expectedUri.getScheme());
NameResolver nameResolver = ManagedChannelImpl.getNameResolver(target, overrideAuthority, nameResolverFactory, NAMERESOLVER_ARGS);
assertThat(nameResolver.getServiceAuthority()).isEqualTo(overrideAuthority);
}
use of io.grpc.NameResolver in project grpc-java by grpc.
the class XdsNameResolverProviderTest method newProvider_overrideBootstrap.
@Test
public void newProvider_overrideBootstrap() {
Map<String, ?> b = ImmutableMap.of("node", ImmutableMap.of("id", "ENVOY_NODE_ID", "cluster", "ENVOY_CLUSTER"), "xds_servers", Collections.singletonList(ImmutableMap.of("server_uri", "trafficdirector.googleapis.com:443", "channel_creds", Collections.singletonList(ImmutableMap.of("type", "insecure")))));
NameResolverRegistry registry = new NameResolverRegistry();
XdsNameResolverProvider provider = XdsNameResolverProvider.createForTest("no-scheme", b);
registry.register(provider);
NameResolver resolver = registry.asFactory().newNameResolver(URI.create("no-scheme:///localhost"), args);
resolver.start(mock(NameResolver.Listener2.class));
assertThat(resolver).isInstanceOf(XdsNameResolver.class);
assertThat(((XdsNameResolver) resolver).getXdsClient().getBootstrapInfo().node().getId()).isEqualTo("ENVOY_NODE_ID");
resolver.shutdown();
registry.deregister(provider);
}
Aggregations