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


Java RouteDatabase.failed方法代碼示例

本文整理匯總了Java中com.squareup.okhttp.RouteDatabase.failed方法的典型用法代碼示例。如果您正苦於以下問題:Java RouteDatabase.failed方法的具體用法?Java RouteDatabase.failed怎麽用?Java RouteDatabase.failed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.squareup.okhttp.RouteDatabase的用法示例。


在下文中一共展示了RouteDatabase.failed方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: failedRoutesAreLast

import com.squareup.okhttp.RouteDatabase; //導入方法依賴的package包/類
@Test public void failedRoutesAreLast() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, sslSocketFactory,
      hostnameVerifier, authenticator, Proxy.NO_PROXY, protocols);

  RouteDatabase routeDatabase = new RouteDatabase();
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      routeDatabase);
  dns.inetAddresses = makeFakeAddresses(255, 1);

  // Extract the regular sequence of routes from selector.
  List<Connection> regularRoutes = new ArrayList<Connection>();
  while (routeSelector.hasNext()) {
    regularRoutes.add(routeSelector.next("GET"));
  }

  // Check that we do indeed have more than one route.
  assertTrue(regularRoutes.size() > 1);
  // Add first regular route as failed.
  routeDatabase.failed(regularRoutes.get(0).getRoute());
  // Reset selector
  routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns, routeDatabase);

  List<Connection> routesWithFailedRoute = new ArrayList<Connection>();
  while (routeSelector.hasNext()) {
    routesWithFailedRoute.add(routeSelector.next("GET"));
  }

  assertEquals(regularRoutes.get(0).getRoute(),
      routesWithFailedRoute.get(routesWithFailedRoute.size() - 1).getRoute());
  assertEquals(regularRoutes.size(), routesWithFailedRoute.size());
}
 
開發者ID:xin3liang,項目名稱:platform_external_okhttp,代碼行數:32,代碼來源:RouteSelectorTest.java

示例4: failedRoutesAreLast

import com.squareup.okhttp.RouteDatabase; //導入方法依賴的package包/類
@Test public void failedRoutesAreLast() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, hostnameVerifier, authenticator,
      Proxy.NO_PROXY, transports);

  RouteDatabase routeDatabase = new RouteDatabase();
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      routeDatabase);
  dns.inetAddresses = makeFakeAddresses(255, 1);

  // Extract the regular sequence of routes from selector.
  List<Connection> regularRoutes = new ArrayList<Connection>();
  while (routeSelector.hasNext()) {
    regularRoutes.add(routeSelector.next("GET"));
  }

  // Check that we do indeed have more than one route.
  assertTrue(regularRoutes.size() > 1);
  // Add first regular route as failed.
  routeDatabase.failed(regularRoutes.get(0).getRoute(), new SSLHandshakeException("none"));
  // Reset selector
  routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns, routeDatabase);

  List<Connection> routesWithFailedRoute = new ArrayList<Connection>();
  while (routeSelector.hasNext()) {
    routesWithFailedRoute.add(routeSelector.next("GET"));
  }

  assertEquals(regularRoutes.get(0).getRoute(),
      routesWithFailedRoute.get(routesWithFailedRoute.size() - 1).getRoute());
  assertEquals(regularRoutes.size(), routesWithFailedRoute.size());
}
 
開發者ID:c-ong,項目名稱:mirrored-okhttp,代碼行數:32,代碼來源:RouteSelectorTest.java


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