directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r689830 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/ apacheds/trunk/protocol-ldap/src/main/java/org/apach...
Date Thu, 28 Aug 2008 14:11:19 GMT
Author: elecharny
Date: Thu Aug 28 07:11:15 2008
New Revision: 689830

URL: http://svn.apache.org/viewvc?rev=689830&view=rev
Log:
o Removed the JNDI elements out of the Add operation in the frontend
o Fixed DIRSERVER-1239
o Added some tests for DIRSERVER-1239
o Moved a test from ModifyITest to AddITest (it was not a modification)

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
    directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java Thu Aug 28 07:11:15 2008
@@ -22,8 +22,8 @@
 
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.shared.ldap.message.AddRequest;
 import org.apache.directory.shared.ldap.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -91,9 +91,9 @@
     public AddOperationContext( CoreSession session, AddRequest addRequest ) throws Exception
     {
         super( session );
-        this.entry = new ClonedServerEntry( ServerEntryUtils.toServerEntry( addRequest.getAttributes(), addRequest.getEntry(), 
-            session.getDirectoryService().getRegistries() ) );
-        this.dn = addRequest.getEntry();
+        this.entry = new ClonedServerEntry( 
+            new DefaultServerEntry( session.getDirectoryService().getRegistries(), addRequest.getEntry() ) );
+        this.dn = addRequest.getEntry().getDn();
         this.requestControls = addRequest.getControls();
     }
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Thu Aug 28 07:11:15 2008
@@ -1699,14 +1699,39 @@
         for ( AttributeTypeAndValue ava : rdn )
         {
             String value = ( String ) ava.getNormValue();
+            String upValue = ( String ) ava.getUpValue();
             String upId = ava.getUpType();
 
             // Check that the entry contains this AVA
             if ( !entry.contains( upId, value ) )
             {
-                String message = "The RDN '" + upId + "=" + value + "' is not present in the entry";
-                LOG.error( message );
-                throw new LdapInvalidAttributeValueException( message, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                String message = "The RDN '" + upId + "=" + upValue + "' is not present in the entry";
+                LOG.warn( message );
+                
+                // We don't have this attribute : add it.
+                // Two cases : 
+                // 1) The attribute does not exist
+                if ( !entry.containsAttribute( upId ) )
+                {
+                    entry.add( upId, upValue );
+                }
+                // 2) The attribute exists
+                else
+                {
+                    AttributeType at = atRegistry.lookup( upId );
+                    
+                    // 2.1 if the attribute is single valued, replace the value
+                    if ( at.isSingleValue() )
+                    {
+                        entry.removeAttributes( upId );
+                        entry.put( upId, upValue );
+                    }
+                    // 2.2 the attribute is multi-valued : add the missing value
+                    else
+                    {
+                        entry.add( upId, upValue );
+                    }
+                }
             }
         }
     }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ReferralAwareRequestHandler.java Thu Aug 28 07:11:15 2008
