directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r165254 - in /directory/apacheds/trunk/core/src: main/java/org/apache/ldap/server/ main/java/org/apache/ldap/server/jndi/ test/org/apache/ldap/server/authn/ test/org/apache/ldap/server/authz/ test/org/apache/ldap/server/jndi/ test/org/apache/ldap/server/operational/ test/org/apache/ldap/server/prefs/
Date Fri, 29 Apr 2005 03:28:28 GMT
Author: akarasulu
Date: Thu Apr 28 20:28:27 2005
New Revision: 165254

URL: http://svn.apache.org/viewcvs?rev=165254&view=rev
Log:
changes ...

 o cleaned up test cases dependent on old data from LDIF import
 o tests now depend on CoreContextFactory rather than moved ServerContextFactory
 o the groups, users and system prefs root are created by CCF w/o an LDIF
 o removed ImportConfigurationTest which is not needed because LDIF is not used
 o added extra attribute for testing non admin users on startup by loading
   additional entries to be added for testing and passed within the environment
 o renamed code that creates admin user to now create bootstrap entries

Removed:
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ImportConfirmationTest.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceTest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ListTest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
Thu Apr 28 20:28:27 2005
@@ -19,6 +19,7 @@
 
 import junit.framework.TestCase;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.exception.NestableRuntimeException;
 import org.apache.ldap.common.exception.LdapConfigurationException;
 import org.apache.ldap.common.ldif.LdifIterator;
 import org.apache.ldap.common.ldif.LdifParser;
@@ -26,7 +27,6 @@
 import org.apache.ldap.common.message.LockableAttributesImpl;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.server.jndi.EnvKeys;
-import org.apache.mina.util.AvailablePortFinder;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -39,6 +39,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Hashtable;
+import java.util.ArrayList;
 
                                                                                         
                   
 /**
@@ -49,6 +50,24 @@
  */
 public abstract class AbstractCoreTest extends TestCase
 {
+    public static final String LDIF = "dn: uid=akarasulu,ou=users,ou=system\n" +
+            "cn: Alex Karasulu\n" +
+            "sn: Karasulu\n" +
+            "givenname: Alex\n" +
+            "objectclass: top\n" +
+            "objectclass: person\n" +
+            "objectclass: organizationalPerson\n" +
+            "objectclass: inetOrgPerson\n" +
+            "ou: Engineering\n" +
+            "ou: People\n" +
+            "l: Bogusville\n" +
+            "uid: akarasulu\n" +
+            "mail: akarasulu@apache.org\n" +
+            "telephonenumber: +1 408 555 4798\n" +
+            "facsimiletelephonenumber: +1 408 555 9751\n" +
+            "roomnumber: 4612\n" +
+            "userpassword: test\n";
+
     /** the context root for the system partition */
     protected LdapContext sysRoot;
 
@@ -61,7 +80,32 @@
     /** extra environment parameters that can be added before setUp to override values */
     protected Hashtable overrides = new Hashtable();
 
-    protected int port = -1;
+
+    private ArrayList list = null;
+
+
+    public AbstractCoreTest()
+    {
+        list = new ArrayList();
+
+        Attributes attributes = new LockableAttributesImpl();
+
+        LdifParserImpl parser = new LdifParserImpl();
+
+        try
+        {
+            parser.parse( attributes, LDIF );
+        }
+        catch ( NamingException e )
+        {
+            e.printStackTrace();
+
+            throw new NestableRuntimeException( e );
+        }
+
+        list.add( attributes );
+    }
+
 
     /**
      * Get's the initial context factory for the provider's ou=system context
@@ -73,6 +117,8 @@
     {
         super.setUp();
 
+        extras.put( EnvKeys.TEST_ENTRIES, list );
+        
         if ( overrides.containsKey( EnvKeys.WKDIR ) )
         {
             doDelete( new File( ( String ) overrides.get( EnvKeys.WKDIR ) ) );
@@ -82,10 +128,6 @@
             doDelete( new File( "target" + File.separator + "apacheds" ) );
         }
 
-        port = AvailablePortFinder.getNextAvailable( 1024 );
-        
-        extras.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
-
         setSysRoot( "uid=admin,ou=system", "secret" );
     }
 
@@ -152,7 +194,7 @@
 
         envFinal.put( EnvKeys.WKDIR, "target" + File.separator + "apacheds" );
 
-        envFinal.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+        envFinal.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
 
         envFinal.putAll( overrides );
 
@@ -173,7 +215,7 @@
 
         env.put( Context.PROVIDER_URL, "ou=system" );
 
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
 
         env.put( EnvKeys.SHUTDOWN, "" );
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java
Thu Apr 28 20:28:27 2005
@@ -44,6 +44,7 @@
 import javax.naming.Name;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
 import javax.naming.spi.InitialContextFactory;
 import java.io.File;
 import java.lang.reflect.Constructor;
@@ -210,7 +211,35 @@
 
             initialize();
 
-            createMode = createAdminAccount();
+            createMode = createBootstrapEntries();
+
+            /*
+             * Unfortunately to test non-root user startup of the core and make sure
+             * all the appropriate functionality is there we need to load more user
+             * entries at startup due to a chicken and egg like problem.  The value
+             * of this property is a list of attributes to be added.
+             */
+
+            if ( createMode && env.containsKey( EnvKeys.TEST_ENTRIES ) )
+            {
+                ArrayList list = ( ArrayList ) initialEnv.get( EnvKeys.TEST_ENTRIES );
+
+                if ( list != null )
+                {
+                    for ( int ii = 0; ii < list.size(); ii++ )
+                    {
+                        Attributes attributes = ( Attributes ) list.get( ii );
+
+                        attributes.put( "creatorsName", ADMIN );
+
+                        attributes.put( "createTimestamp", DateUtils.getGeneralizedTime()
);
+
+                        Attribute dn = attributes.remove( "dn" );
+
+                        nexus.add( ( String ) dn.get(), new LdapName( ( String ) dn.get()
), attributes );
+                    }
+                }
+            }
         }
 
         ctx = ( ServerContext ) provider.getLdapContext( env );
