directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r638228 [6/20] - in /directory/sandbox/akarasulu/bigbang/apacheds: ./ apacheds-xbean-spring/src/site/ benchmarks/src/site/ bootstrap-extract/src/site/ bootstrap-partition/src/site/ bootstrap-plugin/src/main/java/org/apache/directory/server/...
Date Tue, 18 Mar 2008 06:13:18 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=638228&r1=638227&r2=638228&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 Mon Mar 17 23:12:41 2008
@@ -29,7 +29,6 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
@@ -44,6 +43,7 @@
 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.Value;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -53,6 +53,7 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 
@@ -68,7 +69,6 @@
     private static BootstrapSchemaLoader loader;
     private static Registries registries;
     private static OidRegistry oidRegistry;
-    //private static AttributeType AT;
     
     /**
      * Initialize the registries once for the whole test suite
@@ -89,281 +89,6 @@
         bootstrapSchemas.add( new InetorgpersonSchema() );
         bootstrapSchemas.add( new CosineSchema() );
         loader.loadWithDependencies( bootstrapSchemas, registries );
-        
-        /*
-        AT = new AttributeType()
-        {
-            private static final long serialVersionUID = 1L;
-
-            public boolean isSingleValue()
-            {
-                return false;
-            }
-
-
-            public boolean isCanUserModify()
-            {
-                return true;
-            }
-
-
-            public boolean isCollective()
-            {
-                return false;
-            }
-
-
-            public UsageEnum getUsage()
-            {
-                return null;
-            }
-
-
-            public AttributeType getSuperior() throws NamingException
-            {
-                return null;
-            }
-
-
-            public Syntax getSyntax() throws NamingException
-            {
-                return new Syntax()
-                {
-
-                    private static final long serialVersionUID = 1L;
-
-                    public boolean isHumanReadable()
-                    {
-                        return true;
-                    }
-
-                    public SyntaxChecker getSyntaxChecker() throws NamingException
-                    {
-                        return null;
-                    }
-
-                    public boolean isObsolete()
-                    {
-                        return false;
-                    }
-
-                    public String getOid()
-                    {
-                        return null;
-                    }
-
-                    public String[] getNames()
-                    {
-                        return null;
-                    }
-
-                    public String getName()
-                    {
-                        return null;
-                    }
-
-                    public String getDescription()
-                    {
-                        return null;
-                    }
-
-                    public String getSchema()
-                    {
-                        return null;
-                    }
-
-                    public void setSchema( String schemaName )
-                    {
-                    }
-                };
-            }
-
-
-            public int getLength()
-            {
-                return 0;
-            }
-
-
-            public MatchingRule getEquality() throws NamingException
-            {
-                return new MatchingRule()
-                {
-                    private static final long serialVersionUID = 1L;
-
-                    public Syntax getSyntax() throws NamingException
-                    {
-                        return new Syntax()
-                        {
-                            private static final long serialVersionUID = 1L;
-
-
-                            public boolean isHumanReadable()
-                            {
-                                return true;
-                            }
-
-                            public SyntaxChecker getSyntaxChecker() throws NamingException
-                            {
-                                return null;
-                            }
-
-                            public boolean isObsolete()
-                            {
-                                return false;
-                            }
-
-                            public String getOid()
-                            {
-                                return null;
-                            }
-
-                            public String[] getNames()
-                            {
-                                return null;
-                            }
-
-                            public String getName()
-                            {
-                                return null;
-                            }
-
-                            public String getDescription()
-                            {
-                                return null;
-                            }
-
-                            public String getSchema()
-                            {
-                                return null;
-                            }
-
-                            public void setSchema( String schemaName )
-                            {
-                            }
-                        };
-                    }
-
-                    public Comparator getComparator() throws NamingException
-                    {
-                        return null;
-                    }
-
-                    public Normalizer getNormalizer() throws NamingException
-                    {
-                        return new Normalizer()
-                        {
-                            private static final long serialVersionUID = 1L;
-
-                            public Object normalize( Object value ) throws NamingException
-                            {
-                                return StringTools.deepTrimToLower( value.toString() );
-                            }
-                        };
-                    }
-
-                    public boolean isObsolete()
-                    {
-                        return false;
-                    }
-
-                    public String getOid()
-                    {
-                        return null;
-                    }
-
-                    public String[] getNames()
-                    {
-                        return null;
-                    }
-
-                    public String getName()
-                    {
-                        return null;
-                    }
-
-                    public String getDescription()
-                    {
-                        return null;
-                    }
-
-                    public String getSchema()
-                    {
-                        return null;
-                    }
-
-                    public void setSchema( String schemaName )
-                    {
-                    }
-                };
-            }
-
-
-            public MatchingRule getOrdering() throws NamingException
-            {
-                return null;
-            }
-
-
-            public MatchingRule getSubstr() throws NamingException
-            {
-                return null;
-            }
-
-
-            public boolean isAncestorOf( AttributeType descendant ) throws NamingException
-            {
-                return false;
-            }
-
-
-            public boolean isDescentantOf( AttributeType ancestor ) throws NamingException
-            {
-                return false;
-            }
-
-
-            public boolean isObsolete()
-            {
-                return false;
-            }
-
-
-            public String getOid()
-            {
-                return "1.2.3";
-            }
-
-
-            public String[] getNames()
-            {
-                return new String[]
-                    { "test" };
-            }
-
-
-            public String getName()
-            {
-                return "test";
-            }
-
-
-            public String getDescription()
-            {
-                return "test";
-            }
-
-
-            public String getSchema()
-            {
-                return null;
-            }
-
-
-            public void setSchema( String schemaName )
-            {
-            }
-        };*/
     }
 
 
@@ -375,11 +100,10 @@
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         
-        ObjectClassAttribute oc = new ObjectClassAttribute( registries );
-        oc.add( "top", "person", "inetOrgPerson" );
+        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
         
-        entry.addObjectClass( oc );
-        //entry.put( "cn", registries.getAttributeTypeRegistry().lookup( "cn" ), "test" );
+        entry.put( "objectClass", OBJECT_CLASS_AT, "top", "person", "inetOrgPerson", "organizationalPerson" );
+        entry.put( "cn", registries.getAttributeTypeRegistry().lookup( "cn" ), "test" );
         
         Attributes attributes = ServerEntryUtils.toAttributesImpl( entry );
         
@@ -399,8 +123,8 @@
             
         }
 
-        // We should still have the ObjectClass Attribute
-        assertEquals( 1, expected.size() );
+        // It should be empty
+        assertEquals( 0, expected.size() );
     }
 
 
@@ -412,11 +136,9 @@
         LdapDN dn = new LdapDN( "cn=test" );
         DefaultServerEntry entry = new DefaultServerEntry( registries,dn );
         
-        ObjectClassAttribute oc = new ObjectClassAttribute( registries );
-        oc.add( "top", "person", "inetOrgPerson" );
+        AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
         