@@ -84,7 +84,7 @@
         switch ( req.getType() )
         {
             case ADD_REQUEST:
-                reqTargetDn = ( ( AddRequest ) req ).getEntry();
+                reqTargetDn = ( ( AddRequest ) req ).getEntryDn();
                 break;
             case BIND_REQUEST:
                 // not used for bind but may be in future

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Thu Aug 28 07:11:15 2008
@@ -148,6 +148,7 @@
         Attribute newOcls = attributes.get( "objectClass" );
 
         String[] expectedOcls = { "top", "person", "organizationalPerson", "inetOrgPerson" };
+
         for ( String name : expectedOcls )
         {
             assertTrue( "object class " + name + " is present", newOcls.contains( name ) );
@@ -691,4 +692,174 @@
     	
     	ctx.createSubcontext( "cn=\"Jim, Bean\"", attrs );
     }
+
+
+    /**
+     * Create an entry a RDN which is not present in the entry
+     */
+    @Test
+    public void testAddEntryNoRDNInEntry() throws Exception
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
+        // Create a person
+        Attributes person = new AttributesImpl( "objectClass", "inetOrgPerson", true );
+        person.get( "objectClass" ).add( "top" );
+        person.get( "objectClass" ).add( "person" );
+        person.get( "objectClass" ).add( "organizationalperson" );
+        person.put( "sn", "Michael Jackson" );
+        person.put( "cn", "Jackson" );
+
+        DirContext michaelCtx = ctx.createSubcontext( "givenname=Michael", person );
+        
+        assertNotNull( michaelCtx );
+        
+        DirContext jackson = ( DirContext ) ctx.lookup( "givenname=Michael" );
+        person = jackson.getAttributes( "" );
+        Attribute newOcls = person.get( "objectClass" );
+
+        String[] expectedOcls = { "top", "person", "organizationalPerson", "inetOrgPerson" };
+
+        for ( String name : expectedOcls )
+        {
+            assertTrue( "object class " + name + " is present", newOcls.contains( name ) );
+        }
+        
+        Attribute givenName = person.get( "givenname" );
+        
+        assertEquals( "Michael", givenName.get() );
+    }
+
+
+    /**
+     * Create an entry a RDN which is not present in the entry, but
+     * with another attribute's value
+     */
+    @Test
+    public void testAddEntryDifferentRDNInEntry() throws Exception
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
+        // Create a person
+        Attributes person = new AttributesImpl( "objectClass", "inetOrgPerson", true );
+        person.get( "objectClass" ).add( "top" );
+        person.get( "objectClass" ).add( "person" );
+        person.get( "objectClass" ).add( "organizationalperson" );
+        person.put( "givenName", "Michael" );
+        person.put( "sn", "Michael Jackson" );
+        person.put( "cn", "Jackson" );
+
+        DirContext michaelCtx = ctx.createSubcontext( "cn=Michael", person );
+        
+        assertNotNull( michaelCtx );
+        
+        DirContext jackson = ( DirContext ) ctx.lookup( "cn=Michael" );
+        person = jackson.getAttributes( "" );
+        Attribute newOcls = person.get( "objectClass" );
+
+        String[] expectedOcls = { "top", "person", "organizationalPerson", "inetOrgPerson" };
+
+        for ( String name : expectedOcls )
+        {
+            assertTrue( "object class " + name + " is present", newOcls.contains( name ) );
+        }
+        
+        Attribute cn = person.get( "cn" );
+        
+        assertEquals( 2, cn.size() );
+        String[] expectedCns = { "Jackson", "Michael" };
+
+        for ( String name : expectedCns )
+        {
+            assertTrue( "CN " + name + " is present", cn.contains( name ) );
+        }
+    }
+
+
+    /**
+     * Create an entry a RDN which is not present in the entry, 
+     * with another attribute's value, and on a SingleValued attribute
+     */
+    @Test
+    public void testAddEntryDifferentRDNSingleValuedInEntry() throws Exception
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
+        // Create a person
+        Attributes person = new AttributesImpl( "objectClass", "inetOrgPerson", true );
+        person.get( "objectClass" ).add( "top" );
+        person.get( "objectClass" ).add( "person" );
+        person.get( "objectClass" ).add( "organizationalperson" );
+        person.put( "displayName", "Michael" );
+        person.put( "sn", "Michael Jackson" );
+        person.put( "cn", "Jackson" );
+
+        DirContext michaelCtx = ctx.createSubcontext( "displayName=test", person );
+        
+        assertNotNull( michaelCtx );
+        
+        DirContext jackson = ( DirContext ) ctx.lookup( "displayName=test" );
+        person = jackson.getAttributes( "" );
+        Attribute newOcls = person.get( "objectClass" );
+
+        String[] expectedOcls = { "top", "person", "organizationalPerson", "inetOrgPerson" };
+
+        for ( String name : expectedOcls )
+        {
+            assertTrue( "object class " + name + " is present", newOcls.contains( name ) );
+        }
+        
+        // Check that the displayName attribute has been replaced
+        Attribute displayName = person.get( "displayName" );
+        
+        assertEquals( 1, displayName.size() );
+        assertTrue( displayName.contains( "test" ) );
+    }
+
+
+    /**
+     * Create an entry a composed RDN which is not present in the entry, 
+     * with another attribute's value, and on a SingleValued attribute
+     */
+    @Test
+    public void testAddEntryComposedRDN() throws Exception
+    {
+        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
+        
+        // Create a person
+        Attributes person = new AttributesImpl( "objectClass", "inetOrgPerson", true );
+        person.get( "objectClass" ).add( "top" );
+        person.get( "objectClass" ).add( "person" );
+        person.get( "objectClass" ).add( "organizationalperson" );
+        person.put( "sn", "Michael Jackson" );
+        person.put( "cn", "Jackson" );
+
+        DirContext michaelCtx = ctx.createSubcontext( "displayName=test+cn=Michael", person );
+        
+        assertNotNull( michaelCtx );
+        
+        DirContext jackson = ( DirContext ) ctx.lookup( "displayName=test+cn=Michael" );
+        person = jackson.getAttributes( "" );
+        Attribute newOcls = person.get( "objectClass" );
+
+        String[] expectedOcls = { "top", "person", "organizationalPerson", "inetOrgPerson" };
+
+        for ( String name : expectedOcls )
+        {
+            assertTrue( "object class " + name + " is present", newOcls.contains( name ) );
+        }
+        
+        // Check that the DIsplayName attribute has been added
+        Attribute displayName = person.get( "displayName" );
+        
+        assertEquals( 1, displayName.size() );
+        assertTrue( displayName.contains( "test" ) );
+
+        // Check that the cn attribute value has been added
+        Attribute cn = person.get( "cn" );
+        
+        assertEquals( 2, cn.size() );
+        assertTrue( cn.contains( "Jackson" ) );
+        assertTrue( cn.contains( "Michael" ) );
+    }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java Thu Aug 28 07:11:15 2008
@@ -31,7 +31,6 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.DirContext;
-import javax.naming.directory.InvalidAttributeIdentifierException;
 import javax.naming.directory.InvalidAttributeValueException;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.NoSuchAttributeException;
