use of io.grpc.internal.JndiResourceResolverFactory.RecordFetcher 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.RecordFetcher in project grpc-java by grpc.
the class JndiResourceResolverTest method jndiResolverWorks.
@IgnoreJRERequirement
@Test
public void jndiResolverWorks() throws Exception {
Assume.assumeNoException(new JndiResourceResolverFactory().unavailabilityCause());
RecordFetcher recordFetcher = new JndiRecordFetcher();
try {
recordFetcher.getAllRecords("SRV", "dns:///localhost");
} catch (javax.naming.CommunicationException e) {
Assume.assumeNoException(e);
} catch (javax.naming.NameNotFoundException e) {
Assume.assumeNoException(e);
}
}
use of io.grpc.internal.JndiResourceResolverFactory.RecordFetcher 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