Support Property Placeholders in XML Configuration
Fixes gh-370
This commit is contained in:
@@ -494,4 +494,33 @@ public class LdapTemplateNamespaceHandlerTest {
|
||||
public void verifyParseWithPool1AndPool2WillFail() {
|
||||
new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-with-pool1.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyParsePoolWithPlaceholders() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-config-with-placeholders.xml");
|
||||
ContextSource outerContextSource = ctx.getBean(ContextSource.class);
|
||||
assertNotNull(outerContextSource);
|
||||
|
||||
ContextSource pooledContextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
|
||||
assertNotNull(pooledContextSource);
|
||||
|
||||
GenericKeyedObjectPool objectPool = (GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
|
||||
assertEquals(10, objectPool.getTimeBetweenEvictionRunsMillis());
|
||||
assertEquals(20, objectPool.getMinEvictableIdleTimeMillis());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyParsePool2WithPlaceholders() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling2-config-with-placeholders.xml");
|
||||
ContextSource outerContextSource = ctx.getBean(ContextSource.class);
|
||||
assertNotNull(outerContextSource);
|
||||
|
||||
ContextSource pooledContextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
|
||||
assertNotNull(pooledContextSource);
|
||||
|
||||
org.apache.commons.pool2.impl.GenericKeyedObjectPool objectPool =
|
||||
(org.apache.commons.pool2.impl.GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
|
||||
assertEquals(10, objectPool.getTimeBetweenEvictionRunsMillis());
|
||||
assertEquals(20, objectPool.getMinEvictableIdleTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder location="classpath*:ldap.properties" />
|
||||
|
||||
<ldap:context-source password="apassword" url="ldap://localhost:389" username="uid=admin">
|
||||
<ldap:pooling eviction-run-interval-millis="${ldap.eviction.run.internal.milis}" min-evictable-time-millis="${ldap.min.evictable.time.milis}"/>
|
||||
</ldap:context-source>
|
||||
|
||||
<ldap:ldap-template />
|
||||
</beans>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder location="classpath*:ldap.properties" />
|
||||
|
||||
<ldap:context-source password="apassword" url="ldap://localhost:389" username="uid=admin">
|
||||
<ldap:pooling2 eviction-run-interval-millis="${ldap.eviction.run.internal.milis}" min-evictable-time-millis="${ldap.min.evictable.time.milis}"/>
|
||||
</ldap:context-source>
|
||||
|
||||
<ldap:ldap-template />
|
||||
</beans>
|
||||
2
core/src/test/resources/ldap.properties
Normal file
2
core/src/test/resources/ldap.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
ldap.eviction.run.internal.milis=10
|
||||
ldap.min.evictable.time.milis=20
|
||||
Reference in New Issue
Block a user