Search in sources :

Example 1 with UncategorizedLdapException

use of org.springframework.ldap.UncategorizedLdapException in project spring-security by spring-projects.

the class SpringSecurityLdapTemplateITests method namingExceptionIsTranslatedCorrectly.

// @Test
// public void testNameExistsForInValidNameFails() {
// assertThat(template.nameExists("ou=doesntexist,dc=springframework,dc=org")).isFalse();
// }
//
// @Test
// public void testNameExistsForValidNameSucceeds() {
// assertThat(template.nameExists("ou=groups,dc=springframework,dc=org")).isTrue();
// }
@Test
public void namingExceptionIsTranslatedCorrectly() {
    try {
        template.executeReadOnly(new ContextExecutor() {

            public Object executeWithContext(DirContext dirContext) throws NamingException {
                throw new NamingException();
            }
        });
        fail("Expected UncategorizedLdapException on NamingException");
    } catch (UncategorizedLdapException expected) {
    }
}
Also used : NamingException(javax.naming.NamingException) DirContext(javax.naming.directory.DirContext) UncategorizedLdapException(org.springframework.ldap.UncategorizedLdapException) ContextExecutor(org.springframework.ldap.core.ContextExecutor)

Aggregations

NamingException (javax.naming.NamingException)1 DirContext (javax.naming.directory.DirContext)1 UncategorizedLdapException (org.springframework.ldap.UncategorizedLdapException)1 ContextExecutor (org.springframework.ldap.core.ContextExecutor)1