Package com.twitter.hbc.core

Examples of com.twitter.hbc.core.HttpHosts


  }

  @Test
  public void testUnknownEndpointFails() {
    ClientBase clientBase = new ClientBase("name",
            mock, new HttpHosts("http://hi"), new RawEndpoint("/endpoint", HttpConstants.HTTP_GET), mockAuth,
            mockProcessor, mockReconnectionManager, mockRateTracker
    );
    when(mockStatusLine.getStatusCode())
            .thenReturn(404);
    when(mockStatusLine.getReasonPhrase())
View Full Code Here


  }

  @Test
  public void testServiceUnavailable() {
    ClientBase clientBase = new ClientBase("name",
            mock, new HttpHosts("http://hi"), new RawEndpoint("/endpoint", HttpConstants.HTTP_GET), mockAuth,
            mockProcessor, mockReconnectionManager, mockRateTracker
    );
    when(mockStatusLine.getStatusCode())
            .thenReturn(503);
View Full Code Here

  private HttpEntity mockEntity;

  @Before
  public void setup() {
    client = mock(HttpClient.class);
    hosts = new HttpHosts("https://host.com");
    auth = mock(Authentication.class);
    request = mock(HttpUriRequest.class);
    mockResponse = mock(HttpResponse.class);
    mockStatusLine = mock(StatusLine.class);
    mockEntity = mock(HttpEntity.class);
View Full Code Here

  // the overall flow. Worth it?

  @Test
  public void testIOExceptionDuringProcessing() throws Exception {
    ClientBase clientBase = new ClientBase("name",
            mockClient, new HttpHosts("http://hi"), new RawEndpoint("/endpoint", HttpConstants.HTTP_GET), mockAuth,
            mockProcessor, mockReconnectionManager, mockRateTracker
    );
    BasicClient client = new BasicClient(clientBase, executorService);
    final CountDownLatch latch = new CountDownLatch(1);
    when(mockStatusLine.getStatusCode())
View Full Code Here

  }

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

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

    assertTrue(client.getExitEvent().getUnderlyingException() instanceof InterruptedException);
  }

  @Test
  public void testConnectionRetries() throws Exception {
    HttpHosts mockHttpHosts = mock(HttpHosts.class);
    ClientBase clientBase = new ClientBase("name",
            mockClient, mockHttpHosts, new RawEndpoint("/endpoint", HttpConstants.HTTP_GET), mockAuth,
            mockProcessor, mockReconnectionManager, mockRateTracker
    );

    BasicClient client = new BasicClient(clientBase, executorService);
    final CountDownLatch latch = new CountDownLatch(1);
    when(mockHttpHosts.nextHost())
            .thenReturn("http://somehost.com");
    when(mockClient.execute(any(HttpUriRequest.class)))
            .thenReturn(mockResponse)
            .thenReturn(mockResponse)
            .thenThrow(new IOException())
View Full Code Here

    /**
     * Client builder fails to build with no auth specified
     */
    try {
      new ClientBuilder()
              .hosts(new HttpHosts(Constants.STREAM_HOST))
              .endpoint(new StatusesSampleEndpoint())
              .processor(new NullProcessor())
              .build();
      fail();
    } catch (Exception e) {
      // expected
    }

    /**
     * Client builder fails to build with no host specified
     */
    try {
      new ClientBuilder()
              .endpoint(new StatusesSampleEndpoint())
              .processor(new NullProcessor())
              .authentication(new BasicAuth("username", "password"))
              .build();
      fail();
    } catch (Exception e) {
      // expected
    }


    /**
     * Client builder fails to build with no endpoint specified
     */
    try {
      new ClientBuilder()
              .hosts(new HttpHosts(Constants.STREAM_HOST))
              .processor(new NullProcessor())
              .authentication(new BasicAuth("username", "password"))
              .build();
      fail();
    } catch (Exception e) {
      // expected
    }

    /**
     * Client builder fails to build with no processor specified
     */
    try {
      new ClientBuilder()
              .hosts(new HttpHosts(Constants.STREAM_HOST))
              .endpoint(new StatusesSampleEndpoint())
              .authentication(new BasicAuth("username", "password"))
              .build();
      fail();
    } catch (Exception e) {
View Full Code Here


  @Test
  public void testBuilderSuccess() {
    new ClientBuilder()
            .hosts(new HttpHosts(Constants.STREAM_HOST))
            .endpoint(new StatusesSampleEndpoint())
            .processor(new NullProcessor())
            .authentication(new BasicAuth("username", "password"))
            .build();
View Full Code Here

  @Test
  public void testInvalidHttpMethod() {
    try {
      new ClientBuilder()
              .hosts(new HttpHosts(Constants.STREAM_HOST))
              .endpoint(StatusesSampleEndpoint.PATH, "FAIL!")
              .processor(new NullProcessor())
              .authentication(new BasicAuth("username", "password"))
              .build();
      fail();
View Full Code Here

  }

  @Test
  public void testValidHttpMethod() {
    new ClientBuilder()
            .hosts(new HttpHosts(Constants.STREAM_HOST))
            .endpoint(StatusesSampleEndpoint.PATH, "gEt")
            .processor(new NullProcessor())
            .authentication(new BasicAuth("username", "password"))
            .build();
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.