diff --git a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java
index d096df57..5574cc5c 100644
--- a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java
+++ b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java
@@ -1208,9 +1208,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
* org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception {
- if (contextSource == null) {
- throw new IllegalArgumentException("Property 'contextSource' must be set.");
- }
+ Assert.notNull(contextSource, "Property 'contextSource' must be set.");
}
private void closeContextAndNamingEnumeration(DirContext ctx, NamingEnumeration results) {
diff --git a/settings.gradle b/settings.gradle
index 0e82843e..f6546645 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -8,6 +8,9 @@ include 'ldif/ldif-core'
include 'odm'
include 'sandbox'
include 'test/integration-tests'
+include 'test/integration-tests-spring20'
+include 'test/integration-tests-spring25'
+include 'test/integration-tests-spring30'
include 'test/integration-tests-openldap'
include 'test/integration-tests-sunone'
include 'test/integration-tests-ad'
@@ -29,4 +32,4 @@ rootProject.children.each { p->
p.name = "spring-ldap-" + name
}
-findProject(":spring-ldap-test-support").name = "spring-ldap-test"
\ No newline at end of file
+findProject(":spring-ldap-test-support").name = "spring-ldap-test"
diff --git a/test/integration-tests-spring20/build.gradle b/test/integration-tests-spring20/build.gradle
new file mode 100644
index 00000000..b7b56899
--- /dev/null
+++ b/test/integration-tests-spring20/build.gradle
@@ -0,0 +1,22 @@
+repositories {
+ maven { url "http://download.java.net/maven/2/" }
+}
+apply from: JAVA_SCRIPT
+
+ext.spring20Version = '2.0.8'
+
+dependencies {
+ testCompile (project(":spring-ldap-test")) {
+ exclude group: "org.springframework", module:"spring-core"
+ exclude group: "org.springframework", module:"spring-beans"
+ exclude group: "org.springframework", module:"spring-context"
+ exclude group: "org.springframework", module:"spring-test"
+ exclude group: "org.springframework", module:"spring-tx"
+ }
+
+ testCompile "org.springframework:spring-mock:$spring20Version",
+ "org.springframework:spring-context:$spring20Version",
+ "org.springframework:spring-core:$spring20Version",
+ "org.springframework:spring-dao:$spring20Version",
+ "org.springframework:spring-beans:$spring20Version"
+}
\ No newline at end of file
diff --git a/test/integration-tests-spring20/src/test/java/org.springframework.ldap.itest20/LdapTemplateLookup20ITest.java b/test/integration-tests-spring20/src/test/java/org.springframework.ldap.itest20/LdapTemplateLookup20ITest.java
new file mode 100644
index 00000000..48e5fdf7
--- /dev/null
+++ b/test/integration-tests-spring20/src/test/java/org.springframework.ldap.itest20/LdapTemplateLookup20ITest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.itest20;
+
+import org.springframework.ldap.core.DirContextOperations;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+
+/**
+ * Tests the lookup methods of LdapTemplate together with Spring 2.0.
+ *
+ * @author Mattias Hellborg Arthursson
+ */
+public class LdapTemplateLookup20ITest extends AbstractDependencyInjectionSpringContextTests {
+
+ private LdapTemplate tested;
+
+ public void setTested(LdapTemplate tested) {
+ this.tested = tested;
+ }
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"/conf/ldapTemplateTestContext.xml"};
+ }
+
+ /**
+ * This method depends on a DirObjectFactory (
+ * {@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
+ * being set in the ContextSource.
+ */
+ public void testThatPlainLookupWorksWithSpring20() {
+ DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,c=Sweden");
+
+ assertEquals("Some Person2", result.getStringAttribute("cn"));
+ assertEquals("Person2", result.getStringAttribute("sn"));
+ assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
+ }
+}
diff --git a/test/integration-tests-spring20/src/test/resources/conf/commonTestContext.xml b/test/integration-tests-spring20/src/test/resources/conf/commonTestContext.xml
new file mode 100644
index 00000000..a71c074e
--- /dev/null
+++ b/test/integration-tests-spring20/src/test/resources/conf/commonTestContext.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/test/integration-tests-spring20/src/test/resources/conf/ldap.properties b/test/integration-tests-spring20/src/test/resources/conf/ldap.properties
new file mode 100644
index 00000000..8ae3f6be
--- /dev/null
+++ b/test/integration-tests-spring20/src/test/resources/conf/ldap.properties
@@ -0,0 +1,4 @@
+urls=ldap://127.0.0.1:1888
+userDn=uid=admin,ou=system
+password=secret
+base=dc=jayway,dc=se
diff --git a/test/integration-tests-spring20/src/test/resources/conf/ldapTemplateTestContext.xml b/test/integration-tests-spring20/src/test/resources/conf/ldapTemplateTestContext.xml
new file mode 100644
index 00000000..1b70ae83
--- /dev/null
+++ b/test/integration-tests-spring20/src/test/resources/conf/ldapTemplateTestContext.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/integration-tests-spring20/src/test/resources/log4j.properties b/test/integration-tests-spring20/src/test/resources/log4j.properties
new file mode 100644
index 00000000..43af6587
--- /dev/null
+++ b/test/integration-tests-spring20/src/test/resources/log4j.properties
@@ -0,0 +1,12 @@
+log4j.rootCategory=WARN, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout.ConversionPattern=%r [%t] %-5p\: %-15c{2} - %m%n
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Enable info on Spring LDAP
+#log4j.logger.org.springframework.ldap=INFO
+
+log4j.logger.org.apache.directory.server.schema.registries.DefaultSyntaxRegistry=WARN
+log4j.logger.org.apache.directory.server.core.schema.bootstrap=ERROR
+log4j.logger.org.apache.directory.server.core.partition.impl.btree=ERROR
+log4j.logger.org.apache.directory.shared.ldap.ldif=ERROR
diff --git a/test/integration-tests-spring20/src/test/resources/setup_data.ldif b/test/integration-tests-spring20/src/test/resources/setup_data.ldif
new file mode 100644
index 00000000..885a8ca4
--- /dev/null
+++ b/test/integration-tests-spring20/src/test/resources/setup_data.ldif
@@ -0,0 +1,110 @@
+dn: ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: groups
+
+dn: cn=ROLE_USER,ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: groupOfUniqueNames
+cn: ROLE_USER
+uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=jayway,dc=se
+uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
+
+dn: cn=ROLE_ADMIN,ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: groupOfUniqueNames
+cn: ROLE_ADMIN
+uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+
+dn: c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Sweden
+description: The country of Sweden
+
+dn: c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Norway
+description: The country of Norway
+
+dn: ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Sweden
+
+dn: ou=company2,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company2
+description: Second company in Sweden
+
+dn: ou=company1,c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Norway
+
+dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company1, Some Person
+telephoneNumber: +46 555-123456
+
+dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person2
+userPassword: password
+cn: Some Person2
+sn: Person2
+description: Sweden, Company1, Some Person2
+telephoneNumber: +46 555-654321
+
+dn: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person3
+userPassword: password
+cn: Some Person3
+sn: Person3
+description: Sweden, Company1, Some Person3
+telephoneNumber: +46 555-123654
+
+dn: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person4
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company2, Some Person
+telephoneNumber: +46 555-456321
+
+dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.norwegian
+userPassword: password
+cn: Some Person
+sn: Person
+description: Norway, Company1, Some Person+Person
+telephoneNumber: +45 555-654123
diff --git a/test/integration-tests-spring25/build.gradle b/test/integration-tests-spring25/build.gradle
new file mode 100644
index 00000000..2cdf23d8
--- /dev/null
+++ b/test/integration-tests-spring25/build.gradle
@@ -0,0 +1,27 @@
+repositories {
+ maven { url "http://download.java.net/maven/2/" }
+}
+apply from: JAVA_SCRIPT
+
+ext.spring25Version = '2.5.6.SEC03'
+
+dependencies {
+ testCompile (project(":spring-ldap-test")) {
+ exclude group: "org.springframework", module:"spring-core"
+ exclude group: "org.springframework", module:"spring-beans"
+ exclude group: "org.springframework", module:"spring-context"
+ exclude group: "org.springframework", module:"spring-test"
+ exclude group: "org.springframework", module:"spring-tx"
+ }
+
+ testCompile ("org.springframework:spring-test:$spring25Version") {
+ exclude group: "junit", module:"junit"
+ }
+
+ testCompile "org.springframework:spring-test:$spring25Version",
+ "org.springframework:spring-context:$spring25Version",
+ "org.springframework:spring-core:$spring25Version",
+ "org.springframework:spring-tx:$spring25Version",
+ "org.springframework:spring-beans:$spring25Version",
+ "junit:junit:$junitVersion"
+}
diff --git a/test/integration-tests-spring25/src/test/java/org.springframework.ldap.itest25/LdapTemplateLookup25ITest.java b/test/integration-tests-spring25/src/test/java/org.springframework.ldap.itest25/LdapTemplateLookup25ITest.java
new file mode 100644
index 00000000..1bf9cf24
--- /dev/null
+++ b/test/integration-tests-spring25/src/test/java/org.springframework.ldap.itest25/LdapTemplateLookup25ITest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.itest25;
+
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ldap.core.DirContextOperations;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * Tests the lookup methods of LdapTemplate together with Spring 2.5.
+ *
+ * @author Mattias Hellborg Arthursson
+ */
+@ContextConfiguration(locations = {"/conf/ldapTemplateTestContext.xml"})
+public class LdapTemplateLookup25ITest extends AbstractJUnit4SpringContextTests {
+
+ @Autowired
+ private LdapTemplate tested;
+
+ /**
+ * This method depends on a DirObjectFactory (
+ * {@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
+ * being set in the ContextSource.
+ */
+ @Test
+ public void testThatPlainLookupWorksWithSpring25() {
+ DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,c=Sweden");
+
+ assertEquals("Some Person2", result.getStringAttribute("cn"));
+ assertEquals("Person2", result.getStringAttribute("sn"));
+ assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
+ }
+}
diff --git a/test/integration-tests-spring25/src/test/resources/conf/commonTestContext.xml b/test/integration-tests-spring25/src/test/resources/conf/commonTestContext.xml
new file mode 100644
index 00000000..a71c074e
--- /dev/null
+++ b/test/integration-tests-spring25/src/test/resources/conf/commonTestContext.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/test/integration-tests-spring25/src/test/resources/conf/ldap.properties b/test/integration-tests-spring25/src/test/resources/conf/ldap.properties
new file mode 100644
index 00000000..8ae3f6be
--- /dev/null
+++ b/test/integration-tests-spring25/src/test/resources/conf/ldap.properties
@@ -0,0 +1,4 @@
+urls=ldap://127.0.0.1:1888
+userDn=uid=admin,ou=system
+password=secret
+base=dc=jayway,dc=se
diff --git a/test/integration-tests-spring25/src/test/resources/conf/ldapTemplateTestContext.xml b/test/integration-tests-spring25/src/test/resources/conf/ldapTemplateTestContext.xml
new file mode 100644
index 00000000..1b70ae83
--- /dev/null
+++ b/test/integration-tests-spring25/src/test/resources/conf/ldapTemplateTestContext.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/integration-tests-spring25/src/test/resources/log4j.properties b/test/integration-tests-spring25/src/test/resources/log4j.properties
new file mode 100644
index 00000000..43af6587
--- /dev/null
+++ b/test/integration-tests-spring25/src/test/resources/log4j.properties
@@ -0,0 +1,12 @@
+log4j.rootCategory=WARN, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout.ConversionPattern=%r [%t] %-5p\: %-15c{2} - %m%n
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Enable info on Spring LDAP
+#log4j.logger.org.springframework.ldap=INFO
+
+log4j.logger.org.apache.directory.server.schema.registries.DefaultSyntaxRegistry=WARN
+log4j.logger.org.apache.directory.server.core.schema.bootstrap=ERROR
+log4j.logger.org.apache.directory.server.core.partition.impl.btree=ERROR
+log4j.logger.org.apache.directory.shared.ldap.ldif=ERROR
diff --git a/test/integration-tests-spring25/src/test/resources/setup_data.ldif b/test/integration-tests-spring25/src/test/resources/setup_data.ldif
new file mode 100644
index 00000000..885a8ca4
--- /dev/null
+++ b/test/integration-tests-spring25/src/test/resources/setup_data.ldif
@@ -0,0 +1,110 @@
+dn: ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: groups
+
+dn: cn=ROLE_USER,ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: groupOfUniqueNames
+cn: ROLE_USER
+uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=jayway,dc=se
+uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
+
+dn: cn=ROLE_ADMIN,ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: groupOfUniqueNames
+cn: ROLE_ADMIN
+uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+
+dn: c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Sweden
+description: The country of Sweden
+
+dn: c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Norway
+description: The country of Norway
+
+dn: ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Sweden
+
+dn: ou=company2,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company2
+description: Second company in Sweden
+
+dn: ou=company1,c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Norway
+
+dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company1, Some Person
+telephoneNumber: +46 555-123456
+
+dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person2
+userPassword: password
+cn: Some Person2
+sn: Person2
+description: Sweden, Company1, Some Person2
+telephoneNumber: +46 555-654321
+
+dn: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person3
+userPassword: password
+cn: Some Person3
+sn: Person3
+description: Sweden, Company1, Some Person3
+telephoneNumber: +46 555-123654
+
+dn: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person4
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company2, Some Person
+telephoneNumber: +46 555-456321
+
+dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.norwegian
+userPassword: password
+cn: Some Person
+sn: Person
+description: Norway, Company1, Some Person+Person
+telephoneNumber: +45 555-654123
diff --git a/test/integration-tests-spring30/build.gradle b/test/integration-tests-spring30/build.gradle
new file mode 100644
index 00000000..859864f4
--- /dev/null
+++ b/test/integration-tests-spring30/build.gradle
@@ -0,0 +1,27 @@
+repositories {
+ maven { url "http://download.java.net/maven/2/" }
+}
+apply from: JAVA_SCRIPT
+
+ext.spring30Version = '3.0.7.RELEASE'
+
+dependencies {
+ testCompile (project(":spring-ldap-test")) {
+ exclude group: "org.springframework", module:"spring-core"
+ exclude group: "org.springframework", module:"spring-beans"
+ exclude group: "org.springframework", module:"spring-context"
+ exclude group: "org.springframework", module:"spring-test"
+ exclude group: "org.springframework", module:"spring-tx"
+ }
+
+ testCompile ("org.springframework:spring-test:$spring30Version") {
+ exclude group: "junit", module:"junit"
+ }
+
+ testCompile "org.springframework:spring-test:$spring30Version",
+ "org.springframework:spring-context:$spring30Version",
+ "org.springframework:spring-core:$spring30Version",
+ "org.springframework:spring-tx:$spring30Version",
+ "org.springframework:spring-beans:$spring30Version",
+ "junit:junit:$junitVersion"
+}
diff --git a/test/integration-tests-spring30/src/test/java/org.springframework.ldap.itest30/LdapTemplateLookup30ITest.java b/test/integration-tests-spring30/src/test/java/org.springframework.ldap.itest30/LdapTemplateLookup30ITest.java
new file mode 100644
index 00000000..7bb2e13a
--- /dev/null
+++ b/test/integration-tests-spring30/src/test/java/org.springframework.ldap.itest30/LdapTemplateLookup30ITest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.itest30;
+
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ldap.core.DirContextOperations;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * Tests the lookup methods of LdapTemplate together with Spring 3.0.
+ *
+ * @author Mattias Hellborg Arthursson
+ */
+@ContextConfiguration(locations = {"/conf/ldapTemplateTestContext.xml"})
+public class LdapTemplateLookup30ITest extends AbstractJUnit4SpringContextTests {
+
+ @Autowired
+ private LdapTemplate tested;
+
+ /**
+ * This method depends on a DirObjectFactory (
+ * {@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
+ * being set in the ContextSource.
+ */
+ @Test
+ public void testThatPlainLookupWorksWithSpring30() {
+ DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,c=Sweden");
+
+ assertEquals("Some Person2", result.getStringAttribute("cn"));
+ assertEquals("Person2", result.getStringAttribute("sn"));
+ assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
+ }
+}
diff --git a/test/integration-tests-spring30/src/test/resources/conf/commonTestContext.xml b/test/integration-tests-spring30/src/test/resources/conf/commonTestContext.xml
new file mode 100644
index 00000000..a71c074e
--- /dev/null
+++ b/test/integration-tests-spring30/src/test/resources/conf/commonTestContext.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/test/integration-tests-spring30/src/test/resources/conf/ldap.properties b/test/integration-tests-spring30/src/test/resources/conf/ldap.properties
new file mode 100644
index 00000000..8ae3f6be
--- /dev/null
+++ b/test/integration-tests-spring30/src/test/resources/conf/ldap.properties
@@ -0,0 +1,4 @@
+urls=ldap://127.0.0.1:1888
+userDn=uid=admin,ou=system
+password=secret
+base=dc=jayway,dc=se
diff --git a/test/integration-tests-spring30/src/test/resources/conf/ldapTemplateTestContext.xml b/test/integration-tests-spring30/src/test/resources/conf/ldapTemplateTestContext.xml
new file mode 100644
index 00000000..1b70ae83
--- /dev/null
+++ b/test/integration-tests-spring30/src/test/resources/conf/ldapTemplateTestContext.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/integration-tests-spring30/src/test/resources/log4j.properties b/test/integration-tests-spring30/src/test/resources/log4j.properties
new file mode 100644
index 00000000..43af6587
--- /dev/null
+++ b/test/integration-tests-spring30/src/test/resources/log4j.properties
@@ -0,0 +1,12 @@
+log4j.rootCategory=WARN, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout.ConversionPattern=%r [%t] %-5p\: %-15c{2} - %m%n
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Enable info on Spring LDAP
+#log4j.logger.org.springframework.ldap=INFO
+
+log4j.logger.org.apache.directory.server.schema.registries.DefaultSyntaxRegistry=WARN
+log4j.logger.org.apache.directory.server.core.schema.bootstrap=ERROR
+log4j.logger.org.apache.directory.server.core.partition.impl.btree=ERROR
+log4j.logger.org.apache.directory.shared.ldap.ldif=ERROR
diff --git a/test/integration-tests-spring30/src/test/resources/setup_data.ldif b/test/integration-tests-spring30/src/test/resources/setup_data.ldif
new file mode 100644
index 00000000..885a8ca4
--- /dev/null
+++ b/test/integration-tests-spring30/src/test/resources/setup_data.ldif
@@ -0,0 +1,110 @@
+dn: ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: groups
+
+dn: cn=ROLE_USER,ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: groupOfUniqueNames
+cn: ROLE_USER
+uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person,ou=company1,c=Norway,dc=jayway,dc=se
+uniqueMember: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
+uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
+
+dn: cn=ROLE_ADMIN,ou=groups,dc=jayway,dc=se
+objectclass: top
+objectclass: groupOfUniqueNames
+cn: ROLE_ADMIN
+uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+
+dn: c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Sweden
+description: The country of Sweden
+
+dn: c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: country
+c: Norway
+description: The country of Norway
+
+dn: ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Sweden
+
+dn: ou=company2,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company2
+description: Second company in Sweden
+
+dn: ou=company1,c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: organizationalUnit
+ou: company1
+description: First company in Norway
+
+dn: cn=Some Person,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company1, Some Person
+telephoneNumber: +46 555-123456
+
+dn: cn=Some Person2,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person2
+userPassword: password
+cn: Some Person2
+sn: Person2
+description: Sweden, Company1, Some Person2
+telephoneNumber: +46 555-654321
+
+dn: cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person3
+userPassword: password
+cn: Some Person3
+sn: Person3
+description: Sweden, Company1, Some Person3
+telephoneNumber: +46 555-123654
+
+dn: cn=Some Person,ou=company2,c=Sweden,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.person4
+userPassword: password
+cn: Some Person
+sn: Person
+description: Sweden, Company2, Some Person
+telephoneNumber: +46 555-456321
+
+dn: cn=Some Person+sn=Person,ou=company1,c=Norway,dc=jayway,dc=se
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: some.norwegian
+userPassword: password
+cn: Some Person
+sn: Person
+description: Norway, Company1, Some Person+Person
+telephoneNumber: +45 555-654123