Search in sources :

Example 1 with JndiResourceResolver

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);
}
Also used : JndiRecordFetcher(io.grpc.internal.JndiResourceResolverFactory.JndiRecordFetcher) RecordFetcher(io.grpc.internal.JndiResourceResolverFactory.RecordFetcher) SrvRecord(io.grpc.internal.DnsNameResolver.SrvRecord) JndiResourceResolver(io.grpc.internal.JndiResourceResolverFactory.JndiResourceResolver) Test(org.junit.Test)

Example 2 with JndiResourceResolver

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;
}
Also used : JndiResourceResolver(io.grpc.internal.JndiResourceResolverFactory.JndiResourceResolver)

Example 3 with JndiResourceResolver

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);
}
Also used : JndiRecordFetcher(io.grpc.internal.JndiResourceResolverFactory.JndiRecordFetcher) RecordFetcher(io.grpc.internal.JndiResourceResolverFactory.RecordFetcher) JndiResourceResolver(io.grpc.internal.JndiResourceResolverFactory.JndiResourceResolver) Test(org.junit.Test)

Aggregations

JndiResourceResolver (io.grpc.internal.JndiResourceResolverFactory.JndiResourceResolver)3 JndiRecordFetcher (io.grpc.internal.JndiResourceResolverFactory.JndiRecordFetcher)2 RecordFetcher (io.grpc.internal.JndiResourceResolverFactory.RecordFetcher)2 Test (org.junit.Test)2 SrvRecord (io.grpc.internal.DnsNameResolver.SrvRecord)1