本文整理匯總了Java中com.squareup.okhttp.RouteDatabase類的典型用法代碼示例。如果您正苦於以下問題:Java RouteDatabase類的具體用法?Java RouteDatabase怎麽用?Java RouteDatabase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RouteDatabase類屬於com.squareup.okhttp包,在下文中一共展示了RouteDatabase類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: singleRoute
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void singleRoute() throws Exception {
Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
protocols);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
try {
routeSelector.next("GET");
fail();
} catch (NoSuchElementException expected) {
}
}
示例2: singleRouteReturnsFailedRoute
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void singleRouteReturnsFailedRoute() throws Exception {
Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
protocols);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
Connection connection = routeSelector.next("GET");
RouteDatabase routeDatabase = new RouteDatabase();
routeDatabase.failed(connection.getRoute());
routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns, routeDatabase);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
assertFalse(routeSelector.hasNext());
try {
routeSelector.next("GET");
fail();
} catch (NoSuchElementException expected) {
}
}
示例3: explicitProxyTriesThatProxiesAddressesOnly
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void explicitProxyTriesThatProxiesAddressesOnly() throws Exception {
Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator,
proxyA, protocols);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 2);
assertConnection(routeSelector.next("GET"), address, proxyA, dns.inetAddresses[0], proxyAPort,
false);
assertConnection(routeSelector.next("GET"), address, proxyA, dns.inetAddresses[1], proxyAPort,
false);
assertFalse(routeSelector.hasNext());
dns.assertRequests(proxyAHost);
proxySelector.assertRequests(); // No proxy selector requests!
}
示例4: explicitDirectProxy
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void explicitDirectProxy() throws Exception {
Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator,
NO_PROXY, protocols);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 2);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[1], uriPort,
false);
assertFalse(routeSelector.hasNext());
dns.assertRequests(uri.getHost());
proxySelector.assertRequests(); // No proxy selector requests!
}
示例5: proxySelectorReturnsNull
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void proxySelectorReturnsNull() throws Exception {
Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
protocols);
proxySelector.proxies = null;
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
proxySelector.assertRequests(uri);
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
}
示例6: proxySelectorReturnsNoProxies
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void proxySelectorReturnsNoProxies() throws Exception {
Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
protocols);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 2);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[1], uriPort,
false);
assertFalse(routeSelector.hasNext());
dns.assertRequests(uri.getHost());
proxySelector.assertRequests(uri);
}
示例7: proxySelectorDirectConnectionsAreSkipped
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void proxySelectorDirectConnectionsAreSkipped() throws Exception {
Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
protocols);
proxySelector.proxies.add(NO_PROXY);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
proxySelector.assertRequests(uri);
// Only the origin server will be attempted.
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
}
示例8: singleRoute
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void singleRoute() throws Exception {
Address address = new Address(uriHost, uriPort, null, null, authenticator, null, transports);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
try {
routeSelector.next("GET");
fail();
} catch (NoSuchElementException expected) {
}
}
示例9: singleRouteReturnsFailedRoute
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void singleRouteReturnsFailedRoute() throws Exception {
Address address = new Address(uriHost, uriPort, null, null, authenticator, null, transports);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
Connection connection = routeSelector.next("GET");
RouteDatabase routeDatabase = new RouteDatabase();
routeDatabase.failed(connection.getRoute(), new IOException());
routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns, routeDatabase);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
assertFalse(routeSelector.hasNext());
try {
routeSelector.next("GET");
fail();
} catch (NoSuchElementException expected) {
}
}
示例10: explicitProxyTriesThatProxiesAddressesOnly
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void explicitProxyTriesThatProxiesAddressesOnly() throws Exception {
Address address = new Address(uriHost, uriPort, null, null, authenticator, proxyA, transports);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 2);
assertConnection(routeSelector.next("GET"), address, proxyA, dns.inetAddresses[0], proxyAPort,
false);
assertConnection(routeSelector.next("GET"), address, proxyA, dns.inetAddresses[1], proxyAPort,
false);
assertFalse(routeSelector.hasNext());
dns.assertRequests(proxyAHost);
proxySelector.assertRequests(); // No proxy selector requests!
}
示例11: explicitDirectProxy
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void explicitDirectProxy() throws Exception {
Address address = new Address(uriHost, uriPort, null, null, authenticator, NO_PROXY,
transports);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 2);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[1], uriPort,
false);
assertFalse(routeSelector.hasNext());
dns.assertRequests(uri.getHost());
proxySelector.assertRequests(); // No proxy selector requests!
}
示例12: proxySelectorReturnsNull
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void proxySelectorReturnsNull() throws Exception {
Address address = new Address(uriHost, uriPort, null, null, authenticator, null, transports);
proxySelector.proxies = null;
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
proxySelector.assertRequests(uri);
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
}
示例13: proxySelectorReturnsNoProxies
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void proxySelectorReturnsNoProxies() throws Exception {
Address address = new Address(uriHost, uriPort, null, null, authenticator, null, transports);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 2);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[1], uriPort,
false);
assertFalse(routeSelector.hasNext());
dns.assertRequests(uri.getHost());
proxySelector.assertRequests(uri);
}
示例14: proxySelectorDirectConnectionsAreSkipped
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
@Test public void proxySelectorDirectConnectionsAreSkipped() throws Exception {
Address address = new Address(uriHost, uriPort, null, null, authenticator, null, transports);
proxySelector.proxies.add(NO_PROXY);
RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
new RouteDatabase());
proxySelector.assertRequests(uri);
// Only the origin server will be attempted.
assertTrue(routeSelector.hasNext());
dns.inetAddresses = makeFakeAddresses(255, 1);
assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
false);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
}
示例15: RouteSelector
import com.squareup.okhttp.RouteDatabase; //導入依賴的package包/類
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
Dns dns, RouteDatabase routeDatabase) {
this.address = address;
this.uri = uri;
this.proxySelector = proxySelector;
this.pool = pool;
this.dns = dns;
this.routeDatabase = routeDatabase;
this.postponedRoutes = new LinkedList<Route>();
resetNextProxy(uri, address.getProxy());
}