directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r987606 [21/25] - in /directory/shared/trunk: ./ all/ asn1-codec/ asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/ asn1/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/ asn1/src/main/java/org/apache/director...
Date Fri, 20 Aug 2010 19:23:37 GMT
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java Fri Aug 20 19:23:27 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;
@@ -35,10 +35,12 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.ResponseCarryingException;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
+import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 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.InternalMessage;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -53,6 +55,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class ModifyDNRequestTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a full ModifyDNRequest
      */
@@ -65,23 +71,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00, // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -99,21 +105,22 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
-
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
-        assertEquals( "ou=system", modifyDNRequest.getNewSuperior().toString() );
+        ModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        // Check the length
-        assertEquals( 0x48, modifyDNRequest.computeLength() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
+        assertEquals( "ou=system", modifyDnRequest.getNewSuperior().toString() );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x48, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -126,6 +133,7 @@ public class ModifyDNRequestTest
         }
     }
 
+
     /**
      * Test the decoding of a bad DN ModifyDNRequest
      */
@@ -138,23 +146,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', ':', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00, // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', ':', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' } );
 
         stream.flip();
 
@@ -168,15 +176,17 @@ public class ModifyDNRequestTest
         catch ( DecoderException de )
         {
             assertTrue( de instanceof ResponseCarryingException );
-            InternalMessage response = ((ResponseCarryingException)de).getResponse();
+            Message response = ( ( ResponseCarryingException ) de ).getResponse();
             assertTrue( response instanceof ModifyDnResponseImpl );
-            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl)response).getLdapResult().getResultCode() );
+            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ( ( ModifyDnResponseImpl ) response ).getLdapResult()
+                .getResultCode() );
             return;
         }
 
         fail( "We should not reach this point" );
     }
 
+
     /**
      * Test the decoding of a bad RDN ModifyDNRequest
      */
@@ -189,23 +199,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', ':', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', ':', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' } );
 
         stream.flip();
 
@@ -219,15 +229,17 @@ public class ModifyDNRequestTest
         catch ( DecoderException de )
         {
             assertTrue( de instanceof ResponseCarryingException );
-            InternalMessage response = ((ResponseCarryingException)de).getResponse();
+            Message response = ( ( ResponseCarryingException ) de ).getResponse();
             assertTrue( response instanceof ModifyDnResponseImpl );
-            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl)response).getLdapResult().getResultCode() );
+            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ( ( ModifyDnResponseImpl ) response ).getLdapResult()
+                .getResultCode() );
             return;
         }
 
         fail( "We should not reach this point" );
     }
 
+
     /**
      * Test the decoding of a bad RDN ModifyDNRequest
      */
@@ -240,23 +252,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', ':', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', ':', 's', 'y', 's', 't', 'e', 'm' } );
 
         stream.flip();
 
@@ -270,15 +282,17 @@ public class ModifyDNRequestTest
         catch ( DecoderException de )
         {
             assertTrue( de instanceof ResponseCarryingException );
-            InternalMessage response = ((ResponseCarryingException)de).getResponse();
+            Message response = ( ( ResponseCarryingException ) de ).getResponse();
             assertTrue( response instanceof ModifyDnResponseImpl );
-            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl)response).getLdapResult().getResultCode() );
+            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ( ( ModifyDnResponseImpl ) response ).getLdapResult()
+                .getResultCode() );
             return;
         }
 
         fail( "We should not reach this point" );
     }
-    
+
+
     /**
      * Test the decoding of a full ModifyDNRequest with controls
      */
