directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1421978 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/ interceptors/operational/src/main/java/org/apache/directory/server/core/operational/ ldap-client-test/src/test/java/org/ap...
Date Fri, 14 Dec 2012 17:03:42 GMT
Author: elecharny
Date: Fri Dec 14 17:03:38 2012
New Revision: 1421978

URL: http://svn.apache.org/viewvc?rev=1421978&view=rev
Log:
o Injected the 'EntryDN' virtual attribute in entries
o Fixed many tests accordingly

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java
    directory/apacheds/trunk/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java
Fri Dec 14 17:03:38 2012
@@ -103,10 +103,10 @@ public class LookupIT extends AbstractLd
         Entry entry = connection.lookup( "cn=test,ou=system", "+" );
         assertNotNull( entry );
         
-        // We should have 4 attributes
-        assertEquals( 5, entry.size() );
+        // We should have 6 attributes
+        assertEquals( 6, entry.size() );
 
-        // Check that all the user attributes are abstent
+        // Check that all the user attributes are absent
         assertNull( entry.get( "cn" ) );
         assertNull( entry.get( "sn" ) );
         assertNull( entry.get( "objectClass" ) );
@@ -118,12 +118,15 @@ public class LookupIT extends AbstractLd
         */
 
         // Check that we have all the operational attributes :
-        // We should have 4 operational attributes : createTime, createUser, entryCSN and
entryUUID
+        // We should have 6 operational attributes : createTime, createUser, entryCSN, entryDn,
entryParentId and entryUUID
         assertNotNull( entry.get( "createTimestamp" ).getString() );
+        assertNotNull( entry.get( "creatorsName" ) );
         assertEquals( "uid=admin,ou=system", entry.get( "creatorsName" ).getString() );
         assertNotNull( entry.get( "entryCSN" ).getString() );
         assertNotNull( entry.get( "entryUUID" ).getString() );
         assertNotNull( entry.get( "entryParentId" ).getString() );
+        assertNotNull( entry.get( "entryDn" ));
+        assertEquals( "cn=test,ou=system", entry.get( "entryDn" ).getString() );
     }
 
 

Modified: directory/apacheds/trunk/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
(original)
+++ directory/apacheds/trunk/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
Fri Dec 14 17:03:38 2012
@@ -108,7 +108,8 @@ public class OperationalAttributeInterce
             {
                 return true;
             }
-
+            
+            // Denormalize the operational Attributes
             denormalizeEntryOpAttrs( entry );
             
             return true;

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
Fri Dec 14 17:03:38 2012
@@ -110,7 +110,7 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( entry );
 
-        assertEquals( 8, entry.size() );
+        assertEquals( 9, entry.size() );
         assertTrue( entry.containsAttribute( "objectClass" ) );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "sn" ) );
@@ -118,6 +118,7 @@ public class SearchRequestReturningAttri
         assertTrue( entry.containsAttribute( "createTimestamp" ) );
         assertTrue( entry.containsAttribute( "entryUUID" ) );
         assertTrue( entry.containsAttribute( "entryCSN" ) );
+        assertTrue( entry.containsAttribute( "entryDN" ) );
     }
 
 
@@ -176,11 +177,12 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( entry );
 
-        assertEquals( 5, entry.size() );
+        assertEquals( 6, entry.size() );
         assertTrue( entry.containsAttribute( "creatorsName" ) );
         assertTrue( entry.containsAttribute( "createTimestamp" ) );
         assertTrue( entry.containsAttribute( "entryUUID" ) );
         assertTrue( entry.containsAttribute( "entryCSN" ) );
+        assertTrue( entry.containsAttribute( "entryDN" ) );
         assertTrue( entry.containsAttribute( "entryParentId" ) );
     }
 
@@ -243,13 +245,14 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( entry );
 
-        assertEquals( 7, entry.size() );
+        assertEquals( 8, entry.size() );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "sn" ) );
         assertTrue( entry.containsAttribute( "creatorsName" ) );
         assertTrue( entry.containsAttribute( "createTimestamp" ) );
         assertTrue( entry.containsAttribute( "entryUUID" ) );
         assertTrue( entry.containsAttribute( "entryCSN" ) );
+        assertTrue( entry.containsAttribute( "entryDN" ) );
         assertTrue( entry.containsAttribute( "entryParentId" ) );
     }
 
@@ -462,7 +465,7 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( entry );
 
