directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r502673 - /directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
Date Fri, 02 Feb 2007 17:48:23 GMT
Author: akarasulu
Date: Fri Feb  2 09:48:22 2007
New Revision: 502673

URL: http://svn.apache.org/viewvc?view=rev&rev=502673
Log:
fixing issue with importLdif method on AbstractServerTest

Modified:
    directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java

Modified: directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?view=diff&rev=502673&r1=502672&r2=502673
==============================================================================
--- directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
(original)
+++ directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
Fri Feb  2 09:48:22 2007
@@ -56,6 +56,9 @@
     /** the context root for the system partition */
     protected LdapContext sysRoot;
 
+    /** the context root for the rootDSE */
+    protected LdapContext rootDSE;
+
     /** flag whether to delete database files for each test or not */
     protected boolean doDelete = true;
 
@@ -78,7 +81,7 @@
         port = AvailablePortFinder.getNextAvailable( 1024 );
         configuration.setLdapPort( port );
         configuration.setShutdownHookEnabled( false );
-        setSysRoot( "uid=admin,ou=system", "secret" );
+        setContexts( "uid=admin,ou=system", "secret" );
     }
 
 
@@ -102,40 +105,40 @@
 
 
     /**
-     * Sets and returns the system root.  Values of user and password used to
+     * Sets the contexts for this base class.  Values of user and password used to
      * set the respective JNDI properties.  These values can be overriden by the
      * overrides properties.
      *
      * @param user the username for authenticating as this user
      * @param passwd the password of the user
-     * @return the sysRoot context which is also set
      * @throws NamingException if there is a failure of any kind
      */
-    protected LdapContext setSysRoot( String user, String passwd ) throws NamingException
+    protected void setContexts( String user, String passwd ) throws NamingException
     {
-        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
+        Hashtable<String, Object> env = new Hashtable<String, Object>( configuration.toJndiEnvironment()
);
         env.put( Context.SECURITY_PRINCIPAL, user );
         env.put( Context.SECURITY_CREDENTIALS, passwd );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
-        return setSysRoot( env );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
+        setContexts( env );
     }
 
 
     /**
-     * Sets the system root taking into account the extras and overrides
-     * properties.  In between these it sets the properties for the working
-     * directory, the provider URL and the JNDI InitialContexFactory to use.
+     * Sets the contexts of this class taking into account the extras and overrides
+     * properties.  
      *
      * @param env an environment to use while setting up the system root.
-     * @return the sysRoot context which is also set
      * @throws NamingException if there is a failure of any kind
      */
-    protected LdapContext setSysRoot( Hashtable env ) throws NamingException
+    protected void setContexts( Hashtable<String, Object> env ) throws NamingException
     {
-        Hashtable envFinal = new Hashtable( env );
+        Hashtable<String, Object> envFinal = new Hashtable<String, Object>( env
);
         envFinal.put( Context.PROVIDER_URL, "ou=system" );
-        envFinal.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName()
);
-        return sysRoot = new InitialLdapContext( envFinal, null );
+        sysRoot = new InitialLdapContext( envFinal, null );
+        
+        envFinal.put( Context.PROVIDER_URL, "" );
+        rootDSE = new InitialLdapContext( envFinal, null );
     }
 
 
@@ -147,7 +150,7 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
-        Hashtable env = new Hashtable();
+        Hashtable<String, Object> env = new Hashtable<String, Object>();
         env.put( Context.PROVIDER_URL, "ou=system" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.jndi.ServerContextFactory"
);
         env.putAll( new ShutdownConfiguration().toJndiEnvironment() );
@@ -178,10 +181,6 @@
      */
     protected void importLdif( InputStream in ) throws NamingException
     {
-        Hashtable env = new Hashtable();
-        env.putAll( sysRoot.getEnvironment() );
-        LdapContext ctx = new InitialLdapContext( env, null );
-
         try
         {
             Iterator iterator = new LdifReader( in );
@@ -193,7 +192,7 @@
                 LdapDN dn = new LdapDN( entry.getDn() );
                 dn.remove( 0 );
 
-                ctx.createSubcontext( dn, entry.getAttributes() );
+                rootDSE.createSubcontext( dn, entry.getAttributes() );
             }
         }
         catch ( Exception e )



Mime
View raw message