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 2013/06/26 23:15:35 UTC
svn commit: r1497100 -
/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
Author: elecharny
Date: Wed Jun 26 21:15:35 2013
New Revision: 1497100
URL: http://svn.apache.org/r1497100
Log:
Added a test to check that we can replace an attributeType either with a null value or with no value (in this case, the attribute will be removed)
Modified:
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java?rev=1497100&r1=1497099&r2=1497100&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java Wed Jun 26 21:15:35 2013
@@ -24,6 +24,7 @@ import static org.apache.directory.serve
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -745,4 +746,63 @@ public void testModifyAddWithNullValues(
connection.close();
}
+
+
+@Test
+public void testModifyReplaceWithNullValues() throws LdapException, IOException
+{
+ LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
+ connection.setTimeOut( 0L );
+
+ // Use the client API
+ connection.bind( "uid=admin,ou=system", "secret" );
+
+ // Add a new entry with some null values
+ Entry entry = new DefaultEntry( "uid=12345,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: person",
+ "ObjectClass: person",
+ "ObjectClass: OrganizationalPerson",
+ "ObjectClass: inetOrgPerson",
+ "uid: 12345",
+ "cn: test",
+ "sn: Test",
+ "userPassword: 12345" );
+
+ connection.add( entry );
+
+ // Now modify the entry : we should replace the password with a null value
+ // and add a mail Attribute with a null value
+ connection.modify( new Dn( "uid=12345,ou=system" ),
+ new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "userPassword", Strings.EMPTY_BYTES ),
+ new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "mail", ( String ) null )
+ );
+
+ // Get back the entry
+ Entry found = connection.lookup( "uid=12345,ou=system" );
+
+ assertNotNull( found );
+ assertNotNull( found.get( "mail" ) );
+ assertNotNull( found.get( "userPassword" ) );
+ assertEquals( 1, found.get( "mail" ).size() );
+ assertEquals( 1, found.get( "userPassword" ).size() );
+ assertTrue( found.contains( "mail", Strings.EMPTY_BYTES ) );
+ assertTrue( found.contains( "userPassword", "" ) );
+
+ // Now, do a replace with no value. We should not anymore have a mail
+ connection.modify( new Dn( "uid=12345,ou=system" ),
+ new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "mail" )
+ );
+
+ // Get back the entry
+ found = connection.lookup( "uid=12345,ou=system" );
+
+ assertNotNull( found );
+ assertNull( found.get( "mail" ) );
+ assertNotNull( found.get( "userPassword" ) );
+ assertEquals( 1, found.get( "userPassword" ).size() );
+ assertTrue( found.contains( "userPassword", "" ) );
+
+ connection.close();
+}
}