-        entry.addObjectClass( oc );
-        //entry.put( "cn", registries.getAttributeTypeRegistry().lookup( "cn" ), "test" );
+        entry.put( "objectClass", OBJECT_CLASS_AT, "top", "person", "inetOrgPerson", "organizationalPerson" );
         
         Attributes attributes = ServerEntryUtils.toBasicAttributes( entry );
         
@@ -472,8 +194,8 @@
         assertEquals( 0, result.size() );
         ServerAttribute sa = entry.get( "sn" );
         assertNotNull( sa );
-        assertEquals( atSN, sa.getType() );
-        assertEquals( "sn", sa.getType().getName() );
+        assertEquals( atSN, sa.getAttributeType() );
+        assertEquals( "sn", sa.getAttributeType().getName() );
         
         // Add two AT now
         AttributeType atL = registries.getAttributeTypeRegistry().lookup( "localityName" );
@@ -487,23 +209,23 @@
         assertEquals( 0, result.size() );
         sa = entry.get( "l" );
         assertNotNull( sa );
-        assertEquals( atL, sa.getType() );
-        assertEquals( "l", sa.getType().getName() );
+        assertEquals( atL, sa.getAttributeType() );
+        assertEquals( "l", sa.getAttributeType().getName() );
 
         sa = entry.get( "c" );
         assertNotNull( sa );
-        assertEquals( atC, sa.getType() );
-        assertEquals( "c", sa.getType().getName() );
+        assertEquals( atC, sa.getAttributeType() );
+        assertEquals( "c", sa.getAttributeType().getName() );
 
         sa = entry.get( "2.5.4.9" );
         assertNotNull( sa );
-        assertEquals( atStreet, sa.getType() );
-        assertEquals( "street", sa.getType().getName() );
+        assertEquals( atStreet, sa.getAttributeType() );
+        assertEquals( "street", sa.getAttributeType().getName() );
 
         sa = entry.get( "givenName" );
         assertNotNull( sa );
-        assertEquals( atGN, sa.getType() );
-        assertEquals( "givenName", sa.getType().getName() );
+        assertEquals( atGN, sa.getAttributeType() );
+        assertEquals( "givenName", sa.getAttributeType().getName() );
         
         // Now try to add existing ATs
         // First, set some value to the modified AT
@@ -529,7 +251,7 @@
 
         ServerAttribute oc = entry.get( "objectClass" );
         
-        assertEquals( OBJECT_CLASS_AT, oc.getType() );
+        assertEquals( OBJECT_CLASS_AT, oc.getAttributeType() );
         assertNull( oc.get() );
     }
 
@@ -580,7 +302,7 @@
 
         ServerAttribute sa = entry.get( "sn" );
         assertNotNull( sa );
-        assertEquals( "sn", sa.getType().getName() );
+        assertEquals( "sn", sa.getAttributeType().getName() );
         
         // Add different upIds now
         AttributeType atL = registries.getAttributeTypeRegistry().lookup( "localityName" );
@@ -596,26 +318,26 @@
 
         sa = entry.get( "l" );
         assertNotNull( sa );
-        assertEquals( atL, sa.getType() );
-        assertEquals( "l", sa.getType().getName() );
+        assertEquals( atL, sa.getAttributeType() );
+        assertEquals( "l", sa.getAttributeType().getName() );
         assertEquals( "L", sa.getUpId() );
 
         sa = entry.get( "c" );
         assertNotNull( sa );
-        assertEquals( atC, sa.getType() );
-        assertEquals( "c", sa.getType().getName() );
+        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.getType() );
-        assertEquals( "street", sa.getType().getName() );
+        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.getType() );
-        assertEquals( "givenName", sa.getType().getName() );
+        assertEquals( atGN, sa.getAttributeType() );
+        assertEquals( "givenName", sa.getAttributeType().getName() );
         assertEquals( "gn", sa.getUpId() );
         
         // Now try to add existing ATs
@@ -663,7 +385,7 @@
         ServerAttribute sa = new DefaultServerAttribute( atL, "france" );
         entry.put( sa );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertNotNull( entry.get( "l" ) );
         assertEquals( "france", entry.get( "l" ).get().get() );
         
@@ -672,7 +394,7 @@
         ServerAttribute sd = new DefaultServerAttribute( atStreet, "testStreet" );
         entry.put( sb, sc, sd );
 
-        assertEquals( 5, entry.size() );
+        assertEquals( 4, entry.size() );
         assertNotNull( entry.get( atC ) );
         assertEquals( "countryTest", entry.get( atC ).get().get() );
         assertNotNull( entry.get( atGN ) );
@@ -688,7 +410,7 @@
         assertEquals( 2, result.size() );
         assertEquals( "countryTest", result.get(0).get().get() );
         assertEquals( "test", result.get(1).get().get() );
-        assertEquals( 5, entry.size() );
+        assertEquals( 4, entry.size() );
         assertNotNull( entry.get( atC ) );
         assertEquals( "countryTestTest", entry.get( atC ).get().get() );
         assertNotNull( entry.get( atGN ) );
@@ -698,19 +420,18 @@
         
         // test an ObjectClass replacement
         AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
-        ServerAttribute oc = new ObjectClassAttribute( registries, "OBJECTCLASS", "person", "inetorgperson" );
+        ServerAttribute oc = new DefaultServerAttribute( "OBJECTCLASS", OBJECT_CLASS_AT, "person", "inetorgperson" );
         List<ServerAttribute> oldOc = entry.put( oc );
         
         assertNotNull( oldOc );
-        assertEquals( 1, oldOc.size() );
-        assertEquals( "top", oldOc.get( 0 ).get().get() );
+        assertEquals( 0, oldOc.size() );
         
         assertNotNull( entry.get( "objectClass" ) );
 
         ServerAttribute newOc = entry.get( "objectClass" );
         
         assertNotNull( newOc );
-        assertEquals( OBJECT_CLASS_AT, newOc.getType() );
+        assertEquals( OBJECT_CLASS_AT, newOc.getAttributeType() );
         assertEquals( 2, newOc.size() );
         assertEquals( "OBJECTCLASS", newOc.getUpId() );
         assertTrue( newOc.contains( "person", "inetOrgPerson" ) );
@@ -729,7 +450,7 @@
 
         // Test an empty AT
         entry.put( atCN, (String)null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertNull( entry.get( atCN ).get().get() );
         
@@ -748,7 +469,7 @@
         atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
         entry.put( atCN, "test" );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 1, entry.get( atCN ).size() );
         assertEquals( "test", entry.get( atCN ).get().get() );