@@ -313,48 +342,142 @@
 
 
     /**
-     * Returns true if we had to create the admin account since this is the first time we
started the server.  Otherwise
-     * if the account exists then we are not starting for the first time.
+     * Returns true if we had to create the bootstrap entries on the first
+     * start of the server.  Otherwise if all entries exist, meaning none
+     * had to be created, then we are not starting for the first time.
      *
      * @throws javax.naming.NamingException
      */
-    protected boolean createAdminAccount() throws NamingException
+    private boolean createBootstrapEntries() throws NamingException
     {
+        boolean isFirstStart = false;
+
+        // -------------------------------------------------------------------
+        // create admin entry
+        // -------------------------------------------------------------------
+
         /*
          * If the admin entry is there, then the database was already created
-         * before so we just need to lookup the userPassword field to see if
-         * the password matches.
          */
         if ( nexus.hasEntry( ADMIN_NAME ) )
         {
-            return false;
+            isFirstStart = false;
         }
+        else
+        {
+            isFirstStart = true;
 
-        Attributes attributes = new LockableAttributesImpl();
+            Attributes attributes = new LockableAttributesImpl();
 
-        attributes.put( "objectClass", "top" );
+            attributes.put( "objectClass", "top" );
 
-        attributes.put( "objectClass", "person" );
+            attributes.put( "objectClass", "person" );
 
-        attributes.put( "objectClass", "organizationalPerson" );
+            attributes.put( "objectClass", "organizationalPerson" );
 
-        attributes.put( "objectClass", "inetOrgPerson" );
+            attributes.put( "objectClass", "inetOrgPerson" );
 
-        attributes.put( "uid", SystemPartition.ADMIN_UID );
+            attributes.put( "uid", SystemPartition.ADMIN_UID );
 
-        attributes.put( "userPassword", SystemPartition.ADMIN_PW );
+            attributes.put( "userPassword", SystemPartition.ADMIN_PW );
 
-        attributes.put( "displayName", "Directory Superuser" );
+            attributes.put( "displayName", "Directory Superuser" );
 
-        attributes.put( "creatorsName", ADMIN );
+            attributes.put( "creatorsName", ADMIN );
 
-        attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
 
-        attributes.put( "displayName", "Directory Superuser" );
+            attributes.put( "displayName", "Directory Superuser" );
 
-        nexus.add( ADMIN, ADMIN_NAME, attributes );
+            nexus.add( ADMIN, ADMIN_NAME, attributes );
+        }
 
-        return true;
+        // -------------------------------------------------------------------
+        // create system users area
+        // -------------------------------------------------------------------
+
+        if ( nexus.hasEntry( new LdapName( "ou=users,ou=system" ) ) )
+        {
+            isFirstStart = false;
+        }
+        else
+        {
+            isFirstStart = true;
+
+            Attributes attributes = new LockableAttributesImpl();
+
+            attributes.put( "objectClass", "top" );
+
+            attributes.put( "objectClass", "organizationalUnit" );
+
+            attributes.put( "ou", "users" );
+
+            attributes.put( "creatorsName", ADMIN );
+
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+
+            nexus.add( "ou=users,ou=system", new LdapName( "ou=users,ou=system" ), attributes
);
+        }
+
+        // -------------------------------------------------------------------
+        // create system groups area
+        // -------------------------------------------------------------------
+
+        if ( nexus.hasEntry( new LdapName( "ou=groups,ou=system" ) ) )
+        {
+            isFirstStart = false;
+        }
+        else
+        {
+            isFirstStart = true;
+
+            Attributes attributes = new LockableAttributesImpl();
+
+            attributes.put( "objectClass", "top" );
+
+            attributes.put( "objectClass", "organizationalUnit" );
+
+            attributes.put( "ou", "groups" );
+
+            attributes.put( "creatorsName", ADMIN );
+
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+
+            nexus.add( "ou=groups,ou=system", new LdapName( "ou=groups,ou=system" ), attributes
);
+        }
+
+        // -------------------------------------------------------------------
+        // create system preferences area
+        // -------------------------------------------------------------------
+
+        if ( nexus.hasEntry( new LdapName( "prefNodeName=sysPrefRoot,ou=system" ) ) )
+        {
+            isFirstStart = false;
+        }
+        else
+        {
+            isFirstStart = true;
+
+            Attributes attributes = new LockableAttributesImpl();
+
+            attributes.put( "objectClass", "top" );
+
+            attributes.put( "objectClass", "prefNode" );
+
+            attributes.put( "objectClass", "extensibleObject" );
+
+            attributes.put( "prefNodeName", "sysPrefRoot" );
+
+            attributes.put( "creatorsName", ADMIN );
+
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+
+            LdapName dn = new LdapName( "prefNodeName=sysPrefRoot,ou=system" );
+
+            nexus.add( "prefNodeName=sysPrefRoot,ou=system", dn, attributes );
+        }
+
+        return isFirstStart;
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java Thu
Apr 28 20:28:27 2005
@@ -112,4 +112,13 @@
     public static final String INDICES = "server.db.partition.indices.";
     /** the envprop key base to the Attributes for the context nexus entry */
     public static final String ATTRIBUTES = "server.db.partition.attributes.";
+
+    /**
+     * Unfortunately to test non-root user startup of the core and make sure
+     * all the appropriate functionality is there we need to load more user
+     * entries at startup due to a chicken and egg like problem.  The value
+     * of this property is a list of attributes to be added.  It should only
+     * be used to test the server and not as a feature since it may go away.
+     */
+    public static final String TEST_ENTRIES = "server.test.entries";
 }

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
Thu Apr 28 20:28:27 2005
@@ -143,7 +143,7 @@
         env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "test" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
         InitialDirContext ic = new InitialDirContext( env );
         Attributes attrs = ic.getAttributes( "uid=akarasulu,ou=users" );
         Attribute ou = attrs.get( "ou" );
