Package com.twitter.hbc.core

Examples of com.twitter.hbc.core.HttpHosts


  /**
   * @param host Http host in the form of <scheme>://<host>
   */
  public ClientBuilder hosts(String host) {
    this.hosts = new HttpHosts(Preconditions.checkNotNull(host));
    return this;
  }
View Full Code Here


  /**
   * Construct a sitestream controller using the default host (sitestream.twitter.com)
   */
  public SitestreamController(HttpClient client, Authentication auth) {
    this.client = Preconditions.checkNotNull(client);
    this.hosts = new HttpHosts(Constants.SITESTREAM_HOST);
    this.auth = Preconditions.checkNotNull(auth);
  }
View Full Code Here

   * Construct a sitestream controller using the default host (sitestream.twitter.com) and a
   * DefaultHttpClient.
   */
  public SitestreamController(Authentication auth) {
    this.client = new DefaultHttpClient(new PoolingClientConnectionManager());
    this.hosts = new HttpHosts(Constants.SITESTREAM_HOST);
    this.auth = Preconditions.checkNotNull(auth);
  }
View Full Code Here

      } else {
        hosts.add("https://thisismyawesomehost " + i + ".com");
      }
    }
    try {
      new HttpHosts(hosts);
      fail();
    } catch (RuntimeException e) {
      // is expected
    }
  }
View Full Code Here

    int size = 50;
    List<String> hosts = new ArrayList<String>(size);
    for (int i = 0; i < size; i++) {
      hosts.add("http://thisismyawesomehost " + i + ".com");
    }
    HttpHosts httpHosts = new HttpHosts(hosts);

    boolean allSame = true;
    for (String string : hosts) {
      if (!string.equals(httpHosts.nextHost())) {
        allSame = false;
        break;
      }
    }
    assertFalse("This test failed unless you got EXTREMELY unlucky.", allSame);
View Full Code Here

    int size = 30;
    List<String> hosts = new ArrayList<String>(size);
    for (int i = 0; i < size; i++) {
      hosts.add("http://thisismyawesomehost " + i + ".com");
    }
    HttpHosts httpHosts = new HttpHosts(hosts);
    Set<String> hostsSet = new HashSet<String>(hosts);
    for (int i = 0; i < size; i++) {
      assertTrue(hostsSet.remove(httpHosts.nextHost()));
    }
    assertTrue(hostsSet.isEmpty());
  }
View Full Code Here

    int size = 10;
    List<String> hosts = new ArrayList<String>(size);
    for (int i = 0; i < size; i++) {
      hosts.add("http://thisismyawesomehost " + i + ".com");
    }
    HttpHosts httpHosts = new HttpHosts(hosts);
    Set<String> hostsSet = new HashSet<String>(hosts);
    for (int i = 0; i < size * 10; i++) {
      assertTrue(hostsSet.contains(httpHosts.nextHost()));
    }
  }
View Full Code Here

  }

  @Test
  public void testProperlyHandleSuccessfulConnection() {
    ClientBase clientBase = new ClientBase("name",
            mock, new HttpHosts("http://hi"), new RawEndpoint("/endpoint", HttpConstants.HTTP_GET), mockAuth,
            mockProcessor, mockReconnectionManager, mockRateTracker
    );

    mockStatusLine = mock(StatusLine.class);
    when(mockStatusLine.getStatusCode())
View Full Code Here

  }

  @Test
  public void testHandleIOExceptionOnConnection() throws IOException {
    ClientBase clientBase = new ClientBase("name",
            mock, new HttpHosts("http://hi"), new RawEndpoint("/endpoint", HttpConstants.HTTP_GET), mockAuth,
            mockProcessor, mockReconnectionManager, mockRateTracker
    );
    when(mockConnection.connect(any(HttpUriRequest.class)))
            .thenThrow(new IOException());
View Full Code Here

  }

  @Test
  public void testRetryTransientAuthFailures() {
    ClientBase clientBase = new ClientBase("name",
            mock, new HttpHosts("http://hi"), new RawEndpoint("/endpoint", HttpConstants.HTTP_GET), mockAuth,
            mockProcessor, mockReconnectionManager, mockRateTracker
    );

    when(mockStatusLine.getStatusCode())
            .thenReturn(401);
View Full Code Here

TOP

Related Classes of com.twitter.hbc.core.HttpHosts

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.