@@ -756,7 +477,7 @@
         // Add more than one value
         entry.put( atCN, "test1", "test2", "test3" );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 3, entry.get( atCN ).size() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -768,7 +489,7 @@
         
         assertEquals( 3, sa.size() );
         assertTrue( sa.contains( "test1", "test2", "test3" ) );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 2, entry.get( atCN ).size() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -788,7 +509,7 @@
 
         // Test an empty AT
         entry.put( atPwd, (byte[])null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
         assertNull( entry.get( atPwd ).get().get() );
         
@@ -812,7 +533,7 @@
         atPwd = registries.getAttributeTypeRegistry().lookup( "userPassword" );
         entry.put( atPwd, password );
         
-        assertEquals( 2, entry.size() );
+        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() ) );
@@ -820,7 +541,7 @@
         // Add more than one value
         entry.put( atPwd, test1, test2, test3 );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
         assertEquals( 3, entry.get( atPwd ).size() );
         assertTrue( entry.contains( "userpassword", test1 ) );
@@ -832,7 +553,7 @@
         
         assertEquals( 3, sa.size() );
         assertTrue( sa.contains( test1, test2, test3 ) );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
         assertEquals( 2, entry.get( atPwd ).size() );
         assertTrue( entry.contains( "userpassword", test1 ) );
@@ -841,7 +562,7 @@
     
 
     /**
-     * Test the put( AT, ServerValue... ) method
+     * Test the put( AT, Value... ) method
      */
     @Test public void tesPutAtSVs() throws NamingException
     {
@@ -850,15 +571,15 @@
         
         // Adding a null value to an attribute
         AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        entry.put( atCN, (ServerValue<?>)null );
+        entry.put( atCN, (Value<?>)null );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         
         // Check that we can't use invalid arguments
         try
         {
-            entry.put( (AttributeType)null, (ServerValue<?>)null );
+            entry.put( (AttributeType)null, (Value<?>)null );
             fail();
         }
         catch( IllegalArgumentException iae )
@@ -868,10 +589,10 @@
         
         // Add a single value
         atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        ServerValue<?> ssv = new ServerStringValue( atCN, "test" );
+        Value<?> ssv = new ServerStringValue( atCN, "test" );
         entry.put( atCN, ssv );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 1, entry.get( atCN ).size() );
         assertEquals( "test", entry.get( atCN ).get().get() );
@@ -881,7 +602,7 @@
                          new ServerStringValue( atCN, "test2" ), 
                          new ServerStringValue( atCN, "test3" ));
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 3, entry.get( atCN ).size() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -895,7 +616,7 @@
         
         assertEquals( 3, sa.size() );
         assertTrue( sa.contains( "test1", "test2", "test3" ) );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 2, entry.get( atCN ).size() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -916,7 +637,7 @@
         // Adding a null value should be possible
         entry.put( "cn", (String)null );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertNull( entry.get( atCN ).get().get() );
         
@@ -935,7 +656,7 @@
         atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
         entry.put( "cn", "test" );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 1, entry.get( atCN ).size() );
         assertEquals( "test", entry.get( atCN ).get().get() );
@@ -943,7 +664,7 @@
         // Add more than one value
         entry.put( "cn", "test1", "test2", "test3" );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 3, entry.get( atCN ).size() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -955,7 +676,7 @@
         
         assertEquals( 3, sa.size() );
         assertTrue( sa.contains( "test1", "test2", "test3" ) );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
         assertEquals( 2, entry.get( atCN ).size() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -979,7 +700,7 @@
         
         // Adding a null value should be possible
         entry.put( "userPassword", (byte[])null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
         assertNull( entry.get( atPassword ).get().get() );
         
@@ -1002,7 +723,7 @@
         
         entry.put( "userPassword", test );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
         assertEquals( 1, entry.get( atPassword ).size() );
         assertTrue( Arrays.equals( test, (byte[])entry.get( atPassword ).get().get() ) );
@@ -1010,7 +731,7 @@
         // Add more than one value
         entry.put( "userPassword", test1, test2, test3 );
         
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
         assertEquals( 3, entry.get( atPassword ).size() );
         assertTrue( entry.contains( "userPassword", test1 ) );
@@ -1022,7 +743,7 @@
         
         assertEquals( 3, sa.size() );
         assertTrue( sa.contains( test1, test2, test3 ) );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
         assertEquals( 2, entry.get( atPassword ).size() );
         assertTrue( entry.contains( "userPassword", test1 ) );
@@ -1053,42 +774,35 @@
         
         // Test an empty AT
         entry.put( "commonName", atCN, (String)null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        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, (String)null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        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, (String)null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        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, (String)null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
+        // 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 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( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "CN", entry.get( atCN ).getUpId() );
         assertNotNull( entry.get( atCN ).get() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -1120,36 +834,38 @@
         
         // Test an empty AT
         entry.put( "userPassword", atPassword, (byte[])null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertEquals( "userPassword", entry.get( atPassword ).getType().getName() );
+        assertEquals( "userPassword", entry.get( atPassword ).getAttributeType().getName() );
         assertNull( entry.get( atPassword ).get().get() );
         
         // Check that we can use a null AttributeType
-        entry.put( "userPassword", (AttributeType)null, (byte[])null );
-        assertEquals( 2, entry.size() );
+        try
+        {
+            entry.put( "userPassword", (AttributeType)null, (byte[])null );
+            fail();
+        }
+        catch ( IllegalArgumentException iae )
+        {
+            assertTrue( true );
+        }
+        
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertEquals( "userPassword", entry.get( atPassword ).getType().getName() );
+        assertEquals( "userPassword", entry.get( atPassword ).getAttributeType().getName() );
         assertNull( entry.get( atPassword ).get().get() );
         
         // Test that we can use a null upId
         entry.put( null, atPassword, (byte[])null );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
-        assertEquals( "userPassword", entry.get( atPassword ).getType().getName() );
+        assertEquals( "userPassword", entry.get( atPassword ).getAttributeType().getName() );
         assertNull( entry.get( atPassword ).get().get() );
         
-        // Test that we can't use an upId which is not compatible
-        // with the AT
-        try
-        {
-            entry.put( "sn", atPassword, (byte[])null );
-            fail();
-        }
-        catch( IllegalArgumentException iae )
-        {
-            assertTrue( true );
-        }
+        // 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() );
         
         // Test that we can add some new attributes with values
         byte[] test1 = StringTools.getBytesUtf8( "test1" );
@@ -1159,7 +875,7 @@
         ServerAttribute result = entry.put( "UserPassword", atPassword, test1, test2, test3 );
         assertNotNull( result );
         assertEquals( "userPassword", result.getUpId() );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "UserPassword", entry.get( atPassword ).getUpId() );
         assertNotNull( entry.get( atPassword ).get() );
         assertEquals( 3, entry.get( atPassword ).size() );
@@ -1182,7 +898,7 @@
         // Test that we get an error when the ID or AT are null
         try
         {
-            entry.put( null, (AttributeType)null, (ServerValue<?>)null );
+            entry.put( null, (AttributeType)null, (Value<?>)null );
             fail();
         }
         catch( IllegalArgumentException iae )
@@ -1191,31 +907,31 @@
         }
         
         // Test an empty AT
-        entry.put( "commonName", atCN, (ServerValue<?>)null );
-        assertEquals( 2, entry.size() );
+        entry.put( "commonName", atCN, (Value<?>)null );
+        assertEquals( 1, entry.size() );
         assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        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, (ServerValue<?>)null );
-        assertEquals( 2, entry.size() );
+        entry.put( "commonName", (AttributeType)null, (Value<?>)null );
+        assertEquals( 1, entry.size() );
         assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        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, (ServerValue<?>)null );
-        assertEquals( 2, entry.size() );
+        entry.put( null, atCN, (Value<?>)null );
+        assertEquals( 1, entry.size() );
         assertEquals( "cn", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        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, (ServerValue<?>)null );
+            entry.put( "sn", atCN, (Value<?>)null );
             fail();
         }
         catch( IllegalArgumentException iae )
