### Question:
AuthenticationListener implements org.apache.shiro.authc.AuthenticationListener { @Override @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT") public void onFailure(final AuthenticationToken authenticationToken, final AuthenticationException authenticationException) { if (LOG.isDebugEnabled()) { LOG.debug("{}", AuthenticationTokenUtils.generateUnsuccessfulAuthenticationMessage(authenticationToken)); } }  @Override @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT") void onSuccess(final AuthenticationToken authenticationToken, final AuthenticationInfo authenticationInfo); @Override @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT") void onFailure(final AuthenticationToken authenticationToken,
                          final AuthenticationException authenticationException); @Override void onLogout(final PrincipalCollection principalCollection);  }### Answer:
@Test public void testOnFailure() throws Exception { final AuthenticationListener authenticationListener = new AuthenticationListener(); final UsernamePasswordToken authenticationToken = new UsernamePasswordToken(); authenticationToken.setUsername("unsuccessfulUser1"); authenticationToken.setHost("unsuccessfulHost1"); final AuthenticationException authenticationException = new AuthenticationException("test auth exception"); authenticationListener.onFailure(authenticationToken, authenticationException); final List<LoggingEvent> loggingEvents = TestAppender.getCurrentInstance().getEvents(); final int whichLoggingEvent = loggingEvents.size() - 1; final LoggingEvent latestLoggingEvent = loggingEvents.get(whichLoggingEvent); final String latestLogMessage = latestLoggingEvent.getFormattedMessage(); assertEquals("Unsuccessful authentication attempt by unsuccessfulUser1 from unsuccessfulHost1", latestLogMessage); }