directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r648932 [4/7] - in /directory/sandbox/akarasulu/bigbang/apacheds: ./ apacheds-xbean-spring/ benchmarks/ bootstrap-extract/ bootstrap-partition/ bootstrap-plugin/ btree-base/ core-constants/ core-constants/src/main/java/org/apache/directory/...
Date Thu, 17 Apr 2008 02:55:58 GMT
Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=648932&r1=648931&r2=648932&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java Wed Apr 16 19:55:38 2008
@@ -21,6 +21,7 @@
 
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -29,6 +30,7 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.NoSuchAttributeException;
 
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
@@ -38,12 +40,17 @@
 import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
+import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.DefaultOidRegistry;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -52,6 +59,7 @@
 import org.junit.Test;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -66,10 +74,27 @@
  */
 public class DefaultServerEntryTest
 {
+    private static final byte[] BYTES1 = new byte[]{ 'a', 'b' };
+    private static final byte[] BYTES2 = new byte[]{ 'b' };
+    private static final byte[] BYTES3 = new byte[]{ 'c' };
+
     private static BootstrapSchemaLoader loader;
     private static Registries registries;
+    private static AttributeTypeRegistry atr;
     private static OidRegistry oidRegistry;
     
+    private static AttributeType atObjectClass;
+    private static AttributeType atCN;
+    private static AttributeType atSN;
+    private static AttributeType atC;   
+    private static AttributeType atL;   
+    private static AttributeType atOC;   
+    
+    // A Binary attribute
+    private static AttributeType atPwd;
+
+    private static LdapDN EXAMPLE_DN;
+    
     /**
      * Initialize the registries once for the whole test suite
      */
@@ -89,926 +114,966 @@
         bootstrapSchemas.add( new InetorgpersonSchema() );
         bootstrapSchemas.add( new CosineSchema() );
         loader.loadWithDependencies( bootstrapSchemas, registries );
+
+        atr = registries.getAttributeTypeRegistry();
+
+        atObjectClass = registries.getAttributeTypeRegistry().lookup( "objectClass" );
+        atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+        atC = registries.getAttributeTypeRegistry().lookup( "c" );
+        atL = registries.getAttributeTypeRegistry().lookup( "l" );
+        atOC = registries.getAttributeTypeRegistry().lookup( "objectClass" );
+        atSN = registries.getAttributeTypeRegistry().lookup( "sn" );
+        atPwd = registries.getAttributeTypeRegistry().lookup( "userpassword" );
+        
+        EXAMPLE_DN = new LdapDN( "dc=example,dc=com" );
     }
 
 
+    //-------------------------------------------------------------------------
+    // Test the Constructors
+    //-------------------------------------------------------------------------
     /**
-     * Test a conversion from a ServerEntry to an AttributesImpl
+     * Test for method DefaultServerEntry()
      */
-    @Test public void testToAttributesImpl() throws InvalidNameException, NamingException
+    @Test
+    public void testDefaultServerEntry() throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        Entry entry = new DefaultServerEntry();
+        assertNotNull( entry );
+        assertNull( entry.getDn() );
+        assertEquals( 0, entry.size() );
+    }
+    
+    
+    /**
+     * Test for method DefaultServerEntry( registries )
+     */
+    @Test
+    public void testDefaultServerEntryRegistries() throws NamingException
+    {
+        Entry entry = new DefaultServerEntry( registries );
+        assertNotNull( entry );
+        assertNull( entry.getDn() );
+        assertEquals( 0, entry.size() );
+    }
+    
+    
+    /**
+     * Test for method DefaultServerEntry( registries, LdapDN )
+     */
+    @Test
+    public void testDefaultServerEntryRegistriesDN() throws NamingException
+    {
+        Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+        assertNotNull( entry );
+        assertEquals( EXAMPLE_DN, entry.getDn() );
+        assertEquals( 0, entry.size() );
+    }
+    
+    
+    /**
+     * Test for method DefaultServerEntry( registries, LdapDN, AttributeType... )
+     */
+    @Test
+    public void testDefaultServerEntryRegistriesDNAttributeTypeArray() throws NamingException
+    {
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN, atOC, atPwd, atCN );
+        assertNotNull( entry );
+        assertEquals( EXAMPLE_DN, entry.getDn() );
+        assertEquals( 3, entry.size() );
+        assertTrue( entry.containsAttribute( atOC ) );
+        assertTrue( entry.containsAttribute( atPwd ) );
+        assertTrue( entry.containsAttribute( atCN ) );
+    }
+    
+    
+    /**
+     * Test for method DefaultServerEntry( registries, LdapDN, AttributeType, upId )
+     */
+    @Test
+    public void testDefaultServerEntryRegistriesDNAttributeTypeUpId() throws NamingException
+    {
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN, atOC, "  OBJECTCLASS  " );
+        assertNotNull( entry );
+        assertEquals( EXAMPLE_DN, entry.getDn() );
+        assertEquals( 1, entry.size() );
+        assertTrue( entry.containsAttribute( atOC ) );
+        assertEquals( "objectclass", entry.get( atOC ).getId() );
+        assertEquals( "OBJECTCLASS", entry.get( atOC ).getUpId() );
+    }
+    
+    
+    /**
+     * Test for method DefaultServerEntry( registries, LdapDN, AttributeType, upId )
+     */
+    @Test
+    public void testDefaultServerEntryRegistriesDNUpIdArray() throws NamingException
+    {
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN, "  OBJECTCLASS  ", " Cn " );
+        assertNotNull( entry );
+        assertEquals( EXAMPLE_DN, entry.getDn() );
+        assertEquals( 2, entry.size() );
+        assertTrue( entry.containsAttribute( "objectClass" ) );
+        assertEquals( "objectclass", entry.get( atOC ).getId() );
+        assertEquals( "OBJECTCLASS", entry.get( atOC ).getUpId() );
+        assertTrue( entry.containsAttribute( "2.5.4.3" ) );
+        assertEquals( "cn", entry.get( atCN ).getId() );
+        assertEquals( "Cn", entry.get( atCN ).getUpId() );
+    }
+    
+    
+    //-------------------------------------------------------------------------
+    // Test the Add methods
+    //-------------------------------------------------------------------------
+    /**
+     * Test for method add( EntryAttribute...)
+     */
+    @Test
+    public void testAddEntryAttribute() throws NamingException
+    {
+        Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+        EntryAttribute oc = new DefaultServerAttribute( atObjectClass, "top", "person" );
+        EntryAttribute cn = new DefaultServerAttribute( atCN, "test1", "test2" );
+        EntryAttribute sn = new DefaultServerAttribute( atSN, "Test1", "Test2" );
+        EntryAttribute up = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
+        EntryAttribute c = new DefaultServerAttribute( atC, "FR", "US" );
         
-        entry.put( "objectClass", OBJECT_CLASS_AT, "top", "person", "inetOrgPerson", "organizationalPerson" );
-        entry.put( "cn", registries.getAttributeTypeRegistry().lookup( "cn" ), "test" );
+        entry.add( oc, cn, sn, c );
         
-        Attributes attributes = ServerEntryUtils.toAttributesImpl( entry );
+        assertEquals( 4, entry.size() );
+        assertTrue( entry.containsAttribute( "ObjectClass" ) );
+        assertTrue( entry.containsAttribute( "CN" ) );
+        assertTrue( entry.containsAttribute( "  sn  " ) );
+        assertTrue( entry.containsAttribute( " countryName  " ) );
+    
+        EntryAttribute attr = entry.get( "objectclass" );
+        assertEquals( 2, attr.size() );
         
-        assertNotNull( attributes );
-        assertTrue( attributes instanceof AttributesImpl );
+        EntryAttribute c2 = new DefaultServerAttribute( atC, "UK", "DE" );
+        entry.add( c2, up );
+        assertEquals( 5, entry.size() );
         
-        Set<String> expected = new HashSet<String>();
-        expected.add( "objectClass" );
-        expected.add( "cn" );
-     
-        for ( NamingEnumeration<String> ids = attributes.getIDs(); ids.hasMoreElements();)
-        {
-            String id = ids.nextElement();
-            
-            assertTrue( expected.contains( id ) );
-            expected.remove( id );
-            
-        }
+        assertTrue( entry.containsAttribute( "userPassword" ) );
+        assertTrue( entry.containsAttribute( " countryName " ) );
 
-        // It should be empty
-        assertEquals( 0, expected.size() );
+        EntryAttribute attrC = entry.get( "countryName" );
+        assertEquals( 4, attrC.size() );
+        
+        entry.clear();
     }
 
-
+    
     /**
-     * Test a conversion from a ServerEntry to an BasicAttributes
+     * Test for method add( String, byte[]...)
      */
