You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/12/04 22:09:43 UTC

svn commit: r601086 - in /directory/apacheds/branches/bigbang: core-integ/src/test/java/org/apache/directory/server/core/ core-integ/src/test/java/org/apache/directory/server/core/jndi/ core-unit/src/test/java/org/apache/directory/server/core/jndi/

Author: akarasulu
Date: Tue Dec  4 13:09:43 2007
New Revision: 601086

URL: http://svn.apache.org/viewvc?rev=601086&view=rev
Log:
converted two more tests to the new framework

Added:
    directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java
      - copied, changed from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java
    directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java
      - copied, changed from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java
Removed:
    directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java
    directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java
Modified:
    directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java
    directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java

Modified: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java?rev=601086&r1=601085&r2=601086&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java (original)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java Tue Dec  4 13:09:43 2007
@@ -53,7 +53,9 @@
         DIRSERVER783IT.class,
         DIRSERVER791IT.class,
         ListIT.class,
+        ObjStateFactoryIT.class,
         ExtensibleObjectIT.class,
+        ModifyContextIT.class,
         PartitionConfigurationIT.class  // Leaves the server in a bad state (partition removal is incomplete)
         } )
 @Scope ( ServiceScope.TESTSUITE )

Copied: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java (from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java?p2=directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java&p1=directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java&r1=600818&r2=601086&rev=601086&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java (original)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java Tue Dec  4 13:09:43 2007
@@ -20,14 +20,20 @@
 package org.apache.directory.server.core.jndi;
 
 
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
-
-import org.apache.directory.server.core.unit.AbstractAdminTestCase;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import javax.naming.ldap.LdapContext;
 
 
 /**
@@ -37,120 +43,126 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ModifyContextITest extends AbstractAdminTestCase
+@RunWith ( CiRunner.class )
+public class ModifyContextIT
 {
-    protected void setUp() throws Exception
+    public static DirectoryService service;
+
+
+    /**
+     * @todo put this into an ldif annotation
+     *
+     * @throws NamingException on error
+     */
+    protected void createData() throws NamingException
     {
-        super.setUp();
+        LdapContext sysRoot = getSystemContext( service );
 
-        try
-        {
-            /*
-             * create ou=testing00,ou=system
-             */
-            Attributes attributes = new AttributesImpl( true );
-            Attribute attribute = new AttributeImpl( "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 AttributesImpl( true );
-            attribute = new AttributeImpl( "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 AttributesImpl( true );
-            attribute = new AttributeImpl( "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" ) );
-
-            /*
-             * create ou=subtest,ou=testing01,ou=system
-             */
-            ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
-
-            attributes = new AttributesImpl( true );
-            attribute = new AttributeImpl( "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" ) );
-        }
-        catch ( NamingException e )
-        {
-        }
+        /*
+         * create ou=testing00,ou=system
+         */
+        Attributes attributes = new AttributesImpl( true );
+        Attribute attribute = new AttributeImpl( "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 AttributesImpl( true );
+        attribute = new AttributeImpl( "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 AttributesImpl( true );
+        attribute = new AttributeImpl( "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" ) );
+
+        /*
+         * create ou=subtest,ou=testing01,ou=system
+         */
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" );
+
+        attributes = new AttributesImpl( true );
+        attribute = new AttributeImpl( "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" ) );
     }
 
 
+    @Test
     public void testModifyOperation() throws NamingException
     {
+        createData();
+
+        LdapContext sysRoot = getSystemContext( service );
         Attributes attributes = new AttributesImpl( true );
         attributes.put( "ou", "testCases" );
         sysRoot.modifyAttributes( "ou=testing00", DirContext.ADD_ATTRIBUTE, attributes );
-        attributes = null;
 
         DirContext ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" );
         attributes = ctx.getAttributes( "" );

Copied: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java (from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java?p2=directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java&p1=directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java&r1=600818&r2=601086&rev=601086&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java (original)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java Tue Dec  4 13:09:43 2007
@@ -20,7 +20,18 @@
 package org.apache.directory.server.core.jndi;
 
 
-import java.util.Hashtable;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getUserAddLdif;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getRootContext;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.util.ArrayUtils;
+import org.apache.directory.shared.ldap.ldif.Entry;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import javax.naming.Context;
 import javax.naming.Name;
@@ -28,13 +39,10 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.SchemaViolationException;
+import javax.naming.ldap.LdapContext;
 import javax.naming.spi.DirObjectFactory;
 import javax.naming.spi.DirStateFactory;
-
-import org.apache.directory.server.core.unit.AbstractAdminTestCase;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.util.ArrayUtils;
+import java.util.Hashtable;
 
 
 /**
@@ -43,13 +51,22 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ObjStateFactoryITest extends AbstractAdminTestCase
+@RunWith ( CiRunner.class )
+public class ObjStateFactoryIT
 {
+    public static DirectoryService service;
+
+
+    @Test
     public void testObjectFactory() throws NamingException
     {
-        super.sysRoot.addToEnvironment( Context.OBJECT_FACTORIES, PersonObjectFactory.class.getName() );
-        Object obj = super.sysRoot.lookup( "uid=akarasulu, ou=users" );
-        Attributes attrs = super.sysRoot.getAttributes( "uid=akarasulu, ou=users" );
+        Entry akarasulu = getUserAddLdif();
+        getRootContext( service ).createSubcontext( akarasulu.getDn(), akarasulu.getAttributes() );
+
+        LdapContext sysRoot = getSystemContext( service );
+        sysRoot.addToEnvironment( Context.OBJECT_FACTORIES, PersonObjectFactory.class.getName() );
+        Object obj = sysRoot.lookup( "uid=akarasulu, ou=users" );
+        Attributes attrs = sysRoot.getAttributes( "uid=akarasulu, ou=users" );
         assertEquals( Person.class, obj.getClass() );
         Person me = ( Person ) obj;
         assertEquals( attrs.get( "sn" ).get(), me.getLastname() );
@@ -61,12 +78,15 @@
     }
 
 
+    @Test
     public void testStateFactory() throws NamingException
     {
-        super.sysRoot.addToEnvironment( Context.STATE_FACTORIES, PersonStateFactory.class.getName() );
+        LdapContext sysRoot = getSystemContext( service );
+
+        sysRoot.addToEnvironment( Context.STATE_FACTORIES, PersonStateFactory.class.getName() );
         Person p = new Person( "Rodriguez", "Mr. Kerberos", "noices", "555-1212", "sn=erodriguez", "committer" );
-        super.sysRoot.bind( "uid=erodriguez, ou=users", p );
-        Attributes attrs = super.sysRoot.getAttributes( "uid=erodriguez, ou=users" );
+        sysRoot.bind( "uid=erodriguez, ou=users", p );
+        Attributes attrs = sysRoot.getAttributes( "uid=erodriguez, ou=users" );
         assertEquals( "Rodriguez", attrs.get( "sn" ).get() );
         assertEquals( "Mr. Kerberos", attrs.get( "cn" ).get() );
         assertTrue( ArrayUtils.isEquals( attrs.get( "userPassword" ).get(), "noices".getBytes() ) );
@@ -75,6 +95,7 @@
         assertEquals( "committer", attrs.get( "description" ).get() );
     }
 
+    
     public static class PersonStateFactory implements DirStateFactory
     {
         public Result getStateToBind( Object obj, Name name, Context nameCtx, Hashtable environment, Attributes inAttrs )
@@ -155,6 +176,7 @@
             throw new UnsupportedOperationException( "Please use directory support overload with Attributes argument." );
         }
     }
+
 
     public static class PersonObjectFactory implements DirObjectFactory
     {

Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java?rev=601086&r1=601085&r2=601086&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java Tue Dec  4 13:09:43 2007
@@ -80,20 +80,17 @@
         super.setUp();
     }
 
-
+    
     public void testSearch() throws NamingException
     {
         SearchControls sc = new SearchControls();
         sc.setSearchScope( SearchControls.SUBTREE_SCOPE );
 
         NamingEnumeration ne = sysRoot.search( "", "(objectClass=*)", sc );
-
         assertTrue( "Search should return at least one entry.", ne.hasMore() );
 
         SearchResult sr = ( SearchResult ) ne.next();
-
         assertEquals( "The entry returned should be the root entry.", suffix, sr.getName() );
-
         assertFalse( "Search should return no more entries.", ne.hasMore() );
     }
 
@@ -116,13 +113,10 @@
         sc.setSearchScope( SearchControls.OBJECT_SCOPE );
 
         NamingEnumeration ne = sysRoot.search( dn, "(objectClass=*)", sc );
-
         assertTrue( "Search should return at least one entry.", ne.hasMore() );
 
         SearchResult sr = ( SearchResult ) ne.next();
-
         assertEquals( "The entry returned should be the entry added earlier.", dn + "," + suffix, sr.getName() );
-
         assertFalse( "Search should return no more entries.", ne.hasMore() );
     }
 
@@ -152,18 +146,15 @@
         sc.setSearchScope( SearchControls.OBJECT_SCOPE );
 
         NamingEnumeration ne = sysRoot.search( dn, "(objectClass=*)", sc );
-
         assertTrue( "Search should return at least one entry.", ne.hasMore() );
 
         SearchResult sr = ( SearchResult ) ne.next();
-
         assertEquals( "The entry returned should be the entry added earlier.", dn + "," + suffix, sr.getName() );
 
         attributes = sr.getAttributes();
         attribute = attributes.get( "description" );
 
         assertEquals( "The description attribute should contain the new value.", description, attribute.get() );
-
         assertFalse( "Search should return no more entries.", ne.hasMore() );
     }
 
@@ -190,14 +181,11 @@
         try
         {
             sysRoot.search( dn, "(objectClass=*)", sc );
-
             fail( "Search should throw exception." );
-
         }
         catch ( LdapNameNotFoundException e )
         {
             // ignore
         }
     }
-
 }