@Test public void testPostProcessBeforeInitializationWithLdapNameAwareBasePathSet() throws Exception { String expectedPath = "dc=example, dc=com"; tested.setBasePath(expectedPath); Object result = tested.postProcessBeforeInitialization(ldapNameAwareMock, "someName"); verify(ldapNameAwareMock).setBaseLdapPath(LdapUtils.newLdapName(expectedPath)); assertThat(result).isSameAs(ldapNameAwareMock); }
@Test public void testPostProcessBeforeInitializationWithLdapPathAwareBasePathSet() throws Exception { String expectedPath = "dc=example, dc=com"; tested.setBasePath(new DistinguishedName(expectedPath)); Object result = tested.postProcessBeforeInitialization(ldapPathAwareMock, "someName"); verify(ldapPathAwareMock).setBaseLdapPath(new DistinguishedName(expectedPath)); assertThat(result).isSameAs(ldapPathAwareMock); }
@Test public void testPostProcessBeforeInitializationWithLdapNameAwareNoBasePathSet() throws Exception { final LdapContextSource expectedContextSource = new LdapContextSource(); String expectedPath = "dc=example, dc=com"; expectedContextSource.setBase(expectedPath); tested = new BaseLdapPathBeanPostProcessor() { BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { return expectedContextSource; } }; Object result = tested.postProcessBeforeInitialization(ldapNameAwareMock, "someName"); verify(ldapNameAwareMock).setBaseLdapPath(LdapUtils.newLdapName(expectedPath)); assertThat(result).isSameAs(ldapNameAwareMock); }
@Test public void testPostProcessBeforeInitializationWithLdapPathAwareNoBasePathSet() throws Exception { final LdapContextSource expectedContextSource = new LdapContextSource(); String expectedPath = "dc=example, dc=com"; expectedContextSource.setBase(expectedPath); tested = new BaseLdapPathBeanPostProcessor() { BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { return expectedContextSource; } }; Object result = tested.postProcessBeforeInitialization(ldapPathAwareMock, "someName"); verify(ldapPathAwareMock).setBaseLdapPath(new DistinguishedName(expectedPath)); assertThat(result).isSameAs(ldapPathAwareMock); }