@@ -1224,14 +940,14 @@
         }
         
         // Test that we can add some new attributes with values
-        ServerValue<String> test1 = new ServerStringValue( atCN, "test1" );
-        ServerValue<String> test2 = new ServerStringValue( atCN, "test2" );
-        ServerValue<String> test3 = new ServerStringValue( atCN, "test3" );
+        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( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "CN", entry.get( atCN ).getUpId() );
         assertNotNull( entry.get( atCN ).get() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -1253,7 +969,7 @@
         // Test that we get an error when the ID or AT are null
         try
         {
-            entry.put( (String)null, (ServerValue<?>)null );
+            entry.put( (String)null, (Value<?>)null );
             fail();
         }
         catch( IllegalArgumentException iae )
@@ -1262,21 +978,21 @@
         }
         
         // Test an null valued AT
-        entry.put( "commonName", (ServerValue<?>)null );
-        assertEquals( 2, entry.size() );
+        entry.put( "commonName", (Value<?>)null );
+        assertEquals( 1, entry.size() );
         assertEquals( "commonName", entry.get( atCN ).getUpId() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        assertEquals( "cn", entry.get( atCN ).getAttributeType().getName() );
         assertNull( entry.get( atCN ).get().get() );
 
         // Test that we can add some new attributes with values
-        ServerValue<String> test1 = new ServerStringValue( atCN, "test1" );
-        ServerValue<String> test2 = new ServerStringValue( atCN, "test2" );
-        ServerValue<String> test3 = new ServerStringValue( atCN, "test3" );
+        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( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertEquals( "CN", entry.get( atCN ).getUpId() );
         assertNotNull( entry.get( atCN ).get() );
         assertTrue( entry.contains( "cn", "test1" ) );
@@ -1335,15 +1051,8 @@
         // Test the addition of a binary value
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
         
-        try
-        {
-            entry.add( atCN, test4 );
-            fail();
-        }
-        catch ( InvalidAttributeValueException iave )
-        {
-            assertTrue( true );
-        }
+        entry.add( atCN, test4 );
+        assertFalse( entry.get( atCN ).contains( test4 ) );
     }
 
 
@@ -1399,8 +1108,8 @@
 
         entry.add( atPassword, "test4" );
         assertNotNull( entry.get( atPassword ) );
-        assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( atPassword, test4 ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, test4 ) );
     }
 
 
@@ -1419,13 +1128,13 @@
         byte[] b2 = StringTools.getBytesUtf8( "test2" );
         byte[] b3 = StringTools.getBytesUtf8( "test3" );
 
-        ServerValue<String> test1 = new ServerStringValue( atCN, "test1" );
-        ServerValue<String> test2 = new ServerStringValue( atCN, "test2" );
-        ServerValue<String> test3 = new ServerStringValue( atCN, "test3" );
-        
-        ServerValue<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
-        ServerValue<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
-        ServerValue<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
+        Value<String> test1 = new ServerStringValue( atCN, "test1" );
+        Value<String> test2 = new ServerStringValue( atCN, "test2" );
+        Value<String> test3 = new ServerStringValue( atCN, "test3" );
+        
+        Value<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
+        Value<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
+        Value<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
         
         // Test a simple addition in atCN
         entry.add( atCN, test1 );
@@ -1463,15 +1172,8 @@
         // Test the addition of a String value. It should be converted to a byte array
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
 
-        try
-        {
-            entry.add( atCN, test4 );
-            fail();
-        }
-        catch ( InvalidAttributeValueException iave )
-        {
-            assertTrue( true );
-        }
+        entry.add( atCN, test4 );
+        assertFalse( entry.contains( atCN, test4 ) );
 
         // Now, work with a binary attribute
         // Test a simple addition
@@ -1512,8 +1214,8 @@
 
         entry.add( atPassword, "test4" );
         assertNotNull( entry.get( atPassword ) );
-        assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( atPassword, b4 ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, b4 ) );
     }
 
 
@@ -1530,8 +1232,8 @@
         // Test a simple addition
         entry.add( "CN", "test1" );
         assertNotNull( entry.get( atCN ) );
-        assertEquals( atCN, entry.get( atCN ).getType() );
-        assertEquals( "cn", entry.get( atCN ).getType().getName() );
+        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() );
@@ -1566,15 +1268,8 @@
         // Test the addition of a binary value
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
         
-        try
-        {
-            entry.add( "CN", test4 );
-            fail();
-        }
-        catch ( InvalidAttributeValueException iave )
-        {
-            assertTrue( true );
-        }
+        entry.add( "CN", test4 );
+        assertFalse( entry.contains(  "CN", test4 ) );
     }
 
 
@@ -1630,8 +1325,8 @@
 
         entry.add( "userPassword", "test4" );
         assertNotNull( entry.get( atPassword ) );
-        assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( atPassword, test4 ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, test4 ) );
     }
 
 
@@ -1650,20 +1345,20 @@
         byte[] b2 = StringTools.getBytesUtf8( "test2" );
         byte[] b3 = StringTools.getBytesUtf8( "test3" );
 
-        ServerValue<String> test1 = new ServerStringValue( atCN, "test1" );
-        ServerValue<String> test2 = new ServerStringValue( atCN, "test2" );
-        ServerValue<String> test3 = new ServerStringValue( atCN, "test3" );
-        
-        ServerValue<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
-        ServerValue<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
-        ServerValue<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
+        Value<String> test1 = new ServerStringValue( atCN, "test1" );
+        Value<String> test2 = new ServerStringValue( atCN, "test2" );
+        Value<String> test3 = new ServerStringValue( atCN, "test3" );
+        
+        Value<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
+        Value<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
+        Value<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
         
         // 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() );
-        assertEquals( atCN, entry.get( atCN ).getType() );
+        assertEquals( atCN, entry.get( atCN ).getAttributeType() );
         assertEquals( "cN", entry.get( atCN ).getUpId() );
         
         // Test some more addition
@@ -1673,7 +1368,7 @@
         assertTrue( entry.contains( atCN, "test1" ) );
         assertTrue( entry.contains( atCN, "test2" ) );
         assertTrue( entry.contains( atCN, "test3" ) );
