use of io.grpc.internal.JndiResourceResolverFactory.JndiResourceResolver in project grpc-java by grpc.
the class JndiResourceResolverTest method srvRecordLookup.
@SuppressWarnings("deprecation")
@Test
public void srvRecordLookup() throws Exception {
RecordFetcher recordFetcher = mock(RecordFetcher.class);
when(recordFetcher.getAllRecords("SRV", "dns:///service.example.com")).thenReturn(Arrays.asList("0 0 314 foo.example.com.", "0 0 42 bar.example.com.", "0 0 1 discard.example.com"));
List<SrvRecord> golden = Arrays.asList(new SrvRecord("foo.example.com.", 314), new SrvRecord("bar.example.com.", 42));
JndiResourceResolver resolver = new JndiResourceResolver(recordFetcher);
assertThat(resolver.resolveSrv("service.example.com")).isEqualTo(golden);
}
use of io.grpc.internal.JndiResourceResolverFactory.JndiResourceResolver in project grpc-java by grpc.
the class DnsNameResolverTest method newResolver.
private DnsNameResolver newResolver(String name, Stopwatch stopwatch, boolean isAndroid, NameResolver.Args args) {
DnsNameResolver dnsResolver = new DnsNameResolver(null, name, args, fakeExecutorResource, stopwatch, isAndroid);
// By default, using the mocked ResourceResolver to avoid I/O
dnsResolver.setResourceResolver(new JndiResourceResolver(recordFetcher));
return dnsResolver;
}
use of io.grpc.internal.JndiResourceResolverFactory.JndiResourceResolver in project grpc-java by grpc.
the class JndiResourceResolverTest method txtRecordLookup.
@Test
public void txtRecordLookup() throws Exception {
RecordFetcher recordFetcher = mock(RecordFetcher.class);
when(recordFetcher.getAllRecords("TXT", "dns:///service.example.com")).thenReturn(Arrays.asList("foo", "\"bar\""));
List<String> golden = Arrays.asList("foo", "bar");
JndiResourceResolver resolver = new JndiResourceResolver(recordFetcher);
assertThat(resolver.resolveTxt("service.example.com")).isEqualTo(golden);
}
Aggregations