directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r686082 [7/7] - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/c...
Date Thu, 14 Aug 2008 23:12:13 GMT
Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java Thu Aug 14 16:12:09 2008
@@ -19,9 +19,15 @@
  */
 package org.apache.directory.shared.ldap.ldif;
 
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.client.ClientModification;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -39,7 +45,6 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -58,15 +63,10 @@
     /**
      * Helper method to build a basic entry used by the Modify tests
      */
-    private Attributes buildEntry()
+    private Entry buildEntry()
     {
-        Attributes entry = new AttributesImpl();
-        
-        Attribute oc = new AttributeImpl( "objectclass" );
-        oc.add( "top" );
-        oc.add( "person" );
-        entry.put( oc );
-        
+        Entry entry = new DefaultClientEntry();
+        entry.put( "objectclass", "top", "person" );
         entry.put( "cn", "test" );
         entry.put( "sn", "joe doe" );
         entry.put( "l", "USA" );
@@ -352,10 +352,8 @@
         entry.setDn( "cn=Saarbr\u00FCcken, dc=example, dc=com" );
         entry.setChangeType( ChangeType.Add );
         
-        Attribute oc = new BasicAttribute( "objectClass" );
-        oc.add( "top" );
-        oc.add( "person" );
-        oc.add( "inetorgPerson" );
+        EntryAttribute oc = new DefaultClientAttribute( "objectClass" );
+        oc.add( "top", "person", "inetorgPerson" );
         
         entry.addAttribute( oc );
         
@@ -393,7 +391,7 @@
         attributes.put( "cn", "Saarbrucken" );
         attributes.put( "sn", "test" );
 
-        String ldif = LdifUtils.convertToLdif( attributes, 15 );
+        String ldif = LdifUtils.convertToLdif( attributes, (LdapDN)null, 15 );
         Attributes result = LdifUtils.convertAttributesFromLdif( ldif );
         assertEquals( attributes, result );
     }
@@ -411,9 +409,9 @@
         LdifEntry reversed = LdifUtils.reverseAdd( dn );
         
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Delete, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
     }
 
 
@@ -428,9 +426,9 @@
         LdapDN dn = new LdapDN( "dc=Emmanuel L\u00c9charny" );
         LdifEntry reversed = LdifUtils.reverseAdd( dn );
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Delete, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
     }
 
 
@@ -444,11 +442,10 @@
     {
         LdapDN dn = new LdapDN( "dc=apache, dc=com" );
         
-        Attributes deletedEntry = new AttributesImpl();
+        Entry deletedEntry = new DefaultClientEntry( dn );
         
-        Attribute oc = new AttributeImpl( "objectClass" );
-        oc.add( "top" );
-        oc.add( "person" );
+        EntryAttribute oc = new DefaultClientAttribute( "objectClass" );
+        oc.add( "top", "person" );
         
         deletedEntry.put( oc );
         
@@ -459,10 +456,10 @@
         LdifEntry reversed = LdifUtils.reverseDel( dn, deletedEntry );
         
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Add, reversed.getChangeType() );
-        assertNotNull( reversed.getAttributes() );
-        assertEquals( deletedEntry, reversed.getAttributes() );
+        assertNotNull( reversed.getEntry() );
+        assertEquals( deletedEntry, reversed.getEntry() );
     }
     
     
@@ -487,12 +484,12 @@
         LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
 
         assertNotNull( reversed );
-        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn() );
+        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn().getUpName() );
         assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
         assertTrue( reversed.isDeleteOldRdn() );
         assertEquals( "cn=john doe", reversed.getNewRdn() );
         assertNull( reversed.getNewSuperior() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
     }
 
 
@@ -518,12 +515,12 @@
         LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
 
         assertNotNull( reversed );
-        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn() );
+        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn().getUpName() );
         assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
         assertFalse( reversed.isDeleteOldRdn() );
         assertEquals( "cn=john doe", reversed.getNewRdn() );
         assertNull( reversed.getNewSuperior() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
     }
 
 
