directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r984616 - in /directory: clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/ shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ shared/...
Date Wed, 11 Aug 2010 23:42:43 GMT
Author: elecharny
Date: Wed Aug 11 23:42:42 2010
New Revision: 984616

URL: http://svn.apache.org/viewvc?rev=984616&view=rev
Log:
Removed the AddResponseCodec class

Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponseCodec.java
Modified:
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddResponseImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAddResponse.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddResponseTest.java

Modified: directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Wed Aug 11 23:42:42 2010
@@ -89,7 +89,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.MessageEncoderException;
 import org.apache.directory.shared.ldap.codec.abandon.AbandonRequestCodec;
 import org.apache.directory.shared.ldap.codec.add.AddRequestCodec;
-import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
 import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
 import org.apache.directory.shared.ldap.codec.bind.LdapAuthentication;
 import org.apache.directory.shared.ldap.codec.bind.SaslCredentials;
@@ -127,6 +126,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.control.Control;
+import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
@@ -897,13 +897,13 @@ public class LdapNetworkConnection exten
     /**
      * converts the AddResponseCodec to AddResponse.
      */
-    private AddResponse convert( AddResponseCodec addRespCodec )
+    private AddResponse convert( InternalAddResponse internalAddResponse )
     {
         AddResponse addResponse = new AddResponse();
 
-        addResponse.setMessageId( addRespCodec.getMessageId() );
-        addResponse.setLdapResult( convert( addRespCodec.getLdapResult() ) );
-        addControls( addRespCodec, addResponse );
+        addResponse.setMessageId( internalAddResponse.getMessageId() );
+        addResponse.setLdapResult( convert( internalAddResponse.getLdapResult() ) );
+        addControls( internalAddResponse, addResponse );
 
         return addResponse;
     }
@@ -1659,33 +1659,9 @@ public class LdapNetworkConnection exten
 
                     break;
 