-    @Test public void testToBasicAttributes() throws InvalidNameException, NamingException
+    @Test
+    public void testAddStringByteArrayArray() throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries,dn );
+        Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+        entry.add( "userPassword", (byte[])null );
+        assertEquals( 1, entry.size() );
+        EntryAttribute attributePWD = entry.get( "userPassword" );
+        assertEquals( 1, attributePWD.size() );
+        assertNotNull( attributePWD.get() );
+        assertNull( attributePWD.get().get() );
         
-        entry.put( "objectClass", OBJECT_CLASS_AT, "top", "person", "inetOrgPerson", "organizationalPerson" );
+        entry.clear();
         
-        Attributes attributes = ServerEntryUtils.toBasicAttributes( entry );
+        entry.add( "jpegPhoto", BYTES1, BYTES1, BYTES2 );
+        assertEquals( 1, entry.size() );
+        EntryAttribute attributeJPG = entry.get( "jpegPhoto" );
+        assertEquals( 2, attributeJPG.size() );
+        assertNotNull( attributeJPG.get() );
+        assertTrue( attributeJPG.contains( BYTES1 ) );
+        assertTrue( attributeJPG.contains( BYTES2 ) );
         
-        assertNotNull( attributes );
-        assertTrue( attributes instanceof BasicAttributes );
+        entry.clear();
         
-        Set<String> expected = new HashSet<String>();
-        expected.add( "objectClass" );
-        expected.add( "cn" );
-     
-        for ( NamingEnumeration<String> ids = attributes.getIDs(); ids.hasMoreElements();)
+        try
         {
-            String id = ids.nextElement();
-            
-            assertTrue( expected.contains( id ) );
-            expected.remove( id );
-            
-        }
-
-        // We should still have the ObjectClass Attribute
-        assertEquals( 1, expected.size() );
+            // Cannot add an attribute which does not exist
+            entry.add( "wrongAT", BYTES1, BYTES2 );
+            fail();
+         }
+         catch ( NoSuchAttributeException nsae )
+         {
+             assertTrue( true );
+         }
+
+         // Cannot add String values into a binary attribute
+         entry.add( "jpegPhoto", "test", "test2" );
+         assertEquals( 0, entry.get( "jpegPhoto" ).size() );
     }
-    
-    //-------------------------------------------------------------------------
-    // Test the put methods
-    //-------------------------------------------------------------------------
+     
+
     /**
-     * Test the set(AT...) method
+     * Test for method add( String, String...)
      */
-    @Test public void testSetATElipsis() throws NamingException
+    @Test
+    public void testAddStringStringArray() throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        List<ServerAttribute> result = null;
+        entry.add( "cn", (String)null );
+        assertEquals( 1, entry.size() );
+        EntryAttribute attributeCN = entry.get( "cn" );
         
-        // First check that this method fails if we pass an empty list of ATs
+        assertEquals( 1, attributeCN.size() );
+        assertNotNull( attributeCN.get() );
+        assertNull( attributeCN.get().get() );
+         
+        entry.add( "sn", "test", "test", "TEST" );
+        assertEquals( 2, entry.size() );
+        EntryAttribute attributeSN = entry.get( "sn" );
+         
+        // 'TEST' and 'test' are the same value for 'sn' (this is a case insensitive attributeType)
+        assertEquals( 1, attributeSN.size() );
+        assertNotNull( attributeSN.get() );
+        assertTrue( attributeSN.contains( "test" ) );
+        assertTrue( attributeSN.contains( "TEST" ) );
+         
+        entry.clear();
+
         try
         {
-            result = entry.set( (AttributeType)null);
+            // Cannot add an attribute which does not exist
+            entry.add( "wrongAT", "wrong", "wrong" );
             fail();
         }
-        catch ( IllegalArgumentException iae )
+        catch ( NoSuchAttributeException nsae )
         {
             assertTrue( true );
         }
