directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r985552 - in /directory: apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/ ...
Date Sat, 14 Aug 2010 18:10:55 GMT
Author: elecharny
Date: Sat Aug 14 18:10:55 2010
New Revision: 985552

URL: http://svn.apache.org/viewvc?rev=985552&view=rev
Log:
Merged UbindRequest

Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/
Modified:
    directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.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/message/LdapProtocolEncoder.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.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/codec/unbind/UnBindRequestTest.java

Modified: directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java?rev=985552&r1=985551&r2=985552&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
(original)
+++ directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
Sat Aug 14 18:10:55 2010
@@ -49,7 +49,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.del.DelRequestCodec;
 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.unbind.UnBindRequestCodec;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -59,10 +58,13 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.ldif.ChangeType;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.internal.BindResponse;
 import org.apache.directory.shared.ldap.message.internal.ExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+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;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -556,10 +558,10 @@ public class ImportCommand extends ToolC
      */
     private void unbind( int messageId ) throws EncoderException, DecoderException, IOException
     {
-        UnBindRequestCodec unbindRequest = new UnBindRequestCodec();
+        InternalUnbindRequest unbindRequest = new UnbindRequestImpl( messageId );
+        LdapProtocolEncoder encoder = new LdapProtocolEncoder();
 
-        unbindRequest.setMessageId( messageId );
-        ByteBuffer bb = unbindRequest.encode();
+        ByteBuffer bb = encoder.encodeMessage( unbindRequest );
         bb.flip();
 
         sendMessage( bb );

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=985552&r1=985551&r2=985552&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
Sat Aug 14 18:10:55 2010
@@ -81,7 +81,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.unbind.UnBindRequestCodec;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
@@ -99,6 +98,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+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.AddResponse;
 import org.apache.directory.shared.ldap.message.internal.BindResponse;
@@ -108,6 +108,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalAbandonRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalIntermediateResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.internal.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.ModifyResponse;
 import org.apache.directory.shared.ldap.message.internal.Response;
@@ -1300,13 +1301,12 @@ public class LdapNetworkConnection exten
         // If the session has not been establish, or is closed, we get out immediately
         checkSession();
 
-        // Create the UnbindRequest
-        UnBindRequestCodec unbindRequest = new UnBindRequestCodec();
-
         // Creates the messageID and stores it into the
         // initial message and the transmitted message.
         int newId = messageId.incrementAndGet();
-        unbindRequest.setMessageId( newId );
+
+        // Create the UnbindRequest
+        InternalUnbindRequest unbindRequest = new UnbindRequestImpl( newId );
 
         LOG.debug( "-----------------------------------------------------------------" );
         LOG.debug( "Sending Unbind request \n{}", unbindRequest );

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=985552&r1=985551&r2=985552&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
Sat Aug 14 18:10:55 2010
@@ -30,7 +30,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.unbind.UnBindRequestCodec;
 import org.apache.directory.shared.ldap.message.internal.AddResponse;
 import org.apache.directory.shared.ldap.message.internal.BindResponse;
 import org.apache.directory.shared.ldap.message.internal.CompareResponse;
@@ -154,15 +153,6 @@ public class LdapMessageContainer extend
 
 
     /**
-     * @return Returns the AbandonRequest stored in the container
-     */
-    public InternalAbandonRequest getInternalAbandonRequest()
-    {
-        return ( InternalAbandonRequest ) internalMessage;
-    }
-
-
-    /**
      * @return Returns the AddRequest stored in the container
      */
     public AddRequestCodec getAddRequest()
@@ -363,7 +353,7 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the SearchResultDone stored in the container
      */
-    public SearchResultDone getInternalSearchResultDone()
+    public SearchResultDone getSearchResultDone()
     {
         return ( SearchResultDone ) internalMessage;
     }
@@ -372,16 +362,7 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the UnbindRequest stored in the container
      */
-    public UnBindRequestCodec getUnbindRequest()
-    {
-        return ( UnBindRequestCodec ) ldapMessage;
-    }
-
-
-    /**
-     * @return Returns the UnbindRequest stored in the container
-     */
-    public InternalUnbindRequest getInternalUnbindRequest()
+    public InternalUnbindRequest getUnbindRequest()
     {
         return ( InternalUnbindRequest ) internalMessage;
     }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java?rev=985552&r1=985551&r2=985552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java
Sat Aug 14 18:10:55 2010
@@ -50,6 +50,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalIntermediateResponse;
 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.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.internal.LdapResult;
 import org.apache.directory.shared.ldap.message.internal.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.ModifyResponse;
@@ -122,7 +123,8 @@ public class LdapProtocolEncoder extends
             || ( message instanceof ExtendedResponse ) || ( message instanceof ModifyResponse
)
             || ( message instanceof ModifyDnResponse ) || ( message instanceof InternalIntermediateResponse
)
             || ( message instanceof SearchResultDone ) || ( message instanceof SearchResultEntry
)
-            || ( message instanceof SearchResultReference ) || ( message instanceof InternalAbandonRequest
) )
+            || ( message instanceof SearchResultReference ) || ( message instanceof InternalAbandonRequest
)
+            || ( message instanceof InternalUnbindRequest ) )
         {
             try
             {
@@ -876,6 +878,18 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the UnBindRequest length 
+     * 
+     * UnBindRequest : 
+     * 0x42 00
+     */
+    private int computeUnbindRequestLength( UnbindRequestImpl unbindRequest )
+    {
+        return 2; // Always 2
+    }
+
+
+    /**
      * Encode the Abandon protocolOp part
      */
     private void encodeAbandonRequest( ByteBuffer buffer, AbandonRequestImpl abandonRequest
) throws EncoderException
@@ -1292,6 +1306,27 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the Unbind protocolOp part
+     */
+    private void encodeUnbindRequest( ByteBuffer buffer, UnbindRequestImpl unbindRequest
) throws EncoderException
+    {
+        try
+        {
+            // The tag
+            buffer.put( LdapConstants.UNBIND_REQUEST_TAG );
+
+            // The length is always null.
+            buffer.put( ( byte ) 0 );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            String msg = I18n.err( I18n.ERR_04005 );
+            throw new EncoderException( msg );
+        }
+    }
+
+
+    /**
      * Encode the SearchResultReference message to a PDU.
      * 
      * SearchResultReference :
@@ -1378,6 +1413,9 @@ public class LdapProtocolEncoder extends
             case SEARCH_RESULT_REFERENCE:
                 return computeSearchResultReferenceLength( ( SearchResultReferenceImpl )
message );
 
+            case UNBIND_REQUEST:
+                return computeUnbindRequestLength( ( UnbindRequestImpl ) message );
+
             default:
                 return 0;
         }
@@ -1439,6 +1477,10 @@ public class LdapProtocolEncoder extends
             case SEARCH_RESULT_REFERENCE:
                 encodeSearchResultReference( bb, ( SearchResultReferenceImpl ) message );
                 break;
+
+            case UNBIND_REQUEST:
+                encodeUnbindRequest( bb, ( UnbindRequestImpl ) message );
+                break;
         }
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java?rev=985552&r1=985551&r2=985552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java
Sat Aug 14 18:10:55 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.message.internal.InternalAbstractRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
@@ -39,10 +40,9 @@ public class UnbindRequestImpl extends I
      * outer envelope to disconnect and end a client session on the server
      * without producing any response.
      * 
-     * @param id
-     *            the sequential message identifier.
+     * @param id the sequential message identifier.
      */
-    public UnbindRequestImpl(final int id)
+    public UnbindRequestImpl( final int id )
     {
         super( id, TYPE, false );
     }
@@ -56,4 +56,22 @@ public class UnbindRequestImpl extends I
     {
         throw new UnsupportedOperationException( I18n.err( I18n.ERR_04185 ) );
     }
+
+
+    /**
+     * Get a String representation of a UnBindRequest
+     * 
+     * @return A UnBindRequest String
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "    UnBind Request" );
+
+        // The controls
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java?rev=985552&r1=985551&r2=985552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
Sat Aug 14 18:10:55 2010
@@ -84,7 +84,6 @@ public class LdapControlTest
                 // controlType LDAPOID}
                 0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4'
} );
 
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a LdapMessageContainer Container
@@ -102,8 +101,7 @@ public class LdapControlTest
         }
 
         // Check that everything is OK
-        InternalAbandonRequest abandonRequest = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getInternalAbandonRequest();
+        InternalAbandonRequest abandonRequest = ( ( LdapMessageContainer ) ldapMessageContainer
).getAbandonRequest();
 
         // Copy the message
         InternalAbandonRequest internalAbandonRequest = new AbandonRequestImpl( abandonRequest.getMessageId()
);
@@ -162,7 +160,7 @@ public class LdapControlTest
             }
 
             InternalAbandonRequest abandonRequest2 = ( ( LdapMessageContainer ) ldapMessageContainer
)
-                .getInternalAbandonRequest();
+                .getAbandonRequest();
 
             assertEquals( abandonRequest, abandonRequest2 );
         }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java?rev=985552&r1=985551&r2=985552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
Sat Aug 14 18:10:55 2010
@@ -32,8 +32,10 @@ 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.unbind.UnBindRequestCodec;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
+import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 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 LdapMessageTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     // ~ Methods
     // ------------------------------------------------------------------------------------
 
@@ -310,14 +316,14 @@ public class LdapMessageTest
         assertEquals( 500, message.getMessageId() );
 
         // Check the length
-        UnBindRequestCodec unbindRequestCodec = new UnBindRequestCodec();
-        unbindRequestCodec.setMessageId( message.getMessageId() );
-
-        assertEquals( 8, unbindRequestCodec.computeLength() );
+        InternalUnbindRequest internalUnbindRequest = new UnbindRequestImpl( message.getMessageId()
);
 
         try
         {
-            ByteBuffer bb = unbindRequestCodec.encode();
+            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+
+            // Check the length
+            assertEquals( 0x08, 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/abandon/AbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java?rev=985552&r1=985551&r2=985552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java
Sat Aug 14 18:10:55 2010
@@ -107,8 +107,7 @@ public class AbandonRequestTest
         }
 
         // Check that everything is OK
-        InternalAbandonRequest abandonRequest = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getInternalAbandonRequest();
+        InternalAbandonRequest abandonRequest = ( ( LdapMessageContainer ) ldapMessageContainer
).getAbandonRequest();
 
         // Copy the message
         InternalAbandonRequest internalAbandonRequest = new AbandonRequestImpl( abandonRequest.getMessageId()
);
@@ -167,7 +166,7 @@ public class AbandonRequestTest
             }
 
             InternalAbandonRequest abandonRequest2 = ( ( LdapMessageContainer ) ldapMessageContainer
)
-                .getInternalAbandonRequest();
+                .getAbandonRequest();
 
             assertEquals( abandonRequest, abandonRequest2 );
         }
@@ -214,8 +213,7 @@ public class AbandonRequestTest
         }
 
         // Check that everything is OK
-        InternalAbandonRequest abandonRequest = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getInternalAbandonRequest();
+        InternalAbandonRequest abandonRequest = ( ( LdapMessageContainer ) ldapMessageContainer
).getAbandonRequest();
 
         assertEquals( 32787, abandonRequest.getMessageId() );
         assertEquals( 2, abandonRequest.getAbandoned() );

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=985552&r1=985551&r2=985552&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
Sat Aug 14 18:10:55 2010
@@ -97,8 +97,7 @@ public class SearchResultDoneTest
             fail( de.getMessage() );
         }
 
-        SearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getInternalSearchResultDone();
+        SearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer
).getSearchResultDone();
 
         assertEquals( 1, searchResultDone.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, searchResultDone.getLdapResult().getResultCode()
);
@@ -178,8 +177,7 @@ public class SearchResultDoneTest
             fail( de.getMessage() );
         }
 
-        SearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getInternalSearchResultDone();
+        SearchResultDone searchResultDone = ( ( LdapMessageContainer ) ldapMessageContainer
).getSearchResultDone();
 
         assertEquals( 1, searchResultDone.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, searchResultDone.getLdapResult().getResultCode()
);

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java?rev=985552&r1=985551&r2=985552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java
Sat Aug 14 18:10:55 2010
@@ -34,6 +34,8 @@ 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.message.LdapProtocolEncoder;
+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.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -48,6 +50,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class UnBindRequestTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a UnBindRequest with no controls
      */
@@ -80,20 +86,19 @@ public class UnBindRequestTest
             fail( de.getMessage() );
         }
 
-        InternalUnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getInternalUnbindRequest();
+        InternalUnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer
).getUnbindRequest();
 
         assertEquals( 1, unbindRequest.getMessageId() );
 