-        assertEquals( atCN, entry.get( atCN ).getType() );
+        assertEquals( atCN, entry.get( atCN ).getAttributeType() );
         assertEquals( "cN", entry.get( atCN ).getUpId() );
         
         // Test some addition of existing values
@@ -1698,15 +1393,8 @@
         // Test the addition of a String value. It should be converted to a byte array
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
 
-        try
-        {
-            entry.add( "cN", test4 );
-            fail();
-        }
-        catch ( InvalidAttributeValueException iave )
-        {
-            assertTrue( true );
-        }
+        entry.add( "cN", test4 );
+        assertFalse( entry.contains( "cN", test4 ) );
 
         // Now, work with a binary attribute
         // Test a simple addition
@@ -1714,7 +1402,7 @@
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 1, entry.get( atPassword ).size() );
         assertTrue( Arrays.equals( b1, (byte[])entry.get( atPassword ).get().get() ) );
-        assertEquals( atPassword, entry.get( atPassword ).getType() );
+        assertEquals( atPassword, entry.get( atPassword ).getAttributeType() );
         assertEquals( "userPASSWORD", entry.get( atPassword ).getUpId() );
         
         // Test some more addition
@@ -1749,8 +1437,8 @@
 
         entry.add( "userPASSWORD", "test4" );
         assertNotNull( entry.get( atPassword ) );
-        assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( atPassword, b4 ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, b4 ) );
     }
 
 
@@ -1800,15 +1488,8 @@
         // Test the addition of a binary value
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
         
-        try
-        {
-            entry.add( "cn", atCN, test4 );
-            fail();
-        }
-        catch ( InvalidAttributeValueException iave )
-        {
-            assertTrue( true );
-        }
+        entry.add( "cn", atCN, test4 );
+        assertFalse( entry.contains( "cn", test4 ) );
     }
 
 
@@ -1864,8 +1545,8 @@
 
         entry.add( "userPassword", atPassword, "test4" );
         assertNotNull( entry.get( atPassword ) );
-        assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( atPassword, test4 ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, test4 ) );
     }
 
 
@@ -1884,20 +1565,20 @@
         byte[] b2 = StringTools.getBytesUtf8( "test2" );
         byte[] b3 = StringTools.getBytesUtf8( "test3" );
 
-        ServerValue<String> test1 = new ServerStringValue( atCN, "test1" );
-        ServerValue<String> test2 = new ServerStringValue( atCN, "test2" );
-        ServerValue<String> test3 = new ServerStringValue( atCN, "test3" );
-        
-        ServerValue<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
-        ServerValue<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
-        ServerValue<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
+        Value<String> test1 = new ServerStringValue( atCN, "test1" );
+        Value<String> test2 = new ServerStringValue( atCN, "test2" );
+        Value<String> test3 = new ServerStringValue( atCN, "test3" );
+        
+        Value<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
+        Value<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
+        Value<byte[]> testB3 = new ServerBinaryValue( atPassword, b3 );
         
         // Test a simple addition in atCN
         entry.add( "cN", atCN, test1 );
         assertNotNull( entry.get( atCN ) );
         assertEquals( 1, entry.get( atCN ).size() );
         assertEquals( "test1", entry.get( atCN ).get().get() );
-        assertEquals( atCN, entry.get( atCN ).getType() );
+        assertEquals( atCN, entry.get( atCN ).getAttributeType() );
         assertEquals( "cN", entry.get( atCN ).getUpId() );
         
         // Test some more addition
@@ -1907,7 +1588,7 @@
         assertTrue( entry.contains( atCN, "test1" ) );
         assertTrue( entry.contains( atCN, "test2" ) );
         assertTrue( entry.contains( atCN, "test3" ) );
-        assertEquals( atCN, entry.get( atCN ).getType() );
+        assertEquals( atCN, entry.get( atCN ).getAttributeType() );
         assertEquals( "cN", entry.get( atCN ).getUpId() );
         
         // Test some addition of existing values
@@ -1932,15 +1613,8 @@
         // Test the addition of a String value. It should be converted to a byte array
         byte[] test4 = StringTools.getBytesUtf8( "test4" );
 
-        try
-        {
-            entry.add( "cN", atCN, test4 );
-            fail();
-        }
-        catch ( InvalidAttributeValueException iave )
-        {
-            assertTrue( true );
-        }
+        entry.add( "cN", atCN, test4 );
+        assertFalse( entry.contains( "cN", test4 ) );
 
         // Now, work with a binary attribute
         // Test a simple addition
@@ -1948,7 +1622,7 @@
         assertNotNull( entry.get( atPassword ) );
         assertEquals( 1, entry.get( atPassword ).size() );
         assertTrue( Arrays.equals( b1, (byte[])entry.get( atPassword ).get().get() ) );
-        assertEquals( atPassword, entry.get( atPassword ).getType() );
+        assertEquals( atPassword, entry.get( atPassword ).getAttributeType() );
         assertEquals( "userPASSWORD", entry.get( atPassword ).getUpId() );
         
         // Test some more addition
@@ -1983,8 +1657,8 @@
 
         entry.add( "userPASSWORD", atPassword, "test4" );
         assertNotNull( entry.get( atPassword ) );
-        assertEquals( 1, entry.get( atPassword ).size() );
-        assertTrue( entry.contains( atPassword, b4 ) );
+        assertEquals( 0, entry.get( atPassword ).size() );
+        assertFalse( entry.contains( atPassword, b4 ) );
     }
 
     //-------------------------------------------------------------------------
@@ -2012,13 +1686,12 @@
         
         byte[] b1 = StringTools.getBytesUtf8( "test1" );
         byte[] b2 = StringTools.getBytesUtf8( "test2" );
-        byte[] b3 = StringTools.getBytesUtf8( "test3" );
 
-        ServerValue<String> test1 = new ServerStringValue( atCN, "test1" );
-        ServerValue<String> test2 = new ServerStringValue( atCN, "test2" );
+        Value<String> test1 = new ServerStringValue( atCN, "test1" );
+        Value<String> test2 = new ServerStringValue( atCN, "test2" );
         
-        ServerValue<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
-        ServerValue<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
+        Value<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
+        Value<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
         
         // test a removal of an non existing attribute
         List<ServerAttribute> removed = entry.remove( atCN );
@@ -2026,31 +1699,31 @@
         
         // Test a simple removal
         entry.add( "cN", atCN, test1 );
-        assertEquals( 2, entry.size() );
+        assertEquals( 1, entry.size() );
         assertNotNull( entry.get( atCN ) );
         entry.remove( "CN" );
-        assertEquals( 1, entry.size() );
+        assertEquals( 0, entry.size() );
         assertNull( entry.get( atCN ) );
         
         // Test a removal of many elements
         entry.put( "CN", test1, test2 );
         entry.put( "userPassword", testB1, testB2 );