@@ -207,7 +207,7 @@
 
         // now go in as anonymous user and we should be wh
         env.put( Context.PROVIDER_URL, "ou=system" );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
 
         InitialLdapContext initial = new InitialLdapContext( env, null );
 
@@ -297,7 +297,7 @@
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
         assertNotNull( new InitialContext( env ) );
     }
 
@@ -315,7 +315,7 @@
         env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "test" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
         assertNotNull( new InitialContext( env ) );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authz/AuthorizationServiceTest.java
Thu Apr 28 20:28:27 2005
@@ -157,21 +157,28 @@
     public void testSearchSubtreeByAdmin() throws NamingException
     {
         SearchControls controls = new SearchControls();
+
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
 
         HashSet set = new HashSet();
+
         NamingEnumeration list = sysRoot.search( "", "(objectClass=*)", controls );
+
         while ( list.hasMore() )
         {
             DbSearchResult result = ( DbSearchResult ) list.next();
+
             set.add( result.getName() );
         }
 
         assertTrue( set.contains( "ou=system" ) );
+
         assertTrue( set.contains( "ou=groups,ou=system" ) );
-        assertTrue( set.contains( "cn=administrators,ou=groups,ou=system" ) );
+
         assertTrue( set.contains( "ou=users,ou=system" ) );
+
         assertTrue( set.contains( "uid=akarasulu,ou=users,ou=system" ) );
+
         assertTrue( set.contains( "uid=admin,ou=system" ) );
     }
 

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java
Thu Apr 28 20:28:27 2005
@@ -43,15 +43,23 @@
     protected void setUp() throws Exception
     {
         // bring the system up
+
         super.setUp();
 
         // authenticate as akarasulu
+
         Hashtable env = new Hashtable( );
+
         env.put( Context.PROVIDER_URL, "ou=system" );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
+
         env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
+
         env.put( Context.SECURITY_CREDENTIALS, "test" );
+
         InitialContext ictx = new InitialContext( env );
+
         sysRootAsNonAdminUser = ( ServerLdapContext ) ictx.lookup( "" );
     }
 
