directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r984899 - in /directory: apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/repli...
Date Thu, 12 Aug 2010 18:26:31 GMT
Author: elecharny
Date: Thu Aug 12 18:26:30 2010
New Revision: 984899

URL: http://svn.apache.org/viewvc?rev=984899&view=rev
Log:
o Removed the SearchResultDoneCodec class
o Renamed the SearchResponseDone(Impl) class/interface

Added:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResultDoneImpl.java
      - copied, changed from r982962, directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResultDone.java
      - copied, changed from r982962, directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResponseDone.java
Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneCodec.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResponseDone.java
Modified:
    directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
    directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java
    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/message/SearchRequestImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchRequest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java

Modified: directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=984899&r1=984898&r2=984899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Thu Aug 12 18:26:30 2010
@@ -66,7 +66,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalSearchRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseDone;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseEntry;
 import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseReference;
 import org.apache.directory.shared.ldap.name.DN;
@@ -136,7 +136,7 @@ public class SearchHandler extends LdapR
          */
         if ( ! psearchControl.isChangesOnly() )
         {
-            InternalSearchResponseDone done = doSimpleSearch( session, req );
+            InternalSearchResultDone done = doSimpleSearch( session, req );
 
             // ok if normal search beforehand failed somehow quickly abandon psearch
             if ( done.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
@@ -500,7 +500,7 @@ public class SearchHandler extends LdapR
      * Manage the abandoned Paged Search (when paged size = 0). We have to
      * remove the cookie and its associated cursor from the session.
      */
-    private InternalSearchResponseDone abandonPagedSearch( LdapSession session, InternalSearchRequest req )
+    private InternalSearchResultDone abandonPagedSearch( LdapSession session, InternalSearchRequest req )
         throws Exception
     {
         PagedResultsControl pagedResultsControl = null;
@@ -539,7 +539,7 @@ public class SearchHandler extends LdapR
         InternalLdapResult ldapResult = req.getResultResponse().getLdapResult();
         ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
         req.getResultResponse().add( pagedResultsControl );
-        return ( InternalSearchResponseDone ) req.getResultResponse();
+        return ( InternalSearchResultDone ) req.getResultResponse();
     }
 
 
@@ -562,7 +562,7 @@ public class SearchHandler extends LdapR
     /**
      * Handle a Paged Search request.
      */
-    private InternalSearchResponseDone doPagedSearch( LdapSession session, InternalSearchRequest req, PagedResultsControl control )
+    private InternalSearchResultDone doPagedSearch( LdapSession session, InternalSearchRequest req, PagedResultsControl control )
         throws Exception
     {
         PagedResultsControl pagedSearchControl = control;
@@ -638,7 +638,7 @@ public class SearchHandler extends LdapR
 
                 // If we had a cookie in the session, remove it
                 removeContext( session, pagedContext );
-                return ( InternalSearchResponseDone ) req.getResultResponse();
+                return ( InternalSearchResultDone ) req.getResultResponse();
             }
             else
             {
@@ -677,7 +677,7 @@ public class SearchHandler extends LdapR
                 ldapResult.setErrorMessage( "Invalid cookie for this PagedSearch request." );
                 ldapResult.setResultCode( ResultCodeEnum.UNWILLING_TO_PERFORM );
 
-                return ( InternalSearchResponseDone ) req.getResultResponse();
+                return ( InternalSearchResultDone ) req.getResultResponse();
             }
 
             if ( pagedContext.hasSameRequest( req, session ) )
@@ -742,7 +742,7 @@ public class SearchHandler extends LdapR
             }
         }
 
-        return ( InternalSearchResponseDone ) req.getResultResponse();
+        return ( InternalSearchResultDone ) req.getResultResponse();
     }
 
 
@@ -757,7 +757,7 @@ public class SearchHandler extends LdapR
      * @return the result done
      * @throws Exception if there are failures while processing the request
      */