-        assertEquals( 3, entry.size() );
+        assertEquals( 2, entry.size() );
         assertNotNull( entry.get( atCN ) );
         assertNotNull( entry.get( atPassword ) );
         
         AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
         
         entry.remove( "cN", "UsErPaSsWoRd" );
-        assertEquals( 1, entry.size() );
+        assertEquals( 0, entry.size() );
         assertNull( entry.get( atCN ) );
         assertNull( entry.get( atPassword ) );
-        assertTrue( entry.contains( OBJECT_CLASS_AT, "top" ) );
+        assertFalse( entry.contains( OBJECT_CLASS_AT, "top" ) );
         
         // test the removal of a bad Attribute
         entry.put( "CN", test1, test2 );
         entry.put( "userPassword", testB1, testB2 );
-        assertEquals( 3, entry.size() );
+        assertEquals( 2, entry.size() );
         assertNotNull( entry.get( atCN ) );
         assertNotNull( entry.get( atPassword ) );
         
@@ -2072,6 +1745,5 @@
     {
         
     }
-
 }
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java Mon Mar 17 23:12:41 2008
@@ -20,22 +20,15 @@
 package org.apache.directory.server.core.entry;
 
 
-import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
-import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
-import org.apache.directory.shared.ldap.schema.AbstractSyntax;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
-import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Before;
 import org.junit.Test;
 
 import javax.naming.NamingException;
-import javax.naming.directory.InvalidAttributeValueException;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -43,9 +36,9 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Arrays;
-import java.util.Comparator;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertFalse;
@@ -67,242 +60,22 @@
  */
 public class ServerBinaryValueTest
 {
-    static private S s;
-    static private AT at;
-    static private MR mr;
+    private TestServerEntryUtils.S s;
+    private TestServerEntryUtils.AT at;
+    private TestServerEntryUtils.MR mr;
     
-    /**
-     * A local Syntax class for tests
-     */
-    static class AT extends AbstractAttributeType
-    {
-        public static final long serialVersionUID = 0L;
-        AttributeType superior;
-        Syntax syntax;
-        MatchingRule equality;
-        MatchingRule ordering;
-        MatchingRule substr;
-
-        protected AT( String oid )
-        {
-            super( oid );
-        }
-
-        public AttributeType getSuperior() throws NamingException
-        {
-            return superior;
-        }
-
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-
-        public MatchingRule getEquality() throws NamingException
-        {
-            return equality;
-        }
-
-
-        public MatchingRule getOrdering() throws NamingException
-        {
-            return ordering;
-        }
-
-
-        public MatchingRule getSubstr() throws NamingException
-        {
-            return substr;
-        }
-
-
-        public void setSuperior( AttributeType superior )
-        {
-            this.superior = superior;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setEquality( MatchingRule equality )
-        {
-            this.equality = equality;
-        }
-
-
-        public void setOrdering( MatchingRule ordering )
-        {
-            this.ordering = ordering;
-        }
-
-
-        public void setSubstr( MatchingRule substr )
-        {
-            this.substr = substr;
-        }
-    }
+    private static final byte[] BYTES1 = new byte[]{0x01, 0x02, 0x03, 0x04};
+    private static final byte[] BYTES2 = new byte[]{(byte)0x81, (byte)0x82, (byte)0x83, (byte)0x84};
 
     /**
-     * A local MatchingRule class for tests
-     */
-    static class MR extends AbstractMatchingRule
-    {
-        public static final long serialVersionUID = 0L;
-        private Syntax syntax;
-        private Comparator comparator;
-        private Normalizer normalizer;
-
-        protected MR( String oid )
-        {
-            super( oid );
-        }
-
-        public Syntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-        public Comparator getComparator() throws NamingException
-        {
-            return comparator;
-        }
-
-
-        public Normalizer getNormalizer() throws NamingException
-        {
-            return normalizer;
-        }
-
-
-        public void setSyntax( Syntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setComparator( Comparator<?> comparator )
-        {
-            this.comparator = comparator;
-        }
-
-
-        public void setNormalizer( Normalizer normalizer )
-        {
-            this.normalizer = normalizer;
-        }
-    }
-
-
-    /**
-     * A local Syntax class used for the tests
-     */
-    static class S extends AbstractSyntax
-    {
-        public static final long serialVersionUID = 0L;
-        SyntaxChecker checker;
-
-        public S( String oid, boolean humanReadible )
-        {
-            super( oid, humanReadible );
-        }
-
-        public void setSyntaxChecker( SyntaxChecker checker )
-        {
-            this.checker = checker;
-        }
-
-        public SyntaxChecker getSyntaxChecker() throws NamingException
-        {
-            return checker;
-        }
-    }
-
-
-
-    private AttributeType getBytesAttributeType()
-    {
-        AT at = new AT( "1.1" );
-
-        S s = new S( "1.1.1", true );
-
-        s.setSyntaxChecker( new SyntaxChecker()
-        {
-            public String getSyntaxOid()
-            {
-                return "1.1.1";
-            }
-            public boolean isValidSyntax( Object value )
-            {
-                return ((byte[])value).length < 5 ;
-            }
-
-            public void assertSyntax( Object value ) throws NamingException
-            {
-                if ( ! isValidSyntax( value ) )
-                {
-                    throw new InvalidAttributeValueException();
-                }
-            }
-        } );
-
-        final MR mr = new MR( "1.1.2" );
-        mr.syntax = s;
-        mr.comparator = new Comparator<byte[]>()
-        {
-            public int compare( byte[] o1, byte[] o2 )
-            {
-                return ( ( o1 == null ) ? 
-                    ( o2 == null ? 0 : -1 ) :
-                    ( o2 == null ? 1 : ByteArrayComparator.INSTANCE.compare( o1, o2 ) ) );
-            }
-        };
-        
-        mr.normalizer = new Normalizer()
-        {
-            public static final long serialVersionUID = 1L;
-            
-            public Object normalize( Object value ) throws NamingException
-            {
-                if ( value instanceof byte[] )
-                {
-                    byte[] val = (byte[])value;
-                    // each byte will be changed to be > 0, and spaces will be trimmed
-                    byte[] newVal = new byte[ val.length ];
-                    int i = 0;
-                    
-                    for ( byte b:val )
-                    {
-                        newVal[i++] = (byte)(b & 0x007F); 
-                    }
-                    
-                    return StringTools.trim( newVal );
-                }
-
-                throw new IllegalStateException( "expected byte[] to normalize" );
-            }
-        };
-        
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
-    }
-
-    
-    /**
      * Initialize an AttributeType and the associated MatchingRule 
      * and Syntax
      */
     @Before public void initAT()
     {
-        s = new S( "1.1.1.1", false );
+        s = new TestServerEntryUtils.S( "1.1.1.1", false );
         s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
-        mr = new MR( "1.1.2.1" );
+        mr = new TestServerEntryUtils.MR( "1.1.2.1" );
         mr.syntax = s;
         mr.comparator = new ByteArrayComparator();
         mr.normalizer = new Normalizer()
@@ -329,7 +102,7 @@
                 throw new IllegalStateException( "expected byte[] to normalize" );
             }
         };
-        at = new AT( "1.1.3.1" );
+        at = new TestServerEntryUtils.AT( "1.1.3.1" );
         at.setEquality( mr );
         at.setOrdering( mr );
         at.setSubstr( mr );
@@ -353,7 +126,7 @@
         }
         
         // create a AT without any syntax
-        AttributeType at = new AT( "1.1.3.1" );
+        AttributeType at = new TestServerEntryUtils.AT( "1.1.3.1" );
         
         try
         {
@@ -370,9 +143,9 @@
     /**
      * Test the constructor with a null value
      */
-    @Test public void testNullValue()
+    @Test public void testServerBinaryValueNullValue()
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
         ServerBinaryValue value = new ServerBinaryValue( at, null );
         
@@ -382,17 +155,96 @@
     
     
     /**
+     * Test the constructor with an empty value
+     */
+    @Test public void testServerBinaryValueEmptyValue()
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
+        
+        ServerBinaryValue value = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
+        
+        assertEquals( StringTools.EMPTY_BYTES, value.getReference() );
+        assertFalse( value.isNull() );
+    }
+    
+    
+    /**
+     * Test the constructor with a value
+     */
+    @Test public void testServerBinaryValueNoValue()
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
+        byte[] val = new byte[]{0x01};
+        ServerBinaryValue value = new ServerBinaryValue( at );
+        
+        value.set( val );
+        assertTrue( Arrays.equals( val, value.getReference() ) );
+        assertFalse( value.isNull() );
+        assertTrue( Arrays.equals( val, value.getCopy() ) );
+    }
+    
+    
+    /**
+     * Test the constructor with a value
+     */
+    @Test public void testServerBinaryValue()
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
+        byte[] val = new byte[]{0x01};
+        ServerBinaryValue value = new ServerBinaryValue( at, val );
+        
+        assertTrue( Arrays.equals( val, value.getReference() ) );
+        assertFalse( value.isNull() );
+        assertTrue( Arrays.equals( val, value.getCopy() ) );
+    }
+    
+    
+    /**
+     * Test the clone method
+     */
+    @Test
+    public void testClone() throws NamingException
+    {
+        AttributeType at1 = TestServerEntryUtils.getBytesAttributeType();
+        ServerBinaryValue sbv = new ServerBinaryValue( at1, null );
+        
+        ServerBinaryValue sbv1 = (ServerBinaryValue)sbv.clone();
+        
+        assertEquals( sbv, sbv1 );
+        
+        sbv.set( StringTools.EMPTY_BYTES );
+        
+        assertNotSame( sbv, sbv1 );
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, sbv.get() ) );
+        
+        sbv.set(  BYTES2 );
+        sbv1 = (ServerBinaryValue)sbv.clone();
+        
+        assertEquals( sbv, sbv1 );
+        
+        sbv.normalize();
+        
+        // Even if we didn't normalized sbv2, it should be equal to sbv,
+        // as if they have the same AT, and the same value, they are equal.
+        assertEquals( sbv, sbv1 );
+    }
+    
+
+    /**
      * Test the equals method
      */
     @Test public void testEquals()
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at1 = TestServerEntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value1 = new ServerBinaryValue( at, new byte[]{0x01, (byte)0x02} );
-        ServerBinaryValue value2 = new ServerBinaryValue( at, new byte[]{0x01, (byte)0x02} );
-        ServerBinaryValue value3 = new ServerBinaryValue( at, new byte[]{0x01, (byte)0x82} );
-        ServerBinaryValue value4 = new ServerBinaryValue( at, new byte[]{0x01} );
-        ServerBinaryValue value5 = new ServerBinaryValue( at, null );
+        ServerBinaryValue value1 = new ServerBinaryValue( at1, new byte[]{0x01, (byte)0x02} );
+        ServerBinaryValue value2 = new ServerBinaryValue( at1, new byte[]{0x01, (byte)0x02} );
+        ServerBinaryValue value3 = new ServerBinaryValue( at1, new byte[]{0x01, (byte)0x82} );
+        ServerBinaryValue value4 = new ServerBinaryValue( at1, new byte[]{0x01} );
+        ServerBinaryValue value5 = new ServerBinaryValue( at1, null );
+        ServerBinaryValue value6 = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
+        ServerStringValue value7 = new ServerStringValue( TestServerEntryUtils.getIA5StringAttributeType(), 
+            "test" );
         
         assertTrue( value1.equals( value1 ) );
         assertTrue( value1.equals( value2 ) );