@@ -291,26 +305,28 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x63,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 
-              ( byte ) 0xA0, 0x1B, // A control
+                0x30,
+                0x63, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e',
+                'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01,
+                0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', ( 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 
-            } );
+                0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -328,30 +344,31 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
+        ModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
-        assertEquals( "ou=system", modifyDNRequest.getNewSuperior().toString() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
+        assertEquals( "ou=system", modifyDnRequest.getNewSuperior().toString() );
 
         // Check the Control
-        List<Control> controls = modifyDNRequest.getControls();
+        Map<String, Control> controls = modifyDnRequest.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = modifyDNRequest.getControls( 0 );
+        Control control = modifyDnRequest.getControl( "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( 0x65, modifyDNRequest.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x65, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -376,21 +393,21 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x3D );
 
         stream.put( new byte[]
-            {
-            0x30, 0x3B,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x36,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00        // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
+            { 0x30,
+                0x3B, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x36, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01, 0x00 // deleteoldrdn BOOLEAN,
+            // newSuperior [0] LDAPDN OPTIONAL }
             } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -409,20 +426,21 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
-
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
+        ModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        // Check the length
-        assertEquals( 0x3D, modifyDNRequest.computeLength() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x3D, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -448,24 +466,28 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x58,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x36,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-              ( byte ) 0xA0, 0x1B,      // A control
+                0x30,
+                0x58, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x36, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e',
+                'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01,
+                0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0xA0,
+                0x1B, // A control
                 0x30, 0x19, 0x04, 0x17, 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31,
-                0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 
-            } );
+                0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -483,29 +505,32 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
+        ModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
 
         // Check the Control
-        List<Control> controls = modifyDNRequest.getControls();
+        Map<String, Control> controls = modifyDnRequest.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = modifyDNRequest.getControls( 0 );
+        assertTrue( modifyDnRequest.hasControl( "2.16.840.1.113730.3.4.2" ) );
+
+        Control control = modifyDnRequest.getControl( "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( 0x5A, modifyDNRequest.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x5A, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -532,11 +557,10 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x05,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x00                // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
+            { 0x30, 0x05, // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01, // messageID MessageID
+                0x6C, 0x00 // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+            // ...
             } );
 
         stream.flip();
@@ -568,11 +592,10 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x09 );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x07,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x02,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
+            { 0x30, 0x07, // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01, // messageID MessageID
+                0x6C, 0x02, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
                 0x04, 0x00 } );
 
         stream.flip();
@@ -604,16 +627,15 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2D );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x2B,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x26,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                            // ...
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 
-                0x04, 0x00 
-            } );
+            { 0x30,
+                0x2B, // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x26, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x04, 0x00 } );
 
         stream.flip();
 
@@ -644,17 +666,18 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x3C );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x3A,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x35,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x00              // deleteoldrdn BOOLEAN
+            {
+                0x30,
+                0x3A, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x35, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x04, 0x0F, 'c', 'n', '=', 't',
+                'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x00 // deleteoldrdn BOOLEAN
             } );
 
         stream.flip();

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java Fri Aug 20 19:23:27 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,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.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -50,6 +52,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class ModifyDNResponseTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a ModifyDNResponse
      */
@@ -64,7 +70,7 @@ public class ModifyDNResponseTest
             { 0x30, 0x0C, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x6D, 0x07, // CHOICE { ..., modifyDNResponse ModifyDNResponse,
-                            // ...
+                // ...
                 // ModifyDNResponse ::= [APPLICATION 13] LDAPResult
                 0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
                 // resultCode ENUMERATED {
@@ -94,20 +100,21 @@ public class ModifyDNResponseTest
         }
 
         // Check the decoded ModifyDNResponse PDU
-        ModifyDNResponseCodec modifyDNResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnResponse();
-
-        assertEquals( 1, modifyDNResponse.getMessageId() );
-        assertEquals( ResultCodeEnum.SUCCESS, modifyDNResponse.getLdapResult().getResultCode() );
-        assertEquals( "", modifyDNResponse.getLdapResult().getMatchedDN() );
-        assertEquals( "", modifyDNResponse.getLdapResult().getErrorMessage() );
+        ModifyDnResponse modifyDnResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnResponse();
 