-    private InternalSearchResponseDone doSimpleSearch( LdapSession session, InternalSearchRequest req )
+    private InternalSearchResultDone doSimpleSearch( LdapSession session, InternalSearchRequest req )
         throws Exception
     {
         InternalLdapResult ldapResult = req.getResultResponse().getLdapResult();
@@ -814,7 +814,7 @@ public class SearchHandler extends LdapR
             }
         }
 
-        return ( InternalSearchResponseDone ) req.getResultResponse();
+        return ( InternalSearchResultDone ) req.getResultResponse();
     }
 
 
@@ -1040,7 +1040,7 @@ public class SearchHandler extends LdapR
             // ===============================================================
 
             //long t0 = System.nanoTime();
-            InternalSearchResponseDone done = doSimpleSearch( session, req );
+            InternalSearchResultDone done = doSimpleSearch( session, req );
             //long t1 = System.nanoTime();
             session.getIoSession().write( done );
             //.print( "Handler;" + ((t1-t0)/1000) + ";" );

Modified: directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java?rev=984899&r1=984898&r2=984899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java Thu Aug 12 18:26:30 2010
@@ -81,7 +81,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalSearchRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseDone;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseEntry;
 import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseReference;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -334,7 +334,7 @@ public class SyncReplProvider implements
         }
         else
         {
-            InternalSearchResponseDone searchDoneResp = ( InternalSearchResponseDone ) req.getResultResponse();
+            InternalSearchResultDone searchDoneResp = ( InternalSearchResultDone ) req.getResultResponse();
             searchDoneResp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
             SyncDoneValueControl syncDone = new SyncDoneValueControl();
             syncDone.setCookie( cookie );
@@ -404,7 +404,7 @@ public class SyncReplProvider implements
         ExprNode initialContentFilter = new AndNode( modifiedFilter, csnNode );
         req.setFilter( initialContentFilter );
 
-        InternalSearchResponseDone searchDoneResp = doSimpleSearch( session, req );
+        InternalSearchResultDone searchDoneResp = doSimpleSearch( session, req );
         
         if ( searchDoneResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
         {
@@ -457,10 +457,10 @@ public class SyncReplProvider implements
     }
 
 
-    private InternalSearchResponseDone doSimpleSearch( LdapSession session, InternalSearchRequest req )
+    private InternalSearchResultDone doSimpleSearch( LdapSession session, InternalSearchRequest req )
         throws Exception
     {
-        InternalSearchResponseDone searchDoneResp = ( InternalSearchResponseDone ) req.getResultResponse();
+        InternalSearchResultDone searchDoneResp = ( InternalSearchResultDone ) req.getResultResponse();
         InternalLdapResult ldapResult = searchDoneResp.getLdapResult();
 
         // A normal search
@@ -981,7 +981,7 @@ public class SyncReplProvider implements
     
     private void sendESyncRefreshRequired( LdapSession session, InternalSearchRequest req ) throws Exception
     {
-        InternalSearchResponseDone searchDoneResp = ( InternalSearchResponseDone ) req.getResultResponse();
+        InternalSearchResultDone searchDoneResp = ( InternalSearchResultDone ) req.getResultResponse();
         searchDoneResp.getLdapResult().setResultCode( ResultCodeEnum.E_SYNC_REFRESH_REQUIRED );
         SyncDoneValueControl syncDone = new SyncDoneValueControl();
         searchDoneResp.add( syncDone );

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=984899&r1=984898&r2=984899&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 Thu Aug 12 18:26:30 2010
@@ -101,7 +101,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.Filter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
-import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
 import org.apache.directory.shared.ldap.codec.unbind.UnBindRequestCodec;
@@ -131,6 +130,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.message.internal.InternalModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -490,13 +490,13 @@ public class LdapNetworkConnection exten
     /**
      * Convert a SearchResultDoneCodec to a SearchResultDone message
      */
-    private SearchResultDone convert( SearchResultDoneCodec searchResultDoneCodec )
+    private SearchResultDone convert( InternalSearchResultDone internalSearchResultDone )
     {
         SearchResultDone searchResultDone = new SearchResultDone();
 
-        searchResultDone.setMessageId( searchResultDoneCodec.getMessageId() );
-        searchResultDone.setLdapResult( convert( searchResultDoneCodec.getLdapResult() ) );
-        addControls( searchResultDoneCodec, searchResultDone );
+        searchResultDone.setMessageId( internalSearchResultDone.getMessageId() );
+        searchResultDone.setLdapResult( convert( internalSearchResultDone.getLdapResult() ) );
+        addControls( internalSearchResultDone, searchResultDone );
 
         return searchResultDone;
     }
@@ -1837,32 +1837,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 SEARCH_RESULT_DONE:
                     // Store the response into the responseQueue
-                    SearchResultDoneCodec searchResultDoneCodec = ( SearchResultDoneCodec ) response;
-                    searchResultDoneCodec.setMessageId( messageId );
-                    searchResultDoneCodec.addControls( response.getControls() );
-                    SearchResultDone searchResultDone = convert( searchResultDoneCodec );
+                    SearchResultDone searchResultDone = convert( ( InternalSearchResultDone ) response );
 
                     SearchFuture searchFuture = ( SearchFuture ) responseFuture;
 
@@ -1894,6 +1871,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 SEARCH_RESULT_ENTRY:
                     // Store the response into the responseQueue
                     SearchResultEntryCodec searchResultEntryCodec = ( SearchResultEntryCodec ) response;
@@ -1902,7 +1899,7 @@ public class LdapNetworkConnection exten
 
                     SearchResultEntry srchEntry = convert( searchResultEntryCodec );
 
-                    searchFuture = ( SearchFuture ) responseFuture;
+                    SearchFuture searchFuture = ( SearchFuture ) responseFuture;
 
                     if ( searchFuture == null )
                     {

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=984899&r1=984898&r2=984899&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 Thu Aug 12 18:26:30 2010
@@ -31,7 +31,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
-import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
 import org.apache.directory.shared.ldap.codec.unbind.UnBindRequestCodec;
@@ -49,6 +48,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.message.internal.InternalModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
 
@@ -364,9 +364,9 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the SearchResultDone stored in the container
      */
-    public SearchResultDoneCodec getSearchResultDone()
+    public InternalSearchResultDone getInternalSearchResultDone()
     {
-        return ( SearchResultDoneCodec ) ldapMessage;
+        return ( InternalSearchResultDone ) 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=984899&r1=984898&r2=984899&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 Thu Aug 12 18:26:30 2010
@@ -77,7 +77,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
-import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
@@ -99,7 +98,7 @@ import org.apache.directory.shared.ldap.
 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.SearchResultDoneImpl;
 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;
@@ -119,6 +118,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 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.InternalSearchResultDone;
 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;
@@ -1373,9 +1373,9 @@ public class LdapMessageGrammar extends 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
                     // Now, we can allocate the SearchResultDone Object
-                    SearchResultDoneCodec searchResultDone = new SearchResultDoneCodec();
-                    searchResultDone.setMessageId( ldapMessageContainer.getMessageId() );
-                    ldapMessageContainer.setLdapMessage( searchResultDone );
+                    InternalSearchResultDone searchResultDone = new SearchResultDoneImpl( ldapMessageContainer
+                        .getMessageId() );
+                    ldapMessageContainer.setInternalMessage( searchResultDone );
 
                     log.debug( "Search Result Done found" );
                 }
@@ -3675,7 +3675,7 @@ public class LdapMessageGrammar extends 
                                 + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            SearchResponseDoneImpl response = new SearchResponseDoneImpl( searchRequest.getMessageId() );
+                            SearchResultDoneImpl response = new SearchResultDoneImpl( searchRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                 DN.EMPTY_DN, ine );
                         }

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=984899&r1=984898&r2=984899&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 Thu Aug 12 18:26:30 2010
@@ -39,6 +39,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
+import org.apache.directory.shared.ldap.message.SearchResultDoneImpl;
 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;
@@ -51,6 +52,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalReferral;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
@@ -114,7 +116,8 @@ public class LdapProtocolEncoder extends
         if ( ( message instanceof InternalBindResponse ) || ( message instanceof InternalDeleteResponse )
             || ( message instanceof InternalAddResponse ) || ( message instanceof InternalCompareResponse )
             || ( message instanceof InternalExtendedResponse ) || ( message instanceof InternalModifyResponse )
-            || ( message instanceof InternalModifyDnResponse ) || ( message instanceof InternalIntermediateResponse ) )
+            || ( message instanceof InternalModifyDnResponse ) || ( message instanceof InternalIntermediateResponse )
+            || ( message instanceof InternalSearchResultDone ) )
         {
             try
             {
@@ -533,6 +536,49 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the intermediateResponse length
+     * 
+     * intermediateResponse :
+     * 
+     * 0x79 L1
+     *  |
+     * [+--> 0x80 L2 name
+     * [+--> 0x81 L3 response]]
+     * 
+     * L1 = [ + Length(0x80) + Length(L2) + L2
+     *      [ + Length(0x81) + Length(L3) + L3]]
+     * 
+     * Length(IntermediateResponse) = Length(0x79) + Length(L1) + L1
+     * 
+     * @return The IntermediateResponse length
+     */
+    private int computeIntermediateResponseLength( InternalIntermediateResponse intermediateResponse )
+    {
+        int intermediateResponseLength = 0;
+
+        if ( !StringTools.isEmpty( intermediateResponse.getResponseName() ) )
+        {
+            byte[] responseNameBytes = StringTools.getBytesUtf8( intermediateResponse.getResponseName() );
+
+            int responseNameLength = responseNameBytes.length;
+            intermediateResponseLength += 1 + TLV.getNbBytes( responseNameLength ) + responseNameLength;
+            intermediateResponse.setOidBytes( responseNameBytes );
+        }
+
+        byte[] encodedValue = intermediateResponse.getResponseValue();
+
+        if ( encodedValue != null )
+        {
+            intermediateResponseLength += 1 + TLV.getNbBytes( encodedValue.length ) + encodedValue.length;
+        }
+
+        intermediateResponse.setIntermediateResponseLength( intermediateResponseLength );
+
+        return 1 + TLV.getNbBytes( intermediateResponseLength ) + intermediateResponseLength;
+    }
+
+
+    /**
      * Compute the ModifyResponse length 
      * 
      * ModifyResponse : 
@@ -579,45 +625,25 @@ public class LdapProtocolEncoder extends
 
 
     /**
-     * Compute the intermediateResponse length
-     * 
-     * intermediateResponse :
+     * Compute the SearchResultDone length 
      * 
-     * 0x79 L1
-     *  |
-     * [+--> 0x80 L2 name
-     * [+--> 0x81 L3 response]]
-     * 
-     * L1 = [ + Length(0x80) + Length(L2) + L2
-     *      [ + Length(0x81) + Length(L3) + L3]]
-     * 
-     * Length(IntermediateResponse) = Length(0x79) + Length(L1) + L1
-     * 
-     * @return The IntermediateResponse length
+     * SearchResultDone : 
+     * <pre>
+     * 0x65 L1 
+     *   | 
+     *   +--> LdapResult 
+     *   
+     * L1 = Length(LdapResult) 
+     * Length(SearchResultDone) = Length(0x65) + Length(L1) + L1
+     * </pre>
      */
-    private int computeIntermediateResponseLength( InternalIntermediateResponse intermediateResponse )
+    private int computeSearchResultDoneLength( SearchResultDoneImpl searchResultDone )
     {
-        int intermediateResponseLength = 0;
+        int searchResultDoneLength = computeLdapResultLength( searchResultDone.getLdapResult() );
 
-        if ( !StringTools.isEmpty( intermediateResponse.getResponseName() ) )
-        {
-            byte[] responseNameBytes = StringTools.getBytesUtf8( intermediateResponse.getResponseName() );
+        searchResultDone.setSearchResultDoneLength( searchResultDoneLength );
 
-            int responseNameLength = responseNameBytes.length;
-            intermediateResponseLength += 1 + TLV.getNbBytes( responseNameLength ) + responseNameLength;
-            intermediateResponse.setOidBytes( responseNameBytes );
-        }
-
-        byte[] encodedValue = intermediateResponse.getResponseValue();
-
-        if ( encodedValue != null )
-        {
-            intermediateResponseLength += 1 + TLV.getNbBytes( encodedValue.length ) + encodedValue.length;
-        }
-
-        intermediateResponse.setIntermediateResponseLength( intermediateResponseLength );
-
-        return 1 + TLV.getNbBytes( intermediateResponseLength ) + intermediateResponseLength;
+        return 1 + TLV.getNbBytes( searchResultDoneLength ) + searchResultDoneLength;
     }
 
 
@@ -892,6 +918,30 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the SearchResultDone message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     */
+    private void encodeSearchResultDone( ByteBuffer buffer, SearchResultDoneImpl searchResultDone )
+        throws EncoderException
+    {
+        try
+        {
+            // The searchResultDone Tag
+            buffer.put( LdapConstants.SEARCH_RESULT_DONE_TAG );
+            buffer.put( TLV.getBytes( searchResultDone.getSearchResultDoneLength() ) );
+
+            // The LdapResult
+            encodeLdapResult( buffer, searchResultDone.getLdapResult() );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
+        }
+    }
+
+
+    /**
      * Compute the protocolOp length 
      */
     private int computeProtocolOpLength( InternalMessage message )
@@ -922,6 +972,9 @@ public class LdapProtocolEncoder extends
             case MODIFYDN_RESPONSE:
                 return computeModifyDnResponseLength( ( ModifyDnResponseImpl ) message );
 
+            case SEARCH_RESULT_DONE:
+                return computeSearchResultDoneLength( ( SearchResultDoneImpl ) message );
+
             default:
                 return 0;
         }
@@ -963,6 +1016,9 @@ public class LdapProtocolEncoder extends
             case MODIFYDN_RESPONSE:
                 encodeModifyDnResponse( bb, ( ModifyDnResponseImpl ) message );
                 break;
+
+            case SEARCH_RESULT_DONE:
+                encodeSearchResultDone( bb, ( SearchResultDoneImpl ) message );
         }
     }
 }

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=984899&r1=984898&r2=984899&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 Thu Aug 12 18:26:30 2010
@@ -41,7 +41,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.search.OrFilter;
 import org.apache.directory.shared.ldap.codec.search.PresentFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
-import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
@@ -71,7 +70,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.SearchRequestImpl;
-import org.apache.directory.shared.ldap.message.SearchResponseDoneImpl;
 import org.apache.directory.shared.ldap.message.SearchResponseEntryImpl;
 import org.apache.directory.shared.ldap.message.SearchResponseReferenceImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
@@ -697,26 +695,6 @@ public class LdapTransformer
 
 
     /**
-     * Transform a Internal SearchResponseDone to a Codec SearchResultDone
-     * 
-     * @param internalMessage The incoming Internal SearchResponseDone
-     * @return The SearchResultDone instance
-     */
-    private static LdapMessageCodec transformSearchResultDone( InternalMessage internalMessage )
-    {
-        SearchResponseDoneImpl internalSearchResponseDone = ( SearchResponseDoneImpl ) internalMessage;
-        SearchResultDoneCodec searchResultDone = new SearchResultDoneCodec();
-
-        // Transform the ldapResult
-        searchResultDone.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalSearchResponseDone
-            .getLdapResult() ) );
-
-        // Set the operation into the LdapMessage
-        return searchResultDone;
-    }
-
-
-    /**
      * Transform a Internal SearchResponseEntry to a Codec SearchResultEntry
      * 
      * @param internalMessage The incoming Internal SearchResponseEntry
@@ -799,10 +777,6 @@ public class LdapTransformer
                 codecMessage = transformSearchResultEntry( msg );
                 break;
 
-            case SEARCH_RESULT_DONE:
-                codecMessage = transformSearchResultDone( msg );
-                break;
-
             case SEARCH_RESULT_REFERENCE:
                 codecMessage = transformSearchResultReference( msg );
                 break;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java?rev=984899&r1=984898&r2=984899&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java Thu Aug 12 18:26:30 2010
@@ -32,7 +32,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalSearchRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseDone;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.name.DN;
 
 
@@ -70,7 +70,7 @@ public class SearchRequestImpl extends A
     private List<String> attributes = new ArrayList<String>();
 
     /** The final result containing SearchResponseDone response */