+
+        // Cannot add binary values into a String attribute
+        entry.add( "sn",BYTES1, BYTES2 );
+        assertEquals( 0, entry.get( "sn" ).size() );
+    }
+     
+
+    /**
+     * Test for method add( String, Value<?>...)
+     */
+    @Test
+    public void testAddStringValueArray() throws NamingException
+    {
+        Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+        Value<String> value = new ServerStringValue( atCN, (String)null );
         
-        // Now, check what we get when adding one existing AT
-        AttributeType atSN = registries.getAttributeTypeRegistry().lookup( "sn" );
-        result = entry.set( atSN );
-        
-        assertNotNull( result );
-        assertEquals( 0, result.size() );
-        ServerAttribute sa = entry.get( "sn" );
-        assertNotNull( sa );
-        assertEquals( atSN, sa.getAttributeType() );
-        assertEquals( "sn", sa.getAttributeType().getName() );
-        
-        // Add two AT now
-        AttributeType atL = registries.getAttributeTypeRegistry().lookup( "localityName" );
-        AttributeType atC = registries.getAttributeTypeRegistry().lookup( "countryName" );
-        AttributeType atGN = registries.getAttributeTypeRegistry().lookup( "givenname" );
-        AttributeType atStreet = registries.getAttributeTypeRegistry().lookup( "2.5.4.9" );
-        result = entry.set( atL, atC, atGN, atStreet );
-        
-        assertNotNull( result );
-        
-        assertEquals( 0, result.size() );
-        sa = entry.get( "l" );
-        assertNotNull( sa );
-        assertEquals( atL, sa.getAttributeType() );
-        assertEquals( "l", sa.getAttributeType().getName() );
+        entry.add( "cn", value );
+        assertEquals( 1, entry.size() );
+        EntryAttribute attributeCN = entry.get( "cn" );
+        assertEquals( 1, attributeCN.size() );
+        assertNotNull( attributeCN.get() );
+        assertNull( attributeCN.get().get() );
+         
+        Value<String> value1 = new ServerStringValue( atCN, "test1" );
+        Value<String> value2 = new ServerStringValue( atCN, "test2" );
+        Value<String> value3 = new ServerStringValue( atCN, "test1" );
 
-        sa = entry.get( "c" );
-        assertNotNull( sa );
-        assertEquals( atC, sa.getAttributeType() );
-        assertEquals( "c", sa.getAttributeType().getName() );
+        entry.add( "sn", value1, value2, value3 );
+        assertEquals( 2, entry.size() );
+        EntryAttribute attributeSN = entry.get( "sn" );
+        assertEquals( 2, attributeSN.size() );
+        assertNotNull( attributeSN.get() );
+        assertTrue( attributeSN.contains( value1 ) );
+        assertTrue( attributeSN.contains( value2 ) );
+         
+        Value<byte[]> value4 = new ServerBinaryValue( atPwd, BYTES1 );
+        entry.add( "l", value1, value4 );
+        assertEquals( 3, entry.size() );
+        EntryAttribute attributeL = entry.get( "l" );
+         
+        // Cannot store a binary value in a String attribute
+        assertEquals( 1, attributeL.size() );
+        assertNotNull( attributeL.get() );
+        assertTrue( attributeL.contains( value1 ) );
 
-        sa = entry.get( "2.5.4.9" );
-        assertNotNull( sa );
-        assertEquals( atStreet, sa.getAttributeType() );
-        assertEquals( "street", sa.getAttributeType().getName() );
+        entry.clear();
 
-        sa = entry.get( "givenName" );
-        assertNotNull( sa );
-        assertEquals( atGN, sa.getAttributeType() );
-        assertEquals( "givenName", sa.getAttributeType().getName() );
+        try
+        {
+            // Cannot add an attribute which does not exist
+            entry.add( "wrongAT", value1, value2 );
+            fail();
+        }
+        catch ( NoSuchAttributeException nsae )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * Test method for add( AttributeType, byte[]... )
+     */
+    @Test
+    public void testAddAttributeTypeByteArrayArray() throws NamingException
+    {
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        // Now try to add existing ATs
-        // First, set some value to the modified AT
-        sa = entry.get( "sn" );
-        sa.add( "test" );
+        entry.add( atPwd, BYTES1, BYTES2 );
+        assertEquals( 1, entry.size() );
+        assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
         
-        // Check that the value has been added to the entry
-        assertEquals( "test", entry.get( "sn" ).get().get() ); 
+        entry.add( atPwd, (byte[])null, BYTES1 );
+        assertEquals( 1, entry.size() );
         
-        // Now add a new SN empty AT : it should replace the existing one.
-        AttributeType atSNEmpty = registries.getAttributeTypeRegistry().lookup( "sn" );
-        sa = entry.set( atSNEmpty ).get( 0 );
-        assertEquals( "test", sa.get().get() ); 
-        assertNotNull( entry.get(  "sn" ) );
-        assertNull( entry.get(  "sn" ).get() );
+        EntryAttribute attribute = entry.get( atPwd );
+        assertEquals( 3, attribute.size() );
+        assertTrue( attribute.contains( BYTES1 ) );
+        assertTrue( attribute.contains( BYTES2 ) );
+        assertTrue( attribute.contains( (byte[])null ) );
+    }
+    
+     
+    /**
+     * Test method for add( AttributeType, String... )
+     */
+    @Test
+    public void testAddAttributeTypeStringArray() throws NamingException
+    {
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        // Last, not least, put an ObjectClass AT
-        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+        entry.add( atC, "us", "fr" );
+        assertEquals( 1, entry.size() );
+        assertTrue( entry.contains( atC, "fr", "us" ) );
         
-        entry.set( OBJECT_CLASS_AT );
+        entry.add( atC, (String)null, "de", "fr" );
+        assertEquals( 1, entry.size() );
         
-        assertNotNull( entry.get( "objectClass" ) );
-
-        ServerAttribute oc = entry.get( "objectClass" );
+        EntryAttribute attribute = entry.get( atC );
+        assertEquals( 4, attribute.size() );
+        assertTrue( attribute.contains( "de" ) );
+        assertTrue( attribute.contains( "fr" ) );
+        assertTrue( attribute.contains( (String)null ) );
+        assertTrue( attribute.contains( "us" ) );
         
-        assertEquals( OBJECT_CLASS_AT, oc.getAttributeType() );
-        assertNull( oc.get() );
+        entry.clear();
+        
+        assertEquals( 0, entry.size() );
     }
-
+    
+     
     /**
-     * Test the set( upId ) method
+     * Test method for add( AttributeType, Value<?>... )
      */
-    @Test public void tesSetUpID() throws NamingException
+    @Test
+    public void testAddAttributeTypeValueArray() throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        // First check that this method fails if we pass a null or empty ID
-        try
-        {
-            entry.set( (String)null );
-            fail();
-        }
-        catch ( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
+        Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
+        Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
+        Value<String> strValue3 = new ServerStringValue( atCN, "test3" );
+        Value<String> strNullValue = new ServerStringValue( atCN, null);
+
+        Value<byte[]> binValue1 = new ServerBinaryValue( atPwd, BYTES1 );
+        Value<byte[]> binValue2 = new ServerBinaryValue( atPwd, BYTES2 );
+        Value<byte[]> binValue3 = new ServerBinaryValue( atPwd, BYTES3 );
         
         try
         {
-            entry.set( "  " );
+            entry.add( (AttributeType)null, strValue1 );
             fail();
         }
-        catch ( IllegalArgumentException iae )
+        catch( IllegalArgumentException iae )
         {
             assertTrue( true );
         }
         
-        // Now check that we can't put invalid IDs
+        entry.add( atCN, strValue1, strValue2, strValue1 );
+        entry.add( atPwd, binValue1, binValue2, binValue1 );
+        
+        assertEquals( 2, entry.size() );
+        assertTrue( entry.contains( atCN, "test1", "test2" ) );
+        assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
+        
+        entry.add( atCN, strValue3, strNullValue );
+        
+        assertEquals( 4, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, strNullValue ) );
+        
+        entry.add( atCN, binValue3 );
+        assertFalse( entry.contains( atCN, binValue3 ) );
+    }
+    
+    
+
+
+    /**
+     * Test method for add( String, AttributeType, byte[]... )
+     */
+    @Test
+    public void testAddStringAttributeTypeByteArrayArray() throws NamingException
+    {
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+        
+        entry.add( "UserPassword", atPwd, BYTES1, BYTES2 );
+        assertEquals( 1, entry.size() );
+        assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
+        assertEquals( "UserPassword", entry.get( atPwd ).getUpId() );
+        assertEquals( "userpassword", entry.get( atPwd ).getId() );
+        
+        entry.add( "  UserPassword  ", atPwd, (byte[])null, BYTES1 );
+        assertEquals( 1, entry.size() );
+        
+        EntryAttribute attribute = entry.get( atPwd );
+        assertEquals( 3, attribute.size() );
+        assertTrue( attribute.contains( BYTES1 ) );
+        assertTrue( attribute.contains( BYTES2 ) );
+        assertTrue( attribute.contains( (byte[])null ) );
+        assertEquals( "UserPassword", attribute.getUpId() );
+        assertEquals( "userpassword", attribute.getId() );
+
         try
         {
-            entry.set( "ThisIsNotAnAttributeType" );
+            entry.add( "  ObjectClass  ", atOC, BYTES1 );
             fail();
         }
-        catch ( NamingException ne )
+        catch( UnsupportedOperationException uoe )
         {
             assertTrue( true );
         }
+    }
+    
+     
+    /**
+     * Test method for add( String, AttributeType, String... )
+     */
+    @Test
+    public void testAddStringAttributeTypeStringArray() throws NamingException
+    {
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        // Now, check what we get when adding one existing AT
-        List<ServerAttribute> result = entry.set( "sn" );
+        entry.add( "CommonName", atCN, "test1", "test2" );
+        assertEquals( 1, entry.size() );
+        assertTrue( entry.contains( atCN, "test1", "test2" ) );
+        assertEquals( "CommonName", entry.get( atCN ).getUpId() );
+        assertEquals( "commonname", entry.get( atCN ).getId() );
         
-        assertNull( result );
+        entry.add( "  CN  ", atCN, (String)null, "test1" );
+        assertEquals( 1, entry.size() );
+        
+        EntryAttribute attribute = entry.get( atCN );
+        assertEquals( 3, attribute.size() );
+        assertTrue( attribute.contains( "test1" ) );
+        assertTrue( attribute.contains( (String)null ) );
+        assertTrue( attribute.contains( "test2" ) );
+        assertEquals( "CN", attribute.getUpId() );
+        assertEquals( "cn", attribute.getId() );
 
-        ServerAttribute sa = entry.get( "sn" );
-        assertNotNull( sa );
-        assertEquals( "sn", sa.getAttributeType().getName() );
-        
-        // Add different upIds now
-        AttributeType atL = registries.getAttributeTypeRegistry().lookup( "localityName" );
-        AttributeType atC = registries.getAttributeTypeRegistry().lookup( "countryName" );
-        AttributeType atGN = registries.getAttributeTypeRegistry().lookup( "givenname" );
-        AttributeType atStreet = registries.getAttributeTypeRegistry().lookup( "2.5.4.9" );
-        
-        entry.set( "L" );
-        entry.set( "CountryName" );
-        entry.set( "gn" );
-        entry.set( "2.5.4.9" );
-        
-
-        sa = entry.get( "l" );
-        assertNotNull( sa );
-        assertEquals( atL, sa.getAttributeType() );
-        assertEquals( "l", sa.getAttributeType().getName() );
-        assertEquals( "L", sa.getUpId() );
-
-        sa = entry.get( "c" );
-        assertNotNull( sa );
-        assertEquals( atC, sa.getAttributeType() );
-        assertEquals( "c", sa.getAttributeType().getName() );
-        assertEquals( "CountryName", sa.getUpId() );
-
-        sa = entry.get( "2.5.4.9" );
-        assertNotNull( sa );
-        assertEquals( atStreet, sa.getAttributeType() );
-        assertEquals( "street", sa.getAttributeType().getName() );
-        assertEquals( "2.5.4.9", sa.getUpId() );
-
-        sa = entry.get( "givenName" );
-        assertNotNull( sa );
-        assertEquals( atGN, sa.getAttributeType() );
-        assertEquals( "givenName", sa.getAttributeType().getName() );
-        assertEquals( "gn", sa.getUpId() );
-        
-        // Now try to add existing ATs
-        // First, set some value to the modified AT
-        sa = entry.get( "sn" );
-        sa.add( "test" );
-        
-        // Check that the value has been added to the entry
-        assertEquals( "test", entry.get( "sn" ).get().get() ); 
+        entry.clear();
         
-        // Now add a new SN empty AT : it should replace the existing one.
-        AttributeType atSNEmpty = registries.getAttributeTypeRegistry().lookup( "sn" );
-        sa = entry.set( atSNEmpty ).get( 0 );
-        assertEquals( "test", sa.get().get() ); 
-        assertNotNull( entry.get(  "sn" ) );
-        assertNull( entry.get(  "sn" ).get() );
+        // Binary values are not allowed
+        entry.add( "  CN  ", atCN, BYTES1 );
+        assertEquals( 1, entry.size() );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 0, entry.get( atCN ).size() );
     }
-
     
+     
     /**
-     * Test the put( SA... ) method
+     * Test method for add( String, AttributeType, Value<?>... )
      */
-    @Test public void tesPutServerAttributeElipsis() throws NamingException
+    @Test
+    public void testAddStringAttributeTypeValueArray() throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+        
+        Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
+        Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
+        Value<String> strValue3 = new ServerStringValue( atCN, "test3" );
+        Value<String> strNullValue = new ServerStringValue( atCN, null);
 
