You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/08/12 13:43:55 UTC

svn commit: r984726 [2/2] - 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...

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseTest.java Thu Aug 12 11:43:54 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.InternalExtendedResponse;
 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 ExtendedResponseTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a full ExtendedResponse
      */
@@ -96,22 +102,23 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
-        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "value", StringTools.utf8ToString( ( byte[] ) extendedResponse.getResponse() ) );
-
-        // Check the length
-        assertEquals( 0x24, extendedResponse.computeLength() );
+        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getID() );
+        assertEquals( "value", StringTools.utf8ToString( ( byte[] ) extendedResponse.getEncodedValue() ) );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x24, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -136,32 +143,38 @@ public class ExtendedResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x41 );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x3F,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-                                        // CHOICE { 
-                                        //    ..., 
-                                        //    extendedResp ExtendedResponse, 
-                                        //    ...
-              0x78, 0x1D,               // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
-                                        //   COMPONENTS OF LDAPResult,
-                0x0A, 0x01, 0x00,       //   LDAPResult ::= SEQUENCE {
-                                        //     resultCode ENUMERATED {
-                                        //         success (0), ...
-                                        //     },
-                0x04, 0x00,             //     matchedDN LDAPDN,
-                0x04, 0x00,             //     errorMessage LDAPString,
-                                        //     referral [3] Referral OPTIONAL }
-                ( byte ) 0x8A, 0x0D,    //   responseName [10] LDAPOID OPTIONAL,
-                  '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
-                ( byte ) 0x8B, 0x05,    // response [11] OCTET STRING OPTIONAL } 
-                  'v', 'a', 'l', 'u', 'e', 
-              ( byte ) 0xA0, 0x1B,      // A control
-                0x30, 0x19, 
-                  0x04, 0x17,
-                    '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', '1', 
-                    '1', '3', '7', '3', '0', '.', '3', '.', '4', '.', '2'
-            } );
+            {
+                0x30,
+                0x3F, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                // CHOICE { 
+                //    ..., 
+                //    extendedResp ExtendedResponse, 
+                //    ...
+                0x78,
+                0x1D, // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
+                //   COMPONENTS OF LDAPResult,
+                0x0A,
+                0x01,
+                0x00, //   LDAPResult ::= SEQUENCE {
+                //     resultCode ENUMERATED {
+                //         success (0), ...
+                //     },
+                0x04,
+                0x00, //     matchedDN LDAPDN,
+                0x04,
+                0x00, //     errorMessage LDAPString,
+                //     referral [3] Referral OPTIONAL }
+                ( byte ) 0x8A,
+                0x0D, //   responseName [10] LDAPOID OPTIONAL,
+                '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', ( byte ) 0x8B,
+                0x05, // response [11] OCTET STRING OPTIONAL } 
+                'v', 'a', 'l', 'u', 'e', ( byte ) 0xA0,
+                0x1B, // A control
+                0x30, 0x19, 0x04, 0x17, '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', '1', '1', '3', '7', '3',
+                '0', '.', '3', '.', '4', '.', '2' } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -181,31 +194,32 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
-        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "value", StringTools.utf8ToString( ( byte[] ) extendedResponse.getResponse() ) );
+        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getID() );
+        assertEquals( "value", StringTools.utf8ToString( ( byte[] ) extendedResponse.getEncodedValue() ) );
 
         // Check the Control
-        List<Control> controls = extendedResponse.getControls();
+        Map<String, Control> controls = extendedResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = extendedResponse.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( 0x41, extendedResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x41, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -263,20 +277,21 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x0E, extendedResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -301,20 +316,29 @@ public class ExtendedResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2B );
 
         stream.put( new byte[]
-            { 0x30, 0x29, // LDAPMessage ::= SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
+            { 0x30,
+                0x29, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
                 // CHOICE { ..., extendedResp Response, ...
-                0x78, 0x07, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                0x78,
+                0x07, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
                 // COMPONENTS OF 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 }
                 // responseName [0] LDAPOID,
-                ( 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 } );
 
@@ -336,29 +360,30 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
 
         // Check the Control
-        List<Control> controls = extendedResponse.getControls();
+        Map<String, Control> controls = extendedResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = extendedResponse.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, extendedResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x2B, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -539,22 +564,23 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
-        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getResponse() ) );
-
-        // Check the length
-        assertEquals( 0x1D, extendedResponse.computeLength() );
+        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getID() );
+        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getEncodedValue() ) );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x1D, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -579,20 +605,30 @@ public class ExtendedResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x3A );
 
         stream.put( new byte[]
-            { 0x30, 0x38, // LDAPMessage ::= SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
+            {
+                0x30,
+                0x38, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
                 // CHOICE { ..., extendedResp Response, ...
-                0x78, 0x16, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                0x78,
+                0x16, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
                 // COMPONENTS OF 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 }
                 // responseName [0] LDAPOID,
-                ( byte ) 0x8A, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', ( byte ) 0xA0,
+                ( byte ) 0x8A, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                ( 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 } );
@@ -615,31 +651,32 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
-        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getResponse() ) );
+        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getID() );
+        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getEncodedValue() ) );
 
         // Check the Control