@@ -556,12 +553,12 @@
         LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
 
         assertNotNull( reversed );
-        assertEquals( "cn=jack doe,ou=system", reversed.getDn() );
+        assertEquals( "cn=jack doe,ou=system", reversed.getDn().getUpName() );
         assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
         assertFalse( reversed.isDeleteOldRdn() );
         assertEquals( "cn=john doe", reversed.getNewRdn() );
         assertEquals( "dc=example, dc=com", StringTools.trim( reversed.getNewSuperior() ) );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
     }
 
 
@@ -586,12 +583,12 @@
         LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, null );
 
         assertNotNull( reversed );
-        assertEquals( "cn=john doe,ou=system", reversed.getDn() );
+        assertEquals( "cn=john doe,ou=system", reversed.getDn().getUpName() );
         assertEquals( ChangeType.ModDn, reversed.getChangeType() );
         assertFalse( reversed.isDeleteOldRdn() );
         assertNull( reversed.getNewRdn() );
         assertEquals( "dc=example, dc=com", StringTools.trim( reversed.getNewSuperior() ) );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
     }
 
 
@@ -615,12 +612,12 @@
         LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
 
         assertNotNull( reversed );
-        assertEquals( "cn=jack doe,ou=system", reversed.getDn() );
+        assertEquals( "cn=jack doe,ou=system", reversed.getDn().getUpName() );
         assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
         assertTrue( reversed.isDeleteOldRdn() );
         assertEquals( "cn=john doe", reversed.getNewRdn() );
         assertEquals( "dc=example, dc=com", StringTools.trim( reversed.getNewSuperior() ) );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
     }
 
     
@@ -631,39 +628,39 @@
     @Test
     public void testReverseModifyAddNewOuValue() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
 
-        Attribute ou = new AttributeImpl( "ou" );
+        EntryAttribute ou = new DefaultClientAttribute( "ou" );
         ou.add( "apache" );
         ou.add( "acme corp" );
         modifiedEntry.put( ou );
         
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        ModificationItemImpl mod = new ModificationItemImpl(
-            DirContext.ADD_ATTRIBUTE, 
-            new AttributeImpl( "ou", "BigCompany inc." ) );
+        Modification mod = new ClientModification(
+            ModificationOperation.ADD_ATTRIBUTE, 
+            new DefaultClientAttribute( "ou", "BigCompany inc." ) );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        assertNull( reversed.getEntry() );
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
         
-        assertEquals( DirContext.REMOVE_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
-        assertEquals( "ou", attr.getID() );
-        assertEquals( "BigCompany inc.", attr.get() );
+        assertEquals( "ou", attr.getId() );
+        assertEquals( "BigCompany inc.", attr.getString() );
     }
 
 
@@ -673,34 +670,34 @@
     @Test
     public void testReverseModifyAddNewOu() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
         
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        ModificationItemImpl mod = new ModificationItemImpl(
-            DirContext.ADD_ATTRIBUTE, 
-            new AttributeImpl( "ou", "BigCompany inc." ) );
+        Modification mod = new ClientModification(
+            ModificationOperation.ADD_ATTRIBUTE, 
+            new DefaultClientAttribute( "ou", "BigCompany inc." ) );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        assertNull( reversed.getEntry() );
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
 
-        assertEquals( DirContext.REMOVE_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
-        assertEquals( "ou", attr.getID() );
-        assertEquals( "BigCompany inc.", attr.get() );
+        assertEquals( "ou", attr.getId() );
+        assertEquals( "BigCompany inc.", attr.getString() );
     }
 
    
@@ -711,15 +708,15 @@
     @Ignore ( "This is just not a valid test since it leaves us with no reverse LDIF" )
     public void testReverseModifyAddExistingCnValue() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
 
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        ModificationItemImpl mod = new ModificationItemImpl(
-            DirContext.ADD_ATTRIBUTE,
-            new AttributeImpl( "cn", "test" ) );
+        Modification mod = new ClientModification(
+            ModificationOperation.ADD_ATTRIBUTE,
+            new DefaultClientAttribute( "cn", "test" ) );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
         assertNull( reversed );
     }