-        // first test a null SA addition. It should be allowed.
+        Value<byte[]> binValue1 = new ServerBinaryValue( atPwd, BYTES1 );
+        Value<byte[]> binValue2 = new ServerBinaryValue( atPwd, BYTES2 );
+        Value<byte[]> binValue3 = new ServerBinaryValue( atPwd, BYTES3 );
+        
         try
         {
-            entry.put( (ServerAttribute)null );
+            entry.add( "cn", (AttributeType)null, strValue1 );
             fail();
         }
-        catch ( IllegalArgumentException iae )
+        catch( IllegalArgumentException iae )
         {
             assertTrue( true );
         }
         
-        // Ajout de serverAttributes
-        AttributeType atL = registries.getAttributeTypeRegistry().lookup( "localityName" );
-        AttributeType atC = registries.getAttributeTypeRegistry().lookup( "countryName" );
-        AttributeType atGN = registries.getAttributeTypeRegistry().lookup( "givenname" );
-        AttributeType atStreet = registries.getAttributeTypeRegistry().lookup( "2.5.4.9" );
-
-        ServerAttribute sa = new DefaultServerAttribute( atL, "france" );
-        entry.put( sa );
-        
-        assertEquals( 1, entry.size() );
-        assertNotNull( entry.get( "l" ) );
-        assertEquals( "france", entry.get( "l" ).get().get() );
-        
-        ServerAttribute sb = new DefaultServerAttribute( atC, "countryTest" );
-        ServerAttribute sc = new DefaultServerAttribute( atGN, "test" );
-        ServerAttribute sd = new DefaultServerAttribute( atStreet, "testStreet" );
-        entry.put( sb, sc, sd );
-
-        assertEquals( 4, entry.size() );
-        assertNotNull( entry.get( atC ) );
-        assertEquals( "countryTest", entry.get( atC ).get().get() );
-        assertNotNull( entry.get( atGN ) );
-        assertEquals( "test", entry.get( atGN ).get().get() );
-        assertNotNull( entry.get( atStreet) );
-        assertEquals( "testStreet", entry.get( atStreet ).get().get() );
-        
-        // Test a replacement
-        ServerAttribute sbb = new DefaultServerAttribute( atC, "countryTestTest" );
-        ServerAttribute scc = new DefaultServerAttribute( atGN, "testtest" );
-        List<ServerAttribute> result = entry.put( sbb, scc );
+        entry.add( "CN", atCN, strValue1, strValue2, strValue1 );
+        entry.add( "UserPassword", atPwd, binValue1, binValue2, binValue1 );
         
-        assertEquals( 2, result.size() );
-        assertEquals( "countryTest", result.get(0).get().get() );
-        assertEquals( "test", result.get(1).get().get() );
-        assertEquals( 4, entry.size() );
-        assertNotNull( entry.get( atC ) );
-        assertEquals( "countryTestTest", entry.get( atC ).get().get() );
-        assertNotNull( entry.get( atGN ) );
-        assertEquals( "testtest", entry.get( atGN ).get().get() );
-        assertNotNull( entry.get( atStreet) );
-        assertEquals( "testStreet", entry.get( atStreet ).get().get() );
+        assertEquals( 2, entry.size() );
+        assertTrue( entry.contains( atCN, "test1", "test2" ) );
+        assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
+        assertEquals( "CN", entry.get( atCN ).getUpId() );
+        assertEquals( "cn", entry.get( atCN ).getId() );
+        assertEquals( "UserPassword", entry.get( atPwd ).getUpId() );
+        assertEquals( "userpassword", entry.get( atPwd ).getId() );
         
-        // test an ObjectClass replacement
-        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
-        ServerAttribute oc = new DefaultServerAttribute( "OBJECTCLASS", OBJECT_CLASS_AT, "person", "inetorgperson" );
-        List<ServerAttribute> oldOc = entry.put( oc );
+        entry.add( "CN", atCN, strValue3, strNullValue );
         
-        assertNotNull( oldOc );
-        assertEquals( 0, oldOc.size() );
+        assertEquals( 4, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, strNullValue ) );
         
-        assertNotNull( entry.get( "objectClass" ) );
-
-        ServerAttribute newOc = entry.get( "objectClass" );
+        entry.add( atCN, binValue3 );
+        assertFalse( entry.contains( atCN, binValue3 ) );
         
-        assertNotNull( newOc );
-        assertEquals( OBJECT_CLASS_AT, newOc.getAttributeType() );
-        assertEquals( 2, newOc.size() );
-        assertEquals( "OBJECTCLASS", newOc.getUpId() );
-        assertTrue( newOc.contains( "person", "inetOrgPerson" ) );
+        try
+        {
+            entry.add( "SN", atCN, "test" );
+            fail();
+        }
+        catch ( IllegalArgumentException iae )
+        {
+            assertTrue( true );
+        }
     }
-
+    
     
     /**
-     * Test the put( AT, String... ) method
+     * Test the add( AT, String... ) method
      */
-    @Test public void tesPutAtStringElipsis() throws NamingException
+    @Test public void testAddAtStringElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         
         AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-
-        // Test an empty AT
-        entry.put( atCN, (String)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertNull( entry.get( atCN ).get().get() );
-        
-        // Check that we can't use invalid arguments
-        try
-        {
-            entry.put( (AttributeType)null, (String)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
-        
-        // Add a single value
-        atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        entry.put( atCN, "test" );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
+        // Test a simple addition
+        entry.add( atCN, "test1" );
+        assertNotNull( entry.get( atCN ) );
         assertEquals( 1, entry.get( atCN ).size() );
-        assertEquals( "test", entry.get( atCN ).get().get() );
+        assertEquals( "test1", entry.get( atCN ).get().get() );
         
-        // Add more than one value
-        entry.put( atCN, "test1", "test2", "test3" );
+        // Test some more addition
+        entry.add( atCN, "test2", "test3" );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 3, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
+        // Test some addition of existing values
+        entry.add( atCN, "test2" );
+        assertNotNull( entry.get( atCN ) );
         assertEquals( 3, entry.get( atCN ).size() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "cn", "test2" ) );
-        assertTrue( entry.contains( "cn", "test3" ) );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
         
-        // Add twice the same value
-        ServerAttribute sa = entry.put( atCN, "test1", "test2", "test1" );
+        // Test the addition of a null value
+        entry.add( atCN, (String)null );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 4, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
+        assertTrue( entry.contains( atCN, (String )null ) ); 
         
-        assertEquals( 3, sa.size() );
-        assertTrue( sa.contains( "test1", "test2", "test3" ) );
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertEquals( 2, entry.get( atCN ).size() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "cn", "test2" ) );
+        entry.clear();
+        
+        // Test the addition of a binary value
+        byte[] test4 = StringTools.getBytesUtf8( "test4" );
+        
+        entry.add( atCN, test4 );
+        assertFalse( entry.get( atCN ).contains( test4 ) );
     }
-    
+
 
     /**
-     * Test the put( AT, Byte[]... ) method
+     * Test the add( AT, byte[]... ) method
      */
-    @Test public void tesPutAtByteElipsis() throws NamingException
+    @Test public void testAddAtBytesElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         
-        AttributeType atPwd = registries.getAttributeTypeRegistry().lookup( "userPassword" );
-
-        // Test an empty AT
-        entry.put( atPwd, (byte[])null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
-        assertNull( entry.get( atPwd ).get().get() );
-        
-        // Check that we can't use invalid arguments
-        try
-        {
-            entry.put( (AttributeType)null, (byte[])null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
+        AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
         
-        byte[] password = StringTools.getBytesUtf8( "test" );
         byte[] test1 = StringTools.getBytesUtf8( "test1" );
         byte[] test2 = StringTools.getBytesUtf8( "test2" );
         byte[] test3 = StringTools.getBytesUtf8( "test3" );
         
-        // Add a single value
-        atPwd = registries.getAttributeTypeRegistry().lookup( "userPassword" );
-        entry.put( atPwd, password );
-        
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
-        assertEquals( 1, entry.get( atPwd ).size() );
-        assertTrue( Arrays.equals( password, (byte[])entry.get( atPwd ).get().get() ) );
+        // Test a simple addition
+        entry.add( atPassword, test1 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 1, entry.get( atPassword ).size() );
+        assertTrue( Arrays.equals( test1, (byte[])entry.get( atPassword ).get().get() ) );
         
-        // Add more than one value
-        entry.put( atPwd, test1, test2, test3 );
+        // Test some more addition
+        entry.add( atPassword, test2, test3 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 3, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, test1 ) );
+        assertTrue( entry.contains( atPassword, test2 ) );
+        assertTrue( entry.contains( atPassword, test3 ) );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
-        assertEquals( 3, entry.get( atPwd ).size() );
-        assertTrue( entry.contains( "userpassword", test1 ) );
-        assertTrue( entry.contains( "userpassword", test2 ) );
-        assertTrue( entry.contains( "userpassword", test3 ) );
+        // Test some addition of existing values
+        entry.add( atPassword, test2 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 3, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, test1 ) );
+        assertTrue( entry.contains( atPassword, test2 ) );
+        assertTrue( entry.contains( atPassword, test3 ) );
         
-        // Add twice the same value
-        ServerAttribute sa = entry.put( atPwd, test1, test2, test1 );
+        // Test the addition of a null value
+        entry.add( atPassword, (byte[])null );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 4, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, test1 ) );
+        assertTrue( entry.contains( atPassword, test2 ) );
+        assertTrue( entry.contains( atPassword, test3 ) );
+        assertTrue( entry.contains( atPassword, (byte[] )null ) ); 
         
