directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1054700 - /directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/
Date Mon, 03 Jan 2011 18:30:37 GMT
Author: elecharny
Date: Mon Jan  3 18:30:36 2011
New Revision: 1054700

URL: http://svn.apache.org/viewvc?rev=1054700&view=rev
Log:
o Added the first tests for the AP search operation
o Added some helper metods in the AbstractSubentry class

Added:
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentrySearchOperationIT.java
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=1054700&r1=1054699&r2=1054700&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 18:30:36 2011
@@ -79,54 +79,40 @@ public class AbstractSubentryUnitTest ex
     
     
     /**
-     * Gets the AccessControl seqNumber of a given AP
+     * Checks that an entry is absent from the DIT
      */
-    protected long getACSeqNumber( String apDn ) throws LdapException
+    protected boolean checkIsAbsent( String dn ) throws LdapException
     {
-        Entry entry = adminConnection.lookup( apDn, "AccessControlSeqNumber" );
-        
-        EntryAttribute attribute = entry.get( ApacheSchemaConstants.ACCESS_CONTROL_SEQ_NUMBER_AT
);
-        
-        if ( attribute == null )
-        {
-            return Long.MIN_VALUE;
-        }
+        Entry entry = adminConnection.lookup( dn );
         
-        return Long.parseLong( attribute.getString() );
+        return entry == null;
     }
 
-
+    
     /**
-     * Gets the CollectiveAttribute seqNumber of a given AP
+     * Checks that an entry is present in the DIT
      */
-    protected long getCASeqNumber( String apDn ) throws LdapException
+    protected boolean checkIsPresent( String dn ) throws LdapException
     {
-        Entry entry = adminConnection.lookup( apDn, "CollectiveAttributeSeqNumber" );
-        
-        EntryAttribute attribute = entry.get( ApacheSchemaConstants.COLLECTIVE_ATTRIBUTE_SEQ_NUMBER_AT
);
-        
-        if ( attribute == null )
-        {
-            return Long.MIN_VALUE;
-        }
+        Entry entry = adminConnection.lookup( dn );
         
-        return Long.parseLong( attribute.getString() );
+        return entry != null;
     }
     
     
     /**
-     * Gets the AccessControl UUIDref
+     * Gets the UUIDref
      */
