Merged all integration tests to one project.
This commit is contained in:
@@ -1,131 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-acegi-support-integration-tests</artifactId>
|
||||
<name>Spring LDAP Acegi Support Integration Tests</name>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<spring.version>2.0.8</spring.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<configuration>
|
||||
<downloadSources>true</downloadSources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<phase>test</phase>
|
||||
<goals></goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
<forkMode>once</forkMode>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-test</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-acegi-support</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-pool</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>ldapbp</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/../../lib/ldapbp.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- Spring Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-dao</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.acegisecurity</groupId>
|
||||
<artifactId>acegi-security</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gsbase</groupId>
|
||||
<artifactId>gsbase</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>1.8.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.authentication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.context.SecurityContextHolder;
|
||||
import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
|
||||
import org.acegisecurity.providers.ldap.LdapAuthenticationProvider;
|
||||
import org.springframework.ldap.authentication.AcegiAuthenticationSource;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
public class AcegiAuthenticationSourceITest extends
|
||||
AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private LdapAuthenticationProvider ldapAuthProvider;
|
||||
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateAcegiTestContext.xml" };
|
||||
}
|
||||
|
||||
public void setLdapAuthProvider(LdapAuthenticationProvider ldapAuthProvider) {
|
||||
this.ldapAuthProvider = ldapAuthProvider;
|
||||
}
|
||||
|
||||
public void setLdapTemplate(LdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
public void testGetPrincipalAndCredentials() {
|
||||
Authentication authentication = ldapAuthProvider
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(
|
||||
"Some Person3", "password"));
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
|
||||
AcegiAuthenticationSource tested = new AcegiAuthenticationSource();
|
||||
assertEquals("cn=Some Person3,ou=company1,c=Sweden,dc=jayway,dc=se",
|
||||
tested.getPrincipal());
|
||||
assertEquals("password", tested.getCredentials());
|
||||
}
|
||||
|
||||
public void testSearchIndividualAuthentication() {
|
||||
Authentication authentication = ldapAuthProvider
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(
|
||||
"Some Person3", "password"));
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
|
||||
List result = ldapTemplate.search("dc=jayway,dc=se",
|
||||
"(objectclass=person)", new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
return attributes.get("cn");
|
||||
}
|
||||
});
|
||||
assertEquals(5, result.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
urls=ldap://127.0.0.1:3905
|
||||
userDn=uid=admin,ou=system
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
@@ -6,51 +6,21 @@
|
||||
<name>Spring LDAP Core Integration Tests</name>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<spring.version>2.0.8</spring.version>
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<configuration>
|
||||
<downloadSources>true</downloadSources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<phase>test</phase>
|
||||
<goals></goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
<forkMode>once</forkMode>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
@@ -65,20 +35,14 @@
|
||||
<version>1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>ldapbp</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/../../lib/ldapbp.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- Spring Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-dao</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>ldapbp</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/../../lib/ldapbp.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- Spring Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
|
||||
@@ -1,49 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-integration-tests</artifactId>
|
||||
<name>Spring LDAP Integration Tests</name>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<name>Spring LDAP Integration Tests</name>
|
||||
|
||||
<modules>
|
||||
<module>core-integration-tests</module>
|
||||
<module>tiger-integration-tests</module>
|
||||
<module>acegi-support-integration-tests</module>
|
||||
</modules>
|
||||
<parent>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<phase>test</phase>
|
||||
<goals></goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
<forkMode>once</forkMode>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-test</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-tiger</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-pool</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Spring Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gsbase</groupId>
|
||||
<artifactId>gsbase</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>1.8.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
/**
|
||||
* Dummy bean to be used in the LdapTemplate integration tests.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class Person {
|
||||
private String fullname;
|
||||
|
||||
private String lastname;
|
||||
|
||||
private String description;
|
||||
|
||||
private String phone;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
return fullname;
|
||||
}
|
||||
|
||||
public void setFullname(String fullname) {
|
||||
this.fullname = fullname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
|
||||
|
||||
/**
|
||||
* Dummy implementation of AttributesMapper for use in integration tests.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*
|
||||
*/
|
||||
public class PersonAttributesMapper implements AttributesMapper {
|
||||
|
||||
/**
|
||||
* Maps the given attributes into a {@link Person} object.
|
||||
*
|
||||
* @see org.springframework.ldap.core.AttributesMapper#mapFromAttributes(javax.naming.directory.Attributes)
|
||||
*/
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
Person person = new Person();
|
||||
person.setFullname((String) attributes.get("cn").get());
|
||||
person.setLastname((String) attributes.get("sn").get());
|
||||
person.setPhone((String) attributes.get("telephoneNumber").get());
|
||||
person.setDescription((String) attributes.get("description").get());
|
||||
return person;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.support.AbstractContextMapper;
|
||||
|
||||
/**
|
||||
* Dummy implemention of ContextMapper for use in the integration tests and for
|
||||
* illustration purposes.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class PersonContextMapper extends AbstractContextMapper {
|
||||
|
||||
protected Object doMapFromContext(DirContextOperations ctx) {
|
||||
Person person = new Person();
|
||||
person.setFullname(ctx.getStringAttribute("cn"));
|
||||
person.setLastname(ctx.getStringAttribute("sn"));
|
||||
person.setPhone(ctx.getStringAttribute("telephoneNumber"));
|
||||
person.setDescription(ctx.getStringAttribute("description"));
|
||||
|
||||
return person;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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.transaction.compensating.manager;
|
||||
|
||||
public interface DummyDao {
|
||||
void createWithException(String country, String company, String fullname,
|
||||
String lastname, String description);
|
||||
|
||||
void create(String country, String company, String fullname,
|
||||
String lastname, String description);
|
||||
|
||||
void update(String dn, String fullname, String lastname, String description);
|
||||
|
||||
void updateWithException(String dn, String fullname, String lastname,
|
||||
String description);
|
||||
|
||||
void updateAndRename(String dn, String newDn, String description);
|
||||
|
||||
void updateAndRenameWithException(String dn, String newDn,
|
||||
String description);
|
||||
|
||||
void modifyAttributes(String dn, String lastName, String description);
|
||||
|
||||
void modifyAttributesWithException(String dn, String lastName,
|
||||
String description);
|
||||
|
||||
void unbind(String dn, String fullname);
|
||||
|
||||
void unbindWithException(String dn, String fullname);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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.transaction.compensating.manager;
|
||||
|
||||
public class DummyException extends RuntimeException {
|
||||
public DummyException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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.transaction.compensating.manager;
|
||||
|
||||
public class DummyServiceImpl {
|
||||
private DummyDao dummyDaoImpl;
|
||||
|
||||
public void setDummyDaoImpl(DummyDao dummyDaoImpl) {
|
||||
this.dummyDaoImpl = dummyDaoImpl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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.transaction.compensating.manager;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
public class LdapAndJdbcDummyDaoImpl implements DummyDao {
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
public void setLdapTemplate(LdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#createWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
public void createWithException(String country, String company,
|
||||
String fullname, String lastname, String description) {
|
||||
create(country, company, fullname, lastname, description);
|
||||
throw new DummyException("This method failed");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#create(java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
public void create(String country, String company, String fullname,
|
||||
String lastname, String description) {
|
||||
DistinguishedName dn = new DistinguishedName();
|
||||
dn.add("c", country);
|
||||
dn.add("ou", company);
|
||||
dn.add("cn", fullname);
|
||||
|
||||
DirContextAdapter ctx = new DirContextAdapter();
|
||||
ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
|
||||
ctx.setAttributeValue("cn", fullname);
|
||||
ctx.setAttributeValue("sn", lastname);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ldapTemplate.bind(dn, ctx, null);
|
||||
jdbcTemplate.update("insert into PERSON values(?, ?, ?)", new Object[] {
|
||||
fullname, lastname, description });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#update(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void update(String dn, String fullname, String lastname,
|
||||
String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", lastname);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
jdbcTemplate
|
||||
.update(
|
||||
"update PERSON set lastname=?, description = ? where fullname = ?",
|
||||
new Object[] { lastname, description, fullname });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#updateWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void updateWithException(String dn, String fullname,
|
||||
String lastname, String description) {
|
||||
update(dn, fullname, lastname, description);
|
||||
throw new DummyException("This method failed.");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#updateAndRename(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void updateAndRename(String dn, String newDn, String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.rename(dn, newDn);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#updateAndRenameWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void updateAndRenameWithException(String dn, String newDn,
|
||||
String description) {
|
||||
updateAndRename(dn, newDn, description);
|
||||
throw new DummyException("This method failed.");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#modifyAttributes(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void modifyAttributes(String dn, String lastName, String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", lastName);
|
||||
ctx.setAttributeValue("description", description);
|
||||
|
||||
ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#modifyAttributesWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void modifyAttributesWithException(String dn, String lastName,
|
||||
String description) {
|
||||
modifyAttributes(dn, lastName, description);
|
||||
throw new DummyException("This method failed.");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#unbind(java.lang.String)
|
||||
*/
|
||||
public void unbind(String dn, String fullname) {
|
||||
ldapTemplate.unbind(dn);
|
||||
jdbcTemplate.update("delete from PERSON where fullname=?",
|
||||
new Object[] { fullname });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#unbindWithException(java.lang.String)
|
||||
*/
|
||||
public void unbindWithException(String dn, String fullname) {
|
||||
unbind(dn, fullname);
|
||||
throw new DummyException("This operation failed.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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.transaction.compensating.manager;
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
public class LdapDummyDaoImpl implements DummyDao {
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
public void setLdapTemplate(LdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#createWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
public void createWithException(String country, String company,
|
||||
String fullname, String lastname, String description) {
|
||||
create(country, company, fullname, lastname, description);
|
||||
throw new DummyException("This method failed");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#create(java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
public void create(String country, String company, String fullname,
|
||||
String lastname, String description) {
|
||||
DistinguishedName dn = new DistinguishedName();
|
||||
dn.add("c", country);
|
||||
dn.add("ou", company);
|
||||
dn.add("cn", fullname);
|
||||
|
||||
DirContextAdapter ctx = new DirContextAdapter();
|
||||
ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
|
||||
ctx.setAttributeValue("cn", fullname);
|
||||
ctx.setAttributeValue("sn", lastname);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ldapTemplate.bind(dn, ctx, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#update(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void update(String dn, String fullname, String lastname,
|
||||
String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", lastname);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#updateWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void updateWithException(String dn, String fullname,
|
||||
String lastname, String description) {
|
||||
update(dn, fullname, lastname, description);
|
||||
throw new DummyException("This method failed.");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#updateAndRename(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void updateAndRename(String dn, String newDn, String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("description", description);
|
||||
ctx.update();
|
||||
|
||||
ldapTemplate.rebind(dn, ctx, null);
|
||||
ldapTemplate.rename(dn, newDn);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#updateAndRenameWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void updateAndRenameWithException(String dn, String newDn,
|
||||
String description) {
|
||||
updateAndRename(dn, newDn, description);
|
||||
throw new DummyException("This method failed.");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#modifyAttributes(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void modifyAttributes(String dn, String lastName, String description) {
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("sn", lastName);
|
||||
ctx.setAttributeValue("description", description);
|
||||
|
||||
ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#modifyAttributesWithException(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void modifyAttributesWithException(String dn, String lastName,
|
||||
String description) {
|
||||
modifyAttributes(dn, lastName, description);
|
||||
throw new DummyException("This method failed.");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#unbind(java.lang.String)
|
||||
*/
|
||||
public void unbind(String dn, String fullname) {
|
||||
ldapTemplate.unbind(dn);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.ldap.transaction.support.DummyDao#unbindWithException(java.lang.String)
|
||||
*/
|
||||
public void unbindWithException(String dn, String fullname) {
|
||||
unbind(dn, fullname);
|
||||
throw new DummyException("This operation failed.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
public abstract class AbstractLdapTemplateIntegrationTest extends
|
||||
AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Tests the attributes mapper search method.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapTemplateAttributesMapperITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testSearch_AttributeMapper() throws Exception {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
List result = tested.search("ou=company1,c=Sweden",
|
||||
"(&(objectclass=person)(sn=Person2))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
Person person = (Person) result.get(0);
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Demonstrates how to retrieve all values of a multi-value attribute.
|
||||
*
|
||||
* @see LdapTemplateContextMapperITest#testSearch_ContextMapper_MultiValue()
|
||||
*/
|
||||
public void testSearch_AttributesMapper_MultiValue() throws Exception {
|
||||
AttributesMapper mapper = new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
LinkedList list = new LinkedList();
|
||||
NamingEnumeration enumeration = attributes.get("uniqueMember").getAll();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
String value = (String) enumeration.nextElement();
|
||||
list.add(value);
|
||||
}
|
||||
String[] members = (String[]) list.toArray(new String[0]);
|
||||
return members;
|
||||
}
|
||||
};
|
||||
List result = tested.search("ou=groups",
|
||||
"(objectclass=groupOfUniqueNames)", mapper);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(1, ((String[]) result.get(0)).length);
|
||||
assertEquals(5, ((String[]) result.get(1)).length);
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttribute;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Tests the bind and unbind methods of LdapTemplate. The test methods in this
|
||||
* class tests a little too much, but we need to clean up after binding, so the
|
||||
* most efficient way to test is to do it all in one test method. Also, the
|
||||
* methods in this class relies on that the lookup method works as it should -
|
||||
* that should be ok, since that is verified in a separate test class. NOTE: if
|
||||
* any of the tests in this class fails, it may be necessary to run the cleanup
|
||||
* script as described in README.txt under /src/iutest/.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapTemplateBindUnbindITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static String DN = "cn=Some Person4,ou=company1,c=Sweden";
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testBindAndUnbind_Attributes_Plain() {
|
||||
Attributes attributes = setupAttributes();
|
||||
tested.bind(DN, null, attributes);
|
||||
verifyBoundCorrectData();
|
||||
tested.unbind(DN);
|
||||
verifyCleanup();
|
||||
}
|
||||
|
||||
public void testBindAndUnbind_Attributes_DIstinguishedName() {
|
||||
Attributes attributes = setupAttributes();
|
||||
tested.bind(new DistinguishedName(DN), null, attributes);
|
||||
verifyBoundCorrectData();
|
||||
tested.unbind(new DistinguishedName(DN));
|
||||
verifyCleanup();
|
||||
}
|
||||
|
||||
public void testBindAndUnbind_DirContextAdapter_Plain() {
|
||||
DirContextAdapter adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person4");
|
||||
adapter.setAttributeValue("sn", "Person4");
|
||||
|
||||
tested.bind(DN, adapter, null);
|
||||
verifyBoundCorrectData();
|
||||
tested.unbind(DN);
|
||||
verifyCleanup();
|
||||
}
|
||||
|
||||
public void testBindAndUnbind_DirContextAdapter_DIstinguishedName() {
|
||||
DirContextAdapter adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person4");
|
||||
adapter.setAttributeValue("sn", "Person4");
|
||||
|
||||
tested.bind(new DistinguishedName(DN), adapter, null);
|
||||
verifyBoundCorrectData();
|
||||
tested.unbind(new DistinguishedName(DN));
|
||||
verifyCleanup();
|
||||
}
|
||||
|
||||
private Attributes setupAttributes() {
|
||||
Attributes attributes = new BasicAttributes();
|
||||
BasicAttribute ocattr = new BasicAttribute("objectclass");
|
||||
ocattr.add("top");
|
||||
ocattr.add("person");
|
||||
attributes.put(ocattr);
|
||||
attributes.put("cn", "Some Person4");
|
||||
attributes.put("sn", "Person4");
|
||||
return attributes;
|
||||
}
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(DN);
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
}
|
||||
|
||||
private void verifyCleanup() {
|
||||
try {
|
||||
tested.lookup(DN);
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import org.springframework.ldap.core.ContextExecutor;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Tests for LdapTemplate's context executor methods.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapTemplateContextExecutorTest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
super.onTearDown();
|
||||
}
|
||||
|
||||
public void testLookupLink() {
|
||||
ContextExecutor executor = new ContextExecutor(){
|
||||
public Object executeWithContext(DirContext ctx) throws NamingException {
|
||||
return ctx.lookupLink("cn=Some Person,ou=company1,c=Sweden");
|
||||
}
|
||||
};
|
||||
|
||||
Object object = tested.executeReadOnly(executor);
|
||||
assertTrue("Should be a DirContextAdapter", object instanceof DirContextAdapter);
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Tests the ContextMapper search method. In its way this method also
|
||||
* demonstrates the use of DirContextAdapter and the DirObjectFactory.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapTemplateContextMapperITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
private LdapTemplate tested;
|
||||
|
||||
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 testSearch_ContextMapper() {
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
List result = tested.search("ou=company1,c=Sweden",
|
||||
"(&(objectclass=person)(sn=Person2))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
Person person = (Person) result.get(0);
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Demonstrates how to retrieve all values of a multi-value attribute.
|
||||
*
|
||||
* @see LdapTemplateAttributesMapperITest#testSearch_AttributesMapper_MultiValue()
|
||||
*/
|
||||
public void testSearch_ContextMapper_MultiValue() throws Exception {
|
||||
ContextMapper mapper = new ContextMapper() {
|
||||
public Object mapFromContext(Object ctx) {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx;
|
||||
String[] members = adapter.getStringAttributes("uniqueMember");
|
||||
return members;
|
||||
}
|
||||
};
|
||||
List result = tested.search("ou=groups",
|
||||
"(objectclass=groupOfUniqueNames)", mapper);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(1, ((String[]) result.get(0)).length);
|
||||
assertEquals(5, ((String[]) result.get(1)).length);
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.support.CountNameClassPairCallbackHandler;
|
||||
import org.springframework.ldap.test.AttributeCheckContextMapper;
|
||||
|
||||
/**
|
||||
* Tests for LdapTemplate's list methods.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class LdapTemplateListITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
private AttributeCheckContextMapper contextMapper;
|
||||
|
||||
private static final String BASE_STRING = "";
|
||||
|
||||
private static final DistinguishedName BASE_NAME = new DistinguishedName(
|
||||
BASE_STRING);
|
||||
|
||||
private static final String[] ALL_ATTRIBUTES = { "cn", "sn", "description",
|
||||
"telephoneNumber" };
|
||||
|
||||
private static final String[] ALL_VALUES = { "Some Person", "Person",
|
||||
"Sweden, Company2, Some Person", "+46 555-456321" };
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
|
||||
contextMapper = new AttributeCheckContextMapper();
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
super.onTearDown();
|
||||
|
||||
contextMapper = null;
|
||||
}
|
||||
|
||||
public void testListBindings_ContextMapper() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.listBindings("ou=company2,c=Sweden" + BASE_STRING,
|
||||
contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testListBindings_ContextMapper_Name() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
DistinguishedName dn = new DistinguishedName("ou=company2,c=Sweden");
|
||||
dn.append(BASE_NAME);
|
||||
List list = tested.listBindings(dn, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testListBindings_ContextMapper_MapToPersons() {
|
||||
DistinguishedName dn = new DistinguishedName("ou=company1,c=Sweden");
|
||||
dn.append(BASE_NAME);
|
||||
List list = tested.listBindings(dn, new PersonContextMapper());
|
||||
assertEquals(3, list.size());
|
||||
String personClass = "org.springframework.ldap.Person";
|
||||
assertEquals(personClass, list.get(0).getClass().getName());
|
||||
assertEquals(personClass, list.get(1).getClass().getName());
|
||||
assertEquals(personClass, list.get(2).getClass().getName());
|
||||
}
|
||||
|
||||
public void testList() {
|
||||
List list = tested.list(BASE_STRING);
|
||||
assertEquals(3, list.size());
|
||||
assertTrue(list.contains("ou=groups"));
|
||||
assertTrue(list.contains("c=Norway"));
|
||||
assertTrue(list.contains("c=Sweden"));
|
||||
}
|
||||
|
||||
public void testList_Name() {
|
||||
List list = tested.list(BASE_NAME);
|
||||
assertEquals(3, list.size());
|
||||
assertTrue(list.contains("ou=groups"));
|
||||
assertTrue(list.contains("c=Norway"));
|
||||
assertTrue(list.contains("c=Sweden"));
|
||||
}
|
||||
|
||||
public void testList_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.list(BASE_STRING, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
}
|
||||
|
||||
public void testList_Name_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.list(BASE_NAME, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
}
|
||||
|
||||
public void testListBindings() {
|
||||
List list = tested.listBindings(BASE_STRING);
|
||||
assertEquals(3, list.size());
|
||||
assertTrue(list.contains("ou=groups"));
|
||||
assertTrue(list.contains("c=Norway"));
|
||||
assertTrue(list.contains("c=Sweden"));
|
||||
}
|
||||
|
||||
public void testListBindings_Name() {
|
||||
List list = tested.listBindings(BASE_NAME);
|
||||
assertEquals(3, list.size());
|
||||
}
|
||||
|
||||
public void testListBindings_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.listBindings(BASE_STRING, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
}
|
||||
|
||||
public void testListBindings_Name_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.listBindings(BASE_NAME, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.support.AbstractContextSource;
|
||||
|
||||
/**
|
||||
* Tests the lookup methods of LdapTemplate.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class LdapTemplateLookupITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
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 testLookup_Plain() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("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"));
|
||||
}
|
||||
|
||||
public void testLookup_AttributesMapper() {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup(
|
||||
"cn=Some Person2, ou=company1,c=Sweden", mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
}
|
||||
|
||||
public void testLookup_AttributesMapper_DistinguishedName() {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup(new DistinguishedName(
|
||||
"cn=Some Person2, ou=company1,c=Sweden"), mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* An {@link AttributesMapper} that only maps a subset of the full
|
||||
* attributes list. Used in tests where the return attributes list has been
|
||||
* limited.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
private final class SubsetPersonAttributesMapper implements
|
||||
AttributesMapper {
|
||||
/**
|
||||
* Maps the <code>cn</code> attribute into a {@link Person} object.
|
||||
* Also verifies that the other attributes haven't been set.
|
||||
*
|
||||
* @see org.springframework.ldap.core.AttributesMapper#mapFromAttributes(javax.naming.directory.Attributes)
|
||||
*/
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
Person person = new Person();
|
||||
person.setFullname((String) attributes.get("cn").get());
|
||||
assertNull("sn should be null", attributes.get("sn"));
|
||||
assertNull("description should be null", attributes
|
||||
.get("description"));
|
||||
return person;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that only the subset is used when specifying a subset of the
|
||||
* available attributes as return attributes.
|
||||
*/
|
||||
public void testLookup_ReturnAttributes_AttributesMapper() {
|
||||
AttributesMapper mapper = new SubsetPersonAttributesMapper();
|
||||
|
||||
Person person = (Person) tested.lookup(
|
||||
"cn=Some Person2, ou=company1,c=Sweden", new String[] { "cn" },
|
||||
mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
assertNull("description should not be set", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that only the subset is used when specifying a subset of the
|
||||
* available attributes as return attributes. Uses DistinguishedName instead
|
||||
* of plain string as name.
|
||||
*/
|
||||
public void testLookup_ReturnAttributes_AttributesMapper_DistinguishedName() {
|
||||
AttributesMapper mapper = new SubsetPersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup(new DistinguishedName(
|
||||
"cn=Some Person2, ou=company1,c=Sweden"),
|
||||
new String[] { "cn" }, mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
assertNull("description should not be set", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method depends on a DirObjectFactory ({@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
|
||||
* being set in the ContextSource.
|
||||
*/
|
||||
public void testLookup_ContextMapper() {
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
Person person = (Person) tested.lookup(
|
||||
"cn=Some Person2, ou=company1,c=Sweden", mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that only the subset is used when specifying a subset of the
|
||||
* available attributes as return attributes.
|
||||
*/
|
||||
public void testLookup_ReturnAttributes_ContextMapper() {
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
|
||||
Person person = (Person) tested.lookup(
|
||||
"cn=Some Person2, ou=company1,c=Sweden", new String[] { "cn" },
|
||||
mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
assertNull("description should not be set", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that we can lookup an entry that has a multi-valued rdn, which
|
||||
* means more than one attribute is part of the relative DN for the entry.
|
||||
*
|
||||
* TODO Enable test when ApacheDS supports multi-valued rdns.
|
||||
*/
|
||||
public void DISABLED_testLookup_MultiValuedRdn() {
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup(
|
||||
"cn=Some Person+sn=Person, ou=company1,c=Norway", mapper);
|
||||
|
||||
assertEquals("Some Person", person.getFullname());
|
||||
assertEquals("Person", person.getLastname());
|
||||
assertEquals("Norway, Company1, Some Person2", person.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that we can lookup an entry that has a multi-valued rdn, which
|
||||
* means more than one attribute is part of the relative DN for the entry.
|
||||
*
|
||||
* TODO Enable test when ApacheDS supports multi-valued rdns.
|
||||
*/
|
||||
public void DISABLED_testLookup_MultiValuedRdn_DirContextAdapter() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("cn=Some Person+sn=Person, ou=company1,c=Norway");
|
||||
|
||||
assertEquals("Some Person", result.getStringAttribute("cn"));
|
||||
assertEquals("Person", result.getStringAttribute("sn"));
|
||||
assertEquals("Norway, Company1, Some Person", result
|
||||
.getStringAttribute("description"));
|
||||
}
|
||||
|
||||
public void testLookup_GetNameInNamespace_Plain() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("cn=Some Person2, ou=company1,c=Sweden");
|
||||
|
||||
assertEquals("cn=Some Person2, ou=company1, c=Sweden", result.getDn()
|
||||
.toString());
|
||||
assertEquals(
|
||||
"cn=Some Person2, ou=company1, c=Sweden, dc=jayway, dc=se",
|
||||
result.getNameInNamespace());
|
||||
}
|
||||
|
||||
public void testLookup_GetNameInNamespace_MultiRdn() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("cn=Some Person+sn=Person, ou=company1,c=Norway");
|
||||
|
||||
assertEquals("cn=Some Person+sn=Person, ou=company1, c=Norway", result
|
||||
.getDn().toString());
|
||||
assertEquals(
|
||||
"cn=Some Person+sn=Person, ou=company1, c=Norway, dc=jayway, dc=se",
|
||||
result.getNameInNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests bind and lookup with Java objects where the ContextSource already
|
||||
* has a DirObjectFactory configured.
|
||||
*/
|
||||
public void testBindJavaObject() throws Exception {
|
||||
AbstractContextSource contextSource = (AbstractContextSource) tested
|
||||
.getContextSource();
|
||||
Class originalObjectFactory = contextSource.getDirObjectFactory();
|
||||
try {
|
||||
contextSource.setDirObjectFactory(null);
|
||||
contextSource.afterPropertiesSet();
|
||||
tested.bind("cn=myRandomInt", new Integer(54321), null);
|
||||
Integer result = (Integer) tested.lookup("cn=myRandomInt");
|
||||
assertEquals(54321, result.intValue());
|
||||
} finally {
|
||||
// reset the DirObjectFactory so as not to disturb other tests
|
||||
tested.unbind("cn=myRandomInt");
|
||||
contextSource.setDirObjectFactory(originalObjectFactory);
|
||||
contextSource.afterPropertiesSet();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttribute;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.ModificationItem;
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Tests the modification methods (rebind and modifyAttributes) of LdapTemplate.
|
||||
* It also illustrates the use of DirContextAdapter as a means of getting
|
||||
* ModificationItems, in order to avoid doing a full rebind and use
|
||||
* modifyAttributes() instead. We rely on that the bind, unbind and lookup
|
||||
* methods work as they should - that should be ok, since that is verified in a
|
||||
* separate test class. NOTE: if any of the tests in this class fails, it may be
|
||||
* necessary to run the cleanup script as described in README.txt under
|
||||
* /src/iutest/.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class LdapTemplateModifyITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static String PERSON4_DN = "cn=Some Person4,ou=company1,c=Sweden";
|
||||
|
||||
private static String PERSON5_DN = "cn=Some Person5,ou=company1,c=Sweden";
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
|
||||
DirContextAdapter adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person4");
|
||||
adapter.setAttributeValue("sn", "Person4");
|
||||
adapter.setAttributeValue("description", "Some description");
|
||||
|
||||
tested.bind(PERSON4_DN, adapter, null);
|
||||
|
||||
adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person5");
|
||||
adapter.setAttributeValue("sn", "Person5");
|
||||
adapter.setAttributeValues("description", new String[] { "qwe", "123",
|
||||
"rty", "uio" });
|
||||
|
||||
tested.bind(PERSON5_DN, adapter, null);
|
||||
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
tested.unbind(PERSON4_DN);
|
||||
tested.unbind(PERSON5_DN);
|
||||
}
|
||||
|
||||
public void testRebind_Attributes_Plain() {
|
||||
Attributes attributes = setupAttributes();
|
||||
|
||||
tested.rebind(PERSON4_DN, null, attributes);
|
||||
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
public void testRebind_Attributes_DistinguishedName() {
|
||||
Attributes attributes = setupAttributes();
|
||||
|
||||
tested.rebind(new DistinguishedName(PERSON4_DN), null, attributes);
|
||||
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
public void testModifyAttributes_MultiValueReplace() {
|
||||
BasicAttribute attr = new BasicAttribute("description",
|
||||
"Some other description");
|
||||
attr.add("Another description");
|
||||
ModificationItem[] mods = new ModificationItem[1];
|
||||
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr);
|
||||
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(2, attributes.length);
|
||||
assertEquals("Some other description", attributes[0]);
|
||||
assertEquals("Another description", attributes[1]);
|
||||
}
|
||||
|
||||
public void testModifyAttributes_MultiValueAdd() {
|
||||
BasicAttribute attr = new BasicAttribute("description",
|
||||
"Some other description");
|
||||
attr.add("Another description");
|
||||
ModificationItem[] mods = new ModificationItem[1];
|
||||
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
|
||||
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(3, attributes.length);
|
||||
assertEquals("Some description", attributes[0]);
|
||||
assertEquals("Some other description", attributes[1]);
|
||||
assertEquals("Another description", attributes[2]);
|
||||
}
|
||||
|
||||
public void testModifyAttributes_MultiValueAddDuplicateToUnordered() {
|
||||
BasicAttribute attr = new BasicAttribute("description",
|
||||
"Some description");
|
||||
ModificationItem[] mods = new ModificationItem[1];
|
||||
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
|
||||
|
||||
try {
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
fail("AttributeInUseException expected");
|
||||
} catch (AttributeInUseException expected) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test written originally to verify that duplicates are allowed on ordered
|
||||
* attributes, but had to be changed since Apache DS seems to disallow
|
||||
* duplicates even for ordered attributes.
|
||||
*/
|
||||
public void testModifyAttributes_MultiValueAddDuplicateToOrdered() {
|
||||
BasicAttribute attr = new BasicAttribute("description",
|
||||
"Some other description", true); // ordered
|
||||
attr.add("Another description");
|
||||
// Commented out duplicate to make test work for Apache DS
|
||||
// attr.add("Some description");
|
||||
ModificationItem[] mods = new ModificationItem[1];
|
||||
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
|
||||
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(3, attributes.length);
|
||||
assertEquals("Some description", attributes[0]);
|
||||
assertEquals("Some other description", attributes[1]);
|
||||
assertEquals("Another description", attributes[2]);
|
||||
}
|
||||
|
||||
public void testModifyAttributes_Plain() {
|
||||
ModificationItem item = new ModificationItem(
|
||||
DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("description",
|
||||
"Some other description"));
|
||||
|
||||
tested.modifyAttributes(PERSON4_DN, new ModificationItem[] { item });
|
||||
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
public void testModifyAttributes_DistinguishedName() {
|
||||
ModificationItem item = new ModificationItem(
|
||||
DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("description",
|
||||
"Some other description"));
|
||||
|
||||
tested.modifyAttributes(new DistinguishedName(PERSON4_DN),
|
||||
new ModificationItem[] { item });
|
||||
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
public void testModifyAttributes_DirContextAdapter_MultiAttributes() {
|
||||
DirContextAdapter adapter = (DirContextAdapter) tested
|
||||
.lookup(PERSON5_DN);
|
||||
adapter.setAttributeValues("description", new String[] { "qwe", "123",
|
||||
"klytt", "kalle" });
|
||||
|
||||
tested.modifyAttributes(PERSON5_DN, adapter.getModificationItems());
|
||||
|
||||
// Verify
|
||||
adapter = (DirContextAdapter) tested.lookup(PERSON5_DN);
|
||||
String[] attributes = adapter.getStringAttributes("description");
|
||||
assertEquals(4, attributes.length);
|
||||
assertEquals("qwe", attributes[0]);
|
||||
assertEquals("123", attributes[1]);
|
||||
assertEquals("klytt", attributes[2]);
|
||||
assertEquals("kalle", attributes[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Demonstrates how the DirContextAdapter can be used to automatically keep
|
||||
* track of changes of the attributes and deliver ModificationItems to use
|
||||
* in moifyAttributes().
|
||||
*/
|
||||
public void testModifyAttributes_DirContextAdapter() throws Exception {
|
||||
DirContextAdapter adapter = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
|
||||
adapter.setAttributeValue("description", "Some other description");
|
||||
|
||||
ModificationItem[] modificationItems = adapter.getModificationItems();
|
||||
tested.modifyAttributes(PERSON4_DN, modificationItems);
|
||||
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
private Attributes setupAttributes() {
|
||||
Attributes attributes = new BasicAttributes();
|
||||
BasicAttribute ocattr = new BasicAttribute("objectclass");
|
||||
ocattr.add("top");
|
||||
ocattr.add("person");
|
||||
attributes.put(ocattr);
|
||||
attributes.put("cn", "Some Person4");
|
||||
attributes.put("sn", "Person4");
|
||||
attributes.put("description", "Some other description");
|
||||
return attributes;
|
||||
}
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertEquals("Some other description", result
|
||||
.getStringAttribute("description"));
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.support.CountNameClassPairCallbackHandler;
|
||||
|
||||
/**
|
||||
* Tests to verify that not setting a base suffix on the ContextSource (as
|
||||
* defined in ldapTemplateNoBaseSuffixTestContext.xml) works as expected.
|
||||
*
|
||||
* NOTE: This test will not work under Java 1.4.1 or earlier.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapTemplateNoBaseSuffixITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateNoBaseSuffixTestContext.xml" };
|
||||
}
|
||||
|
||||
/**
|
||||
* This method depends on a DirObjectFactory ({@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
|
||||
* being set in the ContextSource.
|
||||
*/
|
||||
public void testLookup_Plain() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("cn=Some Person2, ou=company1, c=Sweden, dc=jayway, dc=se");
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result
|
||||
.getStringAttribute("description"));
|
||||
assertEquals(
|
||||
"cn=Some Person2, ou=company1, c=Sweden, dc=jayway, dc=se",
|
||||
result.getDn().toString());
|
||||
assertEquals(
|
||||
"cn=Some Person2, ou=company1, c=Sweden, dc=jayway, dc=se",
|
||||
result.getNameInNamespace());
|
||||
}
|
||||
|
||||
public void testSearch_Plain() {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
|
||||
tested.search("dc=jayway, dc=se", "(objectclass=person)", handler);
|
||||
assertEquals(5, handler.getNoOfRows());
|
||||
}
|
||||
|
||||
public void testBindAndUnbind_Plain() {
|
||||
DirContextAdapter adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person4");
|
||||
adapter.setAttributeValue("sn", "Person4");
|
||||
tested.bind("cn=Some Person4, ou=company1, c=Sweden, dc=jayway, dc=se",
|
||||
adapter, null);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("cn=Some Person4, ou=company1, c=Sweden, dc=jayway, dc=se");
|
||||
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertEquals(
|
||||
"cn=Some Person4, ou=company1, c=Sweden, dc=jayway, dc=se",
|
||||
result.getDn().toString());
|
||||
|
||||
tested
|
||||
.unbind("cn=Some Person4, ou=company1, c=Sweden, dc=jayway, dc=se");
|
||||
try {
|
||||
tested
|
||||
.lookup("cn=Some Person4, ou=company1, c=Sweden, dc=jayway, dc=se");
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.support.AbstractContextSource;
|
||||
|
||||
/**
|
||||
* Tests bind and lookup with Java objects where the ContextSource has a
|
||||
* <code>null</code> DirObjectFactory configured.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class LdapTemplateObjectBindIntegrationTest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateObjectBindTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testBindJavaObject() throws Exception {
|
||||
String dn = "cn=myRandomInt";
|
||||
tested.bind(dn, new Integer(54321), null);
|
||||
|
||||
Integer result = (Integer) tested.lookup(dn);
|
||||
assertEquals(54321, result.intValue());
|
||||
tested.unbind(dn);
|
||||
}
|
||||
|
||||
public void testBindLinkedList() {
|
||||
LinkedList list = new LinkedList();
|
||||
list.add(new Integer(54321));
|
||||
list.add(new Integer(67890));
|
||||
|
||||
String dn = "cn=myRandomList";
|
||||
tested.bind(dn, list, null);
|
||||
|
||||
LinkedList result = (LinkedList) tested.lookup(dn);
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(54321, ((Integer) result.get(0)).intValue());
|
||||
assertEquals(67890, ((Integer) result.get(1)).intValue());
|
||||
tested.unbind(dn);
|
||||
}
|
||||
|
||||
public void testBindNonSerializableJavaObjectShouldFail() throws Exception {
|
||||
NonSerializablePojo pojo = new NonSerializablePojo();
|
||||
pojo.setName("A Name");
|
||||
|
||||
try {
|
||||
tested.bind("cn=myRandomObject", pojo, null);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
assertEquals(
|
||||
"can only bind Referenceable, Serializable, DirContext",
|
||||
expected.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom non-serializable class used for demonstrating bind and lookup of
|
||||
* Java objects.
|
||||
*/
|
||||
public static class NonSerializablePojo {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public void testBindSerializableJavaObjectShouldSucceed() throws Exception {
|
||||
SerializablePojo pojo = new SerializablePojo();
|
||||
pojo.setName("A Name");
|
||||
|
||||
tested.bind("cn=myRandomObject", pojo, null);
|
||||
|
||||
SerializablePojo result = (SerializablePojo) tested
|
||||
.lookup("cn=myRandomObject");
|
||||
assertEquals("A Name", result.getName());
|
||||
tested.unbind("cn=myRandomObject");
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom serializable class used for demonstrating bind and lookup of Java
|
||||
* objects.
|
||||
*/
|
||||
public static class SerializablePojo implements Serializable {
|
||||
private static final long serialVersionUID = 3655768927093734908L;
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test demonstrates that it's fully possible to perform plain JNDI
|
||||
* operations from Spring LDAP.
|
||||
*/
|
||||
public void testPlainJndiBindJavaObject() throws Exception {
|
||||
AbstractContextSource contextSource = (AbstractContextSource) tested
|
||||
.getContextSource();
|
||||
DirContext ctx = contextSource.getReadWriteContext();
|
||||
|
||||
ctx.bind("cn=myRandomInt", new Integer(28420));
|
||||
|
||||
Integer result = (Integer) ctx.lookup("cn=myRandomInt");
|
||||
assertEquals(28420, result.intValue());
|
||||
tested.unbind("cn=myRandomInt");
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import javax.naming.Name;
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Tests the recursive modification methods (unbind and the protected delete
|
||||
* methods) of LdapTemplate.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class LdapTemplateRecursiveDeleteITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static DistinguishedName DN = new DistinguishedName(
|
||||
"cn=Some Person5,ou=company1,c=Sweden");
|
||||
|
||||
private DistinguishedName firstSubDn;
|
||||
|
||||
private DistinguishedName secondSubDn;
|
||||
|
||||
private DistinguishedName leafDn;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
|
||||
DirContextAdapter adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person5");
|
||||
adapter.setAttributeValue("sn", "Person5");
|
||||
adapter.setAttributeValue("description", "Some description");
|
||||
tested.bind(DN, adapter, null);
|
||||
|
||||
firstSubDn = new DistinguishedName("cn=subPerson");
|
||||
firstSubDn.prepend(DN);
|
||||
adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "subPerson");
|
||||
adapter.setAttributeValue("sn", "subPerson");
|
||||
adapter.setAttributeValue("description",
|
||||
"Should be recursively deleted");
|
||||
tested.bind(firstSubDn, adapter, null);
|
||||
secondSubDn = new DistinguishedName("cn=subPerson2");
|
||||
secondSubDn.prepend(DN);
|
||||
adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "subPerson2");
|
||||
adapter.setAttributeValue("sn", "subPerson2");
|
||||
adapter.setAttributeValue("description",
|
||||
"Should be recursively deleted");
|
||||
tested.bind(secondSubDn, adapter, null);
|
||||
|
||||
leafDn = new DistinguishedName("cn=subSubPerson");
|
||||
leafDn.prepend(firstSubDn);
|
||||
adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "subSubPerson");
|
||||
adapter.setAttributeValue("sn", "subSubPerson");
|
||||
adapter.setAttributeValue("description",
|
||||
"Should be recursively deleted");
|
||||
tested.bind(leafDn, adapter, null);
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
try {
|
||||
tested.unbind(DN, true);
|
||||
} catch (NameNotFoundException ignore) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public void testRecursiveUnbind() {
|
||||
tested.unbind(DN, true);
|
||||
|
||||
verifyDeleted(DN);
|
||||
verifyDeleted(firstSubDn);
|
||||
verifyDeleted(secondSubDn);
|
||||
verifyDeleted(leafDn);
|
||||
}
|
||||
|
||||
public void testRecursiveUnbindOnLeaf() {
|
||||
tested.unbind(leafDn, true);
|
||||
verifyDeleted(leafDn);
|
||||
}
|
||||
|
||||
private void verifyDeleted(Name dn) {
|
||||
try {
|
||||
tested.lookup(dn);
|
||||
fail("Expected entry '" + dn + "' to be non-existent");
|
||||
} catch (NameNotFoundException expected) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import javax.naming.Name;
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Tests the rename methods of LdapTemplate.
|
||||
*
|
||||
* We rely on that the bind, unbind and lookup methods work as they should -
|
||||
* that should be ok, since that is verified in a separate test class. *
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class LdapTemplateRenameITest extends
|
||||
AbstractLdapTemplateIntegrationTest {
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static String DN = "cn=Some Person6,ou=company1,c=Sweden";
|
||||
|
||||
private static String NEWDN = "cn=Some Person6,ou=company2,c=Sweden";
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
|
||||
DirContextAdapter adapter = new DirContextAdapter();
|
||||
adapter.setAttributeValues("objectclass", new String[] { "top",
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person6");
|
||||
adapter.setAttributeValue("sn", "Person6");
|
||||
adapter.setAttributeValue("description", "Some description");
|
||||
|
||||
tested.bind(DN, adapter, null);
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
tested.unbind(NEWDN);
|
||||
tested.unbind(DN);
|
||||
}
|
||||
|
||||
public void testRename() {
|
||||
tested.rename(DN, NEWDN);
|
||||
|
||||
verifyDeleted(new DistinguishedName(DN));
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
public void testRename_DistinguishedName() throws Exception {
|
||||
Name oldDn = new DistinguishedName(DN);
|
||||
Name newDn = new DistinguishedName(NEWDN);
|
||||
tested.rename(oldDn, newDn);
|
||||
|
||||
|
||||
verifyDeleted(oldDn);
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
private void verifyDeleted(Name dn) {
|
||||
try {
|
||||
tested.lookup(dn);
|
||||
fail("Expected entry '" + dn + "' to be non-existent");
|
||||
} catch (NameNotFoundException expected) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(NEWDN);
|
||||
assertEquals("Some Person6", result.getStringAttribute("cn"));
|
||||
assertEquals("Person6", result.getStringAttribute("sn"));
|
||||
assertEquals("Some description", result
|
||||
.getStringAttribute("description"));
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Name;
|
||||
import javax.naming.directory.SearchControls;
|
||||
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.test.AttributeCheckAttributesMapper;
|
||||
import org.springframework.ldap.test.AttributeCheckContextMapper;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
* Tests for LdapTemplate's search methods. This test class tests all the
|
||||
* different versions of the search methods except the generic ones covered in
|
||||
* other tests.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapTemplateSearchResultITest extends
|
||||
AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
private AttributeCheckAttributesMapper attributesMapper;
|
||||
|
||||
private AttributeCheckContextMapper contextMapper;
|
||||
|
||||
private static final String[] ALL_ATTRIBUTES = { "cn", "sn", "description",
|
||||
"telephoneNumber" };
|
||||
|
||||
private static final String[] CN_SN_ATTRS = { "cn", "sn" };
|
||||
|
||||
private static final String[] ABSENT_ATTRIBUTES = { "description",
|
||||
"telephoneNumber" };
|
||||
|
||||
private static final String[] CN_SN_VALUES = { "Some Person2", "Person2" };
|
||||
|
||||
private static final String[] ALL_VALUES = { "Some Person2", "Person2",
|
||||
"Sweden, Company1, Some Person2", "+46 555-654321" };
|
||||
|
||||
private static final String BASE_STRING = "";
|
||||
|
||||
private static final String FILTER_STRING = "(&(objectclass=person)(sn=Person2))";
|
||||
|
||||
private static final Name BASE_NAME = new DistinguishedName(BASE_STRING);
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
super.onSetUp();
|
||||
|
||||
attributesMapper = new AttributeCheckAttributesMapper();
|
||||
contextMapper = new AttributeCheckContextMapper();
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
super.onTearDown();
|
||||
|
||||
attributesMapper = null;
|
||||
contextMapper = null;
|
||||
}
|
||||
|
||||
public void testSearch_AttributesMapper() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_AttributesMapper() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_LimitedAttrs_AttributesMapper() {
|
||||
attributesMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
attributesMapper.setExpectedValues(CN_SN_VALUES);
|
||||
attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_AttributesMapper_Name() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_AttributesMapper_Name() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_LimitedAttrs_AttributesMapper_Name() {
|
||||
attributesMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
attributesMapper.setExpectedValues(CN_SN_VALUES);
|
||||
attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_ContextMapper() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_ContextMapper() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_LimitedAttrs_ContextMapper() {
|
||||
contextMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_ContextMapper_Name() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_ContextMapper_Name() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void testSearch_SearchScope_LimitedAttrs_ContextMapper_Name() {
|
||||
contextMapper.setExpectedAttributes(CN_SN_ATTRS);
|
||||
contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING,
|
||||
SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.control;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.ldap.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
/**
|
||||
* Provides tests that verify that the server supports certain controls.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class SupportedControlsITest extends AbstractLdapTemplateIntegrationTest {
|
||||
/** must use a context source that has no base set */
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static final String SUPPORTED_CONTROL = "supportedcontrol";
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/rootContextSourceTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testExpectedControlsSupported() throws Exception {
|
||||
/**
|
||||
* Maps the 'supportedcontrol' attribute to a string array.
|
||||
*/
|
||||
ContextMapper mapper = new ContextMapper() {
|
||||
|
||||
public Object mapFromContext(Object ctx) {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx;
|
||||
return adapter.getStringAttributes(SUPPORTED_CONTROL);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
String[] controls = (String[]) tested.lookup("",
|
||||
new String[] { SUPPORTED_CONTROL }, mapper);
|
||||
System.out.println(Arrays.toString(controls));
|
||||
assertEquals("Persistent Search LDAPv3 control,",
|
||||
"2.16.840.1.113730.3.4.3", controls[0]);
|
||||
assertEquals("Entry Change Notification LDAPv3 control,",
|
||||
"2.16.840.1.113730.3.4.7", controls[1]);
|
||||
assertEquals("Subentries Control,", "1.3.6.1.4.1.4203.1.10.1",
|
||||
controls[2]);
|
||||
assertEquals("Manage DSA IT LDAPv3 control,",
|
||||
"2.16.840.1.113730.3.4.2", controls[3]);
|
||||
}
|
||||
|
||||
public void setTested(LdapTemplate tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.core;
|
||||
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link DistinguishedNameEditor}.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class DistinguishedNameEditorITest extends AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private DummyDistinguishedNameConsumer distinguishedNameConsumer;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "classpath:conf/distinguishedNameEditorTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testDistinguishedNameEditor() throws Exception {
|
||||
assertNotNull(distinguishedNameConsumer);
|
||||
DistinguishedName name = distinguishedNameConsumer.getDistinguishedName();
|
||||
assertEquals(new DistinguishedName("dc=jayway, dc=se"), name);
|
||||
}
|
||||
|
||||
public void setDistinguishedNameConsumer(DummyDistinguishedNameConsumer distinguishedNameConsumer) {
|
||||
this.distinguishedNameConsumer = distinguishedNameConsumer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.core;
|
||||
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.clarkware.junitperf.LoadTest;
|
||||
|
||||
/**
|
||||
* Performance test for the {@link DistinguishedName} class.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class DnParsePerformanceITest extends TestCase {
|
||||
|
||||
public DnParsePerformanceITest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests parsing and toString.
|
||||
*/
|
||||
public void testContains() {
|
||||
|
||||
DistinguishedName migpath = new DistinguishedName("OU=G,OU=I,OU=M");
|
||||
DistinguishedName path1 = new DistinguishedName(
|
||||
"cn=john.doe, OU=Users,OU=SE,OU=G,OU=I,OU=M");
|
||||
DistinguishedName path2 = new DistinguishedName(
|
||||
"cn=john.doe, OU=Users,OU=SE,ou=G,OU=i,OU=M, ou=foo");
|
||||
DistinguishedName path3 = new DistinguishedName(
|
||||
"ou=G,OU=i,OU=M, ou=foo");
|
||||
DistinguishedName path4 = new DistinguishedName("ou=G,OU=i,ou=m");
|
||||
|
||||
DistinguishedName pathE1 = new DistinguishedName(
|
||||
"cn=john.doe, OU=Users,OU=SE,ou=G,OU=L,OU=M, ou=foo");
|
||||
DistinguishedName pathE2 = new DistinguishedName(
|
||||
"cn=john.doe, OU=Users,OU=SE");
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
int users = 1800;
|
||||
Test testCase = new DnParsePerformanceITest("testContains");
|
||||
Test loadTest = new LoadTest(testCase, users);
|
||||
return loadTest;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.core;
|
||||
|
||||
/**
|
||||
* Dummy implementation of a class that has a {@link DistinguishedName} setter,
|
||||
* used for testing purposes.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class DummyDistinguishedNameConsumer {
|
||||
private DistinguishedName distinguishedName;
|
||||
|
||||
public DistinguishedName getDistinguishedName() {
|
||||
return distinguishedName;
|
||||
}
|
||||
|
||||
public void setDistinguishedName(DistinguishedName distinguishedName) {
|
||||
this.distinguishedName = distinguishedName;
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,10 @@ public class SimpleLdapTemplateITest extends AbstractDependencyInjectionSpringCo
|
||||
private SimpleLdapTemplate ldapTemplate;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
return new String[] { "/conf/simpleLdapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
public void setSimplLdapTemplate(SimpleLdapTemplate ldapTemplate) {
|
||||
public void setSimpleLdapTemplate(SimpleLdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.core.support;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link BaseLdapPathBeanPostProcessor}.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class BaseLdapPathBeanPostprocessorITest extends TestCase {
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/baseLdapPathPostProcessorTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testPostProcessBeforeInitialization() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"/conf/baseLdapPathPostProcessorTestContext.xml");
|
||||
DummyBaseLdapPathAware tested = (DummyBaseLdapPathAware) ctx.getBean("dummyBaseContextAware");
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("dc=jayway,dc=se"), base);
|
||||
}
|
||||
|
||||
public void testPostProcessBeforeInitializationMultipleContextSources() throws Exception {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("/conf/baseLdapPathPostProcessorMultiContextSourceTestContext.xml");
|
||||
fail("BeanCreationException expected");
|
||||
}
|
||||
catch (BeanCreationException expected) {
|
||||
Throwable cause = expected.getCause();
|
||||
assertTrue(cause instanceof NoSuchBeanDefinitionException);
|
||||
}
|
||||
}
|
||||
|
||||
public void testPostProcessBeforeInitializationMultipleContextSourcesOneSpecified() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"/conf/baseLdapPathPostProcessorMultiContextSourceOneSpecTestContext.xml");
|
||||
DummyBaseLdapPathAware tested = (DummyBaseLdapPathAware) ctx.getBean("dummyBaseContextAware");
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("cn=john doe,dc=jayway,dc=se"), base);
|
||||
}
|
||||
|
||||
public void testPostProcessBeforeInitializationNoContextSource() throws Exception {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("/conf/baseLdapPathPostProcessorNoContextSourceTestContext.xml");
|
||||
fail("BeanCreationException expected");
|
||||
}
|
||||
catch (BeanCreationException expected) {
|
||||
Throwable cause = expected.getCause();
|
||||
assertTrue(cause instanceof NoSuchBeanDefinitionException);
|
||||
}
|
||||
}
|
||||
|
||||
public void testPostProcessBeforeInitializationBaseSetInProperty() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"/conf/baseLdapPathPostProcessorPropertyOverrideTestContext.xml");
|
||||
DummyBaseLdapPathAware tested = (DummyBaseLdapPathAware) ctx.getBean("dummyBaseContextAware");
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("cn=john doe"), base);
|
||||
}
|
||||
|
||||
public void testPostProcessBeforeInitializationTransactionProxy() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"/conf/baseLdapPathPostProcessorTransactionTestContext.xml");
|
||||
DummyBaseLdapPathAware tested = (DummyBaseLdapPathAware) ctx.getBean("dummyBaseContextAware");
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("dc=jayway,dc=se"), base);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.core.support;
|
||||
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
|
||||
/**
|
||||
* Dummy implementation of {@link BaseLdapPathAware}.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class DummyBaseLdapPathAware implements BaseLdapPathAware {
|
||||
|
||||
private DistinguishedName base;
|
||||
|
||||
public void setBaseLdapPath(DistinguishedName baseLdapPath) {
|
||||
this.base = baseLdapPath;
|
||||
}
|
||||
|
||||
public DistinguishedName getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.core.support;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
* Integration tests for ContextSourceImpl.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapContextSourcelITest extends
|
||||
AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private ContextSource tested;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapTemplateTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testGetReadOnlyContext() throws NamingException {
|
||||
DirContext ctx = null;
|
||||
|
||||
try {
|
||||
ctx = tested.getReadOnlyContext();
|
||||
assertNotNull(ctx);
|
||||
Hashtable environment = ctx.getEnvironment();
|
||||
assertTrue(environment
|
||||
.containsKey(LdapContextSource.SUN_LDAP_POOLING_FLAG));
|
||||
assertTrue(environment.containsKey(Context.SECURITY_PRINCIPAL));
|
||||
assertTrue(environment.containsKey(Context.SECURITY_CREDENTIALS));
|
||||
} finally {
|
||||
// Always clean up.
|
||||
if (ctx != null) {
|
||||
try {
|
||||
ctx.close();
|
||||
} catch (Exception e) {
|
||||
// Never mind this
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetReadWriteContext() throws NamingException {
|
||||
DirContext ctx = null;
|
||||
|
||||
try {
|
||||
ctx = tested.getReadWriteContext();
|
||||
assertNotNull(ctx);
|
||||
// Double check to see that we are authenticated.
|
||||
Hashtable environment = ctx.getEnvironment();
|
||||
assertTrue(environment.containsKey(Context.SECURITY_PRINCIPAL));
|
||||
assertTrue(environment.containsKey(Context.SECURITY_CREDENTIALS));
|
||||
} finally {
|
||||
// Always clean up.
|
||||
if (ctx != null) {
|
||||
try {
|
||||
ctx.close();
|
||||
} catch (Exception e) {
|
||||
// Never mind this
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTested(ContextSource tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.core.support;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
* Integration tests for ContextSourceImpl.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class LdapContextSourcelMultiServerITest extends
|
||||
AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private LdapContextSource tested;
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "/conf/ldapContextSourceTestContext.xml" };
|
||||
}
|
||||
|
||||
public void testUrls() throws NamingException {
|
||||
String[] urls = tested.getUrls();
|
||||
String string = tested.assembleProviderUrlString(urls);
|
||||
|
||||
assertEquals("ldap://127.0.0.1:389 ldap://127.0.0.2:389", string);
|
||||
}
|
||||
|
||||
public void setTested(LdapContextSource tested) {
|
||||
this.tested = tested;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.transaction.compensating.manager;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ContextSourceAndDataSourceTransactionManager}.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private static Log log = LogFactory
|
||||
.getLog(ContextSourceAndDataSourceTransactionManagerIntegrationTest.class);
|
||||
|
||||
private DummyDao dummyDao;
|
||||
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
public ContextSourceAndDataSourceTransactionManagerIntegrationTest() {
|
||||
setAutowireMode(AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME);
|
||||
}
|
||||
|
||||
public void setLdapTemplate(LdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
public void setDummyDao(DummyDao dummyDaoImpl) {
|
||||
this.dummyDao = dummyDaoImpl;
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "conf/ldapAndJdbcTransactionTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
|
||||
jdbcTemplate
|
||||
.execute("create table PERSON(fullname VARCHAR, lastname VARCHAR, description VARCHAR)");
|
||||
jdbcTemplate.update("insert into PERSON values(?, ?, ?)", new Object[] {
|
||||
"Some Person", "Person", "Sweden, Company1, Some Person" });
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
jdbcTemplate.execute("drop table PERSON");
|
||||
}
|
||||
|
||||
public void testCreateWithException() {
|
||||
try {
|
||||
dummyDao.createWithException("Sweden", "company1",
|
||||
"some testperson", "testperson", "some description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
try {
|
||||
jdbcTemplate.queryForObject(
|
||||
"select * from PERSON where fullname='some testperson'",
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum)
|
||||
throws SQLException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
} catch (EmptyResultDataAccessException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreate() {
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson",
|
||||
"some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate
|
||||
.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
Object dbResult = jdbcTemplate.queryForObject(
|
||||
"select * from PERSON where fullname='some testperson'",
|
||||
new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum)
|
||||
throws SQLException {
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(dbResult);
|
||||
|
||||
ldapTemplate.unbind("cn=some testperson, ou=company1, c=Sweden");
|
||||
}
|
||||
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
try {
|
||||
dummyDao.updateWithException(dn, "Some Person", "Updated Person",
|
||||
"Updated description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = jdbcTemplate.queryForObject(
|
||||
"select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum)
|
||||
throws SQLException {
|
||||
assertEquals("Person", rs.getString("lastname"));
|
||||
assertEquals("Sweden, Company1, Some Person", rs
|
||||
.getString("description"));
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
}
|
||||
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
dummyDao.update(dn, "Some Person", "Updated Person",
|
||||
"Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = jdbcTemplate.queryForObject(
|
||||
"select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum)
|
||||
throws SQLException {
|
||||
assertEquals("Updated Person", rs.getString("lastname"));
|
||||
assertEquals("Updated description", rs
|
||||
.getString("description"));
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
dummyDao.update(dn, "Some Person", "Person",
|
||||
"Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.updateAndRenameWithException(dn, newDn,
|
||||
"Updated description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
try {
|
||||
ldapTemplate.lookup(newDn);
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
}
|
||||
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Updated description", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname",
|
||||
"Updated description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
// Perform test
|
||||
dummyDao
|
||||
.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.unbindWithException(dn, "Some Person");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
Object jdbcResult = jdbcTemplate.queryForObject(
|
||||
"select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum)
|
||||
throws SQLException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
}
|
||||
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
// Perform test
|
||||
dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
try {
|
||||
// Verify result - check that the operation was not rolled back
|
||||
ldapTemplate.lookup(dn);
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
try {
|
||||
jdbcTemplate.queryForObject(
|
||||
"select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum)
|
||||
throws SQLException {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
} catch (EmptyResultDataAccessException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright 2005-2007 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.transaction.compensating.manager;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.ldap.NameNotFoundException;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ContextSourceAndDataSourceTransactionManager}.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class ContextSourceTransactionManagerIntegrationTest extends
|
||||
AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private static Log log = LogFactory
|
||||
.getLog(ContextSourceTransactionManagerIntegrationTest.class);
|
||||
|
||||
public ContextSourceTransactionManagerIntegrationTest() {
|
||||
setAutowireMode(AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME);
|
||||
}
|
||||
|
||||
private DummyDao dummyDao;
|
||||
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
public void setLdapTemplate(LdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
public void setDummyDao(DummyDao dummyDaoImpl) {
|
||||
this.dummyDao = dummyDaoImpl;
|
||||
}
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[] { "conf/ldapTemplateTransactionTestContext.xml" };
|
||||
}
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.clearSynchronization();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
}
|
||||
|
||||
public void testCreateWithException() {
|
||||
try {
|
||||
dummyDao.createWithException("Sweden", "company1",
|
||||
"some testperson", "testperson", "some description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
// Verify that no entry was created
|
||||
try {
|
||||
ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreate() {
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson",
|
||||
"some description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
String expectedDn = "cn=some testperson, ou=company1, c=Sweden";
|
||||
Object ldapResult = ldapTemplate.lookup(expectedDn);
|
||||
assertNotNull(ldapResult);
|
||||
|
||||
ldapTemplate.unbind(expectedDn);
|
||||
}
|
||||
|
||||
public void testUpdateWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
try {
|
||||
dummyDao.updateWithException(dn, "Some Person", "Updated Person",
|
||||
"Updated description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
}
|
||||
|
||||
public void testUpdate() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
dummyDao.update(dn, "Some Person", "Updated Person",
|
||||
"Updated description");
|
||||
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
|
||||
dummyDao.update(dn, "Some Person", "Person",
|
||||
"Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
public void testUpdateAndRenameWithException() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.updateAndRenameWithException(dn, newDn,
|
||||
"Updated description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
try {
|
||||
ldapTemplate.lookup(newDn);
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
}
|
||||
|
||||
public void testUpdateAndRename() {
|
||||
String dn = "cn=Some Person2,ou=company1,c=Sweden";
|
||||
String newDn = "cn=Some Person2,ou=company2,c=Sweden";
|
||||
// Perform test
|
||||
dummyDao.updateAndRename(dn, newDn, "Updated description");
|
||||
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Updated description", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
public void testModifyAttributesWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.modifyAttributesWithException(dn, "Updated lastname",
|
||||
"Updated description");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
public void testModifyAttributes() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
// Perform test
|
||||
dummyDao
|
||||
.modifyAttributes(dn, "Updated lastname", "Updated description");
|
||||
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get(
|
||||
"description").get());
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
public void testUnbindWithException() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
try {
|
||||
// Perform test
|
||||
dummyDao.unbindWithException(dn, "Some Person");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes)
|
||||
throws NamingException {
|
||||
// Just verify that the entry still exists.
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
}
|
||||
|
||||
public void testUnbind() {
|
||||
String dn = "cn=Some Person,ou=company1,c=Sweden";
|
||||
// Perform test
|
||||
dummyDao.unbind(dn, "Some Person");
|
||||
|
||||
try {
|
||||
// Verify result - check that the operation was not rolled back
|
||||
ldapTemplate.lookup(dn);
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
This context automatically starts the Apache Directory Server
|
||||
and sets up the test data
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<!-- Used mainly to enable injecting base into LdapServerManager -->
|
||||
<bean
|
||||
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor" />
|
||||
|
||||
<!-- JNDI environment variable -->
|
||||
<bean id="environment"
|
||||
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="java.naming.security.authentication">
|
||||
simple
|
||||
</prop>
|
||||
<prop key="java.naming.security.principal">
|
||||
${userDn}
|
||||
</prop>
|
||||
<prop key="java.naming.security.credentials">
|
||||
${password}
|
||||
</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
Note the non-standard port, in order to leave 389 unused, thus
|
||||
making it easier for the integration tests requiring OpenLDAP.
|
||||
-->
|
||||
<bean id="configuration" class="org.apache.directory.server.configuration.MutableServerStartupConfiguration">
|
||||
<property name="ldapPort" value="3900" />
|
||||
<property name="contextPartitionConfigurations">
|
||||
<set>
|
||||
<ref bean="jaywayPartitionConfiguration"/>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="jaywayPartitionConfiguration"
|
||||
class="org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration">
|
||||
<property name="name" value="jayway" />
|
||||
<property name="suffix" value="dc=jayway,dc=se" />
|
||||
<property name="contextEntry">
|
||||
<value>
|
||||
objectClass: top
|
||||
objectClass: domain
|
||||
objectClass: extensibleObject
|
||||
dc: jayway
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="configEnvHelper" class="org.springframework.ldap.ConfigEnvHelper">
|
||||
<constructor-arg ref="environment" />
|
||||
<constructor-arg ref="configuration" />
|
||||
</bean>
|
||||
|
||||
<bean name="serverContext" class="javax.naming.InitialContext">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
|
||||
<property name="targetObject" ref="configEnvHelper" />
|
||||
<property name="propertyPath" value="env" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean name="ldapServerManager" class="org.springframework.ldap.LdapServerManager">
|
||||
<property name="contextSource" ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<!-- Custom editors required to launch ApacheDS -->
|
||||
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
<property name="customEditors">
|
||||
<map>
|
||||
<entry key="javax.naming.directory.Attributes">
|
||||
<bean class="org.apache.directory.server.core.configuration.AttributesPropertyEditor"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="contextSource2"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="cn=john doe, ${base}" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="dummyBaseContextAware"
|
||||
class="org.springframework.ldap.core.support.DummyBaseLdapPathAware" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor">
|
||||
<property name="baseLdapPathSourceName" value="contextSource2" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="contextSource2"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="dummyBaseContextAware"
|
||||
class="org.springframework.ldap.core.support.DummyBaseLdapPathAware" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor" />
|
||||
</beans>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="dummyBaseContextAware"
|
||||
class="org.springframework.ldap.core.support.DummyBaseLdapPathAware" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor" />
|
||||
</beans>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="dummyBaseContextAware"
|
||||
class="org.springframework.ldap.core.support.DummyBaseLdapPathAware" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor">
|
||||
<property name="basePath" value="cn=john doe"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="dummyBaseContextAware"
|
||||
class="org.springframework.ldap.core.support.DummyBaseLdapPathAware" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor" />
|
||||
</beans>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.core.support.LdapContextSource">
|
||||
<property name="urls" value="${urls}" />
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="base" value="${base}" />
|
||||
<property name="dirObjectFactory"
|
||||
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="contextSourceProxy"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="dummyBaseContextAware"
|
||||
class="org.springframework.ldap.core.support.DummyBaseLdapPathAware" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor" />
|
||||
</beans>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="distinguishedNameConsumer"
|
||||
class="org.springframework.ldap.core.DummyDistinguishedNameConsumer">
|
||||
<property name="distinguishedName" value="dc=jayway, dc=se" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -1,4 +1,4 @@
|
||||
urls=ldap://127.0.0.1:3901
|
||||
urls=ldap://127.0.0.1:3900
|
||||
userDn=uid=admin,ou=system
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSourceTarget"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3900" />
|
||||
<property name="pooled" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:aname" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
|
||||
<constructor-arg ref="contextSourceTarget" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="jdbcTemplate"
|
||||
class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="contextSource" ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="dummyDaoTarget"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.LdapAndJdbcDummyDaoImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager"
|
||||
ref="transactionManager" />
|
||||
<property name="target" ref="dummyDaoTarget" />
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRES_NEW</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<bean id="contextSource2" class="org.springframework.ldap.core.support.LdapContextSource" >
|
||||
<property name="urls" value="ldap://127.0.0.1:389,ldap://127.0.0.2:389" />
|
||||
<property name="userDn" value="cn=dummy" />
|
||||
<property name="password" value="dummy" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -13,7 +13,7 @@
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3905" />
|
||||
<property name="port" value="3900" />
|
||||
<property name="authenticationSource">
|
||||
<bean
|
||||
class="org.springframework.ldap.authentication.AcegiAuthenticationSource" />
|
||||
@@ -3,11 +3,8 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="placeholderConfig"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:/conf/ldap.properties" />
|
||||
</bean>
|
||||
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
@@ -16,14 +13,15 @@
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3901" />
|
||||
<property name="port" value="3900" />
|
||||
<property name="baseOnTarget" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleLdapTemplate" class="org.springframework.ldap.core.simple.SimpleLdapTemplate">
|
||||
<constructor-arg ref="ldapTemplate" />
|
||||
</bean>
|
||||
</beans>
|
||||
<!--
|
||||
<bean id="dataLoader" class="org.ddsteps.data.excel.CachingExcelDataLoader" />
|
||||
-->
|
||||
</beans>
|
||||
@@ -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"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3900" />
|
||||
<property name="dirObjectFactory"><null/></property>
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml" />
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3900" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
<bean id="dataLoader" class="org.ddsteps.data.excel.CachingExcelDataLoader" />
|
||||
-->
|
||||
</beans>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<import resource="classpath:/conf/commonTestContext.xml"/>
|
||||
|
||||
<bean id="contextSourceTarget"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3900" />
|
||||
<property name="pooled" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
|
||||
<constructor-arg ref="contextSourceTarget" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager">
|
||||
<property name="contextSource" ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="dummyDaoTarget"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.LdapDummyDaoImpl">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
</bean>
|
||||
|
||||
<bean name="dummyDao"
|
||||
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager"
|
||||
ref="transactionManager" />
|
||||
<property name="target" ref="dummyDaoTarget" />
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRES_NEW</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml" />
|
||||
|
||||
<!-- note that this has no base set, since we want to get at the root entry -->
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3900" />
|
||||
<property name="baseOnTarget" value="false" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
<import resource="classpath:/conf/commonTestContext.xml" />
|
||||
|
||||
<bean id="contextSource"
|
||||
class="org.springframework.ldap.test.TestContextSourceFactoryBean">
|
||||
<property name="defaultPartitionSuffix" value="dc=jayway,dc=se" />
|
||||
<property name="defaultPartitionName" value="jayway" />
|
||||
<property name="principal" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
<property name="ldifFile" value="classpath:/setup_data.ldif" />
|
||||
<property name="port" value="3900" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleLdapTemplate"
|
||||
class="org.springframework.ldap.core.simple.SimpleLdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
<bean id="dataLoader" class="org.ddsteps.data.excel.CachingExcelDataLoader" />
|
||||
-->
|
||||
</beans>
|
||||
@@ -0,0 +1,6 @@
|
||||
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
|
||||
|
||||
log4j.logger.org.apache.directory.server.schema.registries.DefaultSyntaxRegistry=WARN
|
||||
@@ -1,125 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-tiger-integration-tests</artifactId>
|
||||
<name>Spring LDAP Tiger Integration Tests</name>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<spring.version>2.0.8</spring.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<configuration>
|
||||
<downloadSources>true</downloadSources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<phase>test</phase>
|
||||
<goals></goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
<forkMode>once</forkMode>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-test</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-tiger</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-pool</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>ldapbp</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/../../lib/ldapbp.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- Spring Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-dao</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gsbase</groupId>
|
||||
<artifactId>gsbase</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>1.8.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,9 +0,0 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
#Enable debug logging
|
||||
log4j.category.net.sf.ldaptemplate=INFO
|
||||
log4j.category.net.sf.ldaptemplate.LdapTemplate=DEBUG
|
||||
Reference in New Issue
Block a user