-        assertEquals( 3, sa.size() );
-        assertTrue( sa.contains( test1, test2, test3 ) );
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
-        assertEquals( 2, entry.get( atPwd ).size() );
-        assertTrue( entry.contains( "userpassword", test1 ) );
-        assertTrue( entry.contains( "userpassword", test2 ) );
+        entry.clear();
+        
+        // Test the addition of a String value. It should be converted to a byte array
+        byte[] test4 = StringTools.getBytesUtf8( "test4" );
+
+        entry.add( atPassword, "test4" );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, test4 ) );
     }
-    
+
 
     /**
-     * Test the put( AT, Value... ) method
+     * Test the add( AT, SV... ) method
      */
-    @Test public void tesPutAtSVs() throws NamingException
+    @Test public void testAddAtServerValueElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         
-        // Adding a null value to an attribute
         AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        entry.put( atCN, (Value<?>)null );
-        
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
+        AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
         
-        // Check that we can't use invalid arguments
-        try
-        {
-            entry.put( (AttributeType)null, (Value<?>)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
+        byte[] b1 = StringTools.getBytesUtf8( "test1" );
+        byte[] b2 = StringTools.getBytesUtf8( "test2" );
+        byte[] b3 = StringTools.getBytesUtf8( "test3" );
+
+        Value<String> test1 = new ServerStringValue( atCN, "test1" );
+        Value<String> test2 = new ServerStringValue( atCN, "test2" );
+        Value<String> test3 = new ServerStringValue( atCN, "test3" );
         
-        // Add a single value
-        atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        Value<?> ssv = new ServerStringValue( atCN, "test" );
-        entry.put( atCN, ssv );
+        Value<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
+        Value<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
+        Value<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
+        // Test a simple addition in atCN
+        entry.add( atCN, test1 );
+        assertNotNull( entry.get( atCN ) );
         assertEquals( 1, entry.get( atCN ).size() );
-        assertEquals( "test", entry.get( atCN ).get().get() );
+        assertEquals( "test1", entry.get( atCN ).get().get() );
         
-        // Add more than one value
-        entry.put( atCN, new ServerStringValue( atCN, "test1" ),
-                         new ServerStringValue( atCN, "test2" ), 
-                         new ServerStringValue( atCN, "test3" ));
+        // Test some more addition
+        entry.add( atCN, test2, test3 );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 3, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
+        // Test some addition of existing values
+        entry.add( atCN, test2 );
+        assertNotNull( entry.get( atCN ) );
         assertEquals( 3, entry.get( atCN ).size() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "cn", "test2" ) );
-        assertTrue( entry.contains( "cn", "test3" ) );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
         
-        // Add twice the same value
-        ServerAttribute sa = entry.put( atCN, new ServerStringValue( atCN, "test1" ),
-                         new ServerStringValue( atCN, "test2" ), 
-                         new ServerStringValue( atCN, "test1" ));
+        // Test the addition of a null value
+        entry.add( atCN, (String)null );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 4, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
+        assertTrue( entry.contains( atCN, (String )null ) ); 
         
-        assertEquals( 3, sa.size() );
-        assertTrue( sa.contains( "test1", "test2", "test3" ) );
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertEquals( 2, entry.get( atCN ).size() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "cn", "test2" ) );
+        entry.clear();
+        
+        // Test the addition of a String value. It should be converted to a byte array
+        byte[] test4 = StringTools.getBytesUtf8( "test4" );
+
+        entry.add( atCN, test4 );
+        assertFalse( entry.contains( atCN, test4 ) );
+
+        // Now, work with a binary attribute
+        // Test a simple addition
+        entry.add( atPassword, testB1 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 1, entry.get( atPassword ).size() );
+        assertTrue( Arrays.equals( b1, (byte[])entry.get( atPassword ).get().get() ) );
+        
+        // Test some more addition
+        entry.add( atPassword, testB2, testB3 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 3, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, b1 ) );
+        assertTrue( entry.contains( atPassword, b2 ) );
+        assertTrue( entry.contains( atPassword, b3 ) );
+        
+        // Test some addition of existing values
+        entry.add( atPassword, testB2 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 3, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, b1 ) );
+        assertTrue( entry.contains( atPassword, b2 ) );
+        assertTrue( entry.contains( atPassword, b3 ) );
+        
+        // Test the addition of a null value
+        entry.add( atPassword, (byte[])null );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 4, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, b1 ) );
+        assertTrue( entry.contains( atPassword, b2 ) );
+        assertTrue( entry.contains( atPassword, b3 ) );
+        assertTrue( entry.contains( atPassword, (byte[] )null ) ); 
+        
+        entry.clear();
+        
+        // Test the addition of a String value. It should be converted to a byte array
+        byte[] b4 = StringTools.getBytesUtf8( "test4" );
+
+        entry.add( atPassword, "test4" );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, b4 ) );
     }
 
 
     /**
-     * Test the put( upId, String... ) method
+     * Test the add( upId, String... ) method
      */
-    @Test public void tesPutUpIdStringElipsis() throws NamingException
+    @Test public void testAddUpIdStringElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         
         AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
         
-        // Adding a null value should be possible
-        entry.put( "cn", (String)null );
-        
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertNull( entry.get( atCN ).get().get() );
-        
-        // Check that we can't use invalid arguments
-        try
-        {
-            entry.put( (String)null, (String)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
-        
-        // Add a single value
-        atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        entry.put( "cn", "test" );
-        
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
+        // Test a simple addition
+        entry.add( "CN", "test1" );
+        assertNotNull( entry.get( atCN ) );
+        assertTrue( entry.containsAttribute( atCN ) );
+        assertEquals( "cn", entry.get( atCN ).getId() );
+        assertEquals( "CN", entry.get( atCN ).getUpId() );
         assertEquals( 1, entry.get( atCN ).size() );
-        assertEquals( "test", entry.get( atCN ).get().get() );
+        assertEquals( "test1", entry.get( atCN ).get().get() );
         
-        // Add more than one value
-        entry.put( "cn", "test1", "test2", "test3" );
+        // Test some more addition
+        entry.add( "CN", "test2", "test3" );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 3, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
+        // Test some addition of existing values
+        entry.add( "CN", "test2" );
+        assertNotNull( entry.get( atCN ) );
         assertEquals( 3, entry.get( atCN ).size() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "cn", "test2" ) );
-        assertTrue( entry.contains( "cn", "test3" ) );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
         
-        // Add twice the same value
-        ServerAttribute sa = entry.put( "cn", "test1", "test2", "test1" );
+        // Test the addition of a null value
+        entry.add( "CN", (String)null );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 4, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
+        assertTrue( entry.contains( atCN, (String )null ) ); 
         
-        assertEquals( 3, sa.size() );
-        assertTrue( sa.contains( "test1", "test2", "test3" ) );
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertEquals( 2, entry.get( atCN ).size() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "cn", "test2" ) );
+        entry.clear();
         
-        // Check the UpId
-        entry.put( "CN", "test4" );
-        assertEquals( "CN", entry.get( atCN ).getUpId() );
+        // Test the addition of a binary value
+        byte[] test4 = StringTools.getBytesUtf8( "test4" );
+        
+        entry.add( "CN", test4 );
+        assertFalse( entry.contains(  "CN", test4 ) );
     }
-    
+
 
     /**
-     * Test the put( upId, byte[]... ) method
+     * Test the add( upId, byte[]... ) method
      */
-    @Test public void tesPutUpIdBytesElipsis() throws NamingException
+    @Test public void testAddUpIdBytesElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         
         AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
         
