[java-identity-provider COMMIT] /trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java

noreply at shibboleth.net noreply at shibboleth.net
Mon Jun 29 14:18:22 EDT 2015


Author: tzeller
Date: Mon Jun 29 14:18:22 2015
New Revision: 7609

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7609&view=rev
Log:
IDP-757 - Add ability to configure the test directory server port.

https://issues.shibboleth.net/jira/browse/IDP-757

Modified:
    trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java

Modified: trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java?rev=7609&r1=7608&r2=7609&view=diff
==============================================================================
--- trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java	(original)
+++ trunk/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java	Mon Jun 29 14:18:22 2015
@@ -22,8 +22,6 @@
 
 import javax.annotation.Nonnull;
 
-import net.shibboleth.utilities.java.support.logic.Constraint;
-
 import org.springframework.core.io.Resource;
 
 import com.unboundid.ldap.listener.InMemoryDirectoryServer;
@@ -34,6 +32,9 @@
 import com.unboundid.util.ssl.KeyStoreKeyManager;
 import com.unboundid.util.ssl.SSLUtil;
 
+import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
 /**
  * Manages an instance of the in-memory directory server.
  */
@@ -43,17 +44,31 @@
     @Nonnull private final InMemoryDirectoryServer directoryServer;
 
     /**
-     * Constructor without STARTTLS support.
+     * Constructor without STARTTLS support. Listens on port 10389.
      * 
-     * @param LDIF the LDIF resource to be imported
+     * @param ldif the LDIF resource to be imported
      * 
      * @throws LDAPException if the in-memory directory server cannot be created
      * @throws IOException if the LDIF resource cannot be imported
      */
     public InMemoryDirectory(@Nonnull final Resource ldif) throws LDAPException, IOException {
+       this(ldif, 10389);
+    }
+    
+    /**
+     * Constructor without STARTTLS support.
+     *
+     * @param ldif the LDIF resource to be imported
+     * @param port port to listen on
+     * @throws LDAPException if the in-memory directory server cannot be created
+     * @throws IOException if the LDIF resource cannot be imported
+     */
+    public InMemoryDirectory(@Nonnull final Resource ldif, @Positive final int port) throws LDAPException, IOException {
         Constraint.isNotNull(ldif, "LDIF resource cannot be null");
+        Constraint.isGreaterThan(-1, port, "Port must be greater than -1");
+        System.err.println("PORT " + port);
         final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=org", "ou=system");
-        config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", 10389));
+        config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
         config.addAdditionalBindCredentials("cn=Directory Manager", "password");
         directoryServer = new InMemoryDirectoryServer(config);
         directoryServer.importFromLDIF(true, new LDIFReader(ldif.getInputStream()));



More information about the commits mailing list