-        assertEquals( 8, entry.size() );
+        assertEquals( 9, entry.size() );
         assertTrue( entry.containsAttribute( "objectClass" ) );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "sn" ) );
@@ -470,6 +473,7 @@ public class SearchRequestReturningAttri
         assertTrue( entry.containsAttribute( "createTimestamp" ) );
         assertTrue( entry.containsAttribute( "entryUUID" ) );
         assertTrue( entry.containsAttribute( "entryCSN" ) );
+        assertTrue( entry.containsAttribute( "entryDN" ) );
         assertTrue( entry.containsAttribute( "entryParentId" ) );
     }
 

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
Fri Dec 14 17:03:38 2012
@@ -258,6 +258,7 @@ public class LdifPartition extends Abstr
     public void add( AddOperationContext addContext ) throws LdapException
     {
         super.add( addContext );
+        
         addEntry( addContext.getEntry() );
     }
 
@@ -313,6 +314,9 @@ public class LdifPartition extends Abstr
         Entry modifiedEntry = fetch( id, modifyContext.getDn() );
         modifyContext.setAlteredEntry( modifiedEntry );
 
+        // Remove the EntryDN
+        modifiedEntry.removeAttributes( ENTRY_DN_AT );
+
         // just overwrite the existing file
         Dn dn = modifyContext.getDn();
 
@@ -762,6 +766,9 @@ public class LdifPartition extends Abstr
      */
     private void addEntry( Entry entry ) throws LdapException
     {
+        // Remove the EntryDN
+        entry.removeAttributes( ENTRY_DN_AT );
+
         try
         {
             FileWriter fw = new FileWriter( getFile( entry.getDn(), CREATE ) );

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
Fri Dec 14 17:03:38 2012
@@ -215,6 +215,10 @@ public class SingleFileLdifPartition ext
                 Entry modifiedEntry = super.modify( modifyContext.getDn(),
                     modifyContext.getModItems().toArray( new Modification[]
                         {} ) );
+                
+                // Remove the EntryDN
+                modifiedEntry.removeAttributes( ENTRY_DN_AT );
+
                 modifyContext.setAlteredEntry( modifiedEntry );
             }
             catch ( Exception e )
@@ -352,6 +356,9 @@ public class SingleFileLdifPartition ext
             IndexEntry<ParentIdAndRdn, String> element = cursor.get();
             String childId = element.getId();
             Entry entry = fetch( childId );
+            
+            // Remove the EntryDn
+            entry.removeAttributes( SchemaConstants.ENTRY_DN_AT );
 
             appendLdif( entry );
 

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
Fri Dec 14 17:03:38 2012
@@ -183,8 +183,13 @@ public class SingleFileLdifPartitionTest
 
     private long getEntryLdifLen( Entry entry ) throws LdapException
     {
+        // Remove the entryDn attribute
+        Entry copy = entry.clone();
+        copy.removeAttributes( "entryDn" );
+        
         // while writing to the file 1 extra newline char will be added
-        String ldif = LdifUtils.convertToLdif( entry ) + 1;
+        
+        String ldif = LdifUtils.convertToLdif( copy ) + "\n";
         byte[] data = Strings.getBytesUtf8( ldif );
 
         return data.length;
@@ -242,6 +247,19 @@ public class SingleFileLdifPartitionTest
         Entry fetched = partition.lookup( opCtx );
 
         assertNotNull( fetched );
+        
+        // Check the EntryDn attribute
+        Attribute entryDn = fetched.get( "entryDn" );
+        
+        assertNotNull( entryDn );
+        assertEquals( entryDn.getString(), entry.getDn().getName() );
+        
+        if ( !entry.contains( entryDn ) )
+        {
+            // Removed the entryDn attribute to be able to compare the entries
+            fetched.removeAttributes( "entryDn" );
+        }
+        
         assertEquals( entry, fetched );
     }
 
@@ -444,6 +462,9 @@ public class SingleFileLdifPartitionTest
         String ldif = Strings.utf8ToString( entry1Data );
 
         LdifEntry ldifEntry = reader.parseLdif( ldif ).get( 0 );
+        
+        // Remove the EntryDN
+        entry1.removeAttributes( "entryDn" );
 
         assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
 
@@ -478,6 +499,9 @@ public class SingleFileLdifPartitionTest
 
         ldifEntry = reader.parseLdif( ldif ).get( 0 );
 
+        // Remove the EntryDN
+        entry1.removeAttributes( "entryDn" );
+
         assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
 
         partition = reloadPartition();

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
Fri Dec 14 17:03:38 2012
@@ -1193,7 +1193,7 @@ public class SearchIT extends AbstractLd
     
         // ensure that all operational attributes are returned
         // and no user attributes
-        assertEquals( 5, attrs.size() );
+        assertEquals( 6, attrs.size() );
         assertNull( attrs.get( "cn" ) );
         assertNull( attrs.get( "sn" ) );
         assertNull( attrs.get( "objectClass" ) );
@@ -1203,6 +1203,7 @@ public class SearchIT extends AbstractLd
         assertNotNull( attrs.get( "creatorsname" ) );
         assertNotNull( attrs.get( "entryuuid" ) );
         assertNotNull( attrs.get( "entrycsn" ) );
+        assertNotNull( attrs.get( "entryDn" ) );
     }
     
     
@@ -1228,7 +1229,7 @@ public class SearchIT extends AbstractLd
         Attributes attrs = result.getAttributes();
     
         // ensure that all user attributes are returned
-        assertEquals( 11, attrs.size() );
+        assertEquals( 12, attrs.size() );
         assertNotNull( attrs.get( "cn" ) );
         assertNotNull( attrs.get( "sn" ) );
         assertNotNull( attrs.get( "objectClass" ) );
@@ -1239,6 +1240,7 @@ public class SearchIT extends AbstractLd
         assertNotNull( attrs.get( "creatorsname" ) );
         assertNotNull( attrs.get( "entryuuid" ) );
         assertNotNull( attrs.get( "entrycsn" ) );
+        assertNotNull( attrs.get( "entryDn" ) );
     }
     
     

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1421978&r1=1421977&r2=1421978&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Fri Dec 14 17:03:38 2012
@@ -159,6 +159,7 @@ public abstract class AbstractBTreeParti
     /** Cached attributes types to avoid lookup all over the code */
     protected AttributeType OBJECT_CLASS_AT;
     protected AttributeType ENTRY_CSN_AT;
+    protected AttributeType ENTRY_DN_AT;
     protected AttributeType ENTRY_UUID_AT;
     protected AttributeType ALIASED_OBJECT_NAME_AT;
 
@@ -189,6 +190,7 @@ public abstract class AbstractBTreeParti
         OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT
);
         ALIASED_OBJECT_NAME_AT = schemaManager.getAttributeType( SchemaConstants.ALIASED_OBJECT_NAME_AT
);
         ENTRY_CSN_AT = schemaManager.getAttributeType( SchemaConstants.ENTRY_CSN_AT );
+        ENTRY_DN_AT = schemaManager.getAttributeType( SchemaConstants.ENTRY_DN_AT );
         ENTRY_UUID_AT = schemaManager.getAttributeType( SchemaConstants.ENTRY_UUID_AT );
     }
 
@@ -583,6 +585,10 @@ public abstract class AbstractBTreeParti
         try
         {
             Entry entry = ( ( ClonedServerEntry ) addContext.getEntry() ).getClonedEntry();
+            
+            // Remove the EntryDN
+            entry.removeAttributes( ENTRY_DN_AT );
+            
             Dn entryDn = entry.getDn();
 
             // check if the entry already exists
@@ -1056,8 +1062,10 @@ public abstract class AbstractBTreeParti
         {
             Entry entry = lookupCache( id );
             
-            if( entry != null )
+            if ( entry != null )
             {
+                entry.add( ENTRY_DN_AT, dn.getName() );
+                
                 return new ClonedServerEntry( entry );
             }
             
@@ -1079,6 +1087,8 @@ public abstract class AbstractBTreeParti
                     entry.setDn( dn );
                 }
 
+                entry.add( ENTRY_DN_AT, dn.getName() );
+
                 addToCache( id, entry );
                 
                 return new ClonedServerEntry( entry );
@@ -1106,6 +1116,10 @@ public abstract class AbstractBTreeParti
             Entry modifiedEntry = modify( modifyContext.getDn(),
                 modifyContext.getModItems().toArray( new Modification[]
                     {} ) );
+            
+            // Remove the EntryDN
+            modifiedEntry.removeAttributes( ENTRY_DN_AT );
+
             modifyContext.setAlteredEntry( modifiedEntry );
             
             updateCache( modifyContext );



Mime
View raw message