@Test
    void testGetAuthenticationInfoNamingException() throws NamingException {
        assertThrows(AuthenticationException.class, () -> {
            realm.setUserDnTemplate("uid={0},ou=users,dc=mycompany,dc=com");
            LdapContextFactory factory = createMock(LdapContextFactory.class);
            realm.setContextFactory(factory);

            expect(factory.getLdapContext(isA(Object.class), isA(Object.class)))
                    .andThrow(new NamingException("Communication error."));
            replay(factory);

            realm.getAuthenticationInfo(new UsernamePasswordToken("jsmith", "secret"));
        });
    }
Tests for the {@link DefaultLdapRealm} class.

@since 1.3
core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java