-        List<Control> controls = extendedResponse.getControls();
+        Map<String, Control> controls = extendedResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = extendedResponse.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( 0x3A, extendedResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x3A, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -664,17 +701,25 @@ public class ExtendedResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x1F );
 
         stream.put( new byte[]
-            { 0x30, 0x1D, // LDAPMessage ::= SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
+            { 0x30,
+                0x1D, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
                 // CHOICE { ..., extendedResp Response, ...
-                0x78, 0x18, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                0x78,
+                0x18, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
                 // COMPONENTS OF 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 }
                 // responseName [0] LDAPOID,
                 ( byte ) 0x8A, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', ( byte ) 0x8B,
@@ -698,22 +743,23 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
-        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getResponse() ) );
-
-        // Check the length
-        assertEquals( 0x1F, extendedResponse.computeLength() );
+        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getID() );
+        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getEncodedValue() ) );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x1F, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -739,21 +785,31 @@ public class ExtendedResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x3C );
 
         stream.put( new byte[]
-            { 0x30, 0x3A, // LDAPMessage ::= SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
+            {
+                0x30,
+                0x3A, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
                 // CHOICE { ..., extendedResp Response, ...
-                0x78, 0x18, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                0x78,
+                0x18, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
                 // COMPONENTS OF 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 }
                 // responseName [0] LDAPOID,
                 ( byte ) 0x8A, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', ( byte ) 0x8B,
-                0x00, ( byte ) 0xA0, 0x1B, // A control
+                0x00, ( 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 } );
 
@@ -775,31 +831,32 @@ public class ExtendedResponseTest
         }
 
         // Check the decoded ExtendedResponse PDU
-        ExtendedResponseCodec extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getInternalExtendedResponse();
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", extendedResponse.getLdapResult().getErrorMessage() );
-        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getResponse() ) );
+        assertEquals( "1.3.6.1.5.5.2", extendedResponse.getID() );
+        assertEquals( "", StringTools.utf8ToString( ( byte[] ) extendedResponse.getEncodedValue() ) );
 
         // Check the Control
-        List<Control> controls = extendedResponse.getControls();
+        Map<String, Control> controls = extendedResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = extendedResponse.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( 0x3C, extendedResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = extendedResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( extendedResponse );
+
+            // Check the length
+            assertEquals( 0x3C, 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/ExtendedResponseImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java Thu Aug 12 11:43:54 2010
@@ -59,8 +59,8 @@ public class ExtendedResponseImplTest
     {
         // Construct the Search response to test with results and referrals
         ExtendedResponseImpl response = new ExtendedResponseImpl( 45 );
-        response.setResponse( "Hello World!".getBytes() );
-        response.setResponseName( "1.1.1.1" );
+        response.setEncodedValue( "Hello World!".getBytes() );
+        response.setID( "1.1.1.1" );
         InternalLdapResult result = response.getLdapResult();
 
         try
@@ -118,24 +118,24 @@ public class ExtendedResponseImplTest
             private static final long serialVersionUID = 5297000474419901408L;
 
 
-            public String getResponseName()
+            public String getID()
             {
                 return "1.1.1.1";
             }
 
 
-            public void setResponseName( String a_oid )
+            public void setID( String a_oid )
             {
             }
 
 
-            public byte[] getResponse()
+            public byte[] getEncodedValue()
             {
                 return "Hello World!".getBytes();
             }
 
 
-            public void setResponse( byte[] a_value )
+            public void setEncodedValue( byte[] a_value )
             {
             }
 
@@ -204,18 +204,6 @@ public class ExtendedResponseImplTest
             }
 
 
-            public String getID()
-            {
-                return "1.1.1.1";
-            }
-
-
-            public byte[] getEncodedValue()
-            {
-                return getResponse();
-            }
-
-
             public void addAll( Control[] controls ) throws MessageException
             {
             }
@@ -253,6 +241,28 @@ public class ExtendedResponseImplTest
             public void setMessageLength( int messageLength )
             {
             }
+
+
+            public int getExtendedResponseLength()
+            {
+                return 0;
+            }
+
+
+            public void setExtendedResponseLength( int extendedResponseLength )
+            {
+            }
+
+
+            public byte[] getIDBytes()
+            {
+                return null;
+            }
+
+
+            public void setIDBytes( byte[] oidBytes )
+            {
+            }
         };
 
         assertTrue( resp0.equals( resp1 ) );
@@ -304,9 +314,9 @@ public class ExtendedResponseImplTest
     public void testNotEqualsDiffNames()
     {
         ExtendedResponseImpl resp0 = createStub();
-        resp0.setResponseName( "1.2.3.4" );
+        resp0.setID( "1.2.3.4" );
         ExtendedResponseImpl resp1 = createStub();
-        resp1.setResponseName( "1.2.3.4.5" );
+        resp1.setID( "1.2.3.4.5" );
 
         assertFalse( resp0.equals( resp1 ) );
         assertFalse( resp1.equals( resp0 ) );
@@ -320,9 +330,9 @@ public class ExtendedResponseImplTest
     public void testNotEqualsDiffResponses()
     {
         ExtendedResponseImpl resp0 = createStub();
-        resp0.setResponse( "abc".getBytes() );
+        resp0.setEncodedValue( "abc".getBytes() );
         ExtendedResponseImpl resp1 = createStub();
-        resp1.setResponse( "123".getBytes() );
+        resp1.setEncodedValue( "123".getBytes() );
 
         assertFalse( resp0.equals( resp1 ) );
         assertFalse( resp1.equals( resp0 ) );