changes ...
o reapplied change for making minaRegistry etc static vars - this will surely
cause a conflict when merging things back to the trunk
o corrected tests that were bombing out because they could not bind to 389
as non-admin users by using the AvailablePortFinder
git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/branches/interceptor_revamp@158885 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java b/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
index 1b66b8f..27577aa 100644
--- a/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
+++ b/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
@@ -56,6 +56,10 @@
private static final ServiceRegistry DEFAULT_MINA_REGISTRY;
+ private static Service minaService;
+
+ private static ServiceRegistry minaRegistry;
+
static
{
ServiceRegistry tmp = null;
@@ -75,8 +79,6 @@
// Members
// ------------------------------------------------------------------------
- private Service minaService;
- private ServiceRegistry minaRegistry;
/**
* Default constructor that sets the provider of this ServerContextFactory.
diff --git a/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java b/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java
index 5da831f..90e192b 100644
--- a/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java
+++ b/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java
@@ -30,6 +30,7 @@
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.mina.util.AvailablePortFinder;
/**
@@ -88,6 +89,11 @@
env.put( EnvKeys.SHUTDOWN, "" );
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
try { new InitialContext( env ); } catch( Exception e ) {}
}
@@ -106,6 +112,11 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialContext initCtx = new InitialContext( env );
assertNotNull( initCtx );
}
@@ -125,6 +136,11 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialContext initCtx = new InitialContext( env );
assertNotNull( initCtx );
@@ -149,6 +165,11 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialContext initCtx = new InitialContext( env );
assertNotNull( initCtx );
@@ -173,6 +194,11 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialContext initCtx = new InitialContext( env );
assertNotNull( initCtx );
@@ -207,6 +233,11 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialContext initCtx = new InitialContext( env );
assertNotNull( initCtx );
@@ -241,6 +272,11 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialContext initCtx = new InitialContext( env );
assertNotNull( initCtx );
@@ -277,6 +313,11 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialContext initCtx = new InitialContext( env );
assertNotNull( initCtx );
diff --git a/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java b/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java
index f8f1e0d..690e939 100644
--- a/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java
+++ b/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java
@@ -34,6 +34,7 @@
import org.apache.ldap.common.exception.LdapNoPermissionException;
import org.apache.ldap.common.util.ArrayUtils;
import org.apache.ldap.server.AbstractServerTest;
+import org.apache.mina.util.AvailablePortFinder;
/**
@@ -186,6 +187,10 @@
env.put( Context.SECURITY_AUTHENTICATION, "none" );
env.put( EnvKeys.DISABLE_ANONYMOUS, "true" );
+ int port = AvailablePortFinder.getNextAvailable( 1024 );
+
+ env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
try
{
setSysRoot( env );
@@ -197,6 +202,9 @@
// ok this should start up the system now as admin
Hashtable anonymous = new Hashtable();
+
+ anonymous.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+
InitialLdapContext ctx = ( InitialLdapContext ) setSysRoot( anonymous );
assertNotNull( ctx );