@@ -731,42 +728,41 @@
     @Test
     public void testReverseModifyDelExistingOuValue() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
         
-        Attribute ou = new AttributeImpl( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
+        EntryAttribute ou = new DefaultClientAttribute( "ou" );
+        ou.add( "apache", "acme corp" );
         modifiedEntry.put( ou );
 
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
 
-        ModificationItemImpl mod = new ModificationItemImpl( 
-            DirContext.REMOVE_ATTRIBUTE, 
-            new AttributeImpl( "ou", "acme corp" ) );
+        Modification mod = new ClientModification( 
+            ModificationOperation.REMOVE_ATTRIBUTE, 
+            new DefaultClientAttribute( "ou", "acme corp" ) );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
         
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
         
-        assertEquals( DirContext.ADD_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
 
-        Attribute addedAttr = new AttributeImpl( "ou", "acme corp" );
-        assertEquals( addedAttr, attr );
+        assertEquals( "ou", attr.getId() );
+        assertEquals( "acme corp", attr.getString() );
     }
 
 
@@ -776,41 +772,40 @@
     @Test
     public void testReverseModifyDeleteOU() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
         
-        Attribute ou = new AttributeImpl( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
+        EntryAttribute ou = new DefaultClientAttribute( "ou" );
+        ou.add( "apache", "acme corp" );
         modifiedEntry.put( ou );
 
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
 
-        ModificationItemImpl mod = new ModificationItemImpl(
-            DirContext.REMOVE_ATTRIBUTE, 
-            new AttributeImpl( "ou" ) );
+        Modification mod = new ClientModification(
+            ModificationOperation.REMOVE_ATTRIBUTE, 
+            new DefaultClientAttribute( "ou" ) );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
         
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
         
-        assertEquals( DirContext.ADD_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
-        assertEquals( "ou", attr.getID() );
+        assertEquals( "ou", attr.getId() );
         
         assertEquals( ou, attr );
     }
@@ -822,40 +817,38 @@
     @Test
     public void testReverseModifyDelExistingOuWithAllValues() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
 
-        Attribute ou = new AttributeImpl( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
+        EntryAttribute ou = new DefaultClientAttribute( "ou", "apache", "acme corp" );
         modifiedEntry.put( ou );
         
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
         
-        ModificationItemImpl mod = new ModificationItemImpl(
-            DirContext.REMOVE_ATTRIBUTE, ou );
+        Modification mod = new ClientModification(
+            ModificationOperation.REMOVE_ATTRIBUTE, ou );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn, 
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
         
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
         
-        assertEquals( DirContext.ADD_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
-        assertEquals( "ou", attr.getID() );
+        assertEquals( "ou", attr.getId() );
         
         assertEquals( ou, attr );
     }
@@ -867,42 +860,41 @@
     @Test
     public void testReverseModifyReplaceExistingOuValues() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
         
-        Attribute ou = new AttributeImpl( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
+        EntryAttribute ou = new DefaultClientAttribute( "ou" );
+        ou.add( "apache", "acme corp" );
         modifiedEntry.put( ou );
 
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
 
-        Attribute ouModified = new AttributeImpl( "ou" );
+        EntryAttribute ouModified = new DefaultClientAttribute( "ou" );
         ouModified.add( "directory" );
         ouModified.add( "BigCompany inc." );
         
-        ModificationItemImpl mod = new ModificationItemImpl(
-            DirContext.REPLACE_ATTRIBUTE, ouModified );
+        Modification mod = new ClientModification(
+            ModificationOperation.REPLACE_ATTRIBUTE, ouModified );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
 
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
         
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
         
-        assertEquals( DirContext.REPLACE_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
         assertEquals( ou, attr );
@@ -915,39 +907,39 @@
     @Test
     public void testReverseModifyReplaceNewAttribute() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
         
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
         
-        Attribute newOu = new AttributeImpl( "ou" );
+        EntryAttribute newOu = new DefaultClientAttribute( "ou" );
         newOu.add( "apache" );
         newOu.add( "acme corp" );
 
         
-        ModificationItemImpl mod = new ModificationItemImpl(
-            DirContext.REPLACE_ATTRIBUTE, newOu );
+        Modification mod = new ClientModification(
+            ModificationOperation.REPLACE_ATTRIBUTE, newOu );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
         
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
         
-        assertEquals( DirContext.REPLACE_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
-        assertEquals( "ou", attr.getID() );
+        assertEquals( "ou", attr.getId() );
         
         assertNull( attr.get() );
     }
@@ -959,39 +951,39 @@
     @Test
     public void testReverseModifyReplaceExistingOuWithNothing() throws NamingException
     {
-        Attributes modifiedEntry = buildEntry();
+        Entry modifiedEntry = buildEntry();
 
-        Attribute ou = new AttributeImpl( "ou" );
+        EntryAttribute ou = new DefaultClientAttribute( "ou" );
         ou.add( "apache" );
         ou.add( "acme corp" );
         modifiedEntry.put( ou );
         
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
         
-        ModificationItemImpl mod = new ModificationItemImpl( 
-            DirContext.REPLACE_ATTRIBUTE, new AttributeImpl( "ou" ) );
+        Modification mod = new ClientModification( 
+            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "ou" ) );
 
         LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
+                Collections.<Modification>singletonList( mod ), modifiedEntry );
 
         assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn() );
+        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
         assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getAttributes() );
+        assertNull( reversed.getEntry() );
         
-        List<ModificationItemImpl> mods = reversed.getModificationItems();
+        List<Modification> mods = reversed.getModificationItems();
         
         assertNotNull( mods );
         assertEquals( 1, mods.size() );
         
-        ModificationItemImpl modif = mods.get( 0 );
+        Modification modif = mods.get( 0 );
         
-        assertEquals( DirContext.REPLACE_ATTRIBUTE, modif.getModificationOp() );
+        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
 
-        Attribute attr = modif.getAttribute();
+        EntryAttribute attr = modif.getAttribute();
         
         assertNotNull( attr );
-        assertEquals( "ou", attr.getID() );
+        assertEquals( "ou", attr.getId() );
         
         assertEquals( ou, attr );
     }
@@ -1093,35 +1085,35 @@
         //   - replace the 'ou' attribute with 'apache' value.
         LdapDN dn = new LdapDN( "cn=test, ou=system" );
         
-        List<ModificationItemImpl> modifications = new ArrayList<ModificationItemImpl>();
+        List<Modification> modifications = new ArrayList<Modification>();
 
         // First, inject the 'ou'
         
-        ModificationItemImpl mod = new ModificationItemImpl( 
-            DirContext.ADD_ATTRIBUTE, new AttributeImpl( "ou", "BigCompany inc." ) );
+        Modification mod = new ClientModification( 
+            ModificationOperation.ADD_ATTRIBUTE, new DefaultClientAttribute( "ou", "BigCompany inc." ) );
         modifications.add( mod );
 
         // Remove the 'l'
-        mod = new ModificationItemImpl(
-            DirContext.REMOVE_ATTRIBUTE, new AttributeImpl( "l" ) );
+        mod = new ClientModification(
+            ModificationOperation.REMOVE_ATTRIBUTE, new DefaultClientAttribute( "l" ) );
         modifications.add( mod );
         
         // Add 'l=FR'
-        mod = new ModificationItemImpl( 
-            DirContext.ADD_ATTRIBUTE, new AttributeImpl( "l", "FR" ) );
+        mod = new ClientModification( 
+            ModificationOperation.ADD_ATTRIBUTE, new DefaultClientAttribute( "l", "FR" ) );
         modifications.add( mod );
 
         // Replace it with 'l=USA'
-        mod = new ModificationItemImpl( 
-            DirContext.REPLACE_ATTRIBUTE, new AttributeImpl( "l", "USA" ) );
+        mod = new ClientModification( 
+            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "l", "USA" ) );
         modifications.add( mod );
 
         // Replace the ou value
