directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1054629 - in /directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree: AbstractSubentryUnitTest.java SubentryAddOperationIT.java SubentryDeleteOperationIT.java SubentryLookupOperationIT.java
Date Mon, 03 Jan 2011 14:27:32 GMT
Author: elecharny
Date: Mon Jan  3 14:27:31 2011
New Revision: 1054629

URL: http://svn.apache.org/viewvc?rev=1054629&view=rev
Log:
o Factorized some helper method (createSubentry)
o Added some new Lookup tests

Modified:
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java?rev=1054629&r1=1054628&r2=1054629&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
Mon Jan  3 14:27:31 2011
@@ -113,6 +113,52 @@ public class AbstractSubentryUnitTest ex
         return Long.parseLong( attribute.getString() );
     }
     
+    
+    /**
+     * Gets the AccessControl UUIDref
+     */
+    protected String getACUuidRef( String apDn ) throws LdapException
+    {
+        Entry entry = adminConnection.lookup( apDn, "AccessControlSubentryUuid" );
+        
+        if ( entry == null )
+        {
+            return null;
+        }
+        
+        EntryAttribute attribute = entry.get( "AccessControlSubentryUuid");
+        
+        if ( attribute == null )
+        {
+            return null;
+        }
+        
+        return attribute.getString();
+    }
+
+
+    /**
+     * Gets the CollectiveAttribute UUID ref
+     */
+    protected String getCAUuidRef( String apDn ) throws LdapException
+    {
+        Entry entry = adminConnection.lookup( apDn, "CollectiveAttributeSubentryUuid" );
+        
+        if ( entry == null )
+        {
+            return null;
+        }
+        
+        EntryAttribute attribute = entry.get( "CollectiveAttributeSubentryUuid" );
+        
+        if ( attribute == null )
+        {
+            return null;
+        }
+        
+        return attribute.getString();
+    }
+    
 
     /**
      * Checks that an entry is absent from the DIT
@@ -196,14 +242,14 @@ public class AbstractSubentryUnitTest ex
     /**
      * Creates a CollectiveAttribute subentry
      */
-    protected void createCASubentry( String dn ) throws LdapException
+    protected void createCASubentry( String dn, String subtree ) throws LdapException
     {
         Entry subentry = LdifUtils.createEntry( 
             dn, 
             "ObjectClass: top",
             "ObjectClass: subentry", 
             "ObjectClass: collectiveAttributeSubentry",
-            "subtreeSpecification: {}", 
+            "subtreeSpecification", subtree,
             "c-o: Test Org" );
 
         AddResponse response = adminConnection.add( subentry );

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java?rev=1054629&r1=1054628&r2=1054629&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
Mon Jan  3 14:27:31 2011
@@ -262,17 +262,7 @@ public class SubentryAddOperationIT exte
         createAAP( "ou=AAP,ou=system" );
         
         // Add a subentry now
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=AAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: {}", 
-            "c-o: Test Org" );
-
-        AddResponse response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=AAP,ou=system", "{}" );
         
         Entry subentryEntry = adminConnection.lookup( "cn=test,ou=AAP,ou=system", "+", "*"
);
         assertNotNull( subentryEntry );
@@ -290,7 +280,7 @@ public class SubentryAddOperationIT exte
             "ou: BADAP", 
             "administrativeRole: autonomousArea" );
 
-        response = adminConnection.add( badAP );
+        AddResponse response = adminConnection.add( badAP );
         assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode()
);
     }
     
@@ -662,17 +652,7 @@ public class SubentryAddOperationIT exte
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         
         // Add a subentry now
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=SAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: {}", 
-            "c-o: Test Org" );
-
-        response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=SAP,ou=system", "{}" );
     }
     
     
@@ -768,6 +748,7 @@ public class SubentryAddOperationIT exte
             "sn: entry 1" );
         
         AddResponse response = adminConnection.add( e1 );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
         assertEquals( -1L, getCASeqNumber( "cn=e1,ou=SAP,ou=system" ) );
         
@@ -780,21 +761,12 @@ public class SubentryAddOperationIT exte
             "sn: entry 2" );
 
         response = adminConnection.add( e2 );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
         assertEquals( -1L, getCASeqNumber( "cn=e2,ou=SAP,ou=system" ) );
 
         // Add a subentry now
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=SAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: {}", 
-            "c-o: Test Org" );
-
-        response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=SAP,ou=system", "{}" );
         
         // Get back the CA SeqNumber
         long caSeqNumber = getCASeqNumber( "ou=SAP,ou=system" );
@@ -810,6 +782,7 @@ public class SubentryAddOperationIT exte
             "sn: entry 3" );
 
         response = adminConnection.add( e3 );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
         // The CASeqNumber for this entry must be the same than it's AP
         assertEquals( caSeqNumber, getCASeqNumber( "cn=e3,ou=SAP,ou=system" ) );
