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 2006/07/30 17:11:07 UTC
svn commit: r426891 -
/directory/branches/apacheds/optimization/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java
Author: elecharny
Date: Sun Jul 30 08:11:07 2006
New Revision: 426891
URL: http://svn.apache.org/viewvc?rev=426891&view=rev
Log:
Added two test cases (one of them has been commented, as the
fix is not implemented) to cherck JIRA DIRSERVER_636 and 687
Modified:
directory/branches/apacheds/optimization/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java
Modified: directory/branches/apacheds/optimization/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java?rev=426891&r1=426890&r2=426891&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java (original)
+++ directory/branches/apacheds/optimization/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java Sun Jul 30 08:11:07 2006
@@ -19,15 +19,19 @@
import java.util.Hashtable;
+import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.AttributeInUseException;
+import javax.naming.directory.AttributeModificationException;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InvalidAttributeIdentifierException;
import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
@@ -407,4 +411,101 @@
fail( "Cannot reach this point" );
}
+
+
+ /**
+ * Create a person entry and perform a modify op, in which
+ * we modify an attribute two times.
+ */
+ public void testAttributeValueMultiMofificationDIRSERVER_636() throws NamingException {
+
+ // Create a person entry
+ Attributes attrs = getPersonAttributes("Bush", "Kate Bush");
+ String rdn = "cn=Kate Bush";
+ ctx.createSubcontext(rdn, attrs);
+
+ // Add a decsription with two values
+ String[] descriptions = {
+ "Kate Bush is a British singer-songwriter.",
+ "She has become one of the most influential female artists of the twentieth century." };
+ Attribute desc1 = new BasicAttribute("description");
+ desc1.add(descriptions[0]);
+ desc1.add(descriptions[1]);
+
+ ModificationItem addModOp = new ModificationItem(
+ DirContext.ADD_ATTRIBUTE, desc1);
+
+ Attribute desc2 = new BasicAttribute("description");
+ desc2.add(descriptions[1]);
+ ModificationItem delModOp = new ModificationItem(
+ DirContext.REMOVE_ATTRIBUTE, desc2);
+
+ ctx.modifyAttributes(rdn, new ModificationItem[] { addModOp,
+ delModOp });
+
+ SearchControls sctls = new SearchControls();
+ sctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ String filter = "(sn=Bush)";
+ String base = "";
+
+ // Check entry
+ NamingEnumeration enm = ctx.search(base, filter, sctls);
+ assertTrue(enm.hasMore());
+
+ while (enm.hasMore()) {
+ SearchResult sr = (SearchResult) enm.next();
+ attrs = sr.getAttributes();
+ Attribute desc = sr.getAttributes().get("description");
+ assertNotNull(desc);
+ assertEquals(1, desc.size());
+ assertTrue(desc.contains(descriptions[0]));
+ }
+
+ // Remove the person entry
+ ctx.destroySubcontext(rdn);
+ }
+
+ /**
+ * Create a person entry and perform a modify op on an
+ * attribute which is part of the DN. This is not allowed.
+ *
+ * A JIRA has been created for this bug : DIRSERVER_687
+ */
+ /*
+ public void testDNAttributeMemberMofificationDIRSERVER_687() throws NamingException {
+
+ // Create a person entry
+ Attributes attrs = getPersonAttributes("Bush", "Kate Bush");
+ String rdn = "cn=Kate Bush";
+ ctx.createSubcontext(rdn, attrs);
+
+ // Try to modify the cn attribute
+ Attribute desc1 = new BasicAttribute( "cn", "Georges Bush" );
+
+ ModificationItem addModOp = new ModificationItem(
+ DirContext.REPLACE_ATTRIBUTE, desc1);
+
+ try
+ {
+ ctx.modifyAttributes( rdn, new ModificationItem[] { addModOp } );
+ }
+ catch ( AttributeModificationException ame )
+ {
+ assertTrue( true );
+ // Remove the person entry
+ ctx.destroySubcontext(rdn);
+ }
+ catch ( NamingException ne )
+ {
+ assertTrue( true );
+ // Remove the person entry
+ ctx.destroySubcontext(rdn);
+ }
+
+ // Remove the person entry
+ ctx.destroySubcontext(rdn);
+
+ fail();
+ }
+ */
}