LDAP-267: BaseLdapPath support with namespace configuration.

This commit is contained in:
Mattias Hellborg Arthursson
2013-10-09 07:41:02 +02:00
parent a16646ca2c
commit e43233fd86
9 changed files with 243 additions and 27 deletions

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.itest.core.support;
import org.junit.Test;
@@ -20,8 +21,6 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.itest.core.support.DummyBaseLdapNameAware;
import org.springframework.ldap.itest.core.support.DummyBaseLdapPathAware;
import org.springframework.ldap.support.LdapUtils;
import static junit.framework.Assert.assertEquals;
@@ -30,7 +29,7 @@ import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
/**
* Integration tests for {@link BaseLdapPathBeanPostProcessor}.
* Integration tests for {@link org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor}.
*
* @author Mattias Hellborg Arthursson
*/

View File

@@ -0,0 +1,63 @@
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.itest.core.support;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.support.LdapUtils;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
/**
* Integration tests for {@link org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor}.
*
* @author Mattias Hellborg Arthursson
*/
public class BaseLdapPathBeanPostprocessorNamespaceConfigITest {
@Test
public void testPostProcessBeforeInitializationWithNamespaceConfig() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
"/conf/baseLdapPathPostProcessorNamespaceTestContext.xml");
DummyBaseLdapPathAware tested = ctx.getBean(DummyBaseLdapPathAware.class);
DistinguishedName base = tested.getBase();
assertNotNull(base);
assertEquals(new DistinguishedName("dc=jayway,dc=se"), base);
DummyBaseLdapNameAware otherTested = ctx.getBean(DummyBaseLdapNameAware.class);
assertEquals(LdapUtils.newLdapName("dc=jayway,dc=se"), otherTested.getBaseLdapPath());
}
@Test
public void testPostProcessBeforeInitializationWithNamespaceConfigAndPooling() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
"/conf/baseLdapPathPostProcessorPoolingNamespaceTestContext.xml");
DummyBaseLdapPathAware tested = ctx.getBean(DummyBaseLdapPathAware.class);
DistinguishedName base = tested.getBase();
assertNotNull(base);
assertEquals(new DistinguishedName("dc=jayway,dc=se"), base);
DummyBaseLdapNameAware otherTested = ctx.getBean(DummyBaseLdapNameAware.class);
assertEquals(LdapUtils.newLdapName("dc=jayway,dc=se"), otherTested.getBaseLdapPath());
}
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<import resource="classpath:/conf/commonTestContext.xml"/>
<ldap:context-source
password="${password}"
url="ldap://localhost:1888"
username="${userDn}"
base="dc=jayway,dc=se" />
<bean id="dummyBaseLdapPathAware"
class="org.springframework.ldap.itest.core.support.DummyBaseLdapPathAware" />
<bean class="org.springframework.ldap.itest.core.support.DummyBaseLdapNameAware" />
<bean
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor" />
</beans>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<import resource="classpath:/conf/commonTestContext.xml"/>
<ldap:context-source
password="${password}"
url="ldap://localhost:1888"
username="${userDn}"
base="dc=jayway,dc=se">
<ldap:pooling />
</ldap:context-source>
<bean id="dummyBaseLdapPathAware"
class="org.springframework.ldap.itest.core.support.DummyBaseLdapPathAware" />
<bean class="org.springframework.ldap.itest.core.support.DummyBaseLdapNameAware" />
<bean
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor" />
</beans>