-        mod = new ModificationItemImpl( 
-            DirContext.REPLACE_ATTRIBUTE, new AttributeImpl( "ou", "apache" ) );
+        mod = new ClientModification( 
+            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "ou", "apache" ) );
         modifications.add( mod );
         
-        LdifEntry reversedEntry = LdifUtils.reverseModify( dn, modifications, initialEntry.getAttributes() );
+        LdifEntry reversedEntry = LdifUtils.reverseModify( dn, modifications, initialEntry.getEntry() );
 
         String expectedEntryLdif = 
             "dn: cn=test, ou=system\n" +

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java Thu Aug 14 16:12:09 2008
@@ -260,15 +260,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        atav.writeExternal( out );
+        out.writeObject( atav );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        AttributeTypeAndValue atav2 = new AttributeTypeAndValue();
-        atav2.readExternal( in );
+        AttributeTypeAndValue atav2 = (AttributeTypeAndValue)in.readObject();
 
         assertEquals( atav, atav2 );
     }
@@ -287,15 +286,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        atav.writeExternal( out );
+        out.writeObject( atav );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        AttributeTypeAndValue atav2 = new AttributeTypeAndValue();
-        atav2.readExternal( in );
+        AttributeTypeAndValue atav2 = (AttributeTypeAndValue)in.readObject();
 
         assertEquals( atav, atav2 );
     }