@@ -401,44 +253,98 @@
         assertFalse( value1.equals( value5 ) );
         assertFalse( value1.equals( "test" ) );
         assertFalse( value1.equals( null ) );
+        
+        assertFalse( value1.equals( value6 ) );
+        assertFalse( value1.equals( value7 ) );
     }
 
     
     /**
-     * Test the getNormalized method
-     * TODO testNormalized.
-     *
+     * Test the getNormalizedValue method
      */
-    @Test public void testGetNormalized() throws NamingException
+    @Test public void testGetNormalizedValue() throws NamingException
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( at, new byte[]{0x01, (byte)0x82} );
+        ServerBinaryValue value = new ServerBinaryValue( at, null );
+        assertNull( value.getNormalizedValue() );
+
+        value = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
+        assertTrue( Arrays.equals(  StringTools.EMPTY_BYTES, value.getNormalizedValue() ) );
+
+        value = new ServerBinaryValue( at, BYTES2 );
+        assertTrue( Arrays.equals( BYTES1, value.getNormalizedValue() ) );
+    }
+    
+    
+    /**
+     * Test the getNormalizedValue method
+     */
+    @Test public void testGetNormalizedValueCopy() throws NamingException
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
-        assertTrue( Arrays.equals( new byte[]{0x01, (byte)0x02}, value.getNormalizedReference() ) );
-        assertTrue( Arrays.equals( new byte[]{0x01, (byte)0x02}, value.getNormalizedCopy() ) );
+        ServerBinaryValue value = new ServerBinaryValue( at, null );
+        assertNull( value.getNormalizedValueCopy() );
+
+        value = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
+        assertTrue( Arrays.equals(  StringTools.EMPTY_BYTES, value.getNormalizedValueCopy() ) );
 
