diff --git a/odm/build.gradle b/odm/build.gradle index a70217b3..d0d44450 100644 --- a/odm/build.gradle +++ b/odm/build.gradle @@ -10,8 +10,6 @@ dependencies { "commons-logging:commons-logging:$commonsLoggingVersion", "commons-cli:commons-cli:1.2" - optional apachedsDependencies - runtime "org.springframework:spring-context:$springVersion" provided "commons-pool:commons-pool:$commonsPoolVersion", @@ -24,5 +22,6 @@ dependencies { testCompile project(":spring-ldap-test"), "junit:junit:$junitVersion", "jdepend:jdepend:2.9.1", - "commons-io:commons-io:$commonsIoVersion" + "commons-io:commons-io:$commonsIoVersion", + apachedsDependencies } \ No newline at end of file diff --git a/samples/odm/build.gradle b/samples/odm/build.gradle index e3c6c9f1..7f7f32a0 100644 --- a/samples/odm/build.gradle +++ b/samples/odm/build.gradle @@ -5,9 +5,8 @@ dependencies { 'javax.servlet:jstl:1.2', "org.springframework:spring-context:$springVersion", "org.springframework:spring-webmvc:$springVersion", - "org.springframework.data:spring-data-commons:$springDataVersion" - - optional apachedsDependencies + "org.springframework.data:spring-data-commons:$springDataVersion", + "commons-lang:commons-lang:$commonsLangVersion" provided "javax.servlet:servlet-api:2.5" @@ -15,5 +14,6 @@ dependencies { testCompile "org.springframework:spring-test:$springVersion", "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion" + "org.assertj:assertj-core:$assertjVersion", + apachedsDependencies } diff --git a/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServer.java b/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServer.java index 6e6968fc..5f70907e 100644 --- a/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServer.java +++ b/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServer.java @@ -30,34 +30,34 @@ import com.unboundid.ldap.sdk.Entry; */ public final class EmbeddedLdapServer { - private InMemoryDirectoryServer directoryServer; + private InMemoryDirectoryServer directoryServer; - private EmbeddedLdapServer(InMemoryDirectoryServer directoryServer) { - this.directoryServer = directoryServer; - } + private EmbeddedLdapServer(InMemoryDirectoryServer directoryServer) { + this.directoryServer = directoryServer; + } - public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName, - String defaultPartitionSuffix, int port) throws Exception { - InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig( - defaultPartitionSuffix); - config.addAdditionalBindCredentials("uid=admin,ou=system", "secret"); + public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName, + String defaultPartitionSuffix, int port) throws Exception { + InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig( + defaultPartitionSuffix); + config.addAdditionalBindCredentials("uid=admin,ou=system", "secret"); - config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", port)); + config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", port)); - config.setEnforceSingleStructuralObjectClass(false); - config.setEnforceAttributeSyntaxCompliance(true); + config.setEnforceSingleStructuralObjectClass(false); + config.setEnforceAttributeSyntaxCompliance(true); - Entry entry = new Entry(new DN(defaultPartitionSuffix)); - entry.addAttribute("objectClass", "top", "domain", "extensibleObject"); - entry.addAttribute("dc", defaultPartitionName); + Entry entry = new Entry(new DN(defaultPartitionSuffix)); + entry.addAttribute("objectClass", "top", "domain", "extensibleObject"); + entry.addAttribute("dc", defaultPartitionName); - InMemoryDirectoryServer directoryServer = new InMemoryDirectoryServer(config); - directoryServer.add(entry); - directoryServer.startListening(); - return new EmbeddedLdapServer(directoryServer); - } + InMemoryDirectoryServer directoryServer = new InMemoryDirectoryServer(config); + directoryServer.add(entry); + directoryServer.startListening(); + return new EmbeddedLdapServer(directoryServer); + } - public void shutdown() throws Exception { - this.directoryServer.shutDown(true); - } + public void shutdown() throws Exception { + this.directoryServer.shutDown(true); + } } diff --git a/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/LdapTestUtils.java b/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/LdapTestUtils.java index b3faaab5..6c96cdac 100644 --- a/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/LdapTestUtils.java +++ b/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/LdapTestUtils.java @@ -20,7 +20,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Set; import javax.naming.Binding; import javax.naming.ContextNotEmptyException; @@ -42,7 +41,6 @@ import org.springframework.ldap.core.LdapAttributes; import org.springframework.ldap.core.support.DefaultDirObjectFactory; import org.springframework.ldap.ldif.parser.LdifParser; import org.springframework.ldap.support.LdapUtils; -import org.springframework.ldap.test.DummyDirContext; import com.unboundid.ldap.listener.InMemoryDirectoryServer; import com.unboundid.ldap.sdk.LDAPException; @@ -64,31 +62,6 @@ public final class LdapTestUtils { private LdapTestUtils() { } - - /** - * Start an in-process Apache Directory Server. - * - * @param port the port on which the server will be listening. - * @param defaultPartitionSuffix The default base suffix that will be used - * for the LDAP server. - * @param defaultPartitionName The name to use in the directory server - * configuration for the default base suffix. - * @param principal The principal to use when starting the directory server. - * @param credentials The credentials to use when starting the directory - * server. - * @param extraSchemas Set of extra schemas to add to the bootstrap schemas - * of ApacheDS. May be null. - * @return An unusable DirContext instance. - * @throws NamingException If anything goes wrong when starting the server. - * @deprecated use {@link #startEmbeddedServer(int, String, String)} instead. - */ - public static DirContext startApacheDirectoryServer(int port, String defaultPartitionSuffix, - String defaultPartitionName, String principal, String credentials, Set extraSchemas) throws NamingException { - - startEmbeddedServer(port, defaultPartitionSuffix, defaultPartitionName); - return new DummyDirContext(); - } - /** * Start an embedded Apache Directory Server. Only one embedded server will be permitted in the same JVM. * @@ -99,7 +72,6 @@ public final class LdapTestUtils { * 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) { if(embeddedServer != null) { @@ -118,7 +90,6 @@ public final class LdapTestUtils { * this is silently ignored. * * @throws Exception - * @since 1.3.2 */ public static void shutdownEmbeddedServer() throws Exception { if(embeddedServer != null) { @@ -127,18 +98,6 @@ public final class LdapTestUtils { } } - /** - * Shut down the in-process Apache Directory Server. - * - * @param principal the principal to be used for authentication. - * @param credentials the credentials to be used for authentication. - * @throws Exception If anything goes wrong when shutting down the server. - * @deprecated use {@link #shutdownEmbeddedServer()} instead. - */ - public static void destroyApacheDirectoryServer(String principal, String credentials) throws Exception { - shutdownEmbeddedServer(); - } - /** * Clear the directory sub-tree starting with the node represented by the * supplied distinguished name. @@ -171,7 +130,7 @@ public final class LdapTestUtils { */ public static void clearSubContexts(DirContext ctx, Name name) throws NamingException { - NamingEnumeration enumeration = null; + NamingEnumeration enumeration = null; try { enumeration = ctx.listBindings(name); while (enumeration.hasMore()) { @@ -229,7 +188,8 @@ public final class LdapTestUtils { loadLdif(context, LdapUtils.emptyLdapName(), ldifFile); } - private static void loadLdif(DirContext context, Name rootNode, Resource ldifFile) { + @SuppressWarnings("deprecation") + private static void loadLdif(DirContext context, Name rootNode, Resource ldifFile) { try { LdapName baseDn = (LdapName) context.getEnvironment().get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY); diff --git a/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBean.java b/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBean.java index 40c901f0..fda50f39 100644 --- a/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBean.java +++ b/test-support-unboundid/src/main/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBean.java @@ -16,6 +16,8 @@ package org.springframework.ldap.test.unboundid; +import javax.naming.spi.DirObjectFactory; + import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.core.io.Resource; import org.springframework.ldap.core.AuthenticationSource; @@ -27,79 +29,79 @@ import org.springframework.ldap.support.LdapUtils; /** * @author Mattias Hellborg Arthursson */ -public class TestContextSourceFactoryBean extends AbstractFactoryBean { +public class TestContextSourceFactoryBean extends AbstractFactoryBean { private int port; - private String defaultPartitionSuffix; + private String defaultPartitionSuffix; - private String defaultPartitionName; + private String defaultPartitionName; - private String principal; + private String principal; - private String password; + private String password; - private boolean baseOnTarget = true; + private boolean baseOnTarget = true; - private Resource ldifFile; + private Resource ldifFile; - private Class dirObjectFactory = DefaultDirObjectFactory.class; + private Class dirObjectFactory = DefaultDirObjectFactory.class; - private boolean pooled = true; + private boolean pooled = true; - private AuthenticationSource authenticationSource; + private AuthenticationSource authenticationSource; private ContextSource contextSource; public void setAuthenticationSource(AuthenticationSource authenticationSource) { - this.authenticationSource = authenticationSource; - } + this.authenticationSource = authenticationSource; + } - public void setPooled(boolean pooled) { - this.pooled = pooled; - } + public void setPooled(boolean pooled) { + this.pooled = pooled; + } - public void setDirObjectFactory(Class dirObjectFactory) { - this.dirObjectFactory = dirObjectFactory; - } + public void setDirObjectFactory(Class dirObjectFactory) { + this.dirObjectFactory = dirObjectFactory; + } - public void setLdifFile(Resource ldifFile) { - this.ldifFile = ldifFile; - } + public void setLdifFile(Resource ldifFile) { + this.ldifFile = ldifFile; + } - public void setBaseOnTarget(boolean baseOnTarget) { - this.baseOnTarget = baseOnTarget; - } + public void setBaseOnTarget(boolean baseOnTarget) { + this.baseOnTarget = baseOnTarget; + } - public void setDefaultPartitionSuffix(String defaultPartitionSuffix) { - this.defaultPartitionSuffix = defaultPartitionSuffix; - } + public void setDefaultPartitionSuffix(String defaultPartitionSuffix) { + this.defaultPartitionSuffix = defaultPartitionSuffix; + } - public void setPrincipal(String principal) { - this.principal = principal; - } + public void setPrincipal(String principal) { + this.principal = principal; + } - public void setPassword(String password) { - this.password = password; - } + public void setPassword(String password) { + this.password = password; + } - public void setDefaultPartitionName(String defaultPartitionName) { - this.defaultPartitionName = defaultPartitionName; - } + public void setDefaultPartitionName(String defaultPartitionName) { + this.defaultPartitionName = defaultPartitionName; + } - public void setPort(int port) { - this.port = port; - } + public void setPort(int port) { + this.port = port; + } public void setContextSource(ContextSource contextSource) { this.contextSource = contextSource; } - protected Object createInstance() throws Exception { - LdapTestUtils.startEmbeddedServer(port, - defaultPartitionSuffix, defaultPartitionName); + protected ContextSource createInstance() throws Exception { + LdapTestUtils.startEmbeddedServer(port, + defaultPartitionSuffix, defaultPartitionName); - if (contextSource == null) { + if (contextSource == null) { // If not explicitly configured, create a new instance. LdapContextSource targetContextSource = new LdapContextSource(); if (baseOnTarget) { @@ -123,25 +125,25 @@ public class TestContextSourceFactoryBean extends AbstractFactoryBean { Thread.sleep(1000); if (baseOnTarget) { - LdapTestUtils.clearSubContexts(contextSource, LdapUtils.emptyLdapName()); - } - else { - LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName(defaultPartitionSuffix)); - } + LdapTestUtils.clearSubContexts(contextSource, LdapUtils.emptyLdapName()); + } + else { + LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName(defaultPartitionSuffix)); + } - if (ldifFile != null) { + if (ldifFile != null) { LdapTestUtils.loadLdif(contextSource, ldifFile); - } + } - return contextSource; - } + return contextSource; + } - public Class getObjectType() { - return ContextSource.class; - } + public Class getObjectType() { + return ContextSource.class; + } - protected void destroyInstance(Object instance) throws Exception { - super.destroyInstance(instance); + protected void destroyInstance(ContextSource instance) throws Exception { + super.destroyInstance(instance); LdapTestUtils.shutdownEmbeddedServer(); - } + } } diff --git a/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServerFactoryBeanTest.java b/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServerFactoryBeanTest.java index baf9f186..8091b71e 100644 --- a/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServerFactoryBeanTest.java +++ b/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/EmbeddedLdapServerFactoryBeanTest.java @@ -21,6 +21,7 @@ import java.util.List; import javax.naming.NamingException; import javax.naming.directory.Attributes; +import org.junit.After; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -31,10 +32,18 @@ import org.springframework.ldap.query.LdapQueryBuilder; import static org.assertj.core.api.Assertions.assertThat; public class EmbeddedLdapServerFactoryBeanTest { + ClassPathXmlApplicationContext ctx; + + @After + public void setup() { + if(ctx != null) { + ctx.close(); + } + } @Test public void testServerStartup() throws Exception { - ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/applicationContext-ldifPopulator.xml"); + ctx = new ClassPathXmlApplicationContext("/applicationContext-ldifPopulator.xml"); LdapTemplate ldapTemplate = ctx.getBean(LdapTemplate.class); assertThat(ldapTemplate).isNotNull(); diff --git a/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBeanTest.java b/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBeanTest.java index 6e0ce603..25cf7137 100644 --- a/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBeanTest.java +++ b/test-support-unboundid/src/test/java/org/springframework/ldap/test/unboundid/TestContextSourceFactoryBeanTest.java @@ -21,6 +21,7 @@ import java.util.List; import javax.naming.NamingException; import javax.naming.directory.Attributes; +import org.junit.After; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -31,10 +32,18 @@ import org.springframework.ldap.query.LdapQueryBuilder; import static org.assertj.core.api.Assertions.assertThat; public class TestContextSourceFactoryBeanTest { + ClassPathXmlApplicationContext ctx; + + @After + public void setup() { + if(ctx != null) { + ctx.close(); + } + } @Test public void testServerStartup() throws Exception { - ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/applicationContext-testContextSource.xml"); + ctx = new ClassPathXmlApplicationContext("/applicationContext-testContextSource.xml"); LdapTemplate ldapTemplate = ctx.getBean(LdapTemplate.class); assertThat(ldapTemplate).isNotNull(); diff --git a/test/integration-tests-spring20/build.gradle b/test/integration-tests-spring20/build.gradle index 907dece5..6cd761db 100644 --- a/test/integration-tests-spring20/build.gradle +++ b/test/integration-tests-spring20/build.gradle @@ -7,8 +7,6 @@ apply from: JAVA_SCRIPT ext.spring20Version = '2.0.8' dependencies { - optional apachedsDependencies - testCompile (project(":spring-ldap-test")) { exclude group: "org.springframework", module:"spring-core" exclude group: "org.springframework", module:"spring-beans" @@ -23,6 +21,7 @@ dependencies { "org.springframework:spring-dao:$spring20Version", "org.springframework:spring-beans:$spring20Version", "org.slf4j:slf4j-log4j12:$slf4jVersion", - "org.assertj:assertj-core:$assertjVersion" + "org.assertj:assertj-core:$assertjVersion", + apachedsDependencies } diff --git a/test/integration-tests-spring25/build.gradle b/test/integration-tests-spring25/build.gradle index 05b37177..6eb88928 100644 --- a/test/integration-tests-spring25/build.gradle +++ b/test/integration-tests-spring25/build.gradle @@ -7,8 +7,6 @@ apply from: JAVA_SCRIPT ext.spring25Version = '2.5.6.SEC03' dependencies { - optional apachedsDependencies - testCompile (project(":spring-ldap-test")) { exclude group: "org.springframework", module:"spring-core" exclude group: "org.springframework", module:"spring-beans" @@ -33,6 +31,7 @@ dependencies { "org.springframework:spring-beans:$spring25Version", "junit:junit:$junitVersion", "org.slf4j:slf4j-log4j12:$slf4jVersion", - "org.assertj:assertj-core:$assertjVersion" + "org.assertj:assertj-core:$assertjVersion", + apachedsDependencies } diff --git a/test/integration-tests-spring30/build.gradle b/test/integration-tests-spring30/build.gradle index f826679e..dae367b2 100644 --- a/test/integration-tests-spring30/build.gradle +++ b/test/integration-tests-spring30/build.gradle @@ -7,8 +7,6 @@ apply from: JAVA_SCRIPT ext.spring30Version = '3.0.7.RELEASE' dependencies { - optional apachedsDependencies - testCompile (project(":spring-ldap-test")) { exclude group: "org.springframework", module:"spring-core" exclude group: "org.springframework", module:"spring-beans" @@ -28,7 +26,8 @@ dependencies { "org.springframework:spring-beans:$spring30Version", "junit:junit:$junitVersion", "org.slf4j:slf4j-log4j12:$slf4jVersion", - "org.assertj:assertj-core:$assertjVersion" + "org.assertj:assertj-core:$assertjVersion", + apachedsDependencies testCompile("org.springframework.data:spring-data-commons:$springDataVersion") { exclude group: "org.springframework" diff --git a/test/integration-tests-sunone/build.gradle b/test/integration-tests-sunone/build.gradle index fa20fae0..e326d88f 100644 --- a/test/integration-tests-sunone/build.gradle +++ b/test/integration-tests-sunone/build.gradle @@ -7,8 +7,6 @@ dependencies { project(":spring-ldap-core-tiger"), "commons-pool:commons-pool:1.4" - optional apachedsDependencies - provided "org.springframework:spring-jdbc:$springVersion", "com.sun:ldapbp:1.0" @@ -17,7 +15,8 @@ dependencies { "org.springframework:spring-aop:$springVersion", "gsbase:gsbase:$gsbaseVersion", "org.slf4j:slf4j-log4j12:$slf4jVersion", - "org.assertj:assertj-core:$assertjVersion" + "org.assertj:assertj-core:$assertjVersion", + apachedsDependencies } diff --git a/test/integration-tests/build.gradle b/test/integration-tests/build.gradle index e86780eb..5e882579 100644 --- a/test/integration-tests/build.gradle +++ b/test/integration-tests/build.gradle @@ -27,6 +27,7 @@ dependencies { project(":spring-ldap-core-tiger") compile "com.querydsl:querydsl-apt:$queryDslVersion", + "commons-lang:commons-lang:$commonsLangVersion" compile("org.springframework.data:spring-data-commons:$springDataVersion") { exclude group: "org.springframework", module: "spring-beans" @@ -41,8 +42,6 @@ dependencies { exclude group: "org.springframework", module: "spring-aop" } - optional apachedsDependencies - provided "commons-pool:commons-pool:$commonsPoolVersion", "org.springframework:spring-jdbc:$springVersion", "org.springframework:spring-orm:$springVersion" @@ -57,7 +56,8 @@ dependencies { "junit:junit:$junitVersion", "org.springframework.security:spring-security-config:$springSecurityVersion", "org.slf4j:slf4j-log4j12:$slf4jVersion", - "org.assertj:assertj-core:$assertjVersion" + "org.assertj:assertj-core:$assertjVersion", + apachedsDependencies testCompile("org.springframework.security:spring-security-ldap:$springSecurityVersion") {