LDAP-232: Finalized migration to ApacheDS 1.5.5 for integration tests.
This commit is contained in:
@@ -6,6 +6,10 @@ dependencies {
|
||||
"org.springframework.batch:spring-batch-infrastructure:$springBatchVersion"
|
||||
|
||||
testCompile "junit:junit:$junitVersion",
|
||||
"log4j:log4j:$log4jVersion",
|
||||
"commons-io:commons-io:2.4"
|
||||
testCompile ("log4j:log4j:$log4jVersion") {
|
||||
exclude group: 'javax.jms'
|
||||
exclude group: 'com.sun.jdmk'
|
||||
exclude group: 'com.sun.jmx'
|
||||
}
|
||||
}
|
||||
@@ -118,12 +118,12 @@ public final class TestLdap {
|
||||
port=GetFreePort.getFreePort();
|
||||
|
||||
// Start an LDAP server and import test data
|
||||
LdapTestUtils.startApacheDirectoryServer(port, baseName.toString(), "odm-test", "", "", null);
|
||||
LdapTestUtils.startEmbeddedServer(port, baseName.toString(), "odm-test");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
LdapTestUtils.destroyApacheDirectoryServer("", "");
|
||||
LdapTestUtils.shutdownEmbeddedServer();
|
||||
}
|
||||
|
||||
private static ContextSource getContextSource(String url, String username, String password) throws Exception {
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
package org.springframework.ldap.odm.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Iterator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
@@ -31,6 +21,16 @@ import org.springframework.ldap.odm.typeconversion.impl.converters.FromStringCon
|
||||
import org.springframework.ldap.odm.typeconversion.impl.converters.ToStringConverter;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Iterator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
// Tests the generation of entry Java classes from LDAP schema
|
||||
public final class TestSchemaToJava {
|
||||
private static final Log LOG = LogFactory.getLog(TestLdap.class);
|
||||
@@ -53,13 +53,13 @@ public final class TestSchemaToJava {
|
||||
port=GetFreePort.getFreePort();
|
||||
|
||||
// Start an in process LDAP server
|
||||
LdapTestUtils.startApacheDirectoryServer(port, baseName.toString(), "odm-test", "", "", null);
|
||||
LdapTestUtils.startEmbeddedServer(port, baseName.toString(), "odm-test");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
// Stop the in process LDAP server
|
||||
LdapTestUtils.destroyApacheDirectoryServer("", "");
|
||||
LdapTestUtils.shutdownEmbeddedServer();
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package org.springframework.ldap.odm.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
@@ -20,12 +12,18 @@ import org.springframework.ldap.odm.test.utils.RunnableTest;
|
||||
import org.springframework.ldap.odm.tools.SchemaViewer;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class TestSchemaViewer {
|
||||
// Base DN for test data
|
||||
private static final DistinguishedName baseName = new DistinguishedName("o=Whoniverse");
|
||||
|
||||
private static final String PRINCIPAL="";
|
||||
private static final String CREDENTIALS="";
|
||||
private static final String lineSeparator = System.getProperty ("line.separator");
|
||||
|
||||
private static int port;
|
||||
@@ -44,12 +42,12 @@ public final class TestSchemaViewer {
|
||||
"--error"};
|
||||
|
||||
// Start an in process LDAP server
|
||||
LdapTestUtils.startApacheDirectoryServer(port, baseName.toString(), "odm-test", "", "", null);
|
||||
LdapTestUtils.startEmbeddedServer(port, baseName.toString(), "odm-test");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
LdapTestUtils.destroyApacheDirectoryServer(PRINCIPAL, CREDENTIALS);
|
||||
LdapTestUtils.shutdownEmbeddedServer();
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -98,17 +96,13 @@ public final class TestSchemaViewer {
|
||||
// This makes the test dependent on the order in which the data is returned - it is invalid to assume that this will not change
|
||||
private static TestData[] viewerTestData=new TestData[] {
|
||||
new TestData("-o", "top",
|
||||
"NAME:top|MUST:objectClass |NAME:top |NUMERICOID:2.5.6.0 |DESC:top of the superclass chain |ABSTRACT:true"),
|
||||
"NAME:top|MUST:objectClass |X-SCHEMA:system |NAME:top |NUMERICOID:2.5.6.0 |DESC:top of the superclass chain |ABSTRACT:true"),
|
||||
new TestData("-o", "country",
|
||||
"NAME:country|MUST:c |SUP:top |NAME:country |STRUCTURAL:true |NUMERICOID:2.5.6.2 |DESC:RFC2256: a country |MAY:searchGuide description"),
|
||||
new TestData("-a", "sn",
|
||||
"NAME:sn|SUP:name |SYNTAX:1.3.6.1.4.1.1466.115.121.1.15 |NAME:sn surname |EQUALITY:caseIgnoreMatch |SUBSTR:caseIgnoreSubstringsMatch |USAGE:userApplications |NUMERICOID:2.5.4.4 |DESC:RFC2256: last (family) name(s) for which the entity is known by"),
|
||||
"NAME:country|MUST:c |X-SCHEMA:core |SUP:top |NAME:country |STRUCTURAL:true |NUMERICOID:2.5.6.2 |DESC:RFC2256: a country |MAY:searchGuide description"),
|
||||
new TestData("-a", "sn",
|
||||
"NAME:sn|NAME:sn surname |SUBSTR:caseIgnoreSubstringsMatch |X-SCHEMA:core |SYNTAX:1.3.6.1.4.1.1466.115.121.1.15 |NUMERICOID:2.5.4.4 |SUP:name |DESC:RFC2256: last (family) name(s) for which the entity is known by |USAGE:userApplications |EQUALITY:caseIgnoreMatch"),
|
||||
new TestData("-a", "jpegPhoto",
|
||||
"NAME:jpegPhoto|SYNTAX:1.3.6.1.4.1.1466.115.121.1.28 |NAME:jpegPhoto |USAGE:userApplications |NUMERICOID:0.9.2342.19200300.100.1.60 |DESC:RFC2798: a JPEG image"),
|
||||
new TestData("-s", "jpeg",
|
||||
"NAME:jpeg|NAME:JPEG |NUMERICOID:1.3.6.1.4.1.1466.115.121.1.28"),
|
||||
new TestData("-s", "OID",
|
||||
"NAME:OID|NAME:OID |NUMERICOID:1.3.6.1.4.1.1466.115.121.1.38"),
|
||||
"NAME:jpegPhoto|X-SCHEMA:inetorgperson |SYNTAX:1.3.6.1.4.1.1466.115.121.1.28 |NAME:jpegPhoto |USAGE:userApplications |NUMERICOID:0.9.2342.19200300.100.1.60 |DESC:RFC2798: a JPEG image"),
|
||||
};
|
||||
|
||||
// Very simple test - mainly just to exercise the code and to
|
||||
|
||||
@@ -7,7 +7,11 @@ dependencies {
|
||||
"org.springframework:spring-context:$springVersion",
|
||||
"commons-pool:commons-pool:$commonsPoolVersion"
|
||||
|
||||
runtime "log4j:log4j:$log4jVersion"
|
||||
runtime ("log4j:log4j:$log4jVersion") {
|
||||
exclude group: 'javax.jms'
|
||||
exclude group: 'com.sun.jdmk'
|
||||
exclude group: 'com.sun.jmx'
|
||||
}
|
||||
|
||||
testCompile project(":spring-ldap-test"),
|
||||
"junit:junit:$junitVersion"
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package org.springframework.ldap.odm.sample.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
@@ -17,6 +12,11 @@ import org.springframework.ldap.core.support.LdapContextSource;
|
||||
import org.springframework.ldap.odm.sample.SearchForPeople;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestSearchForPeople {
|
||||
// Base DN for test data
|
||||
private static final DistinguishedName baseName = new DistinguishedName("o=Whoniverse");
|
||||
@@ -30,12 +30,12 @@ public class TestSearchForPeople {
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
// Start an LDAP server and import test data
|
||||
LdapTestUtils.startApacheDirectoryServer(PORT, baseName.toString(), "odm-test", PRINCIPAL, CREDENTIALS, null);
|
||||
LdapTestUtils.startEmbeddedServer(PORT, baseName.toString(), "odm-test");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
LdapTestUtils.destroyApacheDirectoryServer(PRINCIPAL, CREDENTIALS);
|
||||
LdapTestUtils.shutdownEmbeddedServer();
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -81,7 +81,7 @@ telephonenumber: 11
|
||||
dn: cn=Bramble Harvey,ou=Doctors,o=Whoniverse
|
||||
objectClass: person
|
||||
objectClass: top
|
||||
cn: Bramble
|
||||
cn: Bramble Harvey
|
||||
description: Really not a Doctor
|
||||
sn: Harvey
|
||||
telephonenumber: 22
|
||||
|
||||
@@ -3,7 +3,7 @@ dependencies {
|
||||
compile project(":spring-ldap-core"),
|
||||
project(":spring-ldap-ldif-core"),
|
||||
"com.google.code.typica:typica:1.3",
|
||||
"commons-io:commons-io:1.4",
|
||||
"commons-io:commons-io:2.4",
|
||||
"javax.xml:jsr173:1.0",
|
||||
"javax.activation:activation:1.1",
|
||||
"javax.xml.bind:jaxb-api:2.1",
|
||||
@@ -12,11 +12,13 @@ dependencies {
|
||||
"org.springframework:spring-beans:$springVersion",
|
||||
"org.springframework:spring-context:$springVersion",
|
||||
"org.springframework:spring-test:$springVersion",
|
||||
"log4j:log4j:$log4jVersion",
|
||||
"org.slf4j:slf4j-log4j12:1.0.1"
|
||||
"org.apache.directory.server:apacheds-all:1.5.5"
|
||||
|
||||
compile "org.apache.directory.server:apacheds-all:1.5.5",
|
||||
"org.slf4j:slf4j-log4j12:1.5.6"
|
||||
compile ("org.slf4j:slf4j-log4j12:1.5.6") {
|
||||
exclude group: 'javax.jms'
|
||||
exclude group: 'com.sun.jdmk'
|
||||
exclude group: 'com.sun.jmx'
|
||||
}
|
||||
|
||||
provided "junit:junit:$junitVersion"
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class LdapTestUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start an embedded Apache Directory Server.
|
||||
* Start an embedded Apache Directory Server. Only one embedded server will be permitted in the same JVM.
|
||||
*
|
||||
* @param port the port on which the server will be listening.
|
||||
* @param defaultPartitionSuffix The default base suffix that will be used
|
||||
@@ -96,6 +96,7 @@ public class LdapTestUtils {
|
||||
* @param defaultPartitionName The name to use in the directory server
|
||||
* configuration for the default base suffix.
|
||||
*
|
||||
* @throws IllegalStateException if an embedded server is already started.
|
||||
* @since 1.3.2
|
||||
*/
|
||||
public static void startEmbeddedServer(int port, String defaultPartitionSuffix, String defaultPartitionName) {
|
||||
@@ -110,6 +111,9 @@ public class LdapTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #startEmbeddedServer(int, String, String)} instead.
|
||||
*/
|
||||
public static DirContext startApacheDirectoryServer(int port, String defaultPartitionSuffix,
|
||||
String defaultPartitionName, String principal, String credentials) throws NamingException {
|
||||
return LdapTestUtils.startApacheDirectoryServer(port, defaultPartitionSuffix, defaultPartitionName, principal,
|
||||
|
||||
@@ -16,15 +16,6 @@
|
||||
|
||||
package org.springframework.ldap;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
@@ -33,6 +24,14 @@ import org.springframework.ldap.itest.Person;
|
||||
import org.springframework.ldap.itest.PersonAttributesMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests the attributes mapper search method.
|
||||
*
|
||||
@@ -78,10 +77,10 @@ public class LdapTemplateAttributesMapperITest extends AbstractLdapTemplateInteg
|
||||
return members;
|
||||
}
|
||||
};
|
||||
List result = tested.search("ou=groups", "(objectclass=groupOfUniqueNames)", mapper);
|
||||
List result = tested.search("ou=groups", "(&(objectclass=groupOfUniqueNames)(cn=ROLE_USER))", mapper);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(1, ((String[]) result.get(0)).length);
|
||||
assertEquals(5, ((String[]) result.get(1)).length);
|
||||
assertEquals(1, result.size());
|
||||
|
||||
assertEquals(5, ((String[]) result.get(0)).length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package org.springframework.ldap;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
@@ -29,6 +25,10 @@ import org.springframework.ldap.itest.Person;
|
||||
import org.springframework.ldap.itest.PersonContextMapper;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests the ContextMapper search method. In its way this method also
|
||||
* demonstrates the use of DirContextAdapter and the DirObjectFactory.
|
||||
@@ -71,10 +71,9 @@ public class LdapTemplateContextMapperITest extends AbstractLdapTemplateIntegrat
|
||||
return members;
|
||||
}
|
||||
};
|
||||
List result = tested.search("ou=groups", "(objectclass=groupOfUniqueNames)", mapper);
|
||||
List result = tested.search("ou=groups", "(&(objectclass=groupOfUniqueNames)(cn=ROLE_USER))", mapper);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(1, ((String[]) result.get(0)).length);
|
||||
assertEquals(5, ((String[]) result.get(1)).length);
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(5, ((String[]) result.get(0)).length);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user