-            }
-        }
-        else
-        {
-            LdapMessageCodec response = ( LdapMessageCodec ) message;
-            LOG.debug( "-------> {} Message received <-------", response );
-            int messageId = response.getMessageId();
-
-            // this check is necessary to prevent adding an abandoned operation's
-            // result(s) to corresponding queue
-            ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( messageId );
-
-            if ( responseFuture == null )
-            {
-                LOG.info( "There is no future associated with the messageId {}, ignoring the message", messageId );
-                return;
-            }
-
-            switch ( response.getMessageType() )
-            {
                 case ADD_RESPONSE:
                     // Transform the response
-                    AddResponseCodec addRespCodec = ( AddResponseCodec ) response;
-                    addRespCodec.addControls( response.getControls() );
-                    addRespCodec.setMessageId( messageId );
-
-                    AddResponse addResponse = convert( addRespCodec );
+                    AddResponse addResponse = convert( ( InternalAddResponse ) response );
 
                     AddFuture addFuture = ( AddFuture ) responseFuture;
 
@@ -1718,6 +1694,26 @@ public class LdapNetworkConnection exten
 
                     break;
 
+            }
+        }
+        else
+        {
+            LdapMessageCodec response = ( LdapMessageCodec ) message;
+            LOG.debug( "-------> {} Message received <-------", response );
+            int messageId = response.getMessageId();
+
+            // this check is necessary to prevent adding an abandoned operation's
+            // result(s) to corresponding queue
+            ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( messageId );
+
+            if ( responseFuture == null )
+            {
+                LOG.info( "There is no future associated with the messageId {}, ignoring the message", messageId );
+                return;
+            }
+
+            switch ( response.getMessageType() )
+            {
                 case COMPARE_RESPONSE:
                     // Transform the response
                     CompareResponseCodec compResCodec = ( CompareResponseCodec ) response;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java Wed Aug 11 23:42:42 2010
@@ -23,7 +23,6 @@ package org.apache.directory.shared.ldap
 import org.apache.directory.shared.asn1.ber.AbstractContainer;
 import org.apache.directory.shared.ldap.codec.abandon.AbandonRequestCodec;
 import org.apache.directory.shared.ldap.codec.add.AddRequestCodec;
-import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
 import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
 import org.apache.directory.shared.ldap.codec.compare.CompareRequestCodec;
 import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
@@ -43,6 +42,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.unbind.UnBindRequestCodec;
 import org.apache.directory.shared.ldap.message.internal.InternalAbandonRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalAddRequest;
+import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalBindRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalCompareRequest;
@@ -184,9 +184,9 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the AddResponse stored in the container
      */
-    public AddResponseCodec getAddResponse()
+    public InternalAddResponse getInternalAddResponse()
     {
-        return ( AddResponseCodec ) ldapMessage;
+        return ( InternalAddResponse ) internalMessage;
     }
 
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Wed Aug 11 23:42:42 2010
@@ -70,7 +70,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.actions.StoreReferenceAction;
 import org.apache.directory.shared.ldap.codec.actions.StoreTypeMatchingRuleAction;
 import org.apache.directory.shared.ldap.codec.actions.ValueAction;
-import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
 import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
 import org.apache.directory.shared.ldap.codec.controls.ControlEnum;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
@@ -101,18 +100,23 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
+import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.SearchResponseDoneImpl;
 import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.message.internal.InternalAbandonRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalAddRequest;
+import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalBindRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalCompareRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalReferral;
+import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
@@ -1005,8 +1009,6 @@ public class LdapMessageGrammar extends 
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapResponseCodec response = ldapMessageContainer.getLdapResponse();
-                    LdapResultCodec ldapResult = response.getLdapResult();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -1021,7 +1023,22 @@ public class LdapMessageGrammar extends 
                         throw new DecoderException( msg );
                     }
 
-                    ldapResult.initReferrals();
+                    if ( ldapMessageContainer.isInternal() )
+                    {
+                        InternalMessage response = ldapMessageContainer.getInternalMessage();
+                        InternalLdapResult ldapResult = ( ( InternalResultResponse ) response ).getLdapResult();
+
+                        InternalReferral referral = new ReferralImpl();
+
+                        ldapResult.setReferral( referral );
+                    }
+                    else
+                    {
+                        LdapResponseCodec response = ldapMessageContainer.getLdapResponse();
+                        LdapResultCodec ldapResult = response.getLdapResult();
+
+                        ldapResult.initReferrals();
+                    }
                 }
             } );
 
@@ -2045,9 +2062,8 @@ public class LdapMessageGrammar extends 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
                     // Now, we can allocate the AddResponse Object
-                    AddResponseCodec addResponse = new AddResponseCodec();
-                    addResponse.setMessageId( ldapMessageContainer.getMessageId() );
-                    ldapMessageContainer.setLdapMessage( addResponse );
+                    InternalAddResponse addResponse = new AddResponseImpl( ldapMessageContainer.getMessageId() );
+                    ldapMessageContainer.setInternalMessage( addResponse );
 
                     // We will check that the request is not null
                     TLV tlv = ldapMessageContainer.getCurrentTLV();

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java Wed Aug 11 23:42:42 2010
@@ -31,9 +31,11 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.controls.CodecControl;
+import org.apache.directory.shared.ldap.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.message.BindResponseImpl;
 import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
+import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
@@ -99,7 +101,8 @@ public class LdapProtocolEncoder extends
         int length = computeMessageLength( message );
         ByteBuffer buffer = ByteBuffer.allocate( length );
 