-        // Check the length
-        UnBindRequestCodec unbindRequestCodec = new UnBindRequestCodec();
-        unbindRequestCodec.setMessageId( unbindRequest.getMessageId() );
-
-        assertEquals( 7, unbindRequestCodec.computeLength() );
+        // Check the encoding
+        InternalUnbindRequest internalUnbindRequest = new UnbindRequestImpl( unbindRequest.getMessageId()
);
 
         try
         {
-            ByteBuffer bb = unbindRequestCodec.encode();
+            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+
+            // Check the length
+            assertEquals( 0x07, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -145,8 +150,7 @@ public class UnBindRequestTest
             fail( de.getMessage() );
         }
 
-        InternalUnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer
)
-            .getInternalUnbindRequest();
+        InternalUnbindRequest unbindRequest = ( ( LdapMessageContainer ) ldapMessageContainer
).getUnbindRequest();
 
         assertEquals( 1, unbindRequest.getMessageId() );
 
@@ -159,16 +163,16 @@ public class UnBindRequestTest
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
-        // Check the length
-        UnBindRequestCodec unbindRequestCodec = new UnBindRequestCodec();
-        unbindRequestCodec.setMessageId( unbindRequest.getMessageId() );
-        unbindRequestCodec.addControl( control );
-
-        assertEquals( 0x24, unbindRequestCodec.computeLength() );
+        // Check the encoding
+        InternalUnbindRequest internalUnbindRequest = new UnbindRequestImpl( unbindRequest.getMessageId()
);
+        internalUnbindRequest.add( control );
 
         try
         {
-            ByteBuffer bb = unbindRequestCodec.encode();
+            ByteBuffer bb = encoder.encodeMessage( internalUnbindRequest );
+
+            // Check the length
+            assertEquals( 0x24, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 



Mime
View raw message