-    private InternalSearchResponseDone response;
+    private InternalSearchResultDone response;
 
 
     // ------------------------------------------------------------------------
@@ -345,7 +345,7 @@ public class SearchRequestImpl extends A
     {
         if ( response == null )
         {
-            response = new SearchResponseDoneImpl( getMessageId() );
+            response = new SearchResultDoneImpl( getMessageId() );
         }
 
         return response;

Copied: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResultDoneImpl.java (from r982962, directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImpl.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResultDoneImpl.java?p2=directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResultDoneImpl.java&p1=directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImpl.java&r1=982962&r2=984899&rev=984899&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImpl.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchResultDoneImpl.java Thu Aug 12 18:26:30 2010
@@ -22,7 +22,7 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.ldap.message.internal.InternalAbstractResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
-import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseDone;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 
 
 /**
@@ -30,8 +30,10 @@ import org.apache.directory.shared.ldap.
  * 
  * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
  */
-public class SearchResponseDoneImpl extends InternalAbstractResultResponse implements InternalSearchResponseDone
+public class SearchResultDoneImpl extends InternalAbstractResultResponse implements InternalSearchResultDone
 {
+    /** The encoded searchResultDone length */
+    private int searchResultDoneLength;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -47,7 +49,7 @@ public class SearchResponseDoneImpl exte
      * @param id
      *            the session unique message id
      */
-    public SearchResponseDoneImpl( final int id )
+    public SearchResultDoneImpl( final int id )
     {
         super( id, TYPE );
     }
@@ -88,7 +90,7 @@ public class SearchResponseDoneImpl exte
             return false;
         }
 
-        InternalLdapResult result = ( ( InternalSearchResponseDone ) obj ).getLdapResult();
+        InternalLdapResult result = ( ( InternalSearchResultDone ) obj ).getLdapResult();
 
         if ( !getLdapResult().equals( result ) )
         {
@@ -97,4 +99,39 @@ public class SearchResponseDoneImpl exte
 
         return true;
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSearchResultDoneLength( int searchResultDoneLength )
+    {
+        this.searchResultDoneLength = searchResultDoneLength;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getSearchResultDoneLength()
+    {
+        return searchResultDoneLength;
+    }
+
+
+    /**
+     * Get a String representation of a SearchResultDone
+     * 
+     * @return A SearchResultDone String
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Search Result Done\n" );
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchRequest.java?rev=984899&r1=984898&r2=984899&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchRequest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchRequest.java Thu Aug 12 18:26:30 2010
@@ -48,7 +48,7 @@ public interface InternalSearchRequest e
      */
     MessageTypeEnum[] RESPONSE_TYPES =
         { 
-        InternalSearchResponseDone.TYPE, 
+        InternalSearchResultDone.TYPE, 
         InternalSearchResponseEntry.TYPE, 
         InternalSearchResponseReference.TYPE, 
         InternalExtendedResponse.TYPE 

Copied: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResultDone.java (from r982962, directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResponseDone.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResultDone.java?p2=directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResultDone.java&p1=directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResponseDone.java&r1=982962&r2=984899&rev=984899&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResponseDone.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalSearchResultDone.java Thu Aug 12 18:26:30 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message.internal;
 
+
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 
 
@@ -29,8 +30,21 @@ import org.apache.directory.shared.ldap.
  * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
  *         $Rev: 910150 $
  */
-public interface InternalSearchResponseDone extends InternalResultResponse
+public interface InternalSearchResultDone extends InternalResultResponse
 {
     /** Search done response message type enumeration value */
     MessageTypeEnum TYPE = MessageTypeEnum.SEARCH_RESULT_DONE;
+
+
+    /**
+     * Stores the encoded length for the SearchResultDone
+     * @param searchResultDoneLength The encoded length
+     */
+    void setSearchResultDoneLength( int searchResultDoneLength );
+
+
+    /**
+     * @return The encoded SearchResultDone's length
+     */
+    int getSearchResultDoneLength();
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?rev=984899&r1=984898&r2=984899&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java Thu Aug 12 18:26:30 2010
@@ -48,7 +48,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.message.SearchResponseDoneImpl;
+import org.apache.directory.shared.ldap.message.SearchResultDoneImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
@@ -1687,8 +1687,8 @@ public class SearchRequestTest
         {
             assertTrue( de instanceof ResponseCarryingException );
             InternalMessage response = ((ResponseCarryingException)de).getResponse();
-            assertTrue( response instanceof SearchResponseDoneImpl );
-            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((SearchResponseDoneImpl)response).getLdapResult().getResultCode() );
+            assertTrue( response instanceof SearchResultDoneImpl );
+            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((SearchResultDoneImpl)response).getLdapResult().getResultCode() );
             return;
         }
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java?rev=984899&r1=984898&r2=984899&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java Thu Aug 12 18:26:30 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.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,6 +52,9 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class SearchResultDoneTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
 
     /**
      * Test the decoding of a SearchResultDone
@@ -92,20 +97,21 @@ public class SearchResultDoneTest
             fail( de.getMessage() );
         }
 
-        SearchResultDoneCodec searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultDone();
+        InternalSearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalSearchResultDone();
 
         assertEquals( 1, searchResultDone.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, searchResultDone.getLdapResult().getResultCode() );
-        assertEquals( "", searchResultDone.getLdapResult().getMatchedDN() );
+        assertEquals( "", searchResultDone.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", searchResultDone.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x0E, searchResultDone.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultDone.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultDone );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -130,19 +136,27 @@ public class SearchResultDoneTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2B );
 
         stream.put( new byte[]
-            { 0x30, 0x29, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x65, 0x07, // CHOICE { ..., delResponse DelResponse, ...
+            { 0x30,
+                0x29, // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x65,
+                0x07, // CHOICE { ..., delResponse DelResponse, ...
                 // SearchResultDone ::= [APPLICATION 5] 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
+                ( 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
 
@@ -164,29 +178,30 @@ public class SearchResultDoneTest
             fail( de.getMessage() );
         }
 
-        SearchResultDoneCodec searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchResultDone();
+        InternalSearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalSearchResultDone();
 
         assertEquals( 1, searchResultDone.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, searchResultDone.getLdapResult().getResultCode() );
-        assertEquals( "", searchResultDone.getLdapResult().getMatchedDN() );
+        assertEquals( "", searchResultDone.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", searchResultDone.getLdapResult().getErrorMessage() );
 
         // Check the Control
-        List<Control> controls = searchResultDone.getControls();
+        Map<String, Control> controls = searchResultDone.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = searchResultDone.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() ) );
 
-        // Check the length
-        assertEquals( 0x2B, searchResultDone.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = searchResultDone.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchResultDone );
+
+            // Check the length
+            assertEquals( 0x2B, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java?rev=984899&r1=984898&r2=984899&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseDoneImplTest.java Thu Aug 12 18:26:30 2010
@@ -32,7 +32,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
-import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseDone;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchResultDone;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -56,10 +56,10 @@ public class SearchResponseDoneImplTest
      * 
      * @return a populated SearchResponseDoneImpl stub
      */
-    private SearchResponseDoneImpl createStub()
+    private SearchResultDoneImpl createStub()
     {
         // Construct the Search response to test with results and referrals
-        SearchResponseDoneImpl response = new SearchResponseDoneImpl( 45 );
+        SearchResultDoneImpl response = new SearchResultDoneImpl( 45 );
         InternalLdapResult result = response.getLdapResult();
 
         try
@@ -87,7 +87,7 @@ public class SearchResponseDoneImplTest
     @Test
     public void testEqualsSameObj()
     {
-        SearchResponseDoneImpl resp = createStub();
+        SearchResultDoneImpl resp = createStub();
         assertTrue( resp.equals( resp ) );
     }
 
@@ -98,8 +98,8 @@ public class SearchResponseDoneImplTest
     @Test
     public void testEqualsExactCopy()
     {
-        SearchResponseDoneImpl resp0 = createStub();
-        SearchResponseDoneImpl resp1 = createStub();
+        SearchResultDoneImpl resp0 = createStub();
+        SearchResultDoneImpl resp1 = createStub();
         assertTrue( resp0.equals( resp1 ) );
         assertTrue( resp1.equals( resp0 ) );
     }
@@ -111,8 +111,8 @@ public class SearchResponseDoneImplTest
     @Test
     public void testEqualsDiffImpl()
     {
-        SearchResponseDoneImpl resp0 = createStub();
-        InternalSearchResponseDone resp1 = new InternalSearchResponseDone()
+        SearchResultDoneImpl resp0 = createStub();
+        InternalSearchResultDone resp1 = new InternalSearchResultDone()
         {
             public InternalLdapResult getLdapResult()
             {
@@ -214,6 +214,20 @@ public class SearchResponseDoneImplTest
             public void setMessageLength( int messageLength )
             {
             }
+
+
+            public int getSearchResultDoneLength()
+            {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+
+
+            public void setSearchResultDoneLength( int searchResultDoneLength )
+            {
+                // TODO Auto-generated method stub
+
+            }
         };
 
         assertTrue( resp0.equals( resp1 ) );
@@ -227,7 +241,7 @@ public class SearchResponseDoneImplTest
     @Test
     public void testHashCodeSameObj()
     {
-        SearchResponseDoneImpl resp = createStub();
+        SearchResultDoneImpl resp = createStub();
         assertTrue( resp.hashCode() == resp.hashCode() );
     }
 
@@ -238,8 +252,8 @@ public class SearchResponseDoneImplTest
     @Test
     public void testHashCodeExactCopy()
     {
-        SearchResponseDoneImpl resp0 = createStub();
-        SearchResponseDoneImpl resp1 = createStub();
+        SearchResultDoneImpl resp0 = createStub();
+        SearchResultDoneImpl resp1 = createStub();
         assertTrue( resp0.hashCode() == resp1.hashCode() );
     }
 
@@ -250,8 +264,8 @@ public class SearchResponseDoneImplTest
     @Test
     public void testNotEqualsDiffIds()
     {
-        SearchResponseDoneImpl resp0 = new SearchResponseDoneImpl( 3 );
-        SearchResponseDoneImpl resp1 = new SearchResponseDoneImpl( 4 );
+        SearchResultDoneImpl resp0 = new SearchResultDoneImpl( 3 );
+        SearchResultDoneImpl resp1 = new SearchResultDoneImpl( 4 );
 
         assertFalse( resp0.equals( resp1 ) );
         assertFalse( resp1.equals( resp0 ) );



Mime
View raw message