@Test
  public void testWrongPort() throws IOException {
    httpClient
        .get(uri, authResponseHandler)
        .addAuth(
            HttpClientDefaultAuthProvider.forUserAndHost(
                localHttpService.getHost(), 22, LOGIN_USER, LOGIN_PASSWORD))
        .perform();

    Assert.assertThat(testHandler.getToken(), is(nullValue()));
  }
  @Test
  public void testWrongScheme() throws IOException {
    httpClient
        .get(uri, authResponseHandler)
        .addAuth(
            new HttpClientDefaultAuthProvider(
                "DIGEST",
                localHttpService.getHost(),
                localHttpService.getPort(),
                "test",
                LOGIN_USER,
                LOGIN_PASSWORD))
        .perform();

    Assert.assertThat(testHandler.getToken(), is(nullValue()));
  }
  @Test
  public void testGetItRight() throws IOException {
    final String response =
        httpClient
            .get(
                uri,
                new ContentResponseHandler<String>(
                    new ResponseCodeCheckingConverter(HttpServletResponse.SC_OK)))
            .addAuth(
                new HttpClientDefaultAuthProvider(
                    "BASIC",
                    localHttpService.getHost(),
                    localHttpService.getPort(),
                    "test",
                    LOGIN_USER,
                    LOGIN_PASSWORD))
            .perform();

    Assert.assertThat(response, is(testString));
    Assert.assertThat(testHandler.getToken(), is(trackingToken));
  }
  @Before
  public void setup() {
    Assert.assertNull(localHttpService);
    Assert.assertNull(httpClient);

    testHandler = new GenericTrackingTestHandler();
    testHandler.setContent(testString);
    testHandler.setContentType("text/plain");

    localHttpService = LocalHttpService.forSecureHandler(testHandler, LOGIN_USER, LOGIN_PASSWORD);
    localHttpService.start();

    final Provider<TrackingToken> passiveProvider = new DummyTokenProvider(trackingToken);

    // Create a http client with the tracker installed.
    httpClient =
        new HttpClient(
                new HttpClientDefaults(),
                ImmutableSet.of(new HttpClientTrackingObserver(passiveProvider)))
            .start();

    uri = "http://" + localHttpService.getHost() + ":" + localHttpService.getPort() + "/data";
  }