@@ -314,7 +312,7 @@
 
         try
         {
-            atav.writeExternal( out );
+            out.writeObject( atav );
             fail();
         }
         catch ( IOException ioe )
@@ -334,7 +332,7 @@
 
         try
         {
-            atav.writeExternal( out );
+            out.writeObject( atav );
             fail();
         }
         catch ( IOException ioe )
@@ -355,7 +353,7 @@
 
         try
         {
-            atav.writeExternal( out );
+            out.writeObject( atav );
             fail();
         }
         catch ( IOException ioe )
@@ -374,15 +372,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        atav.writeExternal( out );
+        out.writeObject( atav );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        AttributeTypeAndValue atav2 = new AttributeTypeAndValue();
-        atav2.readExternal( in );
+        AttributeTypeAndValue atav2 = (AttributeTypeAndValue)in.readObject();
 
         assertEquals( atav, atav2 );
     }
@@ -396,15 +393,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        atav.writeExternal( out );
+        out.writeObject( atav );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        AttributeTypeAndValue atav2 = new AttributeTypeAndValue();
-        atav2.readExternal( in );
+        AttributeTypeAndValue atav2 = (AttributeTypeAndValue)in.readObject();
 
         assertEquals( atav, atav2 );
     }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java Thu Aug 14 16:12:09 2008
@@ -924,15 +924,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }
@@ -948,15 +947,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }
@@ -974,15 +972,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }
@@ -1000,15 +997,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }
@@ -1026,15 +1022,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }
@@ -1052,15 +1047,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }
@@ -1078,15 +1072,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }
@@ -1105,15 +1098,14 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        rdn.writeExternal( out );
+        out.writeObject( rdn );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = new Rdn();
-        rdn2.readExternal( in );
+        Rdn rdn2 = (Rdn)in.readObject();
 
         assertEquals( rdn, rdn2 );
     }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java Thu Aug 14 16:12:09 2008
@@ -22,16 +22,16 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
-
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientModification;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 
 import org.junit.Test;
 import static org.junit.Assert.assertNotNull;
@@ -53,9 +53,9 @@
     @Test
     public void testApplyAddModificationToEmptyEntry() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute attr = new AttributeImpl( "cn", "test" );
-        ModificationItem modification = new ModificationItemImpl(DirContext.ADD_ATTRIBUTE, attr );
+        Entry entry = new DefaultClientEntry();
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
+        Modification modification = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attr );
         AttributeUtils.applyModification( entry, modification );
         assertNotNull( entry.get(  "cn" ) );
         assertEquals( 1, entry.size() );
@@ -69,12 +69,13 @@
     @Test
     public void testApplyAddModificationToEntry() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        entry.put( "dc", "apache" );
+        Entry entry = new DefaultClientEntry();
+        entry.add( "dc", "apache" );
         assertEquals( 1, entry.size() );
 
-        Attribute attr = new AttributeImpl( "cn", "test" );
-        ModificationItem modification = new ModificationItemImpl(DirContext.ADD_ATTRIBUTE, attr );
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
+        Modification modification = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attr );
+
         AttributeUtils.applyModification( entry, modification );
         assertNotNull( entry.get(  "cn" ) );
         assertEquals( 2, entry.size() );
@@ -89,31 +90,31 @@
     @Test
     public void testApplyAddModificationToEntryWithValues() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
+        Entry entry = new DefaultClientEntry();
         entry.put( "cn", "apache" );
         assertEquals( 1, entry.size() );
 
-        Attribute attr = new AttributeImpl( "cn", "test" );
-        ModificationItem modification = new ModificationItemImpl(DirContext.ADD_ATTRIBUTE, attr );
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
+        Modification modification = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attr );
         AttributeUtils.applyModification( entry, modification );
         assertNotNull( entry.get(  "cn" ) );
         assertEquals( 1, entry.size() );
         
-        NamingEnumeration<?> values = entry.get( "cn" ).getAll();
+        EntryAttribute attribute = entry.get( "cn" );
         
-        assertTrue( values.hasMoreElements() );
+        assertTrue( attribute.size() != 0 );
         
         Set<String> expectedValues = new HashSet<String>();
         expectedValues.add( "apache" );
         expectedValues.add( "test" );
         
-        while ( values.hasMoreElements() )
+        for ( Value<?> value:attribute )
         {
-            String value = (String)values.nextElement();
+            String valueStr = (String)value.get();
             
-            assertTrue( expectedValues.contains( value ) );
+            assertTrue( expectedValues.contains( valueStr ) );
             
-            expectedValues.remove( value );
+            expectedValues.remove( valueStr );
         }
         
         assertEquals( 0, expectedValues.size() );
@@ -127,35 +128,31 @@
     @Test
     public void testApplyAddModificationToEntryWithSameValue() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute cn = new AttributeImpl( "cn" );
-        cn.add( "test" );
-        cn.add( "apache" );
-        entry.put( cn );
-        
+        Entry entry = new DefaultClientEntry();
+        entry.put( "cn", "test", "apache" );
         assertEquals( 1, entry.size() );
 
-        Attribute attr = new AttributeImpl( "cn", "test" );
-        ModificationItem modification = new ModificationItemImpl(DirContext.ADD_ATTRIBUTE, attr );
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
+        Modification modification = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attr );
         AttributeUtils.applyModification( entry, modification );
-        assertNotNull( entry.get(  "cn" ) );
+        assertNotNull( entry.get( "cn" ) );
         assertEquals( 1, entry.size() );
         
-        NamingEnumeration<?> values = entry.get( "cn" ).getAll();
+        EntryAttribute cnAttr = entry.get( "cn" );
         
-        assertTrue( values.hasMoreElements() );
+        assertTrue( cnAttr.size() != 0 );
         
         Set<String> expectedValues = new HashSet<String>();
         expectedValues.add( "apache" );
         expectedValues.add( "test" );
         
-        while ( values.hasMoreElements() )
+        for ( Value<?> value:cnAttr )
         {
-            String value = (String)values.nextElement();
+            String valueStr = (String)value.get();
             
-            assertTrue( expectedValues.contains( value ) );
+            assertTrue( expectedValues.contains( valueStr ) );
             
-            expectedValues.remove( value );
+            expectedValues.remove( valueStr );
         }
         
         assertEquals( 0, expectedValues.size() );
@@ -168,9 +165,11 @@
     @Test
     public void testApplyRemoveModificationFromEmptyEntry() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute attr = new AttributeImpl( "cn", "test" );
-        ModificationItem modification = new ModificationItemImpl(DirContext.REMOVE_ATTRIBUTE, attr );
+        Entry entry = new DefaultClientEntry();
+
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
+
+        Modification modification = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
         AttributeUtils.applyModification( entry, modification );
         assertNull( entry.get( "cn" ) );
         assertEquals( 0, entry.size() );
@@ -183,13 +182,14 @@
     @Test
     public void testApplyRemoveModificationFromEntryAttributeNotPresent() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute dc = new AttributeImpl( "dc", "apache" );
+        Entry entry = new DefaultClientEntry();
+
+        EntryAttribute dc = new DefaultClientAttribute( "dc", "apache" );
         entry.put( dc );
         
-        Attribute attr = new AttributeImpl( "cn", "test" );
+        EntryAttribute cn = new DefaultClientAttribute( "cn", "test" );
         
-        ModificationItem modification = new ModificationItemImpl(DirContext.REMOVE_ATTRIBUTE, attr );
+        Modification modification = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, cn );
         
         AttributeUtils.applyModification( entry, modification );
         
@@ -207,13 +207,14 @@
     @Test
     public void testApplyRemoveModificationFromEntryAttributeNotSameValue() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute cn = new AttributeImpl( "cn", "apache" );
+        Entry entry = new DefaultClientEntry();
+
+        EntryAttribute cn = new DefaultClientAttribute( "cn", "apache" );
         entry.put( cn );
         
-        Attribute attr = new AttributeImpl( "cn", "test" );
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
         
-        ModificationItem modification = new ModificationItemImpl(DirContext.REMOVE_ATTRIBUTE, attr );
+        Modification modification = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
         
         AttributeUtils.applyModification( entry, modification );
         
@@ -231,13 +232,12 @@
     @Test
     public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute cn = new AttributeImpl( "cn", "test" );
-        entry.put( cn );
-        
-        Attribute attr = new AttributeImpl( "cn", "test" );
+        Entry entry = new DefaultClientEntry();
+        entry.put( "cn", "test" );
         
-        ModificationItem modification = new ModificationItemImpl(DirContext.REMOVE_ATTRIBUTE, attr );
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
+
+        Modification modification = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
         
         AttributeUtils.applyModification( entry, modification );
         
@@ -255,34 +255,30 @@
     @Test
     public void testApplyRemoveModificationFromEntrySameAttributeValues() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute cn = new AttributeImpl( "cn", "test" );
-        cn.add( "apache" );
-        entry.put( cn );
+        Entry entry = new DefaultClientEntry();
+        entry.put( "cn", "test", "apache" );
         
-        Attribute attr = new AttributeImpl( "cn", "test" );
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
         
-        ModificationItem modification = new ModificationItemImpl(DirContext.REMOVE_ATTRIBUTE, attr );
+        Modification modification = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
         
         AttributeUtils.applyModification( entry, modification );
         
         assertNotNull( entry.get( "cn" ) );
         assertEquals( 1, entry.size() );
         
-        Attribute modifiedAttr = entry.get( "cn" );
+        EntryAttribute modifiedAttr = entry.get( "cn" );
         
-        NamingEnumeration<?> values = modifiedAttr.getAll();
-        
-        assertTrue( values.hasMoreElements() );
+        assertTrue( modifiedAttr.size() != 0 );
         
         boolean isFirst = true;
         
-        while ( values.hasMoreElements() )
+        for ( Value<?> value:modifiedAttr )
         {
             assertTrue( isFirst );
             
             isFirst = false;
-            assertEquals( "apache", values.nextElement() );
+            assertEquals( "apache", value.get() );
         }
     }
     
@@ -296,9 +292,12 @@
     @Test
     public void testApplyModifyModificationFromEmptyEntry() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute attr = new AttributeImpl( "cn", "test" );
-        ModificationItem modification = new ModificationItemImpl(DirContext.REPLACE_ATTRIBUTE, attr );
+        Entry entry = new DefaultClientEntry();
+        
+        EntryAttribute attr = new DefaultClientAttribute( "cn", "test" );
+
+        
+        Modification modification = new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
         AttributeUtils.applyModification( entry, modification );
         assertNotNull( entry.get( "cn" ) );
         assertEquals( 1, entry.size() );
@@ -315,9 +314,11 @@
     @Test
     public void testApplyModifyEmptyModificationFromEmptyEntry() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute attr = new AttributeImpl( "cn" );
-        ModificationItem modification = new ModificationItemImpl(DirContext.REPLACE_ATTRIBUTE, attr );
+        Entry entry = new DefaultClientEntry();
+        
+        EntryAttribute attr = new DefaultClientAttribute( "cn" );
+
+        Modification modification = new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
         AttributeUtils.applyModification( entry, modification );
         assertNull( entry.get( "cn" ) );
         assertEquals( 0, entry.size() );
@@ -334,22 +335,13 @@
     @Test
     public void testApplyModifyAttributeModification() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute cn = new AttributeImpl( "cn", "test" );
-        
-        entry.put( cn );
-
-        Attribute ou = new AttributeImpl( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
-        
-        entry.put( ou );
+        Entry entry = new DefaultClientEntry();
+        entry.put( "cn", "test" );
+        entry.put( "ou", "apache", "acme corp" );
         
-        Attribute newOu = new AttributeImpl( "ou" );
-        newOu.add( "Big Company" );
-        newOu.add( "directory" );
+        EntryAttribute newOu = new DefaultClientAttribute( "ou", "Big Company", "directory" );
         
-        ModificationItem modification = new ModificationItemImpl(DirContext.REPLACE_ATTRIBUTE, newOu );
+        Modification modification = new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu );
         
         AttributeUtils.applyModification( entry, modification );
         
@@ -358,23 +350,21 @@
         assertNotNull( entry.get( "cn" ) );
         assertNotNull( entry.get( "ou" ) );
         
-        Attribute modifiedAttr = entry.get( "ou" );
+        EntryAttribute modifiedAttr = entry.get( "ou" );
         
-        NamingEnumeration<?> values = modifiedAttr.getAll();
-        
-        assertTrue( values.hasMoreElements() );
+        assertTrue( modifiedAttr.size() != 0 );
         
         Set<String> expectedValues = new HashSet<String>();
         expectedValues.add( "Big Company" );
         expectedValues.add( "directory" );
-        
-        while ( values.hasMoreElements() )
+
+        for ( Value<?> value:modifiedAttr )
         {
-            String value = (String)values.nextElement();
+            String valueStr = (String)value.get();
             
-            assertTrue( expectedValues.contains( value ) );
+            assertTrue( expectedValues.contains( valueStr ) );
             
-            expectedValues.remove( value );
+            expectedValues.remove( valueStr );
         }
         
         assertEquals( 0, expectedValues.size() );
@@ -389,20 +379,13 @@
     @Test
     public void testApplyModifyModificationRemoveAttribute() throws NamingException
     {
-        Attributes entry = new AttributesImpl();
-        Attribute cn = new AttributeImpl( "cn", "test" );
-        
-        entry.put( cn );
-
-        Attribute ou = new AttributeImpl( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
-        
-        entry.put( ou );
+        Entry entry = new DefaultClientEntry();
+        entry.put(  "cn", "test" );
+        entry.put( "ou", "apache", "acme corp" );
         
-        Attribute newOu = new AttributeImpl( "ou" );
+        EntryAttribute newOu = new DefaultClientAttribute( "ou" );
         
-        ModificationItem modification = new ModificationItemImpl(DirContext.REPLACE_ATTRIBUTE, newOu );
+        Modification modification = new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu );
         
         AttributeUtils.applyModification( entry, modification );
         



Mime
View raw message