@Test
public void testOnUnsuccessfulAuthentication() throws IOException, ServletException {

  // GIVEN
  HttpServletRequest request = createMock(HttpServletRequest.class);
  HttpServletResponse response = createMock(HttpServletResponse.class);
  AuthenticationException authEx = createMock(AuthenticationException.class);
  expect(request.getHeader("X-Forwarded-For")).andReturn("1.2.3.4");
  expect(request.getHeader("Authorization")).andReturn(
      "Basic " + new String(Base64.encode("admin:admin".getBytes("UTF-8"))));
  expect(mockedAuditLogger.isEnabled()).andReturn(true);
  mockedAuditLogger.log(anyObject(AuditEvent.class));
  expectLastCall().times(1);
  replayAll();
  // WHEN
  underTest.onUnsuccessfulAuthentication(request, response, authEx);
  // THEN
  verifyAll();
}