-        // Adding a null value should be possible
-        entry.put( "userPassword", (byte[])null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertNull( entry.get( atPassword ).get().get() );
+        byte[] test1 = StringTools.getBytesUtf8( "test1" );
+        byte[] test2 = StringTools.getBytesUtf8( "test2" );
+        byte[] test3 = StringTools.getBytesUtf8( "test3" );
         
-        // Check that we can't use invalid arguments
-        try
-        {
-            entry.put( (String)null, (String)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
-        
-        // Add a single value
-        byte[] test = StringTools.getBytesUtf8( "test" );
-        byte[] test1 = StringTools.getBytesUtf8( "test1" );
-        byte[] test2 = StringTools.getBytesUtf8( "test2" );
-        byte[] test3 = StringTools.getBytesUtf8( "test3" );
-        
-        entry.put( "userPassword", test );
-        
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
+        // Test a simple addition
+        entry.add( "userPassword", test1 );
+        assertNotNull( entry.get( atPassword ) );
         assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( Arrays.equals( test, (byte[])entry.get( atPassword ).get().get() ) );
+        assertTrue( Arrays.equals( test1, (byte[])entry.get( atPassword ).get().get() ) );
         
-        // Add more than one value
-        entry.put( "userPassword", test1, test2, test3 );
+        // Test some more addition
+        entry.add( "userPassword", test2, test3 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 3, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, test1 ) );
+        assertTrue( entry.contains( atPassword, test2 ) );
+        assertTrue( entry.contains( atPassword, test3 ) );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
+        // Test some addition of existing values
+        entry.add( "userPassword", test2 );
+        assertNotNull( entry.get( atPassword ) );
         assertEquals( 3, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( "userPassword", test1 ) );
-        assertTrue( entry.contains( "userPassword", test2 ) );
-        assertTrue( entry.contains( "userPassword", test3 ) );
+        assertTrue( entry.contains( atPassword, test1 ) );
+        assertTrue( entry.contains( atPassword, test2 ) );
+        assertTrue( entry.contains( atPassword, test3 ) );
         
-        // Add twice the same value
-        ServerAttribute sa = entry.put( "userPassword", test1, test2, test1 );
+        // Test the addition of a null value
+        entry.add( "userPassword", (byte[])null );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 4, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, test1 ) );
+        assertTrue( entry.contains( atPassword, test2 ) );
+        assertTrue( entry.contains( atPassword, test3 ) );
+        assertTrue( entry.contains( atPassword, (byte[] )null ) ); 
         
-        assertEquals( 3, sa.size() );
-        assertTrue( sa.contains( test1, test2, test3 ) );
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertEquals( 2, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( "userPassword", test1 ) );
-        assertTrue( entry.contains( "userPassword", test2 ) );
+        entry.clear();
+        
+        // Test the addition of a String value. It should be converted to a byte array
+        byte[] test4 = StringTools.getBytesUtf8( "test4" );
+
+        entry.add( "userPassword", "test4" );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, test4 ) );
     }
 
 
     /**
-     * Test the put( upId, AT, String... ) method
+     * Test the add( upId, SV... ) method
      */
-    @Test public void tesPutUpIDAtStringElipsis() throws NamingException
+    @Test public void testAddUpIdServerValueElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        ServerEntry entry = new DefaultServerEntry( registries, dn );
         
         AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+        AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
         