-        value = new ServerBinaryValue( at, null );
+        value = new ServerBinaryValue( at, BYTES2 );
+        assertTrue( Arrays.equals( BYTES1, value.getNormalizedValueCopy() ) );
+    }
+    
+    
+    /**
+     * Test the getNormalizedValue method
+     */
+    @Test public void testGetNormalizedValueReference() throws NamingException
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
-        assertNull( value.getNormalizedReference() );
+        ServerBinaryValue value = new ServerBinaryValue( at, null );
+        assertNull( value.getNormalizedValueReference() );
+
+        value = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
+        assertTrue( Arrays.equals(  StringTools.EMPTY_BYTES, value.getNormalizedValueReference() ) );
+
+        value = new ServerBinaryValue( at, BYTES2 );
+        assertTrue( Arrays.equals( BYTES1, value.getNormalizedValueReference() ) );
     }
     
     
     /**
+     * Test the getAttributeType method
+     */
+    @Test
+    public void testgetAttributeType() throws NamingException
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
+        ServerBinaryValue sbv = new ServerBinaryValue( at );
+        
+        assertEquals( at, sbv.getAttributeType() );
+    }    
+
+    
+    /**
      * Test the isValid method
      * 
      * The SyntaxChecker does not accept values longer than 5 chars.
      */
     @Test public void testIsValid() throws NamingException
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
+        ServerBinaryValue value = new ServerBinaryValue( at, null );
+        assertTrue( value.isValid() );
         
+        value = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
+        assertTrue( value.isValid() );
+
+        value = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
         assertTrue( value.isValid() );
 
         value = new ServerBinaryValue( at, new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06} );
-        
         assertFalse( value.isValid() );
     }
     
@@ -447,9 +353,9 @@
      * Tests to make sure the hashCode method is working properly.
      * @throws Exception on errors
      */
-    @Test public void testHashCodeValidEquals() throws Exception
+    @Test public void testHashCode() throws Exception
     {
-        AttributeType at = getBytesAttributeType();
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
         ServerBinaryValue v0 = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
         ServerBinaryValue v1 = new ServerBinaryValue( at, new byte[]{(byte)0x81, (byte)0x82} );
         ServerBinaryValue v2 = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
@@ -471,6 +377,90 @@
     }
 
 
+    /**
+     * Test the same method
+     */
+    @Test
+    public void testSame() throws NamingException
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
+        ServerBinaryValue sbv = new ServerBinaryValue( at );
+
+        sbv.normalize();
+        assertTrue( sbv.isSame() );
+        
+        sbv.set( StringTools.EMPTY_BYTES );
+        sbv.normalize();
+        assertTrue( sbv.isSame() );
+
+        sbv.set( BYTES1 );
+        sbv.normalize();
+        assertTrue( sbv.isSame() );
+
+        sbv.set( BYTES2 );
+        sbv.normalize();
+        assertFalse( sbv.isSame() );
+    }
+    
+    
+    /**
+     * Test the instanceOf method
+     */
+    @Test
+    public void testInstanceOf() throws NamingException
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
+        ServerBinaryValue sbv = new ServerBinaryValue( at );
+        
+        assertTrue( sbv.instanceOf( at ) );
+        
+        at = TestServerEntryUtils.getIA5StringAttributeType();
+        
+        assertFalse( sbv.instanceOf( at ) );
+    }    
+    
+
+    /**
+     * Test the normalize method
+     */
+    @Test
+    public void testNormalize() throws NamingException
+    {
+        AttributeType at = TestServerEntryUtils.getBytesAttributeType();
+        ServerBinaryValue sbv = new ServerBinaryValue( at );
+
+        sbv.normalize();
+        assertEquals( null, sbv.getNormalizedValue() );
+        
+        sbv.set( StringTools.EMPTY_BYTES );
+        sbv.normalize();
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, sbv.getNormalizedValue() ) );
+
+        sbv.set( BYTES2 );
+        sbv.normalize();
+        assertTrue( Arrays.equals( BYTES1, sbv.getNormalizedValue() ) );
+    }
+    
+
+    /**
+     * Test the compareTo method
+     */
+    @Test
+    public void testCompareTo()
+    {
+        AttributeType at1 = TestServerEntryUtils.getBytesAttributeType();
+        ServerBinaryValue v0 = new ServerBinaryValue( at1, BYTES1 );
+        ServerBinaryValue v1 = new ServerBinaryValue( at1, BYTES2 );
+        
+        assertEquals( 0, v0.compareTo( v1 ) );
+        assertEquals( 0, v1.compareTo( v0 ) );
+
+        ServerBinaryValue v2 = new ServerBinaryValue( at1, null );
+        
+        assertEquals( 1, v0.compareTo( v2 ) );
+        assertEquals( -1, v2.compareTo( v0 ) );
+    }
+
 
     /**
      * Test serialization of a BinaryValue which has a normalized value
@@ -484,7 +474,7 @@
         ServerBinaryValue sv = new ServerBinaryValue( at, v1 );
         
         sv.normalize();
-        byte[] normalized = sv.getNormalizedReference();
+        byte[] normalized = sv.getNormalizedValueReference();
         
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sv.getReference() ) );
@@ -518,7 +508,7 @@
         ServerBinaryValue sv = new ServerBinaryValue( at, v1 );
         
         sv.normalize();
-        byte[] normalized = sv.getNormalizedReference();
+        byte[] normalized = sv.getNormalizedValueReference();
         
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sv.get() ) );
@@ -550,7 +540,7 @@
         ServerBinaryValue sv = new ServerBinaryValue( at );
         
         sv.normalize();
-        byte[] normalized = sv.getNormalizedReference();
+        byte[] normalized = sv.getNormalizedValueReference();
         
         assertEquals( null, normalized );
         assertEquals( null, sv.get() );
@@ -582,7 +572,7 @@
         ServerBinaryValue sv = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
         
         sv.normalize();
-        byte[] normalized = sv.getNormalizedReference();
+        byte[] normalized = sv.getNormalizedValueReference();
         
         assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, normalized ) );
         assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, sv.get() ) );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java Mon Mar 17 23:12:41 2008
@@ -21,8 +21,12 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.junit.Test;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -35,12 +39,22 @@
 {
     @Test public void testCreateServerModification() throws NamingException
     {
-        /*Modification mod = new ServerModification();
+        AttributeType at = TestServerEntryUtils.getIA5StringAttributeType();
+        ServerAttribute attribute = new DefaultServerAttribute( at );
+        attribute.add( "test1", "test2" );
         
-        mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
-        AttributeType cnat = null;//new AT( SchemaConstants.CN_AT_OID );
-        EntryAttribute entry = new BasicServerAttribute( cnat, "test" );
-        mod.setAttribute( entry );*/
-        assertTrue( true );
+        Modification mod = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
+        Modification clone = mod.clone();
+        
+        attribute.remove( "test2" );
+        
+        ServerAttribute clonedAttribute = (ServerAttribute)clone.getAttribute();
+        
+        assertEquals( 1, mod.getAttribute().size() );
+        assertTrue( mod.getAttribute().contains( "test1" ) );
+
+        assertEquals( 2, clonedAttribute.size() );
+        assertTrue( clone.getAttribute().contains( "test1" ) );
+        assertTrue( clone.getAttribute().contains( "test2" ) );
     }
 }



Mime
View raw message