@Test
    void logExceptionAfterDoAuthenticateThrowsNonAuthenticationException() {
        // NOTE: log4j is a test dependency
        final String expectedExceptionMessage = "exception thrown"
                + " for test logExceptionAfterDoAuthenticateThrowsNonAuthenticationException";

        abstractAuthenticator = new AbstractAuthenticator() {
            protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException {
                throw new IllegalArgumentException(expectedExceptionMessage);
            }
        };
        AuthenticationToken token = newToken();

        try {
            abstractAuthenticator.authenticate(token);
            fail("the expected AuthenticationException was not thrown");
        } catch (AuthenticationException ignored) {
        }

        String logMsg = String.join("\n", listAppender.getMessages());
        assertTrue(logMsg.contains("WARN"));
        assertTrue(logMsg.contains("java.lang.IllegalArgumentException: " + expectedExceptionMessage));
    }
Ensures a non-null <tt>Subject</tt> instance is returned from the authenticate() method after a valid
authentication attempt (i.e. the subclass's doAuthenticate implementation returns a valid, non-null
AuthenticationInfo object).
core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java