Search in sources :

Example 1 with RecordFetcher

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);
}
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 RecordFetcher

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

Example 3 with RecordFetcher

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

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