Search in sources :

Example 81 with Address

use of okhttp3.Address in project okhttp by square.

the class AddressTest method differentProxySelectorsAreDifferent.

@Test
public void differentProxySelectorsAreDifferent() throws Exception {
    Address a = new Address("square.com", 80, dns, socketFactory, null, null, null, authenticator, null, protocols, connectionSpecs, new RecordingProxySelector());
    Address b = new Address("square.com", 80, dns, socketFactory, null, null, null, authenticator, null, protocols, connectionSpecs, new RecordingProxySelector());
    assertFalse(a.equals(b));
}
Also used : RecordingProxySelector(okhttp3.internal.http.RecordingProxySelector) Test(org.junit.Test)

Example 82 with Address

use of okhttp3.Address in project okhttp by square.

the class ConnectionPoolTest method allocateAndLeakAllocation.

/** Use a helper method so there's no hidden reference remaining on the stack. */
private void allocateAndLeakAllocation(ConnectionPool pool, RealConnection connection) {
    synchronized (pool) {
        StreamAllocation leak = new StreamAllocation(pool, connection.route().address(), null);
        leak.acquire(connection);
    }
}
Also used : StreamAllocation(okhttp3.internal.connection.StreamAllocation)

Example 83 with Address

use of okhttp3.Address in project okhttp by square.

the class URLConnectionTest method connectViaHttpProxyToHttpsUsingBadProxyAndHttpResponseCache.

/** Tolerate bad https proxy response when using HttpResponseCache. Android bug 6754912. */
@Test
public void connectViaHttpProxyToHttpsUsingBadProxyAndHttpResponseCache() throws Exception {
    initResponseCache();
    server.useHttps(sslClient.socketFactory, true);
    // The inclusion of a body in the response to a CONNECT is key to reproducing b/6754912.
    MockResponse badProxyResponse = new MockResponse().setSocketPolicy(UPGRADE_TO_SSL_AT_END).setBody("bogus proxy connect response content");
    server.enqueue(badProxyResponse);
    server.enqueue(new MockResponse().setBody("response"));
    // Configure a single IP address for the host and a single configuration, so we only need one
    // failure to fail permanently.
    urlFactory.setClient(urlFactory.client().newBuilder().dns(new SingleInetAddressDns()).sslSocketFactory(sslClient.socketFactory, sslClient.trustManager).connectionSpecs(Util.immutableList(ConnectionSpec.MODERN_TLS)).hostnameVerifier(new RecordingHostnameVerifier()).proxy(server.toProxyAddress()).build());
    URL url = new URL("https://android.com/foo");
    connection = urlFactory.open(url);
    assertContent("response", connection);
    RecordedRequest connect = server.takeRequest();
    assertEquals("CONNECT android.com:443 HTTP/1.1", connect.getRequestLine());
    assertEquals("android.com:443", connect.getHeader("Host"));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) SingleInetAddressDns(okhttp3.internal.SingleInetAddressDns) URL(java.net.URL) Test(org.junit.Test)

Example 84 with Address

use of okhttp3.Address in project okhttp by square.

the class RouteSelectorTest method singleRoute.

@Test
public void singleRoute() throws Exception {
    Address address = httpAddress();
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    assertTrue(routeSelector.hasNext());
    dns.set(uriHost, dns.allocate(1));
    assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
    dns.assertRequests(uriHost);
    assertFalse(routeSelector.hasNext());
    try {
        routeSelector.next();
        fail();
    } catch (NoSuchElementException expected) {
    }
}
Also used : SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Example 85 with Address

use of okhttp3.Address in project okhttp by square.

the class RouteSelectorTest method proxySelectorReturnsNull.

@Test
public void proxySelectorReturnsNull() throws Exception {
    ProxySelector nullProxySelector = new ProxySelector() {

        @Override
        public List<Proxy> select(URI uri) {
            assertEquals(uriHost, uri.getHost());
            return null;
        }

        @Override
        public void connectFailed(URI uri, SocketAddress socketAddress, IOException e) {
            throw new AssertionError();
        }
    };
    Address address = new Address(uriHost, uriPort, dns, socketFactory, null, null, null, authenticator, null, protocols, connectionSpecs, nullProxySelector);
    RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
    assertTrue(routeSelector.hasNext());
    dns.set(uriHost, dns.allocate(1));
    assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
    dns.assertRequests(uriHost);
    assertFalse(routeSelector.hasNext());
}
Also used : ProxySelector(java.net.ProxySelector) RecordingProxySelector(okhttp3.internal.http.RecordingProxySelector) Proxy(java.net.Proxy) SocketAddress(java.net.SocketAddress) Address(okhttp3.Address) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) IOException(java.io.IOException) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)92 Address (org.orcid.jaxb.model.record_v2.Address)84 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 OtherName (org.orcid.jaxb.model.record_v2.OtherName)43 Addresses (org.orcid.jaxb.model.record_v2.Addresses)42 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)32 Name (org.orcid.jaxb.model.record_v2.Name)30 Person (org.orcid.jaxb.model.record_v2.Person)30 DBUnitTest (org.orcid.test.DBUnitTest)20 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