directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r643029 - /directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
Date Mon, 31 Mar 2008 15:39:46 GMT
Author: akarasulu
Date: Mon Mar 31 08:39:44 2008
New Revision: 643029

URL: http://svn.apache.org/viewvc?rev=643029&view=rev
Log:
Test to make sure bug DIRSERVER-1149 is actually gone

Modified:
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java

Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java?rev=643029&r1=643028&r2=643029&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
(original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
Mon Mar 31 08:39:44 2008
@@ -29,6 +29,7 @@
 import javax.naming.directory.DirContext;
 import javax.naming.directory.InvalidAttributeIdentifierException;
 import javax.naming.directory.InvalidAttributeValueException;
+import javax.naming.directory.ModificationItem;
 import javax.naming.directory.NoSuchAttributeException;
 import javax.naming.directory.SchemaViolationException;
 import javax.naming.directory.SearchControls;
@@ -140,6 +141,49 @@
         assertNotNull( ctx );
         DirContext tori = ( DirContext ) ctx.lookup( RDN );
         assertNotNull( tori );
+    }
+
+
+    /**
+     * Remove an attribute which does not exist in an attribute making sure 
+     * it does not remove other values in that attribute.  Tests if the 
+     * following JIRA issue is still valid:
+     * 
+     *    https://issues.apache.org/jira/browse/DIRSERVER-1149
+     * 
+     * @throws NamingException
+     */
+    public void testRemoveAttemptWithoutChange() throws NamingException
+    {
+        // Get the attributes and check the contents
+        Attributes tori = ctx.getAttributes( RDN );
+        assertNotNull( tori.get( "objectClass" ) );
+        assertNotNull( tori.get( "cn" ) );
+        assertEquals( 1, tori.get( "cn" ).size() );
+        assertEquals( "Tori Amos", tori.get( "cn" ).get() );
+        assertNotNull( tori.get( "sn" ) );
+        
+        // Test an add operation first
+        ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, new AttributeImpl(
"cn", "foo" ) );
+        ctx.modifyAttributes( RDN, new ModificationItem[] { mod } );
+        tori = ctx.getAttributes( RDN );
+        assertNotNull( tori.get( "objectClass" ) );
+        assertNotNull( tori.get( "cn" ) );
+        assertEquals( 2, tori.get( "cn" ).size() );
+        assertEquals( "Tori Amos", tori.get( "cn" ).get( 0 ) );
+        assertEquals( "foo", tori.get( "cn" ).get( 1 ) );
+        assertNotNull( tori.get( "sn" ) );
+        
+        // Now test remove of value ( bar ) that does not exist in cn
+        mod = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, new AttributeImpl( "cn",
"bar" ) );
+        ctx.modifyAttributes( RDN, new ModificationItem[] { mod } );
+        tori = ctx.getAttributes( RDN );
+        assertNotNull( tori.get( "objectClass" ) );
+        assertNotNull( tori.get( "cn" ) );
+        assertEquals( 2, tori.get( "cn" ).size() );
+        assertEquals( "Tori Amos", tori.get( "cn" ).get( 0 ) );
+        assertEquals( "foo", tori.get( "cn" ).get( 1 ) );
+        assertNotNull( tori.get( "sn" ) );
     }
 
 



Mime
View raw message