當前位置: 首頁>>代碼示例>>Java>>正文


Java RouteDatabase類代碼示例

本文整理匯總了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) {
  }
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:20,代碼來源:RouteSelectorTest.java

示例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) {
  }
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:22,代碼來源:RouteSelectorTest.java

示例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!
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:18,代碼來源:RouteSelectorTest.java

示例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!
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:18,代碼來源:RouteSelectorTest.java

示例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());
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:18,代碼來源:RouteSelectorTest.java

示例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);
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:18,代碼來源:RouteSelectorTest.java

示例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());
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:19,代碼來源:RouteSelectorTest.java

示例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) {
  }
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:19,代碼來源:RouteSelectorTest.java

示例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) {
  }
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:21,代碼來源:RouteSelectorTest.java

示例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!
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:17,代碼來源:RouteSelectorTest.java

示例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!
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:18,代碼來源:RouteSelectorTest.java

示例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());
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:17,代碼來源:RouteSelectorTest.java

示例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);
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:17,代碼來源:RouteSelectorTest.java

示例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());
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:18,代碼來源:RouteSelectorTest.java

示例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());
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:13,代碼來源:RouteSelector.java


注:本文中的com.squareup.okhttp.RouteDatabase類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。