Search in sources :

Example 76 with Address

use of io.grpc.channelz.v1.Address in project okhttp by square.

the class RouteSelectorTest method proxyDnsFailureContinuesToNextProxy.

@Test
public void proxyDnsFailureContinuesToNextProxy() throws Exception {
    Address address = httpAddress();
    proxySelector.proxies.add(proxyA);
    proxySelector.proxies.add(proxyB);
    proxySelector.proxies.add(proxyA);
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    proxySelector.assertRequests(address.url().uri());
    assertTrue(routeSelector.hasNext());
    dns.set(proxyAHost, dns.allocate(1));
    assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 0), proxyAPort);
    dns.assertRequests(proxyAHost);
    assertTrue(routeSelector.hasNext());
    dns.clear(proxyBHost);
    try {
        routeSelector.next();
        fail();
    } catch (UnknownHostException expected) {
    }
    dns.assertRequests(proxyBHost);
    assertTrue(routeSelector.hasNext());
    dns.set(proxyAHost, dns.allocate(1));
    assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 0), proxyAPort);
    dns.assertRequests(proxyAHost);
    assertFalse(routeSelector.hasNext());
}
Also used : SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) UnknownHostException(java.net.UnknownHostException) Test(org.junit.Test)

Example 77 with Address

use of io.grpc.channelz.v1.Address in project okhttp by square.

the class RouteSelectorTest method proxySelectorReturnsMultipleProxies.

@Test
public void proxySelectorReturnsMultipleProxies() throws Exception {
    Address address = httpAddress();
    proxySelector.proxies.add(proxyA);
    proxySelector.proxies.add(proxyB);
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    proxySelector.assertRequests(address.url().uri());
    // First try the IP addresses of the first proxy, in sequence.
    assertTrue(routeSelector.hasNext());
    dns.set(proxyAHost, dns.allocate(2));
    assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 0), proxyAPort);
    assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 1), proxyAPort);
    dns.assertRequests(proxyAHost);
    // Next try the IP address of the second proxy.
    assertTrue(routeSelector.hasNext());
    dns.set(proxyBHost, dns.allocate(1));
    assertRoute(routeSelector.next(), address, proxyB, dns.lookup(proxyBHost, 0), proxyBPort);
    dns.assertRequests(proxyBHost);
    // No more proxies to try.
    assertFalse(routeSelector.hasNext());
}
Also used : SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 78 with Address

use of io.grpc.channelz.v1.Address in project okhttp by square.

the class RouteSelectorTest method explicitDirectProxy.

@Test
public void explicitDirectProxy() throws Exception {
    Address address = new Address(uriHost, uriPort, dns, socketFactory, null, null, null, authenticator, NO_PROXY, protocols, connectionSpecs, proxySelector);
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    assertTrue(routeSelector.hasNext());
    dns.set(uriHost, dns.allocate(2));
    assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
    assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 1), uriPort);
    assertFalse(routeSelector.hasNext());
    dns.assertRequests(uriHost);
    // No proxy selector requests!
    proxySelector.assertRequests();
}
Also used : SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 79 with Address

use of io.grpc.channelz.v1.Address in project okhttp by square.

the class RetryAndFollowUpInterceptor method createAddress.

private Address createAddress(HttpUrl url) {
    SSLSocketFactory sslSocketFactory = null;
    HostnameVerifier hostnameVerifier = null;
    CertificatePinner certificatePinner = null;
    if (url.isHttps()) {
        sslSocketFactory = client.sslSocketFactory();
        hostnameVerifier = client.hostnameVerifier();
        certificatePinner = client.certificatePinner();
    }
    return new Address(url.host(), url.port(), client.dns(), client.socketFactory(), sslSocketFactory, hostnameVerifier, certificatePinner, client.proxyAuthenticator(), client.proxy(), client.protocols(), client.connectionSpecs(), client.proxySelector());
}
Also used : Address(okhttp3.Address) CertificatePinner(okhttp3.CertificatePinner) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) HostnameVerifier(javax.net.ssl.HostnameVerifier)

Example 80 with Address

use of io.grpc.channelz.v1.Address in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewAddress.

@Override
public Response viewAddress(String orcid, Long putCode) {
    Address address = addressManagerReadOnly.getAddress(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, address, ScopePathType.ORCID_BIO_READ_LIMITED);
    ElementUtils.setPathToAddress(address, orcid);
    sourceUtils.setSourceName(address);
    return Response.ok(address).build();
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address)

Aggregations

Test (org.junit.Test)86 Address (org.orcid.jaxb.model.record_v2.Address)82 Addresses (org.orcid.jaxb.model.record_v2.Addresses)43 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)42 Email (org.orcid.jaxb.model.record_v2.Email)41 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 Emails (org.orcid.jaxb.model.record_v2.Emails)34 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 Name (org.orcid.jaxb.model.record_v2.Name)31 Person (org.orcid.jaxb.model.record_v2.Person)31 Record (org.orcid.jaxb.model.record_v2.Record)19 Response (javax.ws.rs.core.Response)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18