@Test(timeout = 60000)
public void testRequestWithWrongCredentials() throws Exception {

  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
  final Base64 base64 = new Base64(0);
  String credentials = base64.encodeToString("bjones:foo123".getBytes());
  String authHeader = HttpConstants.BASIC + " " + credentials;
  Mockito.when(request.getHeader(HttpConstants.AUTHORIZATION_HEADER))
      .thenReturn(authHeader);
  try {
    handler.authenticate(request, response);
    Assert.fail();
  } catch (AuthenticationException ex) {
    // Expected
  } catch (Exception ex) {
    Assert.fail();
  }
}