directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r696310 - in /directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify: ModifyRemoveIT.java ModifyReplaceIT.java
Date Wed, 17 Sep 2008 14:06:35 GMT
Author: elecharny
Date: Wed Sep 17 07:06:33 2008
New Revision: 696310

URL: http://svn.apache.org/viewvc?rev=696310&view=rev
Log:
Applied patch submitted by Norval in DIRSERVER-1257

Modified:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java?rev=696310&r1=696309&r2=696310&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
Wed Sep 17 07:06:33 2008
@@ -115,7 +115,7 @@
 
 
     /**
-     * Remove an attribute which does not exist in an attribute making sure 
+     * Remove a value 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:
      * 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java?rev=696310&r1=696309&r2=696310&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
Wed Sep 17 07:06:33 2008
@@ -65,6 +65,8 @@
 import org.junit.runner.RunWith;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -164,7 +166,7 @@
      * Create a person entry and try to remove a not present attribute
      */
     @Test
-    public void testReplaceNotPresentAttribute() throws Exception 
+    public void testReplaceToRemoveNotPresentAttribute() throws Exception
     {
         DirContext sysRoot = ( DirContext ) getWiredContext( ldapService ).lookup( BASE );
         
@@ -181,17 +183,58 @@
         String base = "";
 
         NamingEnumeration<SearchResult> enm = sysRoot.search( base, filter, sctls );
+        
         while ( enm.hasMore() ) 
         {
             SearchResult sr = ( SearchResult ) enm.next();
             Attribute cn = sr.getAttributes().get( "cn" );
             assertNotNull( cn );
-            assertTrue( cn.contains("Kate Bush") );
+            assertTrue( cn.contains( "Kate Bush") );
+            Attribute desc = sr.getAttributes().get( "description" );
+            assertNull( desc );
         }
 
         sysRoot.destroySubcontext( rdn );
     }
+    
+    
+    /**
+     * Create a person entry and try to add a not present attribute via a REPLACE
+     */
+    @Test
+    public void testReplaceToAddNotPresentAttribute() throws Exception 
+    {
+        DirContext sysRoot = ( DirContext ) getWiredContext( ldapService ).lookup( BASE );
+        
+        String rdn = "cn=Kate Bush";
+
+        Attribute attr = new BasicAttribute( "description", "added description" );
+        ModificationItem item = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr
);
+
+        sysRoot.modifyAttributes( rdn, new ModificationItem[] { item } );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        String filter = "(sn=Bush)";
+        String base = "";
 
+        NamingEnumeration<SearchResult> enm = sysRoot.search( base, filter, sctls );
+        
+        while ( enm.hasMore() ) 
+        {
+            SearchResult sr = ( SearchResult ) enm.next();
+            Attribute cn = sr.getAttributes().get( "cn" );
+            assertNotNull( cn );
+            assertTrue( cn.contains( "Kate Bush") );
+            Attribute desc = sr.getAttributes().get( "description" );
+            assertNotNull( desc );
+            assertTrue( desc.contains( "added description") );
+            assertEquals( 1, desc.size() );
+        }
+
+        sysRoot.destroySubcontext( rdn );
+    }
+    
     
     /**
      * Create a person entry and try to remove a non existing attribute
@@ -206,7 +249,7 @@
         Attribute attr = new BasicAttribute( "numberOfOctaves" );
         ModificationItem item = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr
);
 
-        sysRoot.modifyAttributes(rdn, new ModificationItem[] { item });
+        sysRoot.modifyAttributes( rdn, new ModificationItem[] { item } );
 
         SearchControls sctls = new SearchControls();
         sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
@@ -214,6 +257,7 @@
         String base = "";
 
         NamingEnumeration<SearchResult> enm = sysRoot.search( base, filter, sctls );
+        
         while ( enm.hasMore() ) 
         {
             SearchResult sr = enm.next();



Mime
View raw message