-        // Test that we get an error when the ID or AT are null
-        try
-        {
-            entry.put( null, (AttributeType)null, (String)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
-        
-        // Test an empty AT
-        entry.put( "commonName", atCN, (String)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertNull( entry.get( atCN ).get().get() );
+        byte[] b1 = StringTools.getBytesUtf8( "test1" );
+        byte[] b2 = StringTools.getBytesUtf8( "test2" );
+        byte[] b3 = StringTools.getBytesUtf8( "test3" );
+
+        Value<String> test1 = new ServerStringValue( atCN, "test1" );
+        Value<String> test2 = new ServerStringValue( atCN, "test2" );
+        Value<String> test3 = new ServerStringValue( atCN, "test3" );
         
-        // Check that we can use a null AttributeType
-        entry.put( "commonName", (AttributeType)null, (String)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertNull( entry.get( atCN ).get().get() );
+        Value<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
+        Value<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
+        Value<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
         
-        // Test that we can use a null upId
-        entry.put( null, atCN, (String)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertNull( entry.get( atCN ).get().get() );
+        // Test a simple addition in atCN
+        entry.add( "cN", test1 );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 1, entry.get( atCN ).size() );
+        assertEquals( "test1", entry.get( atCN ).get().get() );
+        assertTrue( entry.containsAttribute( atCN ) );
+        assertEquals( "cN", entry.get( atCN ).getUpId() );
         
-        // Test that if we use an upId which is not compatible
-        // with the AT, it is changed to the AT default name
-        entry.put( "sn", atCN, (String)null );
-        assertEquals( "cn", entry.get( atCN ).getId() );
+        // Test some more addition
+        entry.add( "cN", test2, test3 );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 3, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
+        assertTrue( entry.containsAttribute( atCN ) );
+        assertEquals( "cN", entry.get( atCN ).getUpId() );
         
-        // Test that we can add some new attributes with values
-        ServerAttribute result = entry.put( "CN", atCN, "test1", "test2", "test3" );
-        assertNotNull( result );
-        assertEquals( "cn", result.getUpId() );
-        assertEquals( 1, entry.size() );
-        assertEquals( "CN", entry.get( atCN ).getUpId() );
-        assertNotNull( entry.get( atCN ).get() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "CN", "test2" ) );
-        assertTrue( entry.contains( "commonName", "test3" ) );
-    }
-
-
-    /**
-     * Test the put( upId, AT, byte[]... ) method
-     */
-    @Test public void tesPutUpIDAtBytesElipsis() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        // Test some addition of existing values
+        entry.add( "cN", test2 );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 3, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
         
-        AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+        // Test the addition of a null value
+        entry.add( "cN", (String)null );
+        assertNotNull( entry.get( atCN ) );
+        assertEquals( 4, entry.get( atCN ).size() );
+        assertTrue( entry.contains( atCN, "test1" ) );
+        assertTrue( entry.contains( atCN, "test2" ) );
+        assertTrue( entry.contains( atCN, "test3" ) );
+        assertTrue( entry.contains( atCN, (String )null ) ); 
         
-        // Test that we get an error when the ID or AT are null
-        try
-        {
-            entry.put( null, (AttributeType)null, (String)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
+        entry.clear();
         
-        // Test an empty AT
-        entry.put( "userPassword", atPassword, (byte[])null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertEquals( "userPassword", entry.get( atPassword ).getAttributeType().getName() );
-        assertNull( entry.get( atPassword ).get().get() );
+        // Test the addition of a String value. It should be converted to a byte array
+        byte[] test4 = StringTools.getBytesUtf8( "test4" );
+
+        entry.add( "cN", test4 );
+        assertFalse( entry.contains( "cN", test4 ) );
+
+        // Now, work with a binary attribute
+        // Test a simple addition
+        entry.add( "userPASSWORD", testB1 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 1, entry.get( atPassword ).size() );
+        assertTrue( Arrays.equals( b1, (byte[])entry.get( atPassword ).get().get() ) );
+        assertTrue( entry.containsAttribute( atPassword ) );
+        assertEquals( "userPASSWORD", entry.get( atPassword ).getUpId() );
         
-        // Check that we can use a null AttributeType
-        try
-        {
-            entry.put( "userPassword", (AttributeType)null, (byte[])null );
-            fail();
-        }
-        catch ( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
+        // Test some more addition
+        entry.add( "userPASSWORD", testB2, testB3 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 3, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, b1 ) );
+        assertTrue( entry.contains( atPassword, b2 ) );
+        assertTrue( entry.contains( atPassword, b3 ) );
         
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertEquals( "userPassword", entry.get( atPassword ).getAttributeType().getName() );
-        assertNull( entry.get( atPassword ).get().get() );
+        // Test some addition of existing values
+        entry.add( "userPASSWORD", testB2 );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 3, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, b1 ) );
+        assertTrue( entry.contains( atPassword, b2 ) );
+        assertTrue( entry.contains( atPassword, b3 ) );
         
-        // Test that we can use a null upId
-        entry.put( null, atPassword, (byte[])null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertEquals( "userPassword", entry.get( atPassword ).getAttributeType().getName() );
-        assertNull( entry.get( atPassword ).get().get() );
+        // Test the addition of a null value
+        entry.add( "userPASSWORD", (byte[])null );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 4, entry.get( atPassword ).size() );
+        assertTrue( entry.contains( atPassword, b1 ) );
+        assertTrue( entry.contains( atPassword, b2 ) );
+        assertTrue( entry.contains( atPassword, b3 ) );
+        assertTrue( entry.contains( atPassword, (byte[] )null ) ); 
         
-        // Test that if we use an upId which is not compatible
-        // with the AT, it is changed to the AT default name
-        entry.put( "sn", atPassword, (byte[])null );
-        assertEquals( "userpassword", entry.get( atPassword ).getId() );
+        entry.clear();
         
-        // Test that we can add some new attributes with values
-        byte[] test1 = StringTools.getBytesUtf8( "test1" );
-        byte[] test2 = StringTools.getBytesUtf8( "test2" );
-        byte[] test3 = StringTools.getBytesUtf8( "test3" );
+        // Test the addition of a String value. It should be converted to a byte array
+        byte[] b4 = StringTools.getBytesUtf8( "test4" );
 
-        ServerAttribute result = entry.put( "UserPassword", atPassword, test1, test2, test3 );
-        assertNotNull( result );
-        assertEquals( "userPassword", result.getUpId() );
-        assertEquals( 1, entry.size() );
-        assertEquals( "UserPassword", entry.get( atPassword ).getUpId() );
-        assertNotNull( entry.get( atPassword ).get() );
-        assertEquals( 3, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( "UserPassword", test1 ) );
-        assertTrue( entry.contains( "userPassword", test2 ) );
-        assertTrue( entry.contains( "2.5.4.35", test3 ) );
+        entry.add( "userPASSWORD", "test4" );
+        assertNotNull( entry.get( atPassword ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, b4 ) );
     }
 
 
     /**
-     * Test the put( upId, AT, SV... ) method
+     * Test the add( UpId, AT, String... ) method
      */
-    @Test public void tesPutUpIDAtSVElipsis() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
-        
-        AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        
-        // Test that we get an error when the ID or AT are null
-        try
-        {
-            entry.put( null, (AttributeType)null, (Value<?>)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
-        
-        // Test an empty AT
-        entry.put( "commonName", atCN, (Value<?>)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertNull( entry.get( atCN ).get().get() );
-        
-        // Check that we can use a null AttributeType
-        entry.put( "commonName", (AttributeType)null, (Value<?>)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertNull( entry.get( atCN ).get().get() );
-        
-        // Test that we can use a null upId
-        entry.put( null, atCN, (Value<?>)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertNull( entry.get( atCN ).get().get() );
-        
-        // Test that we can't use an upId which is not compatible
-        // with the AT
-        try
-        {
-            entry.put( "sn", atCN, (Value<?>)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
-        
-        // Test that we can add some new attributes with values
-        Value<String> test1 = new ServerStringValue( atCN, "test1" );
-        Value<String> test2 = new ServerStringValue( atCN, "test2" );
-        Value<String> test3 = new ServerStringValue( atCN, "test3" );
-
-        ServerAttribute result = entry.put( "CN", atCN, test1, test2, test3 );
-        assertNotNull( result );
-        assertEquals( "cn", result.getUpId() );
-        assertEquals( 1, entry.size() );
-        assertEquals( "CN", entry.get( atCN ).getUpId() );
-        assertNotNull( entry.get( atCN ).get() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "CN", "test2" ) );
-        assertTrue( entry.contains( "commonName", "test3" ) );
-    }
-
-
-    /**
-     * Test the put( upId, SV... ) method
-     */
-    @Test public void tesPutUpIDSVElipsis() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
-        
-        AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        
-        // Test that we get an error when the ID or AT are null
-        try
-        {
-            entry.put( (String)null, (Value<?>)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
-        
-        // Test an null valued AT
-        entry.put( "commonName", (Value<?>)null );
-        assertEquals( 1, entry.size() );
-        assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertNull( entry.get( atCN ).get().get() );
-
-        // Test that we can add some new attributes with values
-        Value<String> test1 = new ServerStringValue( atCN, "test1" );
-        Value<String> test2 = new ServerStringValue( atCN, "test2" );
-        Value<String> test3 = new ServerStringValue( atCN, "test3" );
-
-        ServerAttribute result = entry.put( "CN", test1, test2, test3 );
-        assertNotNull( result );
-        assertEquals( "commonName", result.getUpId() );
-        assertEquals( 1, entry.size() );
-        assertEquals( "CN", entry.get( atCN ).getUpId() );
-        assertNotNull( entry.get( atCN ).get() );
-        assertTrue( entry.contains( "cn", "test1" ) );
-        assertTrue( entry.contains( "CN", "test2" ) );
-        assertTrue( entry.contains( "commonName", "test3" ) );
-    }
-
-    
-    //-------------------------------------------------------------------------
-    // Test the Add methods
-    //-------------------------------------------------------------------------
-
-    /**
-     * Test the add( AT, String... ) method
-     */
-    @Test public void testAddAtStringElipsis() throws NamingException
+    @Test public void testAddUpIdAtStringElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
@@ -1016,13 +1081,13 @@
         AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
         
         // Test a simple addition
-        entry.add( atCN, "test1" );
+        entry.add( "cn", atCN, "test1" );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 1, entry.get( atCN ).size() );
         assertEquals( "test1", entry.get( atCN ).get().get() );
         
         // Test some more addition
-        entry.add( atCN, "test2", "test3" );
+        entry.add( "CN", atCN, "test2", "test3" );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 3, entry.get( atCN ).size() );
         assertTrue( entry.contains( atCN, "test1" ) );
@@ -1030,7 +1095,7 @@
         assertTrue( entry.contains( atCN, "test3" ) );
         
         // Test some addition of existing values
-        entry.add( atCN, "test2" );
+        entry.add( "commonName", atCN, "test2" );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 3, entry.get( atCN ).size() );
         assertTrue( entry.contains( atCN, "test1" ) );
@@ -1038,7 +1103,7 @@
         assertTrue( entry.contains( atCN, "test3" ) );
         
         // Test the addition of a null value
-        entry.add( atCN, (String)null );
+        entry.add( "COMMONname", atCN, (String)null );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 4, entry.get( atCN ).size() );
         assertTrue( entry.contains( atCN, "test1" ) );
@@ -1051,15 +1116,15 @@
         // Test the addition of a binary value
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
         
-        entry.add( atCN, test4 );
-        assertFalse( entry.get( atCN ).contains( test4 ) );
+        entry.add( "cn", atCN, test4 );
+        assertFalse( entry.contains( "cn", test4 ) );
     }
 
 
     /**
-     * Test the add( AT, byte[]... ) method
+     * Test the add( upId, AT, byte[]... ) method
      */
-    @Test public void testAddAtBytesElipsis() throws NamingException
+    @Test public void testAddUpIdAtBytesElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
@@ -1071,13 +1136,13 @@
         byte[] test3 = StringTools.getBytesUtf8( "test3" );
         
         // Test a simple addition
-        entry.add( atPassword, test1 );
+        entry.add( "userPassword", atPassword, test1 );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 1, entry.get( atPassword ).size() );
         assertTrue( Arrays.equals( test1, (byte[])entry.get( atPassword ).get().get() ) );
         
         // Test some more addition
-        entry.add( atPassword, test2, test3 );
+        entry.add( "userPassword", atPassword, test2, test3 );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 3, entry.get( atPassword ).size() );
         assertTrue( entry.contains( atPassword, test1 ) );
@@ -1085,7 +1150,7 @@
         assertTrue( entry.contains( atPassword, test3 ) );
         
         // Test some addition of existing values
-        entry.add( atPassword, test2 );
+        entry.add( "userPassword", atPassword, test2 );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 3, entry.get( atPassword ).size() );
         assertTrue( entry.contains( atPassword, test1 ) );
@@ -1093,7 +1158,7 @@
         assertTrue( entry.contains( atPassword, test3 ) );
         
         // Test the addition of a null value
-        entry.add( atPassword, (byte[])null );
+        entry.add( "userPassword", atPassword, (byte[])null );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 4, entry.get( atPassword ).size() );
         assertTrue( entry.contains( atPassword, test1 ) );
@@ -1106,7 +1171,7 @@
         // Test the addition of a String value. It should be converted to a byte array
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
 
-        entry.add( atPassword, "test4" );
+        entry.add( "userPassword", atPassword, "test4" );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 0, entry.get( atPassword ).size() );
         assertFalse( entry.contains( atPassword, test4 ) );
@@ -1114,12 +1179,12 @@
 
 
     /**
-     * Test the add( AT, SV... ) method
+     * Test the add( upId, AT, SV... ) method
      */
-    @Test public void testAddAtServerValueElipsis() throws NamingException
+    @Test public void testAddUpIdAtServerValueElipsis() throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        ServerEntry entry = new DefaultServerEntry( registries, dn );
         
         AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
         AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
@@ -1137,21 +1202,25 @@
         Value<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
         
         // Test a simple addition in atCN