-    protected String getACUuidRef( String apDn ) throws LdapException
+    private String getUuidRef( String apDn, String attributeType ) throws LdapException
     {
-        Entry entry = adminConnection.lookup( apDn, "AccessControlSubentryUuid" );
+        Entry entry = adminConnection.lookup( apDn, attributeType );
         
         if ( entry == null )
         {
             return null;
         }
         
-        EntryAttribute attribute = entry.get( "AccessControlSubentryUuid");
+        EntryAttribute attribute = entry.get( attributeType);
         
         if ( attribute == null )
         {
@@ -136,123 +122,290 @@ public class AbstractSubentryUnitTest ex
         return attribute.getString();
     }
 
+    
+    
+    /**
+     * Creates an AAP 
+     */
+    protected void createAAP( String dn ) throws LdapException
+    {
+        Entry autonomousArea = LdifUtils.createEntry( 
+            dn, 
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit", 
+            "administrativeRole: autonomousArea"
+            );
 
+        // It should succeed
+        AddResponse response = adminConnection.add( autonomousArea );
+
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+    }
+    
+    
+    // ---- AC methods -------------------------------------------------------------------
+    
     /**
-     * Gets the CollectiveAttribute UUID ref
+     * Creates an AC SAP 
      */
-    protected String getCAUuidRef( String apDn ) throws LdapException
+    protected void createAcSAP( String dn ) throws LdapException
     {
-        Entry entry = adminConnection.lookup( apDn, "CollectiveAttributeSubentryUuid" );
-        
-        if ( entry == null )
-        {
-            return null;
-        }
+        Entry sap = LdifUtils.createEntry( 
+            dn, 
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit", 
+            "administrativeRole: accessControlSpecificArea"
+            );
+
+        // It should succeed
+        AddResponse response = adminConnection.add( sap );
+
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+    }
+    
+    
+    /**
+     * Creates an AC IAP 
+     */
+    protected void createAcIAP( String dn ) throws LdapException
+    {
+        Entry iap = LdifUtils.createEntry( 
+            dn, 
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit", 
+            "administrativeRole: accessControlInnerArea"
+            );
+
+        // It should succeed
+        AddResponse response = adminConnection.add( iap );
+
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+    }
+    
+    
+    /**
+     * Gets the AccessControl seqNumber of a given AP
+     */
+    protected long getAcSeqNumber( String apDn ) throws LdapException
+    {
+        Entry entry = adminConnection.lookup( apDn, "AccessControlSeqNumber" );
         
-        EntryAttribute attribute = entry.get( "CollectiveAttributeSubentryUuid" );
+        EntryAttribute attribute = entry.get( ApacheSchemaConstants.ACCESS_CONTROL_SEQ_NUMBER_AT
);
         
         if ( attribute == null )
         {
-            return null;
+            return Long.MIN_VALUE;
         }
         
-        return attribute.getString();
+        return Long.parseLong( attribute.getString() );
     }
-    
+
 
     /**
-     * Checks that an entry is absent from the DIT
+     * Gets the AccessControl UUIDref
      */
-    protected boolean checkIsAbsent( String dn ) throws LdapException
+    protected String getAcUuidRef( String apDn ) throws LdapException
     {
-        Entry entry = adminConnection.lookup( dn );
-        
-        return entry == null;
+        return getUuidRef( apDn, "AccessControlSubentryUuid" );
     }
 
-    
+
+    // ---- CA methods -------------------------------------------------------------------
+
     /**
-     * Checks that an entry is present in the DIT
+     * Creates a CA SAP 
      */
-    protected boolean checkIsPresent( String dn ) throws LdapException
+    protected void createCaSAP( String dn ) throws LdapException
     {
-        Entry entry = adminConnection.lookup( dn );
-        
-        return entry != null;
+        Entry sap = LdifUtils.createEntry( 
+            dn, 
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit", 
+            "administrativeRole: collectiveAttributeSpecificArea"
+            );
+
+        // It should succeed
+        AddResponse response = adminConnection.add( sap );
+
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
     }
     
     
     /**
-     * Creates an AAP 
+     * Creates a CA IAP 
      */
-    protected void createAAP( String dn ) throws LdapException
+    protected void createCaIAP( String dn ) throws LdapException
     {
-        Entry autonomousArea = LdifUtils.createEntry( 
+        Entry iap = LdifUtils.createEntry( 
             dn, 
             "ObjectClass: top",
             "ObjectClass: organizationalUnit", 
-            "administrativeRole: autonomousArea"
+            "administrativeRole: collectiveAttributeInnerArea"
             );
 
         // It should succeed
-        AddResponse response = adminConnection.add( autonomousArea );
+        AddResponse response = adminConnection.add( iap );
 
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
     }
     
     
     /**
-     * Creates a CA SAP 
+     * Gets the CollectiveAttribute seqNumber of a given AP
      */
-    protected void createCaSAP( String dn ) throws LdapException
+    protected long getCaSeqNumber( String apDn ) throws LdapException
     {
-        Entry autonomousArea = LdifUtils.createEntry( 
+        Entry entry = adminConnection.lookup( apDn, "CollectiveAttributeSeqNumber" );
+        
+        EntryAttribute attribute = entry.get( ApacheSchemaConstants.COLLECTIVE_ATTRIBUTE_SEQ_NUMBER_AT
);
+        
+        if ( attribute == null )
+        {
+            return Long.MIN_VALUE;
+        }
+        
+        return Long.parseLong( attribute.getString() );
+    }
+    
+    
+    /**
+     * Gets the CollectiveAttribute UUID ref
+     */
+    protected String getCaUuidRef( String apDn ) throws LdapException
+    {
+        return getUuidRef( apDn, "CollectiveAttributeSubentryUuid" );
+    }
+    
+
+    /**
+     * Creates a CollectiveAttribute subentry
+     */
+    protected void createCaSubentry( String dn, String subtree ) throws LdapException
+    {
+        Entry subentry = LdifUtils.createEntry( 
+            dn, 
+            "ObjectClass: top",
+            "ObjectClass: subentry", 
+            "ObjectClass: collectiveAttributeSubentry",
+            "subtreeSpecification", subtree,
+            "c-o: Test Org" );
+
+        AddResponse response = adminConnection.add( subentry );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+    }
+
+    
+    // ---- SS methods -------------------------------------------------------------------
+
+    /**
+     * Creates a SS SAP 
+     */
+    protected void createSsSAP( String dn ) throws LdapException
+    {
+        Entry sap = LdifUtils.createEntry( 
             dn, 
             "ObjectClass: top",
             "ObjectClass: organizationalUnit", 
-            "administrativeRole: collectiveAttributeSpecificArea"
+            "administrativeRole: subschemaSpecificArea"
             );
 
         // It should succeed
-        AddResponse response = adminConnection.add( autonomousArea );
+        AddResponse response = adminConnection.add( sap );
 
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
     }
     
     
     /**
-     * Creates an AC SAP 
+     * Gets the SubSchema UUID ref
      */
-    protected void createAcSAP( String dn ) throws LdapException
+    protected String getSsUuidRef( String apDn ) throws LdapException
     {
-        Entry autonomousArea = LdifUtils.createEntry( 
+        return getUuidRef( apDn, "SubSchemaSubentryUuid" );
+    }
+
+    
+    /**
+     * Gets the SubSchema seqNumber of a given AP
+     */
+    protected long getSsSeqNumber( String apDn ) throws LdapException
+    {
+        Entry entry = adminConnection.lookup( apDn, "SubSchemaSeqNumber" );
+        
+        EntryAttribute attribute = entry.get( ApacheSchemaConstants.SUB_SCHEMA_SEQ_NUMBER_AT
);
+        
+        if ( attribute == null )
+        {
+            return Long.MIN_VALUE;
+        }
+        
+        return Long.parseLong( attribute.getString() );
+    }
+    
+    
+    // ---- TE methods -------------------------------------------------------------------
+
+    /**
+     * Creates a TE SAP 
+     */
+    protected void createTeSAP( String dn ) throws LdapException
+    {
+        Entry sap = LdifUtils.createEntry( 
             dn, 
             "ObjectClass: top",
             "ObjectClass: organizationalUnit", 
-            "administrativeRole: accessControlSpecificArea"
+            "administrativeRole: TriggerExecutionSpecificArea"
             );
 
         // It should succeed
-        AddResponse response = adminConnection.add( autonomousArea );
+        AddResponse response = adminConnection.add( sap );
 
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
     }
     
     
     /**
-     * Creates a CollectiveAttribute subentry
+     * Creates a TE IAP 
      */
-    protected void createCASubentry( String dn, String subtree ) throws LdapException
+    protected void createTeIAP( String dn ) throws LdapException
     {
-        Entry subentry = LdifUtils.createEntry( 
+        Entry iap = LdifUtils.createEntry( 
             dn, 
             "ObjectClass: top",
-            "ObjectClass: subentry", 
-            "ObjectClass: collectiveAttributeSubentry",
-            "subtreeSpecification", subtree,
-            "c-o: Test Org" );
+            "ObjectClass: organizationalUnit", 
+            "administrativeRole: TriggerExecutionInnerArea"
+            );
+
+        // It should succeed
+        AddResponse response = adminConnection.add( iap );
 
-        AddResponse response = adminConnection.add( subentry );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
     }
+    
+    
+    /**
+     * Gets the TriggerExecution UUID ref
+     */
+    protected String getTeUuidRef( String apDn ) throws LdapException
+    {
+        return getUuidRef( apDn, "TriggerExecutionSubentryUuid" );
+    }
+
+    
+    /**
+     * Gets the TriggerExecution seqNumber of a given AP
+     */
+    protected long getTeSeqNumber( String apDn ) throws LdapException
+    {
+        Entry entry = adminConnection.lookup( apDn, "TriggerExecutionSeqNumber" );
+        
+        EntryAttribute attribute = entry.get( ApacheSchemaConstants.TRIGGER_EXECUTION_SEQ_NUMBER_AT
);
+        
+        if ( attribute == null )
+        {
+            return Long.MIN_VALUE;
+        }
+        
+        return Long.parseLong( attribute.getString() );
+    }
 }

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=1054700&r1=1054699&r2=1054700&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 18:30:36 2011
@@ -262,7 +262,7 @@ public class SubentryAddOperationIT exte
         createAAP( "ou=AAP,ou=system" );
         
         // Add a subentry now
-        createCASubentry( "cn=test,ou=AAP,ou=system", "{}" );
+        createCaSubentry( "cn=test,ou=AAP,ou=system", "{}" );
         
         Entry subentryEntry = adminConnection.lookup( "cn=test,ou=AAP,ou=system", "+", "*"
);
         assertNotNull( subentryEntry );
@@ -652,7 +652,7 @@ public class SubentryAddOperationIT exte
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         
         // Add a subentry now
-        createCASubentry( "cn=test,ou=SAP,ou=system", "{}" );
+        createCaSubentry( "cn=test,ou=SAP,ou=system", "{}" );
     }
     
     
@@ -737,7 +737,7 @@ public class SubentryAddOperationIT exte
     {
         // First add an SAP
         createCaSAP( "ou=SAP,ou=system" );
-        assertEquals( -1L, getCASeqNumber( "ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "ou=SAP,ou=system" ) );
         
         // Create a first entry
         Entry e1 = LdifUtils.createEntry( 
@@ -750,7 +750,7 @@ public class SubentryAddOperationIT exte
         AddResponse response = adminConnection.add( e1 );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
-        assertEquals( -1L, getCASeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
         
         // Create a second entry
         Entry e2 = LdifUtils.createEntry( 
@@ -763,13 +763,13 @@ public class SubentryAddOperationIT exte
         response = adminConnection.add( e2 );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
-        assertEquals( -1L, getCASeqNumber( "cn=e2,ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "cn=e2,ou=SAP,ou=system" ) );
 
         // Add a subentry now
-        createCASubentry( "cn=test,ou=SAP,ou=system", "{}" );
+        createCaSubentry( "cn=test,ou=SAP,ou=system", "{}" );
         
         // Get back the CA SeqNumber
-        long caSeqNumber = getCASeqNumber( "ou=SAP,ou=system" );
+        long caSeqNumber = getCaSeqNumber( "ou=SAP,ou=system" );
         
         assertTrue( caSeqNumber > -1L );
         
@@ -785,11 +785,11 @@ public class SubentryAddOperationIT exte
         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" ) );
+        assertEquals( caSeqNumber, getCaSeqNumber( "cn=e3,ou=SAP,ou=system" ) );
 
         // Now, check that when we read the other entries, their CA seqNumber is also updated
-        assertEquals( caSeqNumber, getCASeqNumber( "cn=e1,ou=SAP,ou=system" ) );
-        assertEquals( caSeqNumber, getCASeqNumber( "cn=e2,ou=SAP,ou=system" ) );
+        assertEquals( caSeqNumber, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertEquals( caSeqNumber, getCaSeqNumber( "cn=e2,ou=SAP,ou=system" ) );
     }
     
     
@@ -811,7 +811,7 @@ public class SubentryAddOperationIT exte
             "ou: e1" );
         
         AddResponse response = adminConnection.add( e1 );
-        assertEquals( -1L, getCASeqNumber( "ou=e1,ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "ou=e1,ou=SAP,ou=system" ) );
         
         // Create a second entry
         Entry e2 = LdifUtils.createEntry( 
@@ -822,13 +822,13 @@ public class SubentryAddOperationIT exte
             "sn: entry 2" );
 
         response = adminConnection.add( e2 );
-        assertEquals( -1L, getCASeqNumber( "cn=e2,ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "cn=e2,ou=SAP,ou=system" ) );
 
         // Add a subentry now, selecting only entries with a person AT
-        createCASubentry( "cn=test,ou=SAP,ou=system", "{ specificationFilter item:person
}" );
+        createCaSubentry( "cn=test,ou=SAP,ou=system", "{ specificationFilter item:person
}" );
         
         // Get back the CA SeqNumber
-        long caSeqNumber = getCASeqNumber( "ou=SAP,ou=system" );
+        long caSeqNumber = getCaSeqNumber( "ou=SAP,ou=system" );
         
         assertTrue( caSeqNumber > -1L );
         

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=1054700&r1=1054699&r2=1054700&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 18:30:36 2011
@@ -69,7 +69,7 @@ public class SubentryDeleteOperationIT e
         createAAP( "ou=AAP,ou=system" );
 
         // Add a subentry now
-        createCASubentry( "cn=test,ou=AAP,ou=system", "{}" );
+        createCaSubentry( "cn=test,ou=AAP,ou=system", "{}" );
         
         assertTrue( checkIsPresent( "cn=test,ou=AAP,ou=system" ) );
 
@@ -200,21 +200,21 @@ public class SubentryDeleteOperationIT e
         // First add an AAP
         createAAP( "ou=AAP,ou=system" );
         
-        assertEquals( -1L, getACSeqNumber( "ou=AAP,ou=system" ) );
-        assertEquals( -1L, getCASeqNumber( "ou=AAP,ou=system" ) );
+        assertEquals( -1L, getAcSeqNumber( "ou=AAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "ou=AAP,ou=system" ) );
         
         // Add a subentry now
-        createCASubentry( "cn=test,ou=AAP,ou=system", "{}" );
+        createCaSubentry( "cn=test,ou=AAP,ou=system", "{}" );
 
-        long seqNumber = getCASeqNumber( "ou=AAP,ou=system" );
-        assertEquals( -1L, getACSeqNumber( "ou=AAP,ou=system" ) );
+        long seqNumber = getCaSeqNumber( "ou=AAP,ou=system" );
+        assertEquals( -1L, getAcSeqNumber( "ou=AAP,ou=system" ) );
         
         // Now delete it
         DeleteResponse delResponse = adminConnection.delete( "cn=test,ou=AAP,ou=system" );
         assertEquals( ResultCodeEnum.SUCCESS, delResponse.getLdapResult().getResultCode()
);
         
         // Check the CASeqNumber, it must be 1 now
-        assertEquals( seqNumber + 1, getCASeqNumber( "ou=AAP,ou=system" ) );
+        assertEquals( seqNumber + 1, getCaSeqNumber( "ou=AAP,ou=system" ) );
     }
     
     
@@ -226,21 +226,21 @@ public class SubentryDeleteOperationIT e
     {
         createCaSAP( "ou=SAP,ou=system" );
         
-        assertEquals( Long.MIN_VALUE, getACSeqNumber( "ou=SAP,ou=system" ) );
-        assertEquals( -1L, getCASeqNumber( "ou=SAP,ou=system" ) );
+        assertEquals( Long.MIN_VALUE, getAcSeqNumber( "ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "ou=SAP,ou=system" ) );
         
         // Add a subentry now
-        createCASubentry( "cn=test,ou=SAP,ou=system", "{}"); 
+        createCaSubentry( "cn=test,ou=SAP,ou=system", "{}"); 
 
-        long seqNumber = getCASeqNumber( "ou=SAP,ou=system" );
-        assertEquals( Long.MIN_VALUE, getACSeqNumber( "ou=SAP,ou=system" ) );
+        long seqNumber = getCaSeqNumber( "ou=SAP,ou=system" );
+        assertEquals( Long.MIN_VALUE, getAcSeqNumber( "ou=SAP,ou=system" ) );
         
         // Now delete it
         DeleteResponse delResponse = adminConnection.delete( "cn=test,ou=SAP,ou=system" );
         assertEquals( ResultCodeEnum.SUCCESS, delResponse.getLdapResult().getResultCode()
);
         
         // Check the CASeqNumber, it must be 1 now
-        assertEquals( seqNumber + 1, getCASeqNumber( "ou=SAP,ou=system" ) );
+        assertEquals( seqNumber + 1, getCaSeqNumber( "ou=SAP,ou=system" ) );
     }
     
     
@@ -265,16 +265,16 @@ public class SubentryDeleteOperationIT e
 
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         
-        assertEquals( -1L, getCASeqNumber( "ou=SAP,ou=system" ) );
-        assertEquals( -1L, getCASeqNumber( "ou=IAP,ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "ou=IAP,ou=SAP,ou=system" ) );
         
         // Add a subentry now
-        createCASubentry( "cn=test,ou=IAP,ou=SAP,ou=system", "{}" );
+        createCaSubentry( "cn=test,ou=IAP,ou=SAP,ou=system", "{}" );
 
-        long seqNumberSAP = getCASeqNumber( "ou=SAP,ou=system" );
+        long seqNumberSAP = getCaSeqNumber( "ou=SAP,ou=system" );
         assertEquals( -1L, seqNumberSAP );
         
-        long seqNumberIAP = getCASeqNumber( "ou=IAP,ou=SAP,ou=system" );
+        long seqNumberIAP = getCaSeqNumber( "ou=IAP,ou=SAP,ou=system" );
         assertTrue( seqNumberIAP > -1L );
 
         // Now delete it
@@ -282,8 +282,8 @@ public class SubentryDeleteOperationIT e
         assertEquals( ResultCodeEnum.SUCCESS, delResponse.getLdapResult().getResultCode()
);
         
         // Check the CASeqNumbers, it must be 1 now
-        assertEquals( -1L, getCASeqNumber( "ou=SAP,ou=system" ) );
-        assertEquals( seqNumberIAP + 1, getCASeqNumber( "ou=IAP,ou=SAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "ou=SAP,ou=system" ) );
+        assertEquals( seqNumberIAP + 1, getCaSeqNumber( "ou=IAP,ou=SAP,ou=system" ) );
         
         assertTrue( checkIsAbsent( "cn=test,ou=IAP,ou=SAP,ou=system" ) );
     }

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=1054700&r1=1054699&r2=1054700&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 18:30:36 2011
@@ -105,7 +105,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", "+" );
         
@@ -137,7 +137,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", "+" );
         
@@ -182,7 +182,7 @@ public class SubentryLookupOperationIT e
         AddResponse response = adminConnection.add( e1 );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
-        assertEquals( Long.MIN_VALUE, getCASeqNumber( "cn=e1,ou=system" ) );
+        assertEquals( Long.MIN_VALUE, getCaSeqNumber( "cn=e1,ou=system" ) );
     }
 
 
@@ -207,8 +207,8 @@ public class SubentryLookupOperationIT e
         AddResponse response = adminConnection.add( e1 );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
-        assertEquals( -1L, getCASeqNumber( "cn=e1,ou=AAP,ou=system" ) );
-        assertNull( getCAUuidRef( "cn=e1,ou=AAP,ou=system" ) );
+        assertEquals( -1L, getCaSeqNumber( "cn=e1,ou=AAP,ou=system" ) );
+        assertNull( getCaUuidRef( "cn=e1,ou=AAP,ou=system" ) );
     }
 
 
@@ -222,7 +222,7 @@ public class SubentryLookupOperationIT e
     {
         // Create a CA SAP and a subentry
         createCaSAP( "ou=SAP,ou=System" );
-        createCASubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: person}"
);
+        createCaSubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: person}"
);
         
         // Now, created a selected entry 
         Entry e1 = LdifUtils.createEntry( 
@@ -235,11 +235,11 @@ public class SubentryLookupOperationIT e
         AddResponse response = adminConnection.add( e1 );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
-        long seqNumber = getCASeqNumber( "ou=SAP,ou=System" );
+        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"
) );
+        assertEquals( seqNumber, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertEquals( getCaUuidRef( "cn=test,ou=SAP,ou=System" ), getCaUuidRef( "cn=e1,ou=AAP,ou=system"
) );
     }
 
 
@@ -253,7 +253,7 @@ public class SubentryLookupOperationIT e
     {
         // Create a CA SAP and a subentry
         createCaSAP( "ou=SAP,ou=System" );
-        createCASubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: organization}"
);
+        createCaSubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: organization}"
);
         
         // Now, created a selected entry 
         Entry e1 = LdifUtils.createEntry( 
@@ -266,11 +266,11 @@ public class SubentryLookupOperationIT e
         AddResponse response = adminConnection.add( e1 );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
 
-        long seqNumber = getCASeqNumber( "ou=SAP,ou=System" );
+        long seqNumber = getCaSeqNumber( "ou=SAP,ou=System" );
         
         // Check that the added entry has its AP seqNumber and no ref to the subentry 
-        assertEquals( seqNumber, getCASeqNumber( "cn=e1,ou=SAP,ou=system" ) );
-        assertNull( getCAUuidRef( "cn=e1,ou=AAP,ou=system" ) );
+        assertEquals( seqNumber, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertNull( getCaUuidRef( "cn=e1,ou=AAP,ou=system" ) );
     }
 
 
@@ -284,7 +284,7 @@ public class SubentryLookupOperationIT e
     {
         // Create a CA SAP and a subentry
         createCaSAP( "ou=SAP,ou=System" );
-        createCASubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: person}"
);
+        createCaSubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: person}"
);
         
         // Now, created a selected entry 
         Entry e1 = LdifUtils.createEntry( 
@@ -297,23 +297,23 @@ public class SubentryLookupOperationIT e
         AddResponse addResponse = adminConnection.add( e1 );
         assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode()
);
 
-        long seqNumber1 = getCASeqNumber( "ou=SAP,ou=System" );
+        long seqNumber1 = getCaSeqNumber( "ou=SAP,ou=System" );
         
         // Check that the added entry has its AP seqNumber and its subentry UUID 
-        assertEquals( seqNumber1, getCASeqNumber( "cn=e1,ou=SAP,ou=system" ) );
-        assertEquals( getCAUuidRef( "cn=test,ou=SAP,ou=System" ), getCAUuidRef( "cn=e1,ou=AAP,ou=system"
) );
+        assertEquals( seqNumber1, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertEquals( getCaUuidRef( "cn=test,ou=SAP,ou=System" ), getCaUuidRef( "cn=e1,ou=AAP,ou=system"
) );
         
         // Now, remove the subentry
         DeleteResponse delResponse = adminConnection.delete( "cn=test,ou=SAP,ou=System" );
         assertEquals( ResultCodeEnum.SUCCESS, delResponse.getLdapResult().getResultCode()
);
 
         // The AP seqNumber must have been incremented
-        long seqNumber2 = getCASeqNumber( "ou=SAP,ou=System" );
+        long seqNumber2 = getCaSeqNumber( "ou=SAP,ou=System" );
         
         assertTrue( seqNumber1 < seqNumber2 );
 
         // Now, check the entry 
-        assertEquals( seqNumber2, getCASeqNumber( "cn=e1,ou=SAP,ou=system" ) );
-        assertNull( getCAUuidRef( "cn=e1,ou=AAP,ou=system" ) );
+        assertEquals( seqNumber2, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertNull( getCaUuidRef( "cn=e1,ou=AAP,ou=system" ) );
     }
 }

Added: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentrySearchOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentrySearchOperationIT.java?rev=1054700&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentrySearchOperationIT.java
(added)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentrySearchOperationIT.java
Mon Jan  3 18:30:36 2011
@@ -0,0 +1,396 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.server.core.subtree;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.cursor.SearchCursor;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.message.AddResponse;
+import org.apache.directory.shared.ldap.message.DeleteResponse;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test cases for the AdministrativePoint interceptor Search operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(FrameworkRunner.class)
+@CreateDS(name = "AdministrativePointServiceIT")
+@ApplyLdifs(
+    {
+        // An entry used to create a User session
+        "dn: cn=testUser,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: testUser",
+        "sn: test User",
+        "userpassword: test"
+    })
+public class SubentrySearchOperationIT extends AbstractSubentryUnitTest
+{
+    // ===================================================================
+    // Test the Search operation on APs
+    // -------------------------------------------------------------------
+    /**
+     * Test the Search of an AP. All APs are searcheable by default.
+     */
+    @Test
+    public void testSearchAP() throws Exception
+    {
+        createAAP( "ou=AAP, ou=system" );
+        
+        SearchCursor results = adminConnection.search( "ou=system", "(administrativeRole=*)",
SearchScope.SUBTREE, "+" );
+        
+        assertNotNull( results );
+        int nbEntry = 0;
+        
+        while ( results.next() )
+        {
+            Entry entry = ( ( SearchResultEntry ) results.get() ).getEntry();
+            assertEquals ( "-1", entry.get( "AccessControlSeqNumber" ).getString() );
+            assertEquals ( "-1", entry.get( "CollectiveAttributeSeqNumber" ).getString()
);
+            assertEquals ( "-1", entry.get( "SubSchemaSeqNumber" ).getString() );
+            assertEquals ( "-1", entry.get( "TriggerExecutionSeqNumber" ).getString() );
+            
+            nbEntry++;
+        }
+        
+        assertEquals( 1, nbEntry );
+        results.close();
+    }
+
+    
+    /**
+     * Test the search of an AP. All APs are searcheable by default. We should get the
+     * AP even if we use a non admin user.
+     */
+    @Test
+    public void testSearchAPNotAdmin() throws Exception
+    {
+        createAAP( "ou=AAP, ou=system" );
+        
+        SearchCursor results = adminConnection.search( "ou=system", "(administrativeRole=*)",
SearchScope.SUBTREE, "+" );
+        
+        assertNotNull( results );
+        int nbEntry = 0;
+        
+        while ( results.next() )
+        {
+            Entry entry = ( ( SearchResultEntry ) results.get() ).getEntry();
+            assertEquals ( "-1", entry.get( "AccessControlSeqNumber" ).getString() );
+            assertEquals ( "-1", entry.get( "CollectiveAttributeSeqNumber" ).getString()
);
+            assertEquals ( "-1", entry.get( "SubSchemaSeqNumber" ).getString() );
+            assertEquals ( "-1", entry.get( "TriggerExecutionSeqNumber" ).getString() );
+            
+            nbEntry++;
+        }
+        
+        assertEquals( 1, nbEntry );
+        results.close();
+    }
+    
+    
+    /**
+     * Test the Search of many APs. All APs are searcheable by default.
+     */
+    @Test
+    public void testSearchAPs() throws Exception
+    {
+        createAAP( "ou=AAP, ou=system" );
+        createCaIAP( "ou=IAP, ou=AAP, ou=system" );
+        createCaSAP( "ou=SAP, ou=system" );
+        
+        SearchCursor results = adminConnection.search( "ou=system", "(administrativeRole=*)",
SearchScope.SUBTREE, "+" );
+        
+        assertNotNull( results );
+        int nbEntry = 0;
+        
+        while ( results.next() )
+        {
+            Entry entry = ( ( SearchResultEntry ) results.get() ).getEntry();
+            
+            if ( entry.getDn().equals( "ou=AAP, ou=system" ) )
+            { 
+                assertEquals( "-1", entry.get( "AccessControlSeqNumber" ).getString() );
+                assertEquals( "-1", entry.get( "CollectiveAttributeSeqNumber" ).getString()
);
+                assertEquals( "-1", entry.get( "SubSchemaSeqNumber" ).getString() );
+                assertEquals( "-1", entry.get( "TriggerExecutionSeqNumber" ).getString()
);
+            }
+            else if ( entry.getDn().equals( "ou=IAP, ou=AAP, ou=system" ) )
+            {
+                assertNull( entry.get( "AccessControlSeqNumber" ) );
+                assertEquals( "-1", entry.get( "CollectiveAttributeSeqNumber" ).getString()
);
+                assertNull( entry.get( "SubSchemaSeqNumber" ) );
+                assertNull( entry.get( "TriggerExecutionSeqNumber" ) );
+            }
+            else if ( entry.getDn().equals( "ou=SAP, ou=system" ) )
+            {
+                assertNull( entry.get( "AccessControlSeqNumber" ) );
+                assertEquals( "-1", entry.get( "CollectiveAttributeSeqNumber" ).getString()
);
+                assertNull( entry.get( "SubSchemaSeqNumber" ) );
+                assertNull( entry.get( "TriggerExecutionSeqNumber" ) );
+            }
+            
+            nbEntry++;
+        }
+        
+        assertEquals( 3, nbEntry );
+        results.close();
+    }
+
+    
+
+    
+    // ===================================================================
+    // Test the Lookup operation on Subentries
+    // -------------------------------------------------------------------
+    /**
+     * Test the lookup of a subentry. Subentries can be read directly as it's 
+     * a OBJECT search.
+     */
+    @Test
+    public void testLookupSubentry() throws Exception
+    {
+        createAAP( "ou=AAP, ou=system" );
+        createCaSubentry( "cn=test, ou=AAP, ou=system", "{}" );
+        
+        Entry aap = adminConnection.lookup( "ou=AAP, ou=system", "+" );
+        
+        assertNotNull( aap );
+        long acSN = Long.parseLong( aap.get( "AccessControlSeqNumber" ).getString() );
+        long caSN = Long.parseLong( aap.get( "CollectiveAttributeSeqNumber" ).getString()
);
+        long ssSN = Long.parseLong( aap.get( "SubSchemaSeqNumber" ).getString() );
+        long teSN = Long.parseLong( aap.get( "TriggerExecutionSeqNumber" ).getString() );
+        
+        assertEquals( -1L, acSN );
+        assertNotSame( -1L, caSN );
+        assertEquals( -1L, ssSN );
+        assertEquals( -1L, teSN );
+        
+        Entry subentry = adminConnection.lookup( "cn=test, ou=AAP, ou=system", "+" );
+        assertNotNull( subentry );
+        assertNull( subentry.get( "AccessControlSeqNumber" ) );
+        assertNull( subentry.get( "CollectiveAttributeSeqNumber" ) );
+        assertNull( subentry.get( "SubSchemaSeqNumber" ) );
+        assertNull( subentry.get( "TriggerExecutionSeqNumber" ) );
+    }
+
+
+    /**
+     * Test the lookup of a subentry. Subentries can be read directly as it's 
+     * a OBJECT search. We don't use the admin in this test
+     */
+    @Test
+    public void testLookupSubentryNotAdmin() throws Exception
+    {
+        createAAP( "ou=AAP, ou=system" );
+        createCaSubentry( "cn=test, ou=AAP, ou=system", "{}" );
+        
+        Entry aap = userConnection.lookup( "ou=AAP, ou=system", "+" );
+        
+        assertNotNull( aap );
+        long acSN = Long.parseLong( aap.get( "AccessControlSeqNumber" ).getString() );
+        long caSN = Long.parseLong( aap.get( "CollectiveAttributeSeqNumber" ).getString()
);
+        long ssSN = Long.parseLong( aap.get( "SubSchemaSeqNumber" ).getString() );
+        long teSN = Long.parseLong( aap.get( "TriggerExecutionSeqNumber" ).getString() );
+        
+        assertEquals( -1L, acSN );
+        assertEquals( service.getApSeqNumber(), caSN );
+        assertEquals( -1L, ssSN );
+        assertEquals( -1L, teSN );
+        
+        Entry subentry = userConnection.lookup( "cn=test, ou=AAP, ou=system", "+" );
+        assertNotNull( subentry );
+        assertNull( subentry.get( "AccessControlSeqNumber" ) );
+        assertNull( subentry.get( "CollectiveAttributeSeqNumber" ) );
+        assertNull( subentry.get( "SubSchemaSeqNumber" ) );
+        assertNull( subentry.get( "TriggerExecutionSeqNumber" ) );
+    }
+    
+    
+    // ===================================================================
+    // Test the Lookup operation on Entries
+    // -------------------------------------------------------------------
+    /**
+     * Test the lookup of a entry with no APs. The entry should not have
+     * any SN
+     */
+    @Test
+    public void testLookupEntryNoAp() throws Exception
+    {
+        // Create a first entry
+        Entry e1 = LdifUtils.createEntry( 
+            "cn=e1,ou=system", 
+            "ObjectClass: top",
+            "ObjectClass: person", 
+            "cn: e1", 
+            "sn: entry 1" );
+        
+        AddResponse response = adminConnection.add( e1 );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+
+        assertEquals( Long.MIN_VALUE, getCaSeqNumber( "cn=e1,ou=system" ) );
+    }
+
+
+    /**
+     * Test the lookup of a entry added under an AP with no subentry. All
+     * the entry SN must be set to -1, and not have any subentries reference
+     */
+    @Test
+    public void testLookupEntryUnderApNoSubentry() throws Exception
+    {
+        // Create an AP
+        createAAP( "ou=AAP,ou=system" );
+        
+        // Create a first entry
+        Entry e1 = LdifUtils.createEntry( 
+            "cn=e1,ou=AAP,ou=system", 
+            "ObjectClass: top",
+            "ObjectClass: person", 
+            "cn: e1", 
+            "sn: entry 1" );
+        
+        AddResponse response = adminConnection.add( e1 );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+
+        assertEquals( -1L, getCaSeqNumber( "cn=e1,ou=AAP,ou=system" ) );
+        assertNull( getCaUuidRef( "cn=e1,ou=AAP,ou=system" ) );
+    }
+
+
+    /**
+     * Test the lookup of a entry added under an AP with a subentry. 
+     * The entry is part of the subtreeSpecification.
+     * All the entry SN must be set to the AP SN, and have any subentries reference
+     */
+    @Test
+    public void testLookupEntryUnderApWithSubentrySelected() throws Exception
+    {
+        // 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"
) );
+    }
+
+
+    /**
+     * Test the lookup of a entry when an AP with a subentry is added. 
+     * The entry is not part of the subtreeSpecification.
+     * All the entry SN must be set to the AP SN, and have no subentries reference
+     */
+    @Test
+    public void testLookupEntryAfterApAdditionWithSubentrySelected() throws Exception
+    {
+        // Create a CA SAP and a subentry
+        createCaSAP( "ou=SAP,ou=System" );
+        createCaSubentry( "cn=test,ou=SAP,ou=System", "{specificationFilter item: organization}"
);
+        
+        // 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 no ref to the subentry 
+        assertEquals( seqNumber, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertNull( getCaUuidRef( "cn=e1,ou=AAP,ou=system" ) );
+    }
+
+
+    /**
+     * Test the lookup of a entry when the subentry it referes has been 
+     * removed. The entry's reference to the subentry must be removed, the 
+     * SN must be the new AP SN
+     */
+    @Test
+    public void testLookupEntryAfterSubentryDeletion() throws Exception
+    {
+        // 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 addResponse = adminConnection.add( e1 );
+        assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode()
);
+
+        long seqNumber1 = getCaSeqNumber( "ou=SAP,ou=System" );
+        
+        // Check that the added entry has its AP seqNumber and its subentry UUID 
+        assertEquals( seqNumber1, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertEquals( getCaUuidRef( "cn=test,ou=SAP,ou=System" ), getCaUuidRef( "cn=e1,ou=AAP,ou=system"
) );
+        
+        // Now, remove the subentry
+        DeleteResponse delResponse = adminConnection.delete( "cn=test,ou=SAP,ou=System" );
+        assertEquals( ResultCodeEnum.SUCCESS, delResponse.getLdapResult().getResultCode()
);
+
+        // The AP seqNumber must have been incremented
+        long seqNumber2 = getCaSeqNumber( "ou=SAP,ou=System" );
+        
+        assertTrue( seqNumber1 < seqNumber2 );
+
+        // Now, check the entry 
+        assertEquals( seqNumber2, getCaSeqNumber( "cn=e1,ou=SAP,ou=system" ) );
+        assertNull( getCaUuidRef( "cn=e1,ou=AAP,ou=system" ) );
+    }
+}



Mime
View raw message