@Test
  public void testWrongHost() throws IOException {
    httpClient
        .get(uri, authResponseHandler)
        .addAuth(
            HttpClientDefaultAuthProvider.forUserAndHost(
                "www.cnn.com", localHttpService.getPort(), 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";
  }