-        if ( ( message instanceof InternalBindResponse ) || ( message instanceof InternalDeleteResponse ) )
+        if ( ( message instanceof InternalBindResponse ) || ( message instanceof InternalDeleteResponse )
+            || ( message instanceof InternalAddResponse ) )
         {
             try
             {
@@ -401,6 +404,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the AddResponse length 
+     * 
+     * AddResponse : 
+     * 
+     * 0x69 L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(AddResponse) = Length(0x69) + Length(L1) + L1
+     */
+    private int computeAddResponseLength( AddResponseImpl addResponse )
+    {
+        int addResponseLength = computeLdapResultLength( addResponse.getLdapResult() );
+
+        addResponse.setAddResponseLength( addResponseLength );
+
+        return 1 + TLV.getNbBytes( addResponseLength ) + addResponseLength;
+    }
+
+
+    /**
      * Compute the DelResponse length 
      * 
      * DelResponse :
@@ -424,6 +450,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the AddResponse message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     */
+    private void encodeAddResponse( ByteBuffer buffer, AddResponseImpl addResponse ) throws EncoderException
+    {
+        try
+        {
+            // The AddResponse Tag
+            buffer.put( LdapConstants.ADD_RESPONSE_TAG );
+            buffer.put( TLV.getBytes( addResponse.getAddResponseLength() ) );
+
+            // The LdapResult
+            encodeLdapResult( buffer, addResponse.getLdapResult() );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
+        }
+    }
+
+
+    /**
      * Encode the BindResponse message to a PDU.
      * 
      * BindResponse :
@@ -477,7 +526,7 @@ public class LdapProtocolEncoder extends
     {
         try
         {
-            // The BindResponse Tag
+            // The DelResponse Tag
             buffer.put( LdapConstants.DEL_RESPONSE_TAG );
             buffer.put( TLV.getBytes( deleteResponse.getDeleteResponseLength() ) );
 
@@ -492,26 +541,15 @@ public class LdapProtocolEncoder extends
 
 
     /**
-     * Compute the BindRequest length 
-     * 
-     * BindRequest : 
-     * <pre>
-     * 0x60 L1 
-     *   | 
-     *   +--> 0x02 0x01 (1..127) version 
-     *   +--> 0x04 L2 name 
-     *   +--> authentication 
-     *   
-     * L2 = Length(name)
-     * L3/4 = Length(authentication) 
-     * Length(BindRequest) = Length(0x60) + Length(L1) + L1 + Length(0x02) + 1 + 1 + 
-     *      Length(0x04) + Length(L2) + L2 + Length(authentication)
-     * </pre>
+     * Compute the protocolOp length 
      */
     private int computeProtocolOpLength( InternalMessage message )
     {
         switch ( message.getType() )
         {
+            case ADD_RESPONSE:
+                return computeAddResponseLength( ( AddResponseImpl ) message );
+
             case BIND_RESPONSE:
                 return computeBindResponseLength( ( BindResponseImpl ) message );
 
@@ -528,6 +566,10 @@ public class LdapProtocolEncoder extends
     {
         switch ( message.getType() )
         {
+            case ADD_RESPONSE:
+                encodeAddResponse( bb, ( AddResponseImpl ) message );
+                break;
+
             case BIND_RESPONSE:
                 encodeBindResponse( bb, ( BindResponseImpl ) message );
                 break;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java Wed Aug 11 23:42:42 2010
@@ -27,7 +27,6 @@ import java.util.List;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
 import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
 import org.apache.directory.shared.ldap.codec.bind.SaslCredentials;
 import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
@@ -70,7 +69,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
-import org.apache.directory.shared.ldap.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.BindRequestImpl;
 import org.apache.directory.shared.ldap.message.CompareResponseImpl;
@@ -676,25 +674,6 @@ public class LdapTransformer
 
 
     /**
-     * Transform a Internal AddResponse to a Codec AddResponse
-     * 
-     * @param internalMessage The incoming Internal AddResponse
-     * @return The AddResponseCodec instance
-     */
-    private static LdapMessageCodec transformAddResponse( InternalMessage internalMessage )
-    {
-        AddResponseImpl internalAddResponse = ( AddResponseImpl ) internalMessage;
-
-        AddResponseCodec addResponse = new AddResponseCodec();
-
-        // Transform the ldapResult
-        addResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalAddResponse.getLdapResult() ) );
-
-        return addResponse;
-    }
-
-
-    /**
      * Transform a Internal BindRequest to a Codec BindRequest
      * 
      * @param internalMessage The incoming Internal BindRequest
@@ -968,10 +947,6 @@ public class LdapTransformer
                 codecMessage = transformBindRequest( msg );
                 break;
 
-            case ADD_RESPONSE:
-                codecMessage = transformAddResponse( msg );
-                break;
-
             case COMPARE_RESPONSE:
                 codecMessage = transformCompareResponse( msg );
                 break;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java Wed Aug 11 23:42:42 2010
@@ -30,6 +30,10 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.LdapResultCodec;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
+import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalReferral;
+import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -49,71 +53,133 @@ public class ReferralAction extends Gram
     /** Speedup for logs */
     private static final boolean IS_DEBUG = log.isDebugEnabled();
 
+
     public ReferralAction()
     {
         super( "Add a referral" );
     }
 
+
     /**
      * The initialization action
      */
     public void action( IAsn1Container container ) throws DecoderException
     {
         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-        LdapResponseCodec response = ldapMessageContainer.getLdapResponse();
-        LdapResultCodec ldapResult = response.getLdapResult();
 
         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
-        if ( tlv.getLength() == 0 )
-        {
-            ldapResult.addReferral( LdapURL.EMPTY_URL );
-        }
-        else
+        if ( ldapMessageContainer.isInternal() )
         {
-            if ( ldapResult.getResultCode() == ResultCodeEnum.REFERRAL )
+            InternalMessage response = ldapMessageContainer.getInternalMessage();
+            InternalLdapResult ldapResult = ( ( InternalResultResponse ) response ).getLdapResult();
+            InternalReferral referral = ldapResult.getReferral();
+
+            if ( tlv.getLength() == 0 )
+            {
+                referral.addLdapUrl( "" );
+            }
+            else
             {
-                try
+                if ( ldapResult.getResultCode() == ResultCodeEnum.REFERRAL )
                 {
-                    ldapResult.addReferral( new LdapURL( tlv.getValue().getData() ) );
+                    try
+                    {
+                        referral.addLdapUrl( new LdapURL( tlv.getValue().getData() ).toString() );
+                    }
+                    catch ( LdapURLEncodingException luee )
+                    {
+                        String badUrl = StringTools.utf8ToString( tlv.getValue().getData() );
+                        log.error( I18n.err( I18n.ERR_04015, badUrl, luee.getMessage() ) );
+                        throw new DecoderException( I18n.err( I18n.ERR_04016, luee.getMessage() ) );
+                    }
                 }
-                catch ( LdapURLEncodingException luee )
+                else
                 {
-                    String badUrl = StringTools.utf8ToString( tlv.getValue().getData() );
-                    log.error( I18n.err( I18n.ERR_04015, badUrl, luee.getMessage() ) );
-                    throw new DecoderException( I18n.err( I18n.ERR_04016, luee.getMessage() ) );
+                    log
+                        .warn( "The Referral error message is not allowed when havind an error code no equals to REFERRAL" );
+                    referral.addLdapUrl( LdapURL.EMPTY_URL.toString() );
                 }
             }
-            else
+
+            if ( IS_DEBUG )
             {
-                log.warn( "The Referral error message is not allowed when havind an error code no equals to REFERRAL" );
-                ldapResult.addReferral( LdapURL.EMPTY_URL );
-            }
-        }
+                StringBuffer sb = new StringBuffer();
+                boolean isFirst = true;
 
-        // We can have an END transition
-        ldapMessageContainer.grammarEndAllowed( true );
+                for ( String url : ldapResult.getReferral().getLdapUrls() )
+                {
+                    if ( isFirst )
+                    {
+                        isFirst = false;
+                    }
+                    else
+                    {
+                        sb.append( ", " );
+                    }
 
-        if ( IS_DEBUG )
+                    sb.append( url );
+                }
+
+                log.debug( "The referral error message is set to " + sb.toString() );
+            }
+        }
+        else
         {
-            StringBuffer sb = new StringBuffer();
-            boolean isFirst = true;
+            LdapResponseCodec response = ldapMessageContainer.getLdapResponse();
+            LdapResultCodec ldapResult = response.getLdapResult();
 
-            for ( LdapURL url:ldapResult.getReferrals() )
+            if ( tlv.getLength() == 0 )
+            {
+                ldapResult.addReferral( LdapURL.EMPTY_URL );
+            }
+            else
             {
-                if ( isFirst )
+                if ( ldapResult.getResultCode() == ResultCodeEnum.REFERRAL )
                 {
-                    isFirst = false;
+                    try
+                    {
+                        ldapResult.addReferral( new LdapURL( tlv.getValue().getData() ) );
+                    }
+                    catch ( LdapURLEncodingException luee )
+                    {
+                        String badUrl = StringTools.utf8ToString( tlv.getValue().getData() );
+                        log.error( I18n.err( I18n.ERR_04015, badUrl, luee.getMessage() ) );
+                        throw new DecoderException( I18n.err( I18n.ERR_04016, luee.getMessage() ) );
+                    }
                 }
                 else
                 {
-                    sb.append( ", " );
+                    log
+                        .warn( "The Referral error message is not allowed when havind an error code no equals to REFERRAL" );
+                    ldapResult.addReferral( LdapURL.EMPTY_URL );
                 }
 
-                sb.append( url );
-            }
+                if ( IS_DEBUG )
+                {
+                    StringBuffer sb = new StringBuffer();
+                    boolean isFirst = true;
+
+                    for ( LdapURL url : ldapResult.getReferrals() )
+                    {
+                        if ( isFirst )
+                        {
+                            isFirst = false;
+                        }
+                        else
+                        {
+                            sb.append( ", " );
+                        }
 
-            log.debug( "The referral error message is set to " + sb.toString() );
+                        sb.append( url );
+                    }
+
+                    log.debug( "The referral error message is set to " + sb.toString() );
+                }
+            }
         }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddResponseImpl.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddResponseImpl.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddResponseImpl.java Wed Aug 11 23:42:42 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+
 import org.apache.directory.shared.ldap.message.internal.InternalAbstractResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 
@@ -30,6 +31,9 @@ import org.apache.directory.shared.ldap.
  */
 public class AddResponseImpl extends InternalAbstractResultResponse implements InternalAddResponse
 {
+    /** The encoded addResponse length */
+    private int addResponseLength;
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -40,10 +44,9 @@ public class AddResponseImpl extends Int
     /**
      * Creates a Lockable AddResponse as a reply to an AddRequest.
      * 
-     * @param id
-     *            the session unique message id
+     * @param id the session unique message id
      */
-    public AddResponseImpl(final int id)
+    public AddResponseImpl( final int id )
     {
         super( id, TYPE );
     }
@@ -64,4 +67,22 @@ public class AddResponseImpl extends Int
 
         return sb.toString();
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setAddResponseLength( int addResponseLength )
+    {
+        this.addResponseLength = addResponseLength;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getAddResponseLength()
+    {
+        return addResponseLength;
+    }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAddResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAddResponse.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAddResponse.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAddResponse.java Wed Aug 11 23:42:42 2010
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.ldap.message.internal;
 
+
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 
 
@@ -33,4 +34,17 @@ public interface InternalAddResponse ext
 {
     /** Add response message type enumeration value */
     MessageTypeEnum TYPE = MessageTypeEnum.ADD_RESPONSE;
+
+
+    /**
+     * Stores the encoded length for the AddResponse
+     * @param addResponseLength The encoded length
+     */
+    void setAddResponseLength( int addResponseLength );
+
+
+    /**
+     * @return The encoded AddResponse's length
+     */
+    int getAddResponseLength();
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapResultTest.java Wed Aug 11 23:42:42 2010
@@ -21,10 +21,12 @@ package org.apache.directory.shared.ldap
 
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
+import java.util.Collection;
 
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
@@ -32,9 +34,9 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
-import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.util.LdapURL;
+import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalReferral;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,6 +52,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class LdapResultTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     // ~ Methods
     // ------------------------------------------------------------------------------------
 
@@ -284,19 +290,19 @@ public class LdapResultTest
         }
 
         // Check the decoded AddResponse
-        AddResponseCodec addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getAddResponse();
+        InternalAddResponse addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getInternalAddResponse();
 
         assertEquals( 1, addResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode() );
-        assertEquals( "", addResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", addResponse.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x0E, addResponse.computeLength() );
-
         try
         {
-            ByteBuffer bb = addResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( addResponse );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -347,25 +353,27 @@ public class LdapResultTest
         }
 
         // Check the decoded AddResponse
-        AddResponseCodec addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getAddResponse();
+        InternalAddResponse addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getInternalAddResponse();
 
         assertEquals( 1, addResponse.getMessageId() );
         assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
-        assertEquals( "", addResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", addResponse.getLdapResult().getErrorMessage() );
 
-        assertEquals( 1, addResponse.getLdapResult().getReferrals().size() );
-
-        LdapURL referral = addResponse.getLdapResult().getReferrals().get( 0 );
+        InternalReferral referral = addResponse.getLdapResult().getReferral();
 
-        assertEquals( "ldap:///", referral.toString() );
+        assertNotNull( referral );
+        assertEquals( 1, referral.getLdapUrls().size() );
+        Collection<String> ldapUrls = referral.getLdapUrls();
 
-        // Check the length
-        assertEquals( 0x1A, addResponse.computeLength() );
+        assertTrue( ldapUrls.contains( "ldap:///" ) );
 
         try
         {
-            ByteBuffer bb = addResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( addResponse );
+
+            // Check the length
+            assertEquals( 0x1A, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -390,12 +398,18 @@ public class LdapResultTest
         ByteBuffer stream = ByteBuffer.allocate( 0x24 );
 
         stream.put( new byte[]
-            { 0x30, 0x22, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x69, 0x1D, // CHOICE { ..., addResponse AddResponse, ...
-                0x0A, 0x01, 0x0A, // resultCode success (Referral)
-                0x04, 0x00, // Empty matched DN
-                0x04, 0x00, // Empty errorMessage
+            { 0x30,
+                0x22, // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x69,
+                0x1D, // CHOICE { ..., addResponse AddResponse, ...
+                0x0A, 0x01,
+                0x0A, // resultCode success (Referral)
+                0x04,
+                0x00, // Empty matched DN
+                0x04,
+                0x00, // Empty errorMessage
                 ( byte ) 0xA3, 0x14, 0x04, 0x08, 'l', 'd', 'a', 'p', ':', '/', '/', '/', 0x04, 0x08, 'l', 'd', 'a',
                 'p', ':', '/', '/', '/' } );
 
@@ -417,29 +431,32 @@ public class LdapResultTest
         }
 
         // Check the decoded AddResponse
-        AddResponseCodec addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getAddResponse();
+        InternalAddResponse addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getInternalAddResponse();
 
         assertEquals( 1, addResponse.getMessageId() );
         assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
-        assertEquals( "", addResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", addResponse.getLdapResult().getErrorMessage() );
 
-        assertEquals( 2, addResponse.getLdapResult().getReferrals().size() );
-
-        LdapURL referral = addResponse.getLdapResult().getReferrals().get( 0 );
+        InternalReferral referral = addResponse.getLdapResult().getReferral();
 
-        assertEquals( "ldap:///", referral.toString() );
+        assertNotNull( referral );
 
-        referral = addResponse.getLdapResult().getReferrals().get( 1 );
+        assertEquals( 2, referral.getLdapUrls().size() );
 
-        assertEquals( "ldap:///", referral.toString() );
+        Collection<String> ldapUrls = referral.getLdapUrls();
 
-        // Check the length
-        assertEquals( 0x24, addResponse.computeLength() );
+        for ( String ldapUrl : ldapUrls )
+        {
+            assertEquals( "ldap:///", ldapUrl );
+        }
 
         try
         {
-            ByteBuffer bb = addResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( addResponse );
+
+            // Check the length
+            assertEquals( 0x24, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -491,29 +508,37 @@ public class LdapResultTest
         }
 
         // Check the decoded AddResponse
-        AddResponseCodec addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getAddResponse();
+        InternalAddResponse addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getInternalAddResponse();
 
         assertEquals( 1, addResponse.getMessageId() );
         assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
-        assertEquals( "", addResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", addResponse.getLdapResult().getErrorMessage() );
 
-        assertEquals( 2, addResponse.getLdapResult().getReferrals().size() );
+        InternalReferral referral = addResponse.getLdapResult().getReferral();
 
-        LdapURL referral = addResponse.getLdapResult().getReferrals().get( 0 );
+        assertNotNull( referral );
 
-        assertEquals( "ldap:///", referral.toString() );
+        assertEquals( 2, referral.getLdapUrls().size() );
 
-        referral = addResponse.getLdapResult().getReferrals().get( 1 );
+        Collection<String> ldapUrls = referral.getLdapUrls();
 
-        assertEquals( "ldap:///", referral.toString() );
+        String[] expected = new String[]
+            { "ldap:///", "" };
+        int i = 0;
 
-        // Check the length
-        assertEquals( 0x1C, addResponse.computeLength() );
+        for ( String ldapUrl : ldapUrls )
+        {
+            assertEquals( expected[i], ldapUrl );
+            i++;
+        }
 
         try
         {
-            ByteBuffer bb = addResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( addResponse );
+
+            // Check the length
+            assertEquals( 0x1C, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddResponseTest.java?rev=984616&r1=984615&r2=984616&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddResponseTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddResponseTest.java Wed Aug 11 23:42:42 2010
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
-import java.util.List;
+import java.util.Map;
 
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
@@ -34,8 +34,10 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapProtocolEncoder;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.control.Control;
+import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -48,6 +50,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class AddResponseTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a AddResponse
      */
@@ -91,19 +97,19 @@ public class AddResponseTest
         }
 
         // Check the decoded AddResponse
-        AddResponseCodec addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getAddResponse();
+        InternalAddResponse addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getInternalAddResponse();
 
         assertEquals( 1, addResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode() );
-        assertEquals( "", addResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", addResponse.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x0E, addResponse.computeLength() );
-
         try
         {
-            ByteBuffer bb = addResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( addResponse );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -164,21 +170,29 @@ public class AddResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2B );
 
         stream.put( new byte[]
-            { 0x30, 0x29, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x69, 0x07, // CHOICE { ..., addResponse AddResponse, ...
+            { 0x30,
+                0x29, // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x69,
+                0x07, // CHOICE { ..., addResponse AddResponse, ...
                 // AddResponse ::= [APPLICATION 9] LDAPResult
-                  0x0A, 0x01, 0x00,// LDAPResult ::= SEQUENCE {
+                0x0A,
+                0x01,
+                0x00,// LDAPResult ::= SEQUENCE {
                 // resultCode ENUMERATED {
                 // success (0), ...
                 // },
-                  0x04, 0x00, // matchedDN LDAPDN,
-                  0x04, 0x00, // errorMessage LDAPString,
+                0x04,
+                0x00, // matchedDN LDAPDN,
+                0x04,
+                0x00, // errorMessage LDAPString,
                 // referral [3] Referral OPTIONAL }
                 // }
-                ( byte ) 0xA0, 0x1B, // A control
-                  0x30, 0x19, 0x04, 0x17, 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31,
-                  0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
+                ( byte ) 0xA0,
+                0x1B, // A control
+                0x30, 0x19, 0x04, 0x17, 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31,
+                0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -198,28 +212,29 @@ public class AddResponseTest
         }
 
         // Check the decoded AddResponse
-        AddResponseCodec addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getAddResponse();
+        InternalAddResponse addResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getInternalAddResponse();
 
         assertEquals( 1, addResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode() );
-        assertEquals( "", addResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", addResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", addResponse.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x2B, addResponse.computeLength() );
-
         // Check the Control
-        List<Control> controls = addResponse.getControls();
+        Map<String, Control> controls = addResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = addResponse.getControls( 0 );
+        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
         try
         {
-            ByteBuffer bb = addResponse.encode();
+            /** The encoder instance */
+            ByteBuffer bb = encoder.encodeMessage( addResponse );
+
+            // Check the length
+            assertEquals( 0x02B, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 



Mime
View raw message