@@ -59,6 +67,7 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
+
         sysRootAsNonAdminUser = null;
     }
 }

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ListTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ListTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ListTest.java (original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ListTest.java Thu Apr
28 20:28:27 2005
@@ -36,15 +36,20 @@
     public void testListSystemAsAdmin() throws NamingException
     {
         HashSet set = new HashSet();
+
         NamingEnumeration list = sysRoot.list( "" );
+
         while ( list.hasMore() )
         {
             NameClassPair ncp = ( NameClassPair ) list.next();
+
             set.add( ncp.getName() );
         }
 
         assertTrue( set.contains( "uid=admin,ou=system" ) );
+
         assertTrue( set.contains( "ou=users,ou=system" ) );
+
         assertTrue( set.contains( "ou=groups,ou=system" ) );
     }
 
@@ -52,15 +57,20 @@
     public void testListSystemAsNonAdmin() throws NamingException
     {
         HashSet set = new HashSet();
+
         NamingEnumeration list = sysRootAsNonAdminUser.list( "" );
+
         while ( list.hasMore() )
         {
             NameClassPair ncp = ( NameClassPair ) list.next();
+
             set.add( ncp.getName() );
         }
 
         assertFalse( set.contains( "uid=admin,ou=system" ) );
+
         assertTrue( set.contains( "ou=users,ou=system" ) );
+
         assertTrue( set.contains( "ou=groups,ou=system" ) );
     }
 
@@ -68,10 +78,13 @@
     public void testListUsersAsAdmin() throws NamingException
     {
         HashSet set = new HashSet();
+
         NamingEnumeration list = sysRoot.list( "ou=users" );
+
         while ( list.hasMore() )
         {
             NameClassPair ncp = ( NameClassPair ) list.next();
+
             set.add( ncp.getName() );
         }
 
@@ -82,10 +95,13 @@
     public void testListUsersAsNonAdmin() throws NamingException
     {
         HashSet set = new HashSet();
+
         NamingEnumeration list = sysRootAsNonAdminUser.list( "ou=users" );
+
         while ( list.hasMore() )
         {
             NameClassPair ncp = ( NameClassPair ) list.next();
+
             set.add( ncp.getName() );
         }
 

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java (original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java Thu
Apr 28 20:28:27 2005
@@ -54,6 +54,7 @@
     protected void setUp() throws Exception
     {
         super.setUp();
+
         doDelete( new File( "target" + File.separator + "eve" ) );
     }
 
@@ -83,16 +84,18 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
+
         Hashtable env = new Hashtable();
+
         env.put( Context.PROVIDER_URL, "ou=system" );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory"
);
+
         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( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.SECURITY_CREDENTIALS, "secret" );
 
         try { new InitialContext( env ); } catch( Exception e ) {}
     }
@@ -107,17 +110,19 @@
     public void testGetInitialContext() throws NamingException
     {
         Hashtable env = new Hashtable();
-        env.put( EnvKeys.WKDIR, "target/eve" );
+
+        env.put( EnvKeys.WKDIR, "target/server" );
+
         env.put( Context.PROVIDER_URL, "" );
+
         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( Context.SECURITY_CREDENTIALS, "secret" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
+
         assertNotNull( initCtx );
     }
 
@@ -131,23 +136,27 @@
     public void testGetInitialContextLookupAttributes() throws NamingException
     {
         Hashtable env = new Hashtable();
-        env.put( EnvKeys.WKDIR, "target/eve" );
+
+        env.put( EnvKeys.WKDIR, "target/server" );
+
         env.put( Context.PROVIDER_URL, "" );
+
         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( Context.SECURITY_CREDENTIALS, "secret" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
+
         assertNotNull( initCtx );
 
         DirContext ctx = ( DirContext ) initCtx.lookup( "" );
+
         Attributes attributes = ctx.getAttributes( "" );
 
         // Added some objectClass attributes to the rootDSE
+
         assertEquals( 1, attributes.size() );
     }
 
@@ -160,23 +169,29 @@
     public void testGetInitialContextLookupAttributesByName() throws NamingException
     {
         Hashtable env = new Hashtable();
-        env.put( EnvKeys.WKDIR, "target/eve" );
+
+        env.put( EnvKeys.WKDIR, "target/server" );
+
         env.put( Context.PROVIDER_URL, "" );
+
         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( Context.SECURITY_CREDENTIALS, "secret" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
+
         assertNotNull( initCtx );
 
         DirContext ctx = ( DirContext ) initCtx.lookup( "" );
+
         Attributes attributes = ctx.getAttributes( "", new String[]{ "namingContexts", "vendorName"
});
+
         assertEquals( 2, attributes.size() );
+
         assertEquals( "Apache Software Foundation", attributes.get( "vendorName" ).get()
);
+
         assertTrue( attributes.get( "namingContexts" ).contains( "ou=system" ) );
     }
 
@@ -189,17 +204,19 @@
     public void testDelete() throws NamingException
     {
         Hashtable env = new Hashtable();
-        env.put( EnvKeys.WKDIR, "target/eve" );
+
+        env.put( EnvKeys.WKDIR, "target/server" );
+
         env.put( Context.PROVIDER_URL, "" );
+
         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( Context.SECURITY_CREDENTIALS, "secret" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
+
         assertNotNull( initCtx );
 
         DirContext ctx = ( DirContext ) initCtx.lookup( "" );
@@ -209,6 +226,7 @@
         try
         {
             ctx.destroySubcontext( "" );
+
             fail( "we should never get here" );
         }
         catch ( LdapNoPermissionException e )
@@ -228,17 +246,19 @@
     public void testRename() throws NamingException
     {
         Hashtable env = new Hashtable();
-        env.put( EnvKeys.WKDIR, "target/eve" );
+
+        env.put( EnvKeys.WKDIR, "target/server" );
+
         env.put( Context.PROVIDER_URL, "" );
+
         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( Context.SECURITY_CREDENTIALS, "secret" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
+
         assertNotNull( initCtx );
 
         DirContext ctx = ( DirContext ) initCtx.lookup( "" );
@@ -248,6 +268,7 @@
         try
         {
             ctx.rename( "", "ou=system" );
+
             fail( "we should never get here" );
         }
         catch ( LdapNoPermissionException e )
@@ -267,17 +288,19 @@
     public void testModify() throws NamingException
     {
         Hashtable env = new Hashtable();
-        env.put( EnvKeys.WKDIR, "target/eve" );
+
+        env.put( EnvKeys.WKDIR, "target/server" );
+
         env.put( Context.PROVIDER_URL, "" );
+
         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( Context.SECURITY_CREDENTIALS, "secret" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
+
         assertNotNull( initCtx );
 
         DirContext ctx = ( DirContext ) initCtx.lookup( "" );
@@ -287,6 +310,7 @@
         try
         {
             ctx.modifyAttributes( "", 0, null );
+
             fail( "we should never get here" );
         }
         catch ( LdapNoPermissionException e )
@@ -298,8 +322,6 @@
     }
 
 
-
-
     /**
      * Checks for lack of permissions to modify this entry.
      *
@@ -308,17 +330,19 @@
     public void testModify2() throws NamingException
     {
         Hashtable env = new Hashtable();
-        env.put( EnvKeys.WKDIR, "target/eve" );
+
+        env.put( EnvKeys.WKDIR, "target/server" );
+
         env.put( Context.PROVIDER_URL, "" );
+
         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( Context.SECURITY_CREDENTIALS, "secret" );
 
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
+
         assertNotNull( initCtx );
 
         DirContext ctx = ( DirContext ) initCtx.lookup( "" );
@@ -328,6 +352,7 @@
         try
         {
             ctx.modifyAttributes( "", new ModificationItem[]{} );
+
             fail( "we should never get here" );
         }
         catch ( LdapNoPermissionException e )

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SearchContextTest.java
Thu Apr 28 20:28:27 2005
@@ -42,69 +42,111 @@
          * create ou=testing00,ou=system
          */
         Attributes attributes = new BasicAttributes();
+
         Attribute attribute = new BasicAttribute( "objectClass" );
+
         attribute.add( "top" );
+
         attribute.add( "organizationalUnit" );
+
         attributes.put( attribute );
+
         attributes.put( "ou", "testing00" );
+
         DirContext ctx = sysRoot.createSubcontext( "ou=testing00", attributes );
+
         assertNotNull( ctx );
 
         ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" );
+
         assertNotNull( ctx );
 
         attributes = ctx.getAttributes( "" );
+
         assertNotNull( attributes );
+
         assertEquals( "testing00", attributes.get( "ou" ).get() );
+
         attribute = attributes.get( "objectClass" );
+
         assertNotNull( attribute );
+
         assertTrue( attribute.contains( "top" ) );
+
         assertTrue( attribute.contains( "organizationalUnit" ) );
 
         /*
          * create ou=testing01,ou=system
          */
         attributes = new BasicAttributes();
+
         attribute = new BasicAttribute( "objectClass" );
+
         attribute.add( "top" );
+
         attribute.add( "organizationalUnit" );
+
         attributes.put( attribute );
+
         attributes.put( "ou", "testing01" );
+
         ctx = sysRoot.createSubcontext( "ou=testing01", attributes );
+
         assertNotNull( ctx );
 
         ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
+
         assertNotNull( ctx );
 
         attributes = ctx.getAttributes( "" );
+
         assertNotNull( attributes );
+
         assertEquals( "testing01", attributes.get( "ou" ).get() );
+
         attribute = attributes.get( "objectClass" );
+
         assertNotNull( attribute );
+
         assertTrue( attribute.contains( "top" ) );
+
         assertTrue( attribute.contains( "organizationalUnit" ) );
 
         /*
          * create ou=testing02,ou=system
          */
         attributes = new BasicAttributes();
+
         attribute = new BasicAttribute( "objectClass" );
+
         attribute.add( "top" );
+
         attribute.add( "organizationalUnit" );
+
         attributes.put( attribute );
+
         attributes.put( "ou", "testing02" );
+
         ctx = sysRoot.createSubcontext( "ou=testing02", attributes );
+
         assertNotNull( ctx );
 
         ctx = ( DirContext ) sysRoot.lookup( "ou=testing02" );
+
         assertNotNull( ctx );
 
         attributes = ctx.getAttributes( "" );
+
         assertNotNull( attributes );
+
         assertEquals( "testing02", attributes.get( "ou" ).get() );
+
         attribute = attributes.get( "objectClass" );
+
         assertNotNull( attribute );
+
         assertTrue( attribute.contains( "top" ) );
+
         assertTrue( attribute.contains( "organizationalUnit" ) );
 
         /*
@@ -113,23 +155,37 @@
         ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
 
         attributes = new BasicAttributes();
+
         attribute = new BasicAttribute( "objectClass" );
+
         attribute.add( "top" );
+
         attribute.add( "organizationalUnit" );
+
         attributes.put( attribute );
+
         attributes.put( "ou", "subtest" );
+
         ctx = ctx.createSubcontext( "ou=subtest", attributes );
+
         assertNotNull( ctx );
 
         ctx = ( DirContext ) sysRoot.lookup( "ou=subtest,ou=testing01" );
+
         assertNotNull( ctx );
 
         attributes = ctx.getAttributes( "" );
+
         assertNotNull( attributes );
+
         assertEquals( "subtest", attributes.get( "ou" ).get() );
+
         attribute = attributes.get( "objectClass" );
+
         assertNotNull( attribute );
+
         assertTrue( attribute.contains( "top" ) );
+
         assertTrue( attribute.contains( "organizationalUnit" ) );
     }
 
@@ -137,22 +193,30 @@
     public void testSearchOneLevel() throws NamingException
     {
         SearchControls controls = new SearchControls();
+
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+
         controls.setDerefLinkFlag( false );
-        sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP,
-                DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+
+        sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName()
);
 
         HashMap map = new HashMap();
+
         NamingEnumeration list = sysRoot.search( "", "(ou=*)", controls );
+
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
+
             map.put( result.getName(), result.getAttributes() );
         }
 
         assertEquals( "Expected number of results returned was incorrect!", 5, map.size()
);
+
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
+
         assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
+
         assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
     }
 
@@ -160,24 +224,34 @@
     public void testSearchSubTreeLevel() throws NamingException
     {
         SearchControls controls = new SearchControls();
+
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
         controls.setDerefLinkFlag( false );
-        sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP,
-                DerefAliasesEnum.NEVERDEREFALIASES.getName() );
+
+        sysRoot.addToEnvironment( DerefAliasesEnum.JNDI_PROP, DerefAliasesEnum.NEVERDEREFALIASES.getName()
);
 
         HashMap map = new HashMap();
+
         NamingEnumeration list = sysRoot.search( "", "(ou=*)", controls );
+
         while ( list.hasMore() )
         {
             SearchResult result = ( SearchResult ) list.next();
+
             map.put( result.getName(), result.getAttributes() );
         }
 
-        assertEquals( "Expected number of results returned was incorrect", 9, map.size()
);
+        assertEquals( "Expected number of results returned was incorrect", 8, map.size()
);
+
         assertTrue( map.containsKey( "ou=system" ) );
+
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
+
         assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
+
         assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
+
         assertTrue( map.containsKey( "ou=subtest,ou=testing01,ou=system" ) );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/operational/OperationalAttributeServiceTest.java
Thu Apr 28 20:28:27 2005
@@ -132,9 +132,8 @@
      */
     public void testConfirmNonAdminUserDnIsCreatorsName() throws NamingException
     {
-        Attributes attributes = sysRoot.getAttributes( "uid=akarasulu,ou=users",
-                new String[] { "creatorsName" } );
-        assertFalse( "uid=akarasulu,ou=users,ou=system"
-                .equals( attributes.get( "creatorsName" ).get() ) );
+        Attributes attributes = sysRoot.getAttributes( "uid=akarasulu,ou=users", new String[]
{ "creatorsName" } );
+        
+        assertFalse( "uid=akarasulu,ou=users,ou=system".equals( attributes.get( "creatorsName"
).get() ) );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerPreferencesFactoryTest.java
Thu Apr 28 20:28:27 2005
@@ -38,6 +38,6 @@
 
         assertNotNull( prefs );
 
-        assertEquals( "abc123", prefs.get( "test", "blah" ) );
+        assertEquals( "sysPrefRoot", prefs.get( "prefNodeName", "sysPrefRoot" ) );
     }
 }

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java?rev=165254&r1=165253&r2=165254&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java
Thu Apr 28 20:28:27 2005
@@ -38,13 +38,7 @@
     {
         ServerSystemPreferences prefs = new ServerSystemPreferences();
 
-        assertEquals( "abc123", prefs.get( "test", "not the value" ) );
-
-        String[] keys = prefs.keys();
-
-        assertEquals( 1, keys.length );
-
-        assertEquals( "test", keys[0] );
+        assertEquals( "sysPrefRoot", prefs.get( "prefNodeName", "not the value" ) );
     }
 
 



Mime
View raw message