-        entry.add( atCN, test1 );
+        entry.add( "cN", atCN, test1 );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 1, entry.get( atCN ).size() );
         assertEquals( "test1", entry.get( atCN ).get().get() );
+        assertTrue( entry.containsAttribute( atCN ) );
+        assertEquals( "cN", entry.get( atCN ).getUpId() );
         
         // Test some more addition
-        entry.add( atCN, test2, test3 );
+        entry.add( "cN", atCN, test2, test3 );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 3, entry.get( atCN ).size() );
         assertTrue( entry.contains( atCN, "test1" ) );
         assertTrue( entry.contains( atCN, "test2" ) );
         assertTrue( entry.contains( atCN, "test3" ) );
+        assertTrue( entry.containsAttribute( atCN ) );
+        assertEquals( "cN", entry.get( atCN ).getUpId() );
         
         // Test some addition of existing values
-        entry.add( atCN, test2 );
+        entry.add( "cN", atCN, test2 );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 3, entry.get( atCN ).size() );
         assertTrue( entry.contains( atCN, "test1" ) );
@@ -1159,7 +1228,7 @@
         assertTrue( entry.contains( atCN, "test3" ) );
         
         // Test the addition of a null value
-        entry.add( atCN, (String)null );
+        entry.add( "cN", atCN, (String)null );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 4, entry.get( atCN ).size() );
         assertTrue( entry.contains( atCN, "test1" ) );
@@ -1172,18 +1241,20 @@
         // Test the addition of a String value. It should be converted to a byte array
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
 
-        entry.add( atCN, test4 );
-        assertFalse( entry.contains( atCN, test4 ) );
+        entry.add( "cN", atCN, test4 );
+        assertFalse( entry.contains( "cN", test4 ) );
 
         // Now, work with a binary attribute
         // Test a simple addition
-        entry.add( atPassword, testB1 );
+        entry.add( "userPASSWORD", atPassword, testB1 );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 1, entry.get( atPassword ).size() );
         assertTrue( Arrays.equals( b1, (byte[])entry.get( atPassword ).get().get() ) );
+        assertTrue( entry.containsAttribute( atPassword ) );
+        assertEquals( "userPASSWORD", entry.get( atPassword ).getUpId() );
         
         // Test some more addition
-        entry.add( atPassword, testB2, testB3 );
+        entry.add( "userPASSWORD", atPassword, testB2, testB3 );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 3, entry.get( atPassword ).size() );
         assertTrue( entry.contains( atPassword, b1 ) );
@@ -1191,7 +1262,7 @@
         assertTrue( entry.contains( atPassword, b3 ) );
         
         // Test some addition of existing values
-        entry.add( atPassword, testB2 );
+        entry.add( "userPASSWORD", atPassword, testB2 );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 3, entry.get( atPassword ).size() );
         assertTrue( entry.contains( atPassword, b1 ) );
@@ -1199,7 +1270,7 @@
         assertTrue( entry.contains( atPassword, b3 ) );
         
         // Test the addition of a null value
-        entry.add( atPassword, (byte[])null );
+        entry.add( "userPASSWORD", atPassword, (byte[])null );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 4, entry.get( atPassword ).size() );
         assertTrue( entry.contains( atPassword, b1 ) );
@@ -1212,7 +1283,7 @@
         // Test the addition of a String value. It should be converted to a byte array
         byte[] b4 = StringTools.getBytesUtf8( "test4" );
 
-        entry.add( atPassword, "test4" );
+        entry.add( "userPASSWORD", atPassword, "test4" );
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 0, entry.get( atPassword ).size() );
         assertFalse( entry.contains( atPassword, b4 ) );
@@ -1220,459 +1291,2214 @@
 
 
     /**
-     * Test the add( upId, String... ) method
+     * Test method for clear()
      */
-    @Test public void testAddUpIdStringElipsis() throws NamingException
+    @Test
+    public void testClear() throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+         
+        assertEquals( 0, entry.size() );
+        assertNull( entry.get( "ObjectClass" ) );
+        entry.clear();
+        assertEquals( 0, entry.size() );
+        assertNull( entry.get( "ObjectClass" ) );
+         
+        entry.add( "ObjectClass", "top", "person" );
+        assertEquals( 1, entry.size() );
+        assertNotNull( entry.get( "ObjectClass" ) );
         
-        AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+        entry.clear();
+        assertEquals( 0, entry.size() );
+        assertNull( entry.get( "ObjectClass" ) );
+    }
+
+
+    /**
+     * Test method for clone()
+     */
+    @Test
+    public void testClone() throws NamingException
+    {
+        Entry entry1 = new DefaultServerEntry( registries );
         
-        // Test a simple addition
-        entry.add( "CN", "test1" );
-        assertNotNull( entry.get( atCN ) );
-        assertEquals( atCN, entry.get( atCN ).getAttributeType() );
-        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
-        assertEquals( "CN", entry.get( atCN ).getUpId() );
-        assertEquals( 1, entry.get( atCN ).size() );
-        assertEquals( "test1", entry.get( atCN ).get().get() );
+        Entry entry2 = entry1.clone();
         
-        // Test some more addition
-        entry.add( "CN", "test2", "test3" );
-        assertNotNull( entry.get( atCN ) );
-        assertEquals( 3, entry.get( atCN ).size() );
-        assertTrue( entry.contains( atCN, "test1" ) );
-        assertTrue( entry.contains( atCN, "test2" ) );
-        assertTrue( entry.contains( atCN, "test3" ) );
+        assertEquals( entry1, entry2 );
+        entry2.setDn( EXAMPLE_DN );
         
-        // Test some addition of existing values
-        entry.add( "CN", "test2" );
-        assertNotNull( entry.get( atCN ) );
-        assertEquals( 3, entry.get( atCN ).size() );
-        assertTrue( entry.contains( atCN, "test1" ) );
-        assertTrue( entry.contains( atCN, "test2" ) );
-        assertTrue( entry.contains( atCN, "test3" ) );
+        assertNull( entry1.getDn() );
         
-        // Test the addition of a null value
-        entry.add( "CN", (String)null );
-        assertNotNull( entry.get( atCN ) );
-        assertEquals( 4, entry.get( atCN ).size() );
-        assertTrue( entry.contains( atCN, "test1" ) );
-        assertTrue( entry.contains( atCN, "test2" ) );
-        assertTrue( entry.contains( atCN, "test3" ) );
-        assertTrue( entry.contains( atCN, (String )null ) ); 
+        entry1.setDn( EXAMPLE_DN );
+        entry2 = entry1.clone();
+        assertEquals( entry1, entry2 );
         
-        entry.clear();
+        entry1.add( "objectClass", "top", "person" );
+        entry1.add( "cn", "test1", "test2" );
         
-        // Test the addition of a binary value
-        byte[] test4 = StringTools.getBytesUtf8( "test4" );
+        entry2 = entry1.clone();
+        assertEquals( entry1, entry2 );
         
-        entry.add( "CN", test4 );
-        assertFalse( entry.contains(  "CN", test4 ) );
+        entry1.add( "cn", "test3" );
+        assertEquals( 2, entry2.get( "cn" ).size() );
+        assertFalse( entry2.contains( "cn", "test3" ) );
+        
+        entry1.add( "sn", (String)null );
+        assertFalse( entry2.containsAttribute( "sn" ) );
     }
-
-
+     
+    
+    //-------------------------------------------------------------------------
+    // Test the Contains methods
+    //-------------------------------------------------------------------------
     /**
-     * Test the add( upId, byte[]... ) method
+     * Test for method contains( AttributeType, byte[]... )
      */
-    @Test public void testAddUpIdBytesElipsis() throws NamingException
+    @Test
+    public void testContainsAttributeTypeByteArrayArray() throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=test" );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
         
-        AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+        assertFalse( entry.contains( (AttributeType )null, BYTES1 ) );
+        assertFalse( entry.contains( atPwd, BYTES1 ) );
         
-        byte[] test1 = StringTools.getBytesUtf8( "test1" );
-        byte[] test2 = StringTools.getBytesUtf8( "test2" );
-        byte[] test3 = StringTools.getBytesUtf8( "test3" );
+        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
+
+        assertFalse( entry.contains( attrPWD ) );
         
-        // Test a simple addition
-        entry.add( "userPassword", test1 );
-        assertNotNull( entry.get( atPassword ) );
-        assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( Arrays.equals( test1, (byte[])entry.get( atPassword ).get().get() ) );
+        entry.add( attrPWD );
         
-        // Test some more addition
-        entry.add( "userPassword", test2, test3 );
-        assertNotNull( entry.get( atPassword ) );
-        assertEquals( 3, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( atPassword, test1 ) );
-        assertTrue( entry.contains( atPassword, test2 ) );

[... 2840 lines stripped ...]


Mime
View raw message