@@ -852,17 +825,7 @@ public class SubentryAddOperationIT exte
         assertEquals( -1L, getCASeqNumber( "cn=e2,ou=SAP,ou=system" ) );
 
         // Add a subentry now, selecting only entries with a person AT
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=SAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: { specificationFilter item:person }", 
-            "c-o: Test Org" );
-
-        response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=SAP,ou=system", "{ specificationFilter item:person
}" );
         
         // Get back the CA SeqNumber
         long caSeqNumber = getCASeqNumber( "ou=SAP,ou=system" );

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java?rev=1054629&r1=1054628&r2=1054629&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
Mon Jan  3 14:27:31 2011
@@ -69,17 +69,7 @@ public class SubentryDeleteOperationIT e
         createAAP( "ou=AAP,ou=system" );
 
         // Add a subentry now
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=AAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: {}", 
-            "c-o: Test Org" );
-
-        AddResponse response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=AAP,ou=system", "{}" );
         
         assertTrue( checkIsPresent( "cn=test,ou=AAP,ou=system" ) );
 
@@ -214,17 +204,7 @@ public class SubentryDeleteOperationIT e
         assertEquals( -1L, getCASeqNumber( "ou=AAP,ou=system" ) );
         
         // Add a subentry now
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=AAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: {}", 
-            "c-o: Test Org" );
-
-        AddResponse response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=AAP,ou=system", "{}" );
 
         long seqNumber = getCASeqNumber( "ou=AAP,ou=system" );
         assertEquals( -1L, getACSeqNumber( "ou=AAP,ou=system" ) );
@@ -250,17 +230,7 @@ public class SubentryDeleteOperationIT e
         assertEquals( -1L, getCASeqNumber( "ou=SAP,ou=system" ) );
         
         // Add a subentry now
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=SAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: {}", 
-            "c-o: Test Org" );
-
-        AddResponse response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=SAP,ou=system", "{}"); 
 
         long seqNumber = getCASeqNumber( "ou=SAP,ou=system" );
         assertEquals( Long.MIN_VALUE, getACSeqNumber( "ou=SAP,ou=system" ) );
@@ -299,17 +269,7 @@ public class SubentryDeleteOperationIT e
         assertEquals( -1L, getCASeqNumber( "ou=IAP,ou=SAP,ou=system" ) );
         
         // Add a subentry now
-        Entry subentry = LdifUtils.createEntry( 
-            "cn=test,ou=IAP,ou=SAP,ou=system", 
-            "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "cn: test",
-            "subtreeSpecification: {}", 
-            "c-o: Test Org" );
-
-        response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        createCASubentry( "cn=test,ou=IAP,ou=SAP,ou=system", "{}" );
 
         long seqNumberSAP = getCASeqNumber( "ou=SAP,ou=system" );
         assertEquals( -1L, seqNumberSAP );

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java?rev=1054629&r1=1054628&r2=1054629&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java
Mon Jan  3 14:27:31 2011
@@ -103,7 +103,7 @@ public class SubentryLookupOperationIT e
     public void testLookupSubentry() throws Exception
     {
         createAAP( "ou=AAP, ou=system" );
-        createCASubentry( "cn=test, ou=AAP, ou=system" );
+        createCASubentry( "cn=test, ou=AAP, ou=system", "{}" );
         
         Entry aap = adminConnection.lookup( "ou=AAP, ou=system", "+" );
         
@@ -135,7 +135,7 @@ public class SubentryLookupOperationIT e
     public void testLookupSubentryNotAdmin() throws Exception
     {
         createAAP( "ou=AAP, ou=system" );
-        createCASubentry( "cn=test, ou=AAP, ou=system" );
+        createCASubentry( "cn=test, ou=AAP, ou=system", "{}" );
         
         Entry aap = userConnection.lookup( "ou=AAP, ou=system", "+" );
         
@@ -206,17 +206,7 @@ public class SubentryLookupOperationIT e
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
         assertEquals( -1L, getCASeqNumber( "cn=e1,ou=AAP,ou=system" ) );
-    }
-
-
-    /**
-     * Test the lookup of a entry when an AP with no subentry has been added. All
-     * the entry SN must be set to -1, and not have any subentries reference
-     */
-    @Test
-    public void testLookupEntryAfterApAdditionNoSubentry() throws Exception
-    {
-        // TODO
+        assertNull( getCAUuidRef( "cn=e1,ou=AAP,ou=system" ) );
     }
 
 
@@ -228,7 +218,26 @@ public class SubentryLookupOperationIT e
     @Test
     public void testLookupEntryUnderApWithSubentrySelected() throws Exception
     {
-        // TODO
+        // Create a CA SAP and a subentry
+        createCaSAP( "ou=SAP,ou=System" );
+        createCASubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: person}"
);
+        
+        // Now, created a selected entry 
+        Entry e1 = LdifUtils.createEntry( 
+            "cn=e1,ou=SAP,ou=system", 
+            "ObjectClass: top",
+            "ObjectClass: person", 
+            "cn: e1", 
+            "sn: entry 1" );
+        
+        AddResponse response = adminConnection.add( e1 );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+
+        long seqNumber = getCASeqNumber( "ou=SAP,ou=System" );
+        
+        // Check that the added entry has its AP seqNumber and its subentry UUID 
+        assertEquals( seqNumber, getCASeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertEquals( getCAUuidRef( "cn=test,ou=SAP,ou=System" ), getCAUuidRef( "cn=e1,ou=AAP,ou=system"
) );
     }
 
 



Mime
View raw message