-        // Check the length
-        assertEquals( 0x0E, modifyDNResponse.computeLength() );
+        assertEquals( 1, modifyDnResponse.getMessageId() );
+        assertEquals( ResultCodeEnum.SUCCESS, modifyDnResponse.getLdapResult().getResultCode() );
+        assertEquals( "", modifyDnResponse.getLdapResult().getMatchedDn().getName() );
+        assertEquals( "", modifyDnResponse.getLdapResult().getErrorMessage() );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnResponse );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -132,20 +139,29 @@ public class ModifyDNResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2B );
 
         stream.put( new byte[]
-            { 0x30, 0x29, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x6D, 0x07, // CHOICE { ..., modifyDNResponse ModifyDNResponse,
-                            // ...
+            { 0x30,
+                0x29, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6D,
+                0x07, // CHOICE { ..., modifyDNResponse ModifyDNResponse,
+                // ...
                 // ModifyDNResponse ::= [APPLICATION 13] 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 } );
 
@@ -167,29 +183,30 @@ public class ModifyDNResponseTest
         }
 
         // Check the decoded ModifyDNResponse PDU
-        ModifyDNResponseCodec modifyDNResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnResponse();
+        ModifyDnResponse modifyDnResponse = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnResponse();
 
-        assertEquals( 1, modifyDNResponse.getMessageId() );
-        assertEquals( ResultCodeEnum.SUCCESS, modifyDNResponse.getLdapResult().getResultCode() );
-        assertEquals( "", modifyDNResponse.getLdapResult().getMatchedDN() );
-        assertEquals( "", modifyDNResponse.getLdapResult().getErrorMessage() );
+        assertEquals( 1, modifyDnResponse.getMessageId() );
+        assertEquals( ResultCodeEnum.SUCCESS, modifyDnResponse.getLdapResult().getResultCode() );
+        assertEquals( "", modifyDnResponse.getLdapResult().getMatchedDn().getName() );
+        assertEquals( "", modifyDnResponse.getLdapResult().getErrorMessage() );
 
         // Check the Control
-        List<Control> controls = modifyDNResponse.getControls();
+        Map<String, Control> controls = modifyDnResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = modifyDNResponse.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, modifyDNResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnResponse );
+
+            // Check the length
+            assertEquals( 0x2B, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -217,7 +234,7 @@ public class ModifyDNResponseTest
             { 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x6D, 0x00 // CHOICE { ..., modifyDNResponse ModifyDNResponse,
-                            // ...
+            // ...
             } );
 
         stream.flip();

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java Fri Aug 20 19:23:27 2010
@@ -38,11 +38,13 @@ 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.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
+import org.apache.directory.shared.ldap.message.SearchRequest;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -60,31 +62,35 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class SearchRequestMatchingRuleAssertionTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
     static Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>();
 
+
     @BeforeClass
     public static void setUp() throws Exception
     {
         // DC normalizer
-        OidNormalizer dcOidNormalizer = new OidNormalizer( "dc",
-            new DeepTrimToLowerNormalizer( SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
-        
+        OidNormalizer dcOidNormalizer = new OidNormalizer( "dc", new DeepTrimToLowerNormalizer(
+            SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
+
         oids.put( "dc", dcOidNormalizer );
         oids.put( "domaincomponent", dcOidNormalizer );
         oids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
 
         // OU normalizer
-        OidNormalizer ouOidNormalizer = new OidNormalizer( "ou",
-            new DeepTrimToLowerNormalizer( SchemaConstants.OU_AT_OID ) );
-        
+        OidNormalizer ouOidNormalizer = new OidNormalizer( "ou", new DeepTrimToLowerNormalizer(
+            SchemaConstants.OU_AT_OID ) );
+
         oids.put( "ou", ouOidNormalizer );
-        oids.put( "organizationalUnitName",ouOidNormalizer );
+        oids.put( "organizationalUnitName", ouOidNormalizer );
         oids.put( "2.5.4.11", ouOidNormalizer );
-        
+
         // ObjectClass normalizer
-        OidNormalizer objectClassOidNormalizer = new OidNormalizer( "objectClass",
-            new DeepTrimToLowerNormalizer( SchemaConstants.OBJECT_CLASS_AT_OID ) );
-        
+        OidNormalizer objectClassOidNormalizer = new OidNormalizer( "objectClass", new DeepTrimToLowerNormalizer(
+            SchemaConstants.OBJECT_CLASS_AT_OID ) );
+
         oids.put( "objectclass", objectClassOidNormalizer );
         oids.put( "2.5.4.0", objectClassOidNormalizer );
     }
@@ -100,41 +106,67 @@ public class SearchRequestMatchingRuleAs
 
         ByteBuffer stream = ByteBuffer.allocate( 0x63 );
         stream.put( new byte[]
-            { 
-            0x30, 0x61,                     // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,             //   messageID       MessageID,
-              0x63, 0x5C,                   //   protocolOp      CHOICE {
-                                            //     searchRequest   SearchRequest,
-                                            //
-                                            // SearchRequest ::= [APPLICATION 3] SEQUENCE {
-                0x04, 0x11,                 //   baseObject      LDAPDN, (dc=example,dc=com)
-                  'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
-                                            //   scope           ENUMERATED {
-                0x0A, 0x01, 0x00,           //      baseObject              (0), ...
-                                            //   derefAliases    ENUMERATED {
-                0x0A, 0x01, 0x02,           //     derefFindingBaseObj     (2),...
-                0x02, 0x01, 0x02,           //   sizeLimit       INTEGER (0 .. maxInt), (2)
-                0x02, 0x01, 0x03,           //   timeLimit       INTEGER (0 .. maxInt), (3)
-                0x01, 0x01, ( byte ) 0xFF,  //   typesOnly       BOOLEAN, (true)
-                ( byte ) 0xA9, 0x21,        //   filter          Filter,
-                                            //
-                                            // Filter ::= CHOICE {
-                                            //   extensibleMatch [9] MatchingRuleAssertion }
-                                            //
-                                            // MatchingRuleAssertion ::= SEQUENCE {
-                  ( byte ) 0x81, 0x02,      //   matchingRule    [1] MatchingRuleId OPTIONAL,
-                    'c', 'n', 
-                  ( byte ) 0x82, 0x13,      //    type            [2] AttributeDescription OPTIONAL,
-                    '1', '.', '2', '.', '8', '4', '0', '.', '4', '8', '0', '1', '8', '.', '1', '.', '2', '.', '2', 
-                  ( byte ) 0x83, 0x03,      //    matchValue      [3] AssertionValue,
-                    'a', 'o', 'k', 
-                                            //    dnAttributes    [4] BOOLEAN DEFAULT FALSE  }
-                  ( byte ) 0x84, 0x01, ( byte ) 0xFF, 
-                0x30, 0x15,                 // attributes      AttributeDescriptionList }
-                  0x04, 0x05, 'a', 't', 't', 'r', '0',
-                  0x04, 0x05, 'a', 't', 't', 'r', '1',
-                  0x04, 0x05, 'a', 't', 't', 'r', '2'
-            } );
+            {
+                0x30,
+                0x61, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, //   messageID       MessageID,
+                0x63,
+                0x5C, //   protocolOp      CHOICE {
+                //     searchRequest   SearchRequest,
+                //
+                // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+                0x04,
+                0x11, //   baseObject      LDAPDN, (dc=example,dc=com)
+                'd', 'c', '=', 'e', 'x', 'a', 'm', 'p',
+                'l',
+                'e',
+                ',',
+                'd',
+                'c',
+                '=',
+                'c',
+                'o',
+                'm',
+                //   scope           ENUMERATED {
+                0x0A,
+                0x01,
+                0x00, //      baseObject              (0), ...
+                //   derefAliases    ENUMERATED {
+                0x0A,
+                0x01,
+                0x02, //     derefFindingBaseObj     (2),...
+                0x02,
+                0x01,
+                0x02, //   sizeLimit       INTEGER (0 .. maxInt), (2)
+                0x02,
+                0x01,
+                0x03, //   timeLimit       INTEGER (0 .. maxInt), (3)
+                0x01,
+                0x01,
+                ( byte ) 0xFF, //   typesOnly       BOOLEAN, (true)
+                ( byte ) 0xA9,
+                0x21, //   filter          Filter,
+                //
+                // Filter ::= CHOICE {
+                //   extensibleMatch [9] MatchingRuleAssertion }
+                //
+                // MatchingRuleAssertion ::= SEQUENCE {
+                ( byte ) 0x81,
+                0x02, //   matchingRule    [1] MatchingRuleId OPTIONAL,
+                'c', 'n',
+                ( byte ) 0x82,
+                0x13, //    type            [2] AttributeDescription OPTIONAL,
+                '1', '.', '2', '.', '8', '4', '0', '.', '4', '8', '0', '1', '8', '.', '1', '.', '2', '.', '2',
+                ( byte ) 0x83,
+                0x03, //    matchValue      [3] AssertionValue,
+                'a', 'o', 'k',
+                //    dnAttributes    [4] BOOLEAN DEFAULT FALSE  }
+                ( byte ) 0x84, 0x01, ( byte ) 0xFF, 0x30,
+                0x15, // attributes      AttributeDescriptionList }
+                0x04, 0x05, 'a', 't', 't', 'r', '0', 0x04, 0x05, 'a', 't', 't', 'r', '1', 0x04, 0x05, 'a', 't', 't',
+                'r', '2' } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -152,33 +184,33 @@ public class SearchRequestMatchingRuleAs
             fail( de.getMessage() );
         }
 
-        SearchRequestCodec searchRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchRequest();
+        SearchRequest searchRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchRequest();
 
         assertEquals( 1, searchRequest.getMessageId() );
-        assertEquals( "dc=example,dc=com", searchRequest.getBaseObject().toString() );
+        assertEquals( "dc=example,dc=com", searchRequest.getBase().toString() );
         assertEquals( SearchScope.OBJECT, searchRequest.getScope() );
-        assertEquals( LdapConstants.DEREF_FINDING_BASE_OBJ, searchRequest.getDerefAliases() );
+        assertEquals( AliasDerefMode.DEREF_FINDING_BASE_OBJ, searchRequest.getDerefAliases() );
         assertEquals( 2, searchRequest.getSizeLimit() );
         assertEquals( 3, searchRequest.getTimeLimit() );
-        assertEquals( true, searchRequest.isTypesOnly() );
+        assertEquals( true, searchRequest.getTypesOnly() );
 
         // The attributes
-        List<EntryAttribute> attributes = searchRequest.getAttributes();
+        List<String> attributes = searchRequest.getAttributes();
 
-        for ( EntryAttribute attribute:attributes  )
+        for ( String attribute : attributes )
         {
             assertNotNull( attribute );
         }
 
-        // Check the length
-        assertEquals( 0x63, searchRequest.computeLength() );
-
         // Check the encoding
         // We won't check the whole PDU, as it may differs because
         // attributes may have been reordered
         try
         {
-            ByteBuffer bb = searchRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( searchRequest );
+
+            // Check the length
+            assertEquals( 0x63, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -199,22 +231,15 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestEmptyExtensibleMatch()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x3B, 
-              0x02, 0x01, 0x04,                 // messageID
-                0x63, 0x36,                     // baseObject LDAPDN,
-                  0x04, 0x1F, 
-                    'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                    'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-                  0x0A, 0x01, 0x01, 
-                  0x0A, 0x01, 0x03, 
-                  0x02, 0x01, 0x00, 
-                  0x02, 0x01, 0x00, 
-                  0x01, 0x01, ( byte ) 0xFF, 
-                  ( byte ) 0xA9, 0x00,             
-                  0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x00 
-            };
+            { 0x30, 0x3B, 0x02,
+                0x01,
+                0x04, // messageID
+                0x63,
+                0x36, // baseObject LDAPDN,
+                0x04, 0x1F, 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e',
+                'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03,
+                0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x00, 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -248,23 +273,17 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchEmptyMatchingRule()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x3D, 
-              0x02, 0x01, 0x04,                 // messageID
-              0x63, 0x38, 
-                0x04, 0x1F,                     // baseObject LDAPDN,
-                  'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                  'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-                0x0A, 0x01, 0x01, 
-                0x0A, 0x01, 0x03, 
-                0x02, 0x01, 0x00, 
-                0x02, 0x01, 0x00, 
-                0x01, 0x01, ( byte ) 0xFF, 
-                ( byte ) 0xA9, 0x02, 
-                  ( byte ) 0x81, 0x00,          // matchingRule    [1] MatchingRuleId OPTIONAL,
-                0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                  0x04, 0x00 
-            };
+            { 0x30, 0x3D, 0x02,
+                0x01,
+                0x04, // messageID
+                0x63, 0x38,
+                0x04,
+                0x1F, // baseObject LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
+                0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x02, ( byte ) 0x81, 0x00, // matchingRule    [1] MatchingRuleId OPTIONAL,
+                0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -298,23 +317,17 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchEmptyType()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x3D, 
-              0x02, 0x01, 0x04,                 // messageID
-              0x63, 0x38, 
-                0x04, 0x1F,                     // baseObject LDAPDN,
-                  'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                  'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-                0x0A, 0x01, 0x01, 
-                0x0A, 0x01, 0x03, 
-                0x02, 0x01, 0x00, 
-                0x02, 0x01, 0x00, 
-                0x01, 0x01, ( byte ) 0xFF, 
-                ( byte ) 0xA9, 0x02, 
-                  ( byte ) 0x82, 0x00,          //    type            [2] AttributeDescription OPTIONAL
-                0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                  0x04, 0x00 
-            };
+            { 0x30, 0x3D, 0x02,
+                0x01,
+                0x04, // messageID
+                0x63, 0x38,
+                0x04,
+                0x1F, // baseObject LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
+                0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x02, ( byte ) 0x82, 0x00, //    type            [2] AttributeDescription OPTIONAL
+                0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -348,24 +361,20 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchEmptyMatchValue()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x43, 
-              0x02, 0x01, 0x04,                 // messageID
-              0x63, 0x3E, 
-                0x04, 0x1F,                     // baseObject LDAPDN,
-                  'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                  'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-                  0x0A, 0x01, 0x01, 
-                  0x0A, 0x01, 0x03, 
-                  0x02, 0x01, 0x00, 
-                  0x02, 0x01, 0x00, 
-                  0x01, 0x01, ( byte ) 0xFF, 
-                  ( byte ) 0xA9, 0x08, 
-                    ( byte ) 0x81, 0x04, 't', 'e', 's', 't', 
-                    ( byte ) 0x83, 0x00,        //    matchValue      [3] AssertionValue,
-                0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                  0x04, 0x00 
-            };
+            { 0x30, 0x43,
+                0x02,
+                0x01,
+                0x04, // messageID
+                0x63,
+                0x3E,
+                0x04,
+                0x1F, // baseObject LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
+                0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x08, ( byte ) 0x81, 0x04, 't', 'e',
+                's', 't', ( byte ) 0x83, 0x00, //    matchValue      [3] AssertionValue,
+                0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -387,18 +396,19 @@ public class SearchRequestMatchingRuleAs
             fail( de.getMessage() );
         }
 
-        SearchRequestCodec searchRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchRequest();
+        SearchRequest searchRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchRequest();
 
         assertEquals( 4, searchRequest.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", searchRequest.getBaseObject().toString() );
+        assertEquals( "uid=akarasulu,dc=example,dc=com", searchRequest.getBase().toString() );
         assertEquals( SearchScope.ONELEVEL, searchRequest.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, searchRequest.getDerefAliases() );
+        assertEquals( AliasDerefMode.DEREF_ALWAYS, searchRequest.getDerefAliases() );
         assertEquals( 0, searchRequest.getSizeLimit() );
         assertEquals( 0, searchRequest.getTimeLimit() );
-        assertEquals( true, searchRequest.isTypesOnly() );
+        assertEquals( true, searchRequest.getTypesOnly() );
 
         // Extended
-        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest.getFilter();
+        Filter filter = ( ( SearchRequestImpl ) searchRequest ).getCurrentFilter();
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
         assertNotNull( extensibleMatchFilter );
 
         assertEquals( "test", extensibleMatchFilter.getMatchingRule() );
@@ -406,7 +416,7 @@ public class SearchRequestMatchingRuleAs
         assertNull( extensibleMatchFilter.getMatchValue().get() );
         assertFalse( extensibleMatchFilter.isDnAttributes() );
 
-        List<EntryAttribute> attributes = searchRequest.getAttributes();
+        List<String> attributes = searchRequest.getAttributes();
 
         assertEquals( 0, attributes.size() );
     }
@@ -420,24 +430,20 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchMatchingRuleEmptyType()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x43, 
-              0x02, 0x01, 0x04,                 // messageID
-              0x63, 0x3E, 
-                0x04, 0x1F,                     // baseObject LDAPDN,
-                  'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                  'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-                0x0A, 0x01, 0x01, 
-                0x0A, 0x01, 0x03, 
-                0x02, 0x01, 0x00, 
-                0x02, 0x01, 0x00, 
-                0x01, 0x01, ( byte ) 0xFF, 
-                ( byte ) 0xA9, 0x08, 
-                  ( byte ) 0x81, 0x04, 't', 'e', 's', 't', 
-                  ( byte ) 0x82, 0x00,          //    type            [2] AttributeDescription OPTIONAL,
-                0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x00 
-            };
+            { 0x30, 0x43,
+                0x02,
+                0x01,
+                0x04, // messageID
+                0x63,
+                0x3E,
+                0x04,
+                0x1F, // baseObject LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
+                0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x08, ( byte ) 0x81, 0x04, 't', 'e',
+                's', 't', ( byte ) 0x82, 0x00, //    type            [2] AttributeDescription OPTIONAL,
+                0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -462,6 +468,7 @@ public class SearchRequestMatchingRuleAs
         fail( "We should not reach this point" );
     }
 
+
     /**
      * Test the decoding of a SearchRequest with an extensible match and an
      * matching rule and an empty dnAttributes
@@ -470,41 +477,67 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchDnAttributesEmptyType()
     {
         byte[] asn1BER = new byte[]
-            { 
-             0x30, 0x60,                     // LDAPMessage ::= SEQUENCE {
-               0x02, 0x01, 0x01,             //   messageID       MessageID,
-               0x63, 0x5B,                   //   protocolOp      CHOICE {
-                                             //     searchRequest   SearchRequest,
-                                             //
-                                             // SearchRequest ::= [APPLICATION 3] SEQUENCE {
-                 0x04, 0x11,                 //   baseObject      LDAPDN, (dc=example,dc=com)
-                   'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
-                                             //   scope           ENUMERATED {
-                 0x0A, 0x01, 0x00,           //      baseObject              (0), ...
-                                             //   derefAliases    ENUMERATED {
-                 0x0A, 0x01, 0x02,           //     derefFindingBaseObj     (2),...
-                 0x02, 0x01, 0x02,           //   sizeLimit       INTEGER (0 .. maxInt), (2)
-                 0x02, 0x01, 0x03,           //   timeLimit       INTEGER (0 .. maxInt), (3)
-                 0x01, 0x01, ( byte ) 0xFF,  //   typesOnly       BOOLEAN, (true)
-                 ( byte ) 0xA9, 0x20,        //   filter          Filter,
-                                             //
-                                             // Filter ::= CHOICE {
-                                             //   extensibleMatch [9] MatchingRuleAssertion }
-                                             //
-                                             // MatchingRuleAssertion ::= SEQUENCE {
-                   ( byte ) 0x81, 0x02,      //   matchingRule    [1] MatchingRuleId OPTIONAL,
-                     'c', 'n', 
-                   ( byte ) 0x82, 0x13,      //    type            [2] AttributeDescription OPTIONAL,
-                     '1', '.', '2', '.', '8', '4', '0', '.', '4', '8', '0', '1', '8', '.', '1', '.', '2', '.', '2', 
-                   ( byte ) 0x83, 0x03,      //    matchValue      [3] AssertionValue,
-                     'a', 'o', 'k', 
-                                             //    dnAttributes    [4] BOOLEAN DEFAULT FALSE  }
-                   ( byte ) 0x84, 0x00, 
-                 0x30, 0x15,                 // attributes      AttributeDescriptionList }
-                   0x04, 0x05, 'a', 't', 't', 'r', '0',
-                   0x04, 0x05, 'a', 't', 't', 'r', '1',
-                   0x04, 0x05, 'a', 't', 't', 'r', '2'
-            };
+            {
+                0x30,
+                0x60, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, //   messageID       MessageID,
+                0x63,
+                0x5B, //   protocolOp      CHOICE {
+                //     searchRequest   SearchRequest,
+                //
+                // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+                0x04,
+                0x11, //   baseObject      LDAPDN, (dc=example,dc=com)
+                'd', 'c', '=', 'e', 'x', 'a', 'm', 'p',
+                'l',
+                'e',
+                ',',
+                'd',
+                'c',
+                '=',
+                'c',
+                'o',
+                'm',
+                //   scope           ENUMERATED {
+                0x0A,
+                0x01,
+                0x00, //      baseObject              (0), ...
+                //   derefAliases    ENUMERATED {
+                0x0A,
+                0x01,
+                0x02, //     derefFindingBaseObj     (2),...
+                0x02,
+                0x01,
+                0x02, //   sizeLimit       INTEGER (0 .. maxInt), (2)
+                0x02,
+                0x01,
+                0x03, //   timeLimit       INTEGER (0 .. maxInt), (3)
+                0x01,
+                0x01,
+                ( byte ) 0xFF, //   typesOnly       BOOLEAN, (true)
+                ( byte ) 0xA9,
+                0x20, //   filter          Filter,
+                //
+                // Filter ::= CHOICE {
+                //   extensibleMatch [9] MatchingRuleAssertion }
+                //
+                // MatchingRuleAssertion ::= SEQUENCE {
+                ( byte ) 0x81,
+                0x02, //   matchingRule    [1] MatchingRuleId OPTIONAL,
+                'c', 'n',
+                ( byte ) 0x82,
+                0x13, //    type            [2] AttributeDescription OPTIONAL,
+                '1', '.', '2', '.', '8', '4', '0', '.', '4', '8', '0', '1', '8', '.', '1', '.', '2', '.', '2',
+                ( byte ) 0x83,
+                0x03, //    matchValue      [3] AssertionValue,
+                'a', 'o', 'k',
+                //    dnAttributes    [4] BOOLEAN DEFAULT FALSE  }
+                ( byte ) 0x84, 0x00, 0x30,
+                0x15, // attributes      AttributeDescriptionList }
+                0x04, 0x05, 'a', 't', 't', 'r', '0', 0x04, 0x05, 'a', 't', 't', 'r', '1', 0x04, 0x05, 'a', 't', 't',
+                'r', '2' };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -538,22 +571,19 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchMatchingRuleAlone()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x41, 
-              0x02, 0x01, 0x04, // messageID
-              0x63, 0x3C, 0x04, 0x1F, // baseObject LDAPDN,
+            { 0x30, 0x41,
+                0x02,
+                0x01,
+                0x04, // messageID
+                0x63,
+                0x3C,
+                0x04,
+                0x1F, // baseObject LDAPDN,
                 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-              0x0A, 0x01, 0x01, 
-              0x0A, 0x01, 0x03, 
-              0x02, 0x01, 0x00, 
-              0x02, 0x01, 0x00, 
-              0x01, 0x01, ( byte ) 0xFF, 
-              ( byte ) 0xA9, 0x06, 
-                ( byte ) 0x81, 0x04, 't', 'e', 's', 't', 
-              0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x00 
-            };
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
+                0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x06, ( byte ) 0x81, 0x04, 't', 'e',
+                's', 't', 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -587,22 +617,19 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchTypeAlone()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x43, 
-              0x02, 0x01, 0x04, // messageID
-              0x63, 0x3E, 0x04, 0x1F, // baseObject LDAPDN,
+            { 0x30, 0x43,
+                0x02,
+                0x01,
+                0x04, // messageID
+                0x63,
+                0x3E,
+                0x04,
+                0x1F, // baseObject LDAPDN,
                 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-              0x0A, 0x01, 0x01, 
-              0x0A, 0x01, 0x03, 
-              0x02, 0x01, 0x00, 
-              0x02, 0x01, 0x00, 
-              0x01, 0x01, ( byte ) 0xFF, 
-              ( byte ) 0xA9, 0x06, 
-                ( byte ) 0x82, 0x04, 't', 'e', 's', 't', 
-              0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x00 
-            };
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
+                0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x06, ( byte ) 0x82, 0x04, 't', 'e',
+                's', 't', 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -636,23 +663,19 @@ public class SearchRequestMatchingRuleAs
     public void testDecodeSearchRequestExtensibleMatchMatchValueAlone()
     {
         byte[] asn1BER = new byte[]
-            { 
-            0x30, 0x43, 
-              0x02, 0x01, 0x04, // messageID
-              0x63, 0x3E, 0x04, 
+            { 0x30, 0x43,
+                0x02,
+                0x01,
+                0x04, // messageID
+                0x63,
+                0x3E,
+                0x04,
                 0x1F, // baseObject LDAPDN,
-                  'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
-                  'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
-                0x0A, 0x01, 0x01, 
-                0x0A, 0x01, 0x03, 
-                0x02, 0x01, 0x00, 
-                0x02, 0x01, 0x00, 
-                0x01, 0x01, ( byte ) 0xFF, 
-                ( byte ) 0xA9, 0x06, 
-                  ( byte ) 0x83, 0x04, 't', 'e', 's', 't', 
-                0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                  0x04, 0x00 
-            };
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
+                0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA9, 0x06, ( byte ) 0x83, 0x04, 't', 'e',
+                's', 't', 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x04, 0x00 };
 
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
@@ -673,18 +696,19 @@ public class SearchRequestMatchingRuleAs
             fail( de.getMessage() );
         }
 
-        SearchRequestCodec searchRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchRequest();
+        SearchRequest searchRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getSearchRequest();
 
         assertEquals( 4, searchRequest.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", searchRequest.getBaseObject().toString() );
+        assertEquals( "uid=akarasulu,dc=example,dc=com", searchRequest.getBase().toString() );
         assertEquals( SearchScope.ONELEVEL, searchRequest.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, searchRequest.getDerefAliases() );
+        assertEquals( AliasDerefMode.DEREF_ALWAYS, searchRequest.getDerefAliases() );
         assertEquals( 0, searchRequest.getSizeLimit() );
         assertEquals( 0, searchRequest.getTimeLimit() );
-        assertEquals( true, searchRequest.isTypesOnly() );
+        assertEquals( true, searchRequest.getTypesOnly() );
 
         // Extended
-        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest.getFilter();
+        Filter filter = ( ( SearchRequestImpl ) searchRequest ).getCurrentFilter();
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
         assertNotNull( extensibleMatchFilter );
 
         assertNull( extensibleMatchFilter.getMatchingRule() );
@@ -692,7 +716,7 @@ public class SearchRequestMatchingRuleAs
         assertEquals( "test", extensibleMatchFilter.getMatchValue().getString() );
         assertFalse( extensibleMatchFilter.isDnAttributes() );
 
-        List<EntryAttribute> attributes = searchRequest.getAttributes();
+        List<String> attributes = searchRequest.getAttributes();
 
         assertEquals( 0, attributes.size() );
     }



Mime
View raw message