@@ -373,32 +372,6 @@
 
 
     /**
-     * Create an entry with a bad attribute : this should fail.
-     */
-    @Test
-    public void testAddUnexistingAttribute() throws Exception
-    {
-        DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
-        
-        // Create a third person with a voice attribute
-        Attributes attributes = this.getPersonAttributes( "Jackson", "Michael Jackson" );
-        attributes.put( "voice", "He is bad ..." );
-
-        try
-        {
-            ctx.createSubcontext( "cn=Mickael Jackson", attributes );
-        }
-        catch ( InvalidAttributeIdentifierException iaie )
-        {
-            assertTrue( true );
-            return;
-        }
-
-        fail( "Should never reach this point" );
-    }
-
-
-    /**
      * Modify the entry with a bad attribute : this should fail 
      */
     @Test

Modified: directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java (original)
+++ directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java Thu Aug 28 07:11:15 2008
@@ -232,11 +232,9 @@
 
         Entry entry = ldifEntry.getEntry();
 
-        addRequest.setEntry( new LdapDN( dn ) );
+        addRequest.setEntryDn( new LdapDN( dn ) );
 
         // Copy the attributes
-        addRequest.initAttributes();
-
         for ( EntryAttribute attribute:entry )
         {
             addRequest.addAttributeType( attribute.getId() );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Thu Aug 28 07:11:15 2008
@@ -21,6 +21,7 @@
 
 
 import javax.naming.InvalidNameException;
+import javax.naming.NamingException;
 
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
 import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
@@ -1926,12 +1927,12 @@
                     }
                     else
                     {
-                        LdapDN entry = null;
+                        LdapDN entryDn = null;
                         byte[] dnBytes = tlv.getValue().getData();
 
                         try
                         {
-                            entry = new LdapDN( dnBytes );
+                            entryDn = new LdapDN( dnBytes );
                         }
                         catch ( InvalidNameException ine )
                         {
@@ -1944,7 +1945,7 @@
                                 LdapDN.EMPTY_LDAPDN, ine );
                         }
 
-                        addRequest.setEntry( entry );
+                        addRequest.setEntryDn( entryDn );
                     }
 
                     log.debug( "Adding an entry with DN : {}", addRequest.getEntry() );
@@ -1962,19 +1963,7 @@
         //
         // Initialize the attribute list
         super.transitions[LdapStatesEnum.ENTRY_STATE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            LdapStatesEnum.ENTRY_STATE, LdapStatesEnum.ATTRIBUTES_STATE, UniversalTag.SEQUENCE_TAG, new GrammarAction(
-                "Init attributes array list" )
-            {
-                public void action( IAsn1Container container )
-                {
-
-                    LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
-                    AddRequest addRequest = ldapMessage.getAddRequest();
-
-                    addRequest.initAttributes();
-                }
-            } );
+            LdapStatesEnum.ENTRY_STATE, LdapStatesEnum.ATTRIBUTES_STATE, UniversalTag.SEQUENCE_TAG, null );
 
         // --------------------------------------------------------------------------------------------
         // Transition from Attributes to Attribute
@@ -2018,12 +2007,24 @@
                         AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
 
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
-                            addRequest.getEntry(), null );
+                            addRequest.getEntry().getDn(), null );
                     }
 
                     String type = StringTools.getType( tlv.getValue().getData() );
 
-                    addRequest.addAttributeType( type );
+                    try
+                    {
+                        addRequest.addAttributeType( type );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        String msg = "Error while injecting the AttributeType";
+                        log.error( msg );
+
+                        AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
+                            addRequest.getEntry().getDn(), ne );
+                    }
 
                     if ( IS_DEBUG )
                     {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Thu Aug 28 07:11:15 2008
@@ -194,7 +194,7 @@
         snickersMessage.setEntry( addRequest.getEntry() );
 
         // Twix : Attributes attributes -> Snickers : Attributes entry
-        snickersMessage.setAttributes( addRequest.getAttributes() );
+        snickersMessage.setEntry( addRequest.getEntry() );
 
         return snickersMessage;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java Thu Aug 28 07:11:15 2008
@@ -26,10 +26,7 @@
 import java.util.List;
 
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
@@ -37,10 +34,13 @@
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
@@ -76,14 +76,11 @@
     // ~ Instance fields
     // ----------------------------------------------------------------------------
 
-    /** The DN to be added. */
-    private LdapDN entry;
-
     /** The attributes list. */
-    private Attributes attributes;
+    private Entry entry;
 
     /** The current attribute being decoded */
-    private Attribute currentAttribute;
+    private EntryAttribute currentAttribute;
 
     /** The add request length */
     private int addRequestLength;
@@ -107,6 +104,7 @@
     public AddRequest()
     {
         super();
+        entry = new DefaultClientEntry();
     }
 
 
@@ -125,22 +123,22 @@
 
 
     /**
-     * Initialize the ArrayList for attributes.
+     * Initialize the Entry.
      */
-    public void initAttributes()
+    public void initEntry()
     {
-        attributes = new AttributesImpl( true );
+        entry = new DefaultClientEntry();
     }
 
 
     /**
-     * Get the entry's attributes to be added
+     * Get the entry to be added
      * 
-     * @return Returns the attributes.
+     * @return Returns the entry.
      */
-    public Attributes getAttributes()
+    public Entry getEntry()
     {
-        return attributes;
+        return entry;
     }
 
     /**
@@ -148,18 +146,18 @@
      * 
      * @param type The attribute's name (called 'type' in the grammar)
      */
-    public void addAttributeType( String type )
+    public void addAttributeType( String type ) throws NamingException
     {
         // do not create a new attribute if we have seen this attributeType before
-        if ( attributes.get( type ) != null )
+        if ( entry.get( type ) != null )
         {
-            currentAttribute = attributes.get( type );
+            currentAttribute = entry.get( type );
             return;
         }
         
         // fix this to use AttributeImpl(type.getString().toLowerCase())
-        currentAttribute = new AttributeImpl( type );
-        attributes.put( currentAttribute );
+        currentAttribute = new DefaultClientAttribute( type );
+        entry.put( currentAttribute );
     }
 
 
@@ -170,29 +168,36 @@
      */
     public void addAttributeValue( Object value )
     {
-        currentAttribute.add( value );
+        if ( value instanceof String )
+        {
+            currentAttribute.add( (String)value );
+        }
+        else
+        {
+            currentAttribute.add( (byte[])value );
+        }
     }
 
 
     /**
      * Get the added DN
      * 
-     * @return Returns the entry.
+     * @return Returns the entry DN.
      */
-    public LdapDN getEntry()
+    public LdapDN getEntryDn()
     {
-        return entry;
+        return entry.getDn();
     }
 
 
     /**
      * Set the added DN.
      * 
-     * @param entry The entry to set.
+     * @param entry The DN to set.
      */
-    public void setEntry( LdapDN entry )
+    public void setEntryDn( LdapDN entryDn )
     {
-        this.entry = entry;
+        entry.setDn( entryDn );
     }
 
 
@@ -238,60 +243,47 @@
     public int computeLength()
     {
         // The entry
-        addRequestLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry );
+        addRequestLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( entry.getDn() ) ) + 
+            LdapDN.getNbBytes( entry.getDn() );
 
         // The attributes sequence
         attributesLength = 0;
 
-        if ( ( attributes != null ) && ( attributes.size() != 0 ) )
+        if ( ( entry != null ) && ( entry.size() != 0 ) )
         {
-            NamingEnumeration<? extends Attribute> attributeIterator = attributes.getAll();
             attributeLength = new LinkedList<Integer>();
             valuesLength = new LinkedList<Integer>();
 
             // Compute the attributes length
-            while ( attributeIterator.hasMoreElements() )
+            for ( EntryAttribute attribute:entry )
             {
-                Attribute attribute = attributeIterator.nextElement();
                 int localAttributeLength = 0;
                 int localValuesLength = 0;
 
                 // Get the type length
-                int idLength = attribute.getID().getBytes().length;
+                int idLength = attribute.getId().getBytes().length;
                 localAttributeLength = 1 + TLV.getNbBytes( idLength ) + idLength;
 
                 // The values
-                try
+                if ( attribute.size() != 0 )
                 {
-                    NamingEnumeration<?> values = attribute.getAll();
+                    localValuesLength = 0;
 
-                    if ( values.hasMoreElements() )
+                    for ( org.apache.directory.shared.ldap.entry.Value<?> value:attribute )
                     {
-                        localValuesLength = 0;
-
-                        while ( values.hasMoreElements() )
+                        if ( value instanceof ClientStringValue )
                         {
-                            Object value = values.next();
-
-                            if ( value instanceof String )
-                            {
-                                int valueLength = StringTools.getBytesUtf8( ( String ) value ).length;
-                                localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
-                            }
-                            else
-                            {
-                                int valueLength = ( ( byte[] ) value ).length;
-                                localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
-                            }
+                            int valueLength = StringTools.getBytesUtf8( ( String ) value.get() ).length;
+                            localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
+                        }
+                        else
+                        {
+                            int valueLength = ( ( byte[] ) value.get() ).length;
+                            localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
                         }
-
-                        localAttributeLength += 1 + TLV.getNbBytes( localValuesLength ) + localValuesLength;
                     }
 
-                }
-                catch ( NamingException ne )
-                {
-                    return 0;
+                    localAttributeLength += 1 + TLV.getNbBytes( localValuesLength ) + localValuesLength;
                 }
 
                 // add the attribute length to the attributes length
@@ -355,61 +347,46 @@
             buffer.put( TLV.getBytes( addRequestLength ) );
 
             // The entry
-            Value.encode( buffer, LdapDN.getBytes( entry ) );
+            Value.encode( buffer, LdapDN.getBytes( entry.getDn() ) );
 
             // The attributes sequence
             buffer.put( UniversalTag.SEQUENCE_TAG );
             buffer.put( TLV.getBytes( attributesLength ) );
 
             // The partial attribute list
-            if ( ( attributes != null ) && ( attributes.size() != 0 ) )
+            if ( ( entry != null ) && ( entry.size() != 0 ) )
             {
-                NamingEnumeration<? extends Attribute> attributeIterator = attributes.getAll();
                 int attributeNumber = 0;
 
                 // Compute the attributes length
-                while ( attributeIterator.hasMoreElements() )
+                for ( EntryAttribute attribute:entry )
                 {
-                    Attribute attribute = attributeIterator.nextElement();
-
                     // The attributes list sequence
                     buffer.put( UniversalTag.SEQUENCE_TAG );
                     int localAttributeLength = attributeLength.get( attributeNumber );
                     buffer.put( TLV.getBytes( localAttributeLength ) );
 
                     // The attribute type
-                    Value.encode( buffer, attribute.getID() );
+                    Value.encode( buffer, attribute.getId() );
 
                     // The values
                     buffer.put( UniversalTag.SET_TAG );
                     int localValuesLength = valuesLength.get( attributeNumber );
                     buffer.put( TLV.getBytes( localValuesLength ) );
 
-                    try
+                    if ( attribute.size() != 0 )
                     {
-                        NamingEnumeration<?> values = attribute.getAll();
-
-                        if ( values.hasMoreElements() )
+                        for ( org.apache.directory.shared.ldap.entry.Value<?> value:attribute )
                         {
-                            while ( values.hasMoreElements() )
+                            if ( value instanceof ClientBinaryValue )
                             {
-                                Object value = values.next();
-
-                                if ( value instanceof byte[] )
-                                {
-                                    Value.encode( buffer, ( byte[] ) value );
-                                }
-                                else
-                                {
-                                    Value.encode( buffer, ( String ) value );
-                                }
+                                Value.encode( buffer, ( byte[] ) value.get() );
+                            }
+                            else
+                            {
+                                Value.encode( buffer, ( String ) value.get() );
                             }
                         }
-
-                    }
-                    catch ( NamingException ne )
-                    {
-                        throw new EncoderException( "Cannot enumerate the values" );
                     }
 
                     // Go to the next attribute number;
@@ -440,19 +417,18 @@
     public String toString()
     {
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
 
         sb.append( "    Add Request\n" );
-        sb.append( "        Entry : '" ).append( entry ).append( "'\n" );
         sb.append( "        Attributes\n" );
 
-        if ( ( attributes == null ) || ( attributes.size() == 0 ) )
+        if ( entry == null ) 
         {
             sb.append( "            No attributes\n" );
         }
         else
         {
-            sb.append( AttributeUtils.toString( "            ", attributes ) );
+            sb.append( entry );
         }
 
         return sb.toString();
@@ -464,6 +440,6 @@
      */
     public String getCurrentAttributeType()
     {
-        return currentAttribute.getID();
+        return currentAttribute.getId();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequest.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequest.java Thu Aug 28 07:11:15 2008
@@ -21,8 +21,11 @@
 package org.apache.directory.shared.ldap.message;
 
 
-import javax.naming.directory.Attributes;
+//import javax.naming.directory.Attributes;
 
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
@@ -46,31 +49,29 @@
      * 
      * @return the Dn of the added entry.
      */
-    LdapDN getEntry();
+    LdapDN getEntryDn();
 
 
     /**
      * Sets the distinguished name of the entry to add.
      * 
-     * @param entry
-     *            the Dn of the added entry.
+     * @param entry the Dn of the added entry.
      */
-    void setEntry( LdapDN entry );
+    void setEntryDn( LdapDN entry );
 
 
     /**
-     * Gets the attributes of the entry to add.
+     * Gets the entry to add.
      * 
-     * @return the Attributes containing attribute value pairs.
+     * @return the added Entry
      */
-    Attributes getAttributes();
+    Entry getEntry();
 
 
     /**
-     * Sets the attribute value pairs of the entry to add.
+     * Sets the Entry to add.
      * 
-     * @param attributes
-     *            the Attributes with attribute value pairs for the added entry.
+     * @param entry the added Entry
      */
-    void setAttributes( Attributes attributes );
+    void setEntry( Entry entry );
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java Thu Aug 28 07:11:15 2008
@@ -20,10 +20,10 @@
 package org.apache.directory.shared.ldap.message;
 
 
-import javax.naming.directory.Attributes;
 
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
 
 
 /**
@@ -36,11 +36,8 @@
 {
     static final long serialVersionUID = 7534132448349520346L;
 
-    /** Distinguished name of the new entry. */
-    private LdapDN entry;
-
     /** A MultiMap of the new entry's attributes and their values */
-    private Attributes attributes;
+    private Entry entry;
 
     private AddResponse response;
 
@@ -58,6 +55,7 @@
     public AddRequestImpl(final int id)
     {
         super( id, TYPE );
+        entry = new DefaultClientEntry();
     }
 
 
@@ -70,44 +68,42 @@
      * 
      * @return the Dn of the added entry.
      */
-    public LdapDN getEntry()
+    public LdapDN getEntryDn()
     {
-        return entry;
+        return entry.getDn();
     }
 
 
     /**
      * Sets the distinguished name of the entry to add.
      * 
-     * @param entry
-     *            the Dn of the added entry.
+     * @param entry the Dn of the added entry.
      */
-    public void setEntry( LdapDN entry )
+    public void setEntryDn( LdapDN dn )
     {
-        this.entry = entry;
+        entry.setDn( dn );
     }
 
 
     /**
-     * Gets the attribute value pairs of the entry to add as a MultiMap.
+     * Gets the entry to add.
      * 
-     * @return the Attribute with attribute value pairs.
+     * @return the added Entry
      */
-    public Attributes getAttributes()
+    public Entry getEntry()
     {
-        return attributes;
+        return entry;
     }
 
 
     /**
-     * Sets the attribute value pairs of the entry to add as a MultiMap.
+     * Sets the Entry to add.
      * 
-     * @param attributes
-     *            the Attributes with attribute value pairs for the added entry.
+     * @param entry the added Entry
      */
-    public void setAttributes( Attributes attributes )
+    public void setEntry( Entry entry )
     {
-        this.attributes = attributes;
+        this.entry = entry;
     }
 
 
@@ -158,12 +154,14 @@
      */
     public boolean equals( Object obj )
     {
+        // Short circuit
         if ( this == obj )
         {
             return true;
         }
         
-        if ( ( obj == null ) || !( obj instanceof AddRequest ) )
+        // Check the object class. If null, it will exit.
+        if ( !( obj instanceof AddRequest ) )
         {
             return false;
         }
@@ -175,45 +173,15 @@
 
         AddRequest req = ( AddRequest ) obj;
 
+        // Check the entry
         if ( entry == null )
         {
-            if ( req.getEntry() != null )
-            {
-                return false;
-            }
+            return ( req.getEntry() == null );
         }
         else
         {
-            if ( req.getEntry() == null )
-            {
-                return false;
-            }
-            else if ( !entry.equals( req.getEntry() ) )
-            {
-                return false;
-            }
-        }
-        
-        if ( attributes == null )
-        {
-            if ( req.getAttributes() != null )
-            {
-                return false;
-            }
+            return ( entry.equals( req.getEntry() ) );
         }
-        else
-        {
-            if ( req.getAttributes() == null )
-            {
-                return false;
-            }
-            else if ( !attributes.equals( req.getAttributes() ) )
-            {
-                return false;
-            }
-        }
-
-        return true;
     }
 
     /**
@@ -223,7 +191,6 @@
     public int hashCode()
     {
         int hash = 37;
-        hash = hash*17 + ( attributes == null ? 0 : attributes.hashCode() );
         hash = hash*17 + ( entry == null ? 0 : entry.hashCode() );
         hash = hash*17 + ( response == null ? 0 : response.hashCode() );
         hash = hash*17 + super.hashCode();
@@ -236,18 +203,17 @@
      */
     public String toString()
     {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
 
-        sb.append( "    Add Request\n" );
-        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
-
-        if ( ( attributes == null ) || ( attributes.size() == 0 ) )
+        sb.append( "    Add Request :\n" );
+        
+        if ( entry == null )
         {
-            sb.append( "            No attributes\n" );
+            sb.append( "            No entry\n" );
         }
         else
         {
-            sb.append( AttributeUtils.toString( "            ", attributes ) );
+            sb.append( entry.toString() );
         }
 
         return sb.toString();

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java Thu Aug 28 07:11:15 2008
@@ -27,10 +27,7 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
@@ -42,6 +39,9 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.ResponseCarryingException;
 import org.apache.directory.shared.ldap.codec.add.AddRequest;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.message.Message;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -116,11 +116,11 @@
 
         // Check the decoded message
         assertEquals( 1, message.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntry().toString() );
+        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntryDn().toString() );
 
-        Attributes attributes = addRequest.getAttributes();
+        Entry entry = addRequest.getEntry();
 
-        assertEquals( 2, attributes.size() );
+        assertEquals( 2, entry.size() );
 
         Set<String> expectedTypes = new HashSet<String>();
 
@@ -139,36 +139,30 @@
         lVal2.add( "test3" );
         typesVals.put( "attrs", lVal2 );
 
-        Attribute attributeValue = attributes.get( "l" );
+        EntryAttribute attribute = entry.get( "l" );
 
-        assertTrue( expectedTypes.contains( attributeValue.getID().toLowerCase() ) );
+        assertTrue( expectedTypes.contains( attribute.getId().toLowerCase() ) );
 
-        NamingEnumeration<?> values = attributeValue.getAll();
-        Set<String> vals = ( Set<String> ) typesVals.get( attributeValue.getID().toLowerCase() );
+        Set<String> vals = ( Set<String> ) typesVals.get( attribute.getId().toLowerCase() );
 
-        while ( values.hasMore() )
+        for ( Value<?> value:attribute )
         {
-            Object value = values.next();
+            assertTrue( vals.contains( value.get() ) );
 
-            assertTrue( vals.contains( value.toString() ) );
-
-            vals.remove( value.toString() );
+            vals.remove( value.get() );
         }
 
-        attributeValue = attributes.get( "attrs" );
+        attribute = entry.get( "attrs" );
 
-        assertTrue( expectedTypes.contains( attributeValue.getID().toLowerCase() ) );
+        assertTrue( expectedTypes.contains( attribute.getId().toLowerCase() ) );
 
-        values = attributeValue.getAll();
-        vals = ( Set<String> ) typesVals.get( attributeValue.getID().toLowerCase() );
+        vals = ( Set<String> ) typesVals.get( attribute.getId().toLowerCase() );
 
-        while ( values.hasMore() )
+        for ( Value<?> value:attribute )
         {
-            Object value = values.next();
-
-            assertTrue( vals.contains( value.toString() ) );
+            assertTrue( vals.contains( value.get() ) );
 
-            vals.remove( value.toString() );
+            vals.remove( value.get() );
         }
 
         // Check the length
@@ -605,23 +599,19 @@
 
         // Check the decoded message
         assertEquals( 1, message.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntry().toString() );
+        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntryDn().toString() );
 
-        Attributes attributes = addRequest.getAttributes();
+        Entry entry = addRequest.getEntry();
 
-        assertEquals( 1, attributes.size() );
+        assertEquals( 1, entry.size() );
 
-        Attribute attributeValue = attributes.get( "l" );
+        EntryAttribute attribute = entry.get( "l" );
 
-        assertEquals( "l", attributeValue.getID().toLowerCase() );
+        assertEquals( "l", attribute.getId().toLowerCase() );
 
-        NamingEnumeration<?> values = attributeValue.getAll();
-
-        while ( values.hasMore() )
+        for ( Value<?> value:attribute )
         {
-            Object value = values.next();
-
-            assertEquals( "", value.toString() );
+            assertEquals( "", value.get() );
         }
 
         // Check the length
@@ -697,23 +687,19 @@
 
         // Check the decoded message
         assertEquals( 1, message.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntry().toString() );
+        assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntryDn().toString() );
 
-        Attributes attributes = addRequest.getAttributes();
+        Entry entry = addRequest.getEntry();
 
-        assertEquals( 1, attributes.size() );
+        assertEquals( 1, entry.size() );
 
-        Attribute attributeValue = attributes.get( "l" );
+        EntryAttribute attribute = entry.get( "l" );
 
-        assertEquals( "l", attributeValue.getID().toLowerCase() );
-
-        NamingEnumeration<?> values = attributeValue.getAll();
-
-        while ( values.hasMore() )
+        assertEquals( "l", attribute.getId().toLowerCase() );
+ 
+        for ( Value<?> value:attribute )
         {
-            Object value = values.next();
-
-            assertEquals( "", value.toString() );
+            assertEquals( "", value.get() );
         }
 
         // Check the length

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java?rev=689830&r1=689829&r2=689830&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java Thu Aug 28 07:11:15 2008
@@ -26,14 +26,17 @@
 import java.util.Map;
 
 import javax.naming.InvalidNameException;
-import javax.naming.directory.Attributes;
+import javax.naming.NamingException;
 
 import javax.naming.ldap.Control;
+
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+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.AbandonListener;
 import org.apache.directory.shared.ldap.message.AddRequest;
 import org.apache.directory.shared.ldap.message.AddRequestImpl;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.MessageException;
 import org.apache.directory.shared.ldap.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.message.ResultResponse;
@@ -57,9 +60,9 @@
      *            the id for the attribute
      * @return the AttributeImpl assembled for testing
      */
-    private AttributeImpl getAttribute( String id )
+    private EntryAttribute getAttribute( String id )
     {
-        AttributeImpl attr = new AttributeImpl( id );
+        EntryAttribute attr = new DefaultClientAttribute( id );
         attr.add( "value0" );
         attr.add( "value1" );
         attr.add( "value2" );
@@ -72,13 +75,22 @@
      * 
      * @return
      */
-    private AttributesImpl getAttributes()
+    private Entry getEntry()
     {
-        AttributesImpl attrs = new AttributesImpl();
-        attrs.put( getAttribute( "attr0" ) );
-        attrs.put( getAttribute( "attr1" ) );
-        attrs.put( getAttribute( "attr2" ) );
-        return attrs;
+        Entry entry = new DefaultClientEntry();
+        
+        try
+        {
+            entry.put( getAttribute( "attr0" ) );
+            entry.put( getAttribute( "attr1" ) );
+            entry.put( getAttribute( "attr2" ) );
+        }
+        catch ( NamingException ne )
+        {
+            // Do nothing
+        }
+        
+        return entry;
     }
 
 
@@ -95,15 +107,15 @@
     /**
      * Tests for equality using exact copies.
      */
-    public void testEqualsExactCopy() throws InvalidNameException
+    public void testEqualsExactCopy() throws InvalidNameException, NamingException
     {
         AddRequestImpl req0 = new AddRequestImpl( 5 );
-        req0.setEntry( new LdapDN( "cn=admin,dc=example,dc=com" ) );
-        req0.setAttributes( getAttributes() );
+        req0.setEntryDn( new LdapDN( "cn=admin,dc=example,dc=com" ) );
+        req0.setEntry( getEntry() );
 
         AddRequestImpl req1 = new AddRequestImpl( 5 );
-        req1.setEntry( new LdapDN( "cn=admin,dc=example,dc=com" ) );
-        req1.setAttributes( getAttributes() );
+        req1.setEntryDn( new LdapDN( "cn=admin,dc=example,dc=com" ) );
+        req1.setEntry( getEntry() );
 
         assertTrue( req0.equals( req1 ) );
     }
@@ -112,15 +124,15 @@
     /**
      * Test for inequality when only the IDs are different.
      */
-    public void testNotEqualDiffId() throws InvalidNameException
+    public void testNotEqualDiffId() throws InvalidNameException, NamingException
     {
         AddRequestImpl req0 = new AddRequestImpl( 7 );
-        req0.setEntry( new LdapDN( "cn=admin,dc=example,dc=com" ) );
-        req0.setAttributes( getAttributes() );
+        req0.setEntryDn( new LdapDN( "cn=admin,dc=example,dc=com" ) );
+        req0.setEntry( getEntry() );
 
         AddRequestImpl req1 = new AddRequestImpl( 5 );
-        req1.setEntry( new LdapDN( "cn=admin,dc=example,dc=com" ) );
-        req1.setAttributes( getAttributes() );
+        req1.setEntryDn( new LdapDN( "cn=admin,dc=example,dc=com" ) );
+        req1.setEntry( getEntry() );
 
         assertFalse( req0.equals( req1 ) );
     }
@@ -129,15 +141,15 @@
     /**
      * Test for inequality when only the DN names are different.
      */
-    public void testNotEqualDiffName() throws InvalidNameException
+    public void testNotEqualDiffName() throws InvalidNameException, NamingException
     {
         AddRequestImpl req0 = new AddRequestImpl( 5 );
-        req0.setEntry( new LdapDN( "cn=admin,dc=example,dc=com" ) );
-        req0.setAttributes( getAttributes() );
+        req0.setEntry( getEntry() );
+        req0.setEntryDn( new LdapDN( "cn=admin,dc=example,dc=com" ) );
 
         AddRequestImpl req1 = new AddRequestImpl( 5 );
-        req1.setEntry( new LdapDN( "cn=admin,dc=apache,dc=org" ) );
-        req1.setAttributes( getAttributes() );
+        req1.setEntry( getEntry() );
+        req1.setEntryDn( new LdapDN( "cn=admin,dc=apache,dc=org" ) );
 
         assertFalse( req0.equals( req1 ) );
     }
@@ -146,24 +158,24 @@
     /**
      * Test for inequality when only the DN names are different.
      */
-    public void testNotEqualDiffAttributes() throws InvalidNameException
+    public void testNotEqualDiffAttributes() throws InvalidNameException, NamingException
     {
         AddRequestImpl req0 = new AddRequestImpl( 5 );
-        req0.setEntry( new LdapDN( "cn=admin,dc=apache,dc=org" ) );
-        req0.setAttributes( getAttributes() );
+        req0.setEntryDn( new LdapDN( "cn=admin,dc=apache,dc=org" ) );
+        req0.setEntry( getEntry() );
 
         AddRequestImpl req1 = new AddRequestImpl( 5 );
-        req1.setEntry( new LdapDN( "cn=admin,dc=apache,dc=org" ) );
+        req1.setEntryDn( new LdapDN( "cn=admin,dc=apache,dc=org" ) );
 
         assertFalse( req0.equals( req1 ) );
         assertFalse( req1.equals( req0 ) );
 
-        req1.setAttributes( getAttributes() );
+        req1.setEntry( getEntry() );
 
         assertTrue( req0.equals( req1 ) );
         assertTrue( req1.equals( req0 ) );
 
-        req1.getAttributes().put( "asdf", "asdf" );
+        req1.getEntry().put( "asdf", "asdf" );
 
         assertFalse( req0.equals( req1 ) );
         assertFalse( req1.equals( req0 ) );
@@ -177,24 +189,24 @@
     {
         AddRequest req0 = new AddRequest()
         {
-            public Attributes getAttributes()
+            public Entry getEntry()
             {
-                return AddRequestImplTest.this.getAttributes();
+                return AddRequestImplTest.this.getEntry();
             }
 
 
-            public void setAttributes( Attributes entry )
+            public void setEntry( Entry entry )
             {
             }
 
 
-            public LdapDN getEntry()
+            public LdapDN getEntryDn()
             {
                 return null;
             }
 
 
-            public void setEntry( LdapDN entry )
+            public void setEntryDn( LdapDN entryDn )
             {
             }
 
@@ -285,7 +297,7 @@
         };
 
         AddRequestImpl req1 = new AddRequestImpl( 5 );
-        req1.setAttributes( getAttributes() );
+        req1.setEntry( getEntry() );
         assertTrue( req1.equals( req0 ) );
     }
 }



Mime
View raw message