You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dj...@apache.org on 2007/10/13 01:28:56 UTC

svn commit: r584320 - /directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ssl/LdapsITest.java

Author: djencks
Date: Fri Oct 12 16:28:56 2007
New Revision: 584320

URL: http://svn.apache.org/viewvc?rev=584320&view=rev
Log:
fix LdapsITest

Modified:
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ssl/LdapsITest.java

Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ssl/LdapsITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ssl/LdapsITest.java?rev=584320&r1=584319&r2=584320&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ssl/LdapsITest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ssl/LdapsITest.java Fri Oct 12 16:28:56 2007
@@ -34,6 +34,7 @@
 import javax.naming.directory.InitialDirContext;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.io.IOException;
 import java.util.Hashtable;
 
 
@@ -58,35 +59,14 @@
     {
         super.setUp();
 
-        int ldapsPort = AvailablePortFinder.getNextAvailable( 8192 );
-        LdapServer ldapsServer = new LdapServer( socketAcceptor, directoryService );
-        ldapsServer.setEnableLdaps( true );
-        ldapsServer.setLdapsCertificatePassword( "boguspw" );
-        ldapsServer.setIpPort( ldapsPort );
-
-        // Copy the bogus certificate to the certificates directory.
-        InputStream in = getClass().getResourceAsStream( "/bogus.cert" );
-        ldapsServer.getLdapsCertificateFile().getParentFile().mkdirs();
-
-        FileOutputStream out = new FileOutputStream( ldapsServer.getLdapsCertificateFile() );
-
-        for ( ;; )
-        {
-            int c = in.read();
-            if ( c < 0 )
-            {
-                break;
-            }
-            out.write( c );
-        }
-
-        in.close();
-        out.close();
+//        int ldapsPort = AvailablePortFinder.getNextAvailable( 8192 );
+//
+//        LdapServer ldapsServer = new LdapServer( socketAcceptor, directoryService );
 
 
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( "java.naming.provider.url", "ldap://localhost:" + ldapsPort + "/ou=system" );
+        env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
         env.put( "java.naming.ldap.factory.socket", SSLSocketFactory.class.getName() );
         env.put( "java.naming.security.principal", "uid=admin,ou=system" );
         env.put( "java.naming.security.credentials", "secret" );
@@ -94,6 +74,40 @@
         ctx = new InitialDirContext( env );
     }
 
+
+    @Override
+    protected void configureLdapServer()
+    {
+        ldapServer.setEnableLdaps( true );
+        ldapServer.setLdapsCertificatePassword( "boguspw" );
+//        ldapServer.setIpPort( ldapsPort );
+
+        // Copy the bogus certificate to the certificates directory.
+        InputStream in = getClass().getResourceAsStream( "/bogus.cert" );
+        ldapServer.getLdapsCertificateFile().getParentFile().mkdirs();
+
+        try
+        {
+            FileOutputStream out = new FileOutputStream( ldapServer.getLdapsCertificateFile() );
+
+            for ( ;; )
+            {
+                int c = in.read();
+                if ( c < 0 )
+                {
+                    break;
+                }
+                out.write( c );
+            }
+
+            in.close();
+            out.close();
+        } catch ( IOException e )
+        {
+            throw new RuntimeException( e );
+        }
+
+    }
 
     /**
      * Remove the person.