You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/07/18 01:39:00 UTC
svn commit: r965149 - in /directory/apacheds/trunk:
core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Author: elecharny
Date: Sat Jul 17 23:39:00 2010
New Revision: 965149
URL: http://svn.apache.org/viewvc?rev=965149&view=rev
Log:
o Fixed a bug in the getOperationalModsForAdd() method : the opAttr wasn't cloned thus it was shared upon many entries
o Added some check in the add test
Modified:
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java?rev=965149&r1=965148&r2=965149&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java Sat Jul 17 23:39:00 2010
@@ -42,6 +42,7 @@ import javax.naming.ldap.LdapContext;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.message.AddResponse;
+import org.apache.directory.ldap.client.api.message.DeleteResponse;
import org.apache.directory.ldap.client.api.message.ModifyRequest;
import org.apache.directory.ldap.client.api.message.SearchResponse;
import org.apache.directory.ldap.client.api.message.SearchResultEntry;
@@ -346,6 +347,14 @@ public class SubentryServiceIT extends A
* AP-A
* not-AP
* C
+ *
+ * Then add a subentry under AP-B
+ * The following entries must be modified :
+ * AP-B
+ * B1
+ * B2
+ *
+ * Then suppress the subentry under AP-B
*/
public void testSubentryAdd() throws Exception
{
@@ -372,7 +381,7 @@ public class SubentryServiceIT extends A
// --------------------------------------------------------------------
String subEntryAPADn = "2.5.4.3=testsubentrya,0.9.2342.19200300.100.1.25=ap-a,0.9.2342.19200300.100.1.25=test,2.5.4.11=system";
- String[] modifiedEntries = new String[]
+ String[] modifiedEntriesA = new String[]
{
"dc=AP-A,dc=test,ou=system",
"cn=A1,dc=AP-A,dc=test,ou=system",
@@ -385,7 +394,7 @@ public class SubentryServiceIT extends A
"cn=B2,dc=AP-B,cn=A2,dc=AP-A,dc=test,ou=system",
};
- for ( String dn : modifiedEntries )
+ for ( String dn : modifiedEntriesA )
{
checkHasOpAttr( results.get( dn ), "collectiveAttributeSubentries", 1, subEntryAPADn );
}
@@ -393,14 +402,14 @@ public class SubentryServiceIT extends A
// --------------------------------------------------------------------
// Make sure entries not selected by subentryA do not have the mark
// --------------------------------------------------------------------
- String[] unchangedEntries = new String[]
+ String[] unchangedEntriesA = new String[]
{
"dc=test,ou=system",
"dc=not-AP,dc=test,ou=system",
"cn=C,dc=not-AP,dc=test,ou=system",
};
- for ( String dn : unchangedEntries )
+ for ( String dn : unchangedEntriesA )
{
checkDoesNotHaveOpAttr( results.get( dn ), "collectiveAttributeSubentries" );
}
@@ -424,7 +433,7 @@ public class SubentryServiceIT extends A
// Make sure entries selected by the subentryA do have the mark for
// the subentry A
// --------------------------------------------------------------------
- modifiedEntries = new String[]
+ String[] modifiedEntriesAB = new String[]
{
"dc=AP-A,dc=test,ou=system",
"cn=A1,dc=AP-A,dc=test,ou=system",
@@ -434,7 +443,7 @@ public class SubentryServiceIT extends A
"cn=A2-1,cn=A2,dc=AP-A,dc=test,ou=system",
};
- for ( String dn : modifiedEntries )
+ for ( String dn : modifiedEntriesAB )
{
checkHasOpAttr( results.get( dn ), "collectiveAttributeSubentries", 1, subEntryAPADn );
}
@@ -445,14 +454,14 @@ public class SubentryServiceIT extends A
// --------------------------------------------------------------------
String subEntryAPBDn = "2.5.4.3=testsubentryb,0.9.2342.19200300.100.1.25=ap-b,2.5.4.3=a2,0.9.2342.19200300.100.1.25=ap-a,0.9.2342.19200300.100.1.25=test,2.5.4.11=system";
- modifiedEntries = new String[]
+ String[] modifiedEntriesB = new String[]
{
"dc=AP-B,cn=A2,dc=AP-A,dc=test,ou=system",
"cn=B1,dc=AP-B,cn=A2,dc=AP-A,dc=test,ou=system",
"cn=B2,dc=AP-B,cn=A2,dc=AP-A,dc=test,ou=system",
};
- for ( String dn : modifiedEntries )
+ for ( String dn : modifiedEntriesB )
{
checkHasOpAttr( results.get( dn ), "collectiveAttributeSubentries", 2, subEntryAPADn, subEntryAPBDn );
}
@@ -460,14 +469,33 @@ public class SubentryServiceIT extends A
// --------------------------------------------------------------------
// Make sure entries not selected by subentryA do not have the mark
// --------------------------------------------------------------------
- unchangedEntries = new String[]
+ String[] unchangedEntriesB = new String[]
{
"dc=test,ou=system",
"dc=not-AP,dc=test,ou=system",
"cn=C,dc=not-AP,dc=test,ou=system",
};
- for ( String dn : unchangedEntries )
+ for ( String dn : unchangedEntriesB )
+ {
+ checkDoesNotHaveOpAttr( results.get( dn ), "collectiveAttributeSubentries" );
+ }
+
+ // Now delete the AP-B subentry
+ DeleteResponse deleteResponse = connection.delete( "cn=testsubentryB,dc=AP-B,cn=A2,dc=AP-A,dc=test,ou=system" );
+
+ // --------------------------------------------------------------------
+ // Check that we are back to where we were before the addition of the B
+ // subentry
+ // --------------------------------------------------------------------
+ results = getAllEntries( connection, "dc=test,ou=system" );
+
+ for ( String dn : modifiedEntriesA )
+ {
+ checkHasOpAttr( results.get( dn ), "collectiveAttributeSubentries", 1, subEntryAPADn );
+ }
+
+ for ( String dn : unchangedEntriesA )
{
checkDoesNotHaveOpAttr( results.get( dn ), "collectiveAttributeSubentries" );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=965149&r1=965148&r2=965149&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Sat Jul 17 23:39:00 2010
@@ -743,12 +743,14 @@ public class SubentryInterceptor extends
if ( ( opAttrInEntry != null ) && ( opAttrInEntry.size() > 0 ) )
{
+ EntryAttribute newOperationalAttribute = operationalAttribute.clone();
+
for ( Value<?> value : opAttrInEntry )
{
- operationalAttribute.add( value );
+ newOperationalAttribute.add( value );
}
- modifications.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, operationalAttribute ) );
+ modifications.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOperationalAttribute ) );
}
else
{