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 2006/01/29 01:27:24 UTC

svn commit: r373267 [2/2] - /directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/search/SearchRequestTest.java

Modified: directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/search/SearchRequestTest.java?rev=373267&r1=373266&r2=373267&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/search/SearchRequestTest.java (original)
+++ directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/search/SearchRequestTest.java Sat Jan 28 16:27:19 2006
@@ -43,9 +43,7 @@
 import org.apache.ldap.common.codec.search.OrFilter;
 import org.apache.ldap.common.codec.search.PresentFilter;
 import org.apache.ldap.common.codec.search.SearchRequest;
-import org.apache.ldap.common.codec.search.SubstringFilter;
 import org.apache.ldap.common.codec.search.controls.SubEntryControl;
-import org.apache.ldap.common.codec.util.LdapString;
 
 import junit.framework.TestCase;
 
@@ -659,52 +657,45 @@
     }
 
     /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=t*)
+     * Tests an search request decode with a simple equality match filter.
      */
-    public void testDecodeSearchRequestSubstringInitialAny()
+    public void testDecodeSearchRequestOrFilters()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x64 );
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x96 );
         stream.put(
             new byte[]
             {
-                0x30, 0x62,                   // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, 0x5D,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				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,        	  //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				(byte)0xA4, 0x12,        	  // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				0x04, 0x0B,                   //     type            AttributeDescription,
-				'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				0x30, 0x03,
-				(byte)0x80, 0x01, 't',        //
-                0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
+                    0x30, 0xFFFFFF81, 0xFFFFFF93, 
+                	0x02, 0x01, 0x21, 
+                	0x63, 0xFFFFFF81, 0xFFFFFF8D, // "dc=example,dc=com"
+                		0x04, 0x11, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 
+                		0x0A, 0x01, 0x00, 
+                		0x0A, 0x01, 0x02, 
+                		0x02, 0x01, 0x02, 
+                		0x02, 0x01, 0x03, 
+                		0x01, 0x01, 0xFFFFFFFF, 
+                		0xFFFFFFA1, 0x52, 								// ( | 
+                			0xFFFFFFA3, 0x10, 							// ( uid=akarasulu )
+                				0x04, 0x03, 0x75, 0x69, 0x64, 			
+                				0x04, 0x09, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 
+                			0xFFFFFFA3, 0x09, 							// ( cn=aok )
+                				0x04, 0x02, 0x63, 0x6E, 
+                				0x04, 0x03, 0x61, 0x6F, 0x6B, 
+                			0xFFFFFFA3, 0x15, 							// ( ou = Human Resources )
+                				0x04, 0x02, 0x6F, 0x75, 
+                				0x04, 0x0F, 0x48, 0x75, 0x6D, 0x61, 0x6E, 0x20, 0x52, 0x65, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x73, 
+                			0xFFFFFFA3, 0x10, 
+                				0x04, 0x01, 0x6C, 						// ( l=Santa Clara )
+                				0x04, 0x0B, 0x53, 0x61, 0x6E, 0x74, 0x61, 0x20, 0x43, 0x6C, 0x61, 0x72, 0x61, 
+                			0xFFFFFFA3, 0x0A, 							// ( cn=abok )
+                				0x04, 0x02, 0x63, 0x6E, 
+                				0x04, 0x04, 0x61, 0x62, 0x6F, 0x6B, 
+                		0x30, 0x15,										// Attributes 
+                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 	// attr0
+                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 	// attr1
+                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32	// attr2
             } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -715,7 +706,7 @@
 
         try
         {
-            ldapDecoder.decode( stream, ldapMessageContainer );
+           ldapDecoder.decode( stream, ldapMessageContainer );
         }
         catch ( DecoderException de )
         {
@@ -726,20 +717,47 @@
         LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
         SearchRequest sr      = message.getSearchRequest();
 
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
+        assertEquals( 33, message.getMessageId() );
+        assertEquals( "dc=example,dc=com", sr.getBaseObject().toString() );
+        assertEquals( LdapConstants.SCOPE_BASE_OBJECT, sr.getScope() );
+        assertEquals( LdapConstants.DEREF_FINDING_BASE_OBJ, sr.getDerefAliases() );
+        assertEquals( 2, sr.getSizeLimit() );
+        assertEquals( 3, sr.getTimeLimit() );
         assertEquals( true, sr.isTypesOnly() );
         
         // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
+        OrFilter orFilter = (OrFilter)sr.getFilter();
+        assertNotNull(orFilter);
+
+        // uid=akarasulu
+        AttributeValueAssertion assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(0)).getAssertion();
+        
+        assertEquals("uid", assertion.getAttributeDesc().toString());
+        assertEquals("akarasulu", assertion.getAssertionValue().toString());
+
+        // cn=aok
+        assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(1)).getAssertion();
+        
+        assertEquals("cn", assertion.getAttributeDesc().toString());
+        assertEquals("aok", assertion.getAssertionValue().toString());
+
+        // ou = Human Resources
+        assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(2)).getAssertion();
+        
+        assertEquals("ou", assertion.getAttributeDesc().toString());
+        assertEquals("Human Resources", assertion.getAssertionValue().toString());
+
+        // l=Santa Clara
+        assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(3)).getAssertion();
+        
+        assertEquals("l", assertion.getAttributeDesc().toString());
+        assertEquals("Santa Clara", assertion.getAssertionValue().toString());
+
+        // cn=abok
+        assertion = (( AttributeValueAssertionFilter )orFilter.getOrFilter().get(4)).getAssertion();
         
-        assertEquals("objectclass", substringFilter.getType().toString());
-        assertEquals("t", substringFilter.getInitialSubstrings().toString());
+        assertEquals("cn", assertion.getAttributeDesc().toString());
+        assertEquals("abok", assertion.getAssertionValue().toString());
 
         // The attributes
         Attributes attributes = sr.getAttributes();
@@ -748,9 +766,9 @@
         {
         	assertNotNull( attributes.get( "attr" + i ) );
         }
-
+        
         // Check the length
-        assertEquals(0x64, message.computeLength());
+        assertEquals(0x96, message.computeLength());
 
         // Check the encoding
         // We won't check the whole PDU, as it may differs because
@@ -761,7 +779,7 @@
             
             String encodedPdu = StringTools.dumpBytes( bb.array() ); 
             
-            assertEquals(encodedPdu.substring( 0, 0x53 ), decodedPdu.substring( 0, 0x53 ) );
+            assertEquals(encodedPdu.substring( 0, 0x87 ), decodedPdu.substring( 0, 0x87 ) );
         }
         catch ( EncoderException ee )
         {
@@ -771,21 +789,119 @@
     }
 
     /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=t*)
+    * Test the decoding of a SearchRequest with controls.
+    */
+    public void testDecodeSearchRequestWithControls()
+    {
+       byte[] asn1BER = new byte[]
+       {
+           0x30, 0x7f,
+               0x02, 0x01, 0x04, // messageID
+               0x63, 0x33,
+                   0x04, 0x13,
+                       0x64, 0x63, 0x3d, 0x6d, 0x79, 0x2d, 0x64, 0x6f, 0x6d, 0x61,
+                               0x69, 0x6e, 0x2c, 0x64, 0x63, 0x3d, 0x63, 0x6f, 0x6d, // baseObject: dc=my-domain,dc=com
+                   0x0a, 0x01, 0x02, // scope: subtree
+                   0x0a, 0x01, 0x03, // derefAliases: derefAlways
+                   0x02, 0x01, 0x00, // sizeLimit: 0
+                   0x02, 0x01, 0x00, // timeLimit: 0
+                   0x01, 0x01, 0x00, // typesOnly: false
+                   (byte)0x87, 0x0b,
+                       0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73, 0x73, // filter: (objectClass=*)
+                   0x30, 0x00,
+               (byte)0xa0, 0x45, // controls
+                   0x30, 0x28,
+                       0x04, 0x16,
+                           0x31, 0x2e, 0x32, 0x2e, 0x38, 0x34, 0x30, 0x2e, 0x31, 0x31,
+                                   0x33, 0x35, 0x35, 0x36, 0x2e, 0x31, 0x2e, 0x34, 0x2e, 0x33,
+                                   0x31, 0x39, // control oid: 1.2.840.113556.1.4.319
+                       0x01, 0x01, (byte)0xff, // criticality: false
+                       0x04, 0x0b,
+                           0x30, 0x09, 0x02, 0x01, 0x02, 0x04, 0x04, 0x47, 0x00, 0x00, 0x00, // value: pageSize=2
+                   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 // control oid: 2.16.840.1.113730.3.4.2
+       };
+    
+       Asn1Decoder ldapDecoder = new LdapDecoder();
+    
+       ByteBuffer  stream      = ByteBuffer.allocate( asn1BER.length );
+       stream.put( asn1BER );
+       String decodedPdu       = StringTools.dumpBytes( stream.array() );
+       stream.flip();
+    
+       IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+    
+       try
+       {
+           ldapDecoder.decode( stream, ldapMessageContainer );
+       }
+       catch ( DecoderException de )
+       {
+           de.printStackTrace();
+           fail( de.getMessage() );
+       }
+    
+       LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+       assertEquals( 4, message.getMessageId() );
+       assertEquals( 2, message.getControls().size() );
+    
+       // this is a constant in Java 5 API
+       String pagedResultsControlOID = "1.2.840.113556.1.4.319";
+       Control pagedResultsControl = message.getControls( 0 );
+       assertEquals( pagedResultsControlOID, pagedResultsControl.getControlType() );
+       assertTrue( pagedResultsControl.getCriticality() );
+    
+       // this is a constant in Java 5 API
+       String manageReferralControlOID = "2.16.840.1.113730.3.4.2";
+       Control manageReferralControl = message.getControls( 1 );
+       assertEquals( manageReferralControlOID, manageReferralControl.getControlType() );
+    
+       SearchRequest sr    = message.getSearchRequest();
+       assertEquals( "dc=my-domain,dc=com", sr.getBaseObject() );
+       assertEquals( LdapConstants.SCOPE_WHOLE_SUBTREE, sr.getScope() );
+       assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
+       assertEquals( 0, sr.getSizeLimit() );
+       assertEquals( 0, sr.getTimeLimit() );
+       assertEquals( false, sr.isTypesOnly() );
+    
+       assertTrue( sr.getFilter() instanceof PresentFilter );
+       assertEquals ( "objectClass",
+           ( (PresentFilter) sr.getFilter() ).getAttributeDescription().getString());
+    
+       // Check the encoding
+       try
+       {
+           ByteBuffer bb = message.encode( null );
+           String encodedPdu = StringTools.dumpBytes( bb.array() );
+           assertEquals(encodedPdu, decodedPdu );
+       }
+       catch ( EncoderException ee )
+       {
+           ee.printStackTrace();
+           fail( ee.getMessage() );
+       }
+    }    
+
+    /**
+     * Test the decoding of a SearchRequest with no controls but with
+     * oid attributes.
+     * The search filter is : 
+     * (&(|(objectclass=top)(2.5.4.11=contacts))(!(organizationalUnitName=ttt)))
      */
-    public void testDecodeSearchRequestSubstringAny()
+    public void testDecodeSearchRequestGlobalNoControlsOidAndAlias()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x64 );
+        ByteBuffer  stream      = ByteBuffer.allocate( 0xA1 );
         stream.put(
             new byte[]
             {
-                0x30, 0x62,                   // LDAPMessage ::=SEQUENCE {
+                0x30, (byte)0x81, (byte)0x9E, // LDAPMessage ::=SEQUENCE {
 				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, 0x5D,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
+				0x63, (byte)0x81, (byte)0x98,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
                         			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
 				0x04, 0x1F, 		     	  //    baseObject LDAPDN,
 				'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=',
@@ -803,23 +919,36 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,   	  //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
-				(byte)0xA4, 0x12,        	  // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				0x04, 0x0B,                   //     type            AttributeDescription,
-				'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				0x30, 0x03,
-				(byte)0x81, 0x01, 't',        //
+				(byte)0xA0, 0x4D,        	  // Filter ::= CHOICE {
+				                         	  //    and             [0] SET OF Filter,
+				(byte)0xA1, 0x2A,        	  //    or              [1] SET of Filter,
+				(byte)0xA3, 0x12,        	  //    equalityMatch   [3] AttributeValueAssertion,
+									     	  // AttributeValueAssertion ::= SEQUENCE {
+								 	          //    attributeDesc   AttributeDescription (LDAPString),
+				0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+									          //    assertionValue  AssertionValue (OCTET STRING) }
+				0x04, 0x03, 't', 'o', 'p',
+				(byte)0xA3, 0x14,             //    equalityMatch   [3] AttributeValueAssertion,
+				                              // AttributeValueAssertion ::= SEQUENCE {
+				0x04, 0x08, '2', '.', '5', '.', '4', '.', '1', '1',         //    attributeDesc   AttributeDescription (LDAPString),
+			                                  //    assertionValue  AssertionValue (OCTET STRING) }
+				0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+				(byte)0xA2, 0x1F,             //    not             [2] Filter,
+				(byte)0xA3, 0x1D,             //    equalityMatch   [3] AttributeValueAssertion,
+			                                  // AttributeValueAssertion ::= SEQUENCE {
+		 	                                  //    attributeDesc   AttributeDescription (LDAPString),
+                0x04, 0x16, 'o', 'r', 'g', 'a', 'n', 'i', 'z', 'a', 't', 'i', 'o', 'n', 'a', 'l', 'U', 'n', 'i', 't', 'N', 'a', 'm', 'e',
+			                                  //    assertionValue  AssertionValue (OCTET STRING) }
+                0x04, 0x03, 't', 't', 't',
+              						          //    attributes      AttributeDescriptionList }
                 0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
                 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
                 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -846,2018 +975,105 @@
         assertEquals( 1000, sr.getTimeLimit() );
         assertEquals( true, sr.isTypesOnly() );
         
-        // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
+        // (& (...
+        AndFilter andFilter = (AndFilter)sr.getFilter();
+        assertNotNull(andFilter);
         
-        assertEquals("objectclass", substringFilter.getType().toString());
-        assertEquals(null, substringFilter.getInitialSubstrings());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
-        assertEquals(null, substringFilter.getFinalSubstrings());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
+        ArrayList andFilters = andFilter.getAndFilter();
         
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-
-        // Check the length
-        assertEquals(0x64, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x53 ), decodedPdu.substring( 0, 0x53 ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=t*)
-     */
-    public void testDecodeSearchRequestSubstringAnyFinal()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x67 );
-        stream.put(
-            new byte[]
-            {
-                0x30, 0x65,                   // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, 0x60,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				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,        	  //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				(byte)0xA4, 0x15,        	  // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				0x04, 0x0B,                   //     type            AttributeDescription,
-				'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				0x30, 0x06,
-				(byte)0x81, 0x01, 't',        //
-				(byte)0x82, 0x01, 't',        //
-                0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
-        
-        assertEquals("objectclass", substringFilter.getType().toString());
-        assertEquals(null, substringFilter.getInitialSubstrings());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
-        assertEquals("t", substringFilter.getFinalSubstrings().toString());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x67, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x58 ), decodedPdu.substring( 0, 0x58 ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=t*)
-     */
-    public void testDecodeSearchRequestSubstringInitialAnyFinal()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x6A );
-        stream.put(
-            new byte[]
-            {
-                0x30, 0x68,                   // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, 0x63,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				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,        	  //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				(byte)0xA4, 0x18,        	  // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				0x04, 0x0B,                   //     type            AttributeDescription,
-				'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				0x30, 0x09,
-				(byte)0x80, 0x01, 't',        //
-				(byte)0x81, 0x01, 't',        //
-				(byte)0x82, 0x01, 't',        //
-                0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
-        
-        assertEquals("objectclass", substringFilter.getType().toString());
-        assertEquals("t", substringFilter.getInitialSubstrings().toString());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
-        assertEquals("t", substringFilter.getFinalSubstrings().toString());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x6A, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x5B ), decodedPdu.substring( 0, 0x5B ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=t*t*)
-     */
-    public void testDecodeSearchRequestSubstringInitialAnyAnyFinal()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x67 );
-        stream.put(
-            new byte[]
-            {
-                0x30, 0x65,                   // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, 0x60,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				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,        	  //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				(byte)0xA4, 0x15,        	  // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				0x04, 0x0B,                   //     type            AttributeDescription,
-				'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				0x30, 0x06,
-				(byte)0x80, 0x01, 't',        //
-				(byte)0x81, 0x01, 't',        //
-                0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
-        
-        assertEquals("objectclass", substringFilter.getType().toString());
-        assertEquals("t", substringFilter.getInitialSubstrings().toString());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x67, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x58 ), decodedPdu.substring( 0, 0x58 ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=t*)
-     */
-    public void testDecodeSearchRequestSubstringAnyAnyFinal()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x6A );
-        stream.put(
-            new byte[]
-            {
-                0x30, 0x68,                   // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, 0x63,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				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,        	  //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				(byte)0xA4, 0x18,        	  // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				0x04, 0x0B,                   //     type            AttributeDescription,
-				'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				0x30, 0x09,
-				(byte)0x81, 0x01, 't',        //
-				(byte)0x81, 0x01, 't',        //
-				(byte)0x82, 0x01, 't',        //
-                0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
-        
-        assertEquals("objectclass", substringFilter.getType().toString());
-        assertEquals(null, substringFilter.getInitialSubstrings());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(1)).toString());
-        assertEquals("t", substringFilter.getFinalSubstrings().toString());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x6A, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x5B ), decodedPdu.substring( 0, 0x5B ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=t*)
-     */
-    public void testDecodeSearchRequestSubstringInitialAnyAny()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x67 );
-        stream.put(
-            new byte[]
-            {
-                0x30, 0x65,                   // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, 0x60,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				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,        	  //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				(byte)0xA4, 0x15,        	  // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				0x04, 0x0B,                   //     type            AttributeDescription,
-				'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				0x30, 0x06,
-				(byte)0x80, 0x01, 't',        //
-				(byte)0x81, 0x01, '*',        //
-                0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
-        
-        assertEquals("objectclass", substringFilter.getType().toString());
-        assertEquals("t", substringFilter.getInitialSubstrings().toString());
-        assertEquals("*", ((LdapString)substringFilter.getAnySubstrings().get(0)).toString());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x67, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x58 ), decodedPdu.substring( 0, 0x58 ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Test the decoding of a SearchRequest with a substring filter.
-     * Test the initial filter : 
-     * (objectclass=*t*t*t*)
-     */
-    public void testDecodeSearchRequestSubstringAnyAnyAny()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x6A );
-        stream.put(
-            new byte[]
-            {
-                0x30, 0x68,                   // LDAPMessage ::=SEQUENCE {
-				  0x02, 0x01, 0x01, 	          //        messageID MessageID
-				  0x63, 0x63,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				    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,         //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				    0x0A, 0x01, 0x03,         //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				    0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				    0x02, 0x02, 0x03, (byte)0xE8,
-				    0x01, 0x01, (byte)0xFF,   //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				    (byte)0xA4, 0x18,         // Filter ::= CHOICE {
-				                         	  //    substrings      [4] SubstringFilter
-											  // }
-									     	  // SubstringFilter ::= SEQUENCE {
-				      0x04, 0x0B,             //     type            AttributeDescription,
-				      'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-				      0x30, 0x09,
-				        (byte)0x81, 0x01, 't',    //
-				        (byte)0x81, 0x01, 't',    //
-				        (byte)0x81, 0x01, 't',    //
-                    0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                      0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                      0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                      0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (objectclass=t*)
-        SubstringFilter substringFilter = (SubstringFilter)sr.getFilter();
-        assertNotNull(substringFilter);
-        
-        assertEquals("objectclass", substringFilter.getType().getString());
-        assertEquals(null, substringFilter.getInitialSubstrings());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(0)).getString());
-        assertEquals("t", ((LdapString)substringFilter.getAnySubstrings().get(1)).getString());
-        assertEquals("t", (( LdapString )substringFilter.getAnySubstrings().get(2)).getString());
-        assertEquals(null, substringFilter.getFinalSubstrings());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x6A, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x5B ), decodedPdu.substring( 0, 0x5B ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Tests an search request decode with a simple equality match filter.
-     */
-    public void testDecodeSearchRequestOrFilters()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x96 );
-        stream.put(
-            new byte[]
-            {
-                    0x30, 0xFFFFFF81, 0xFFFFFF93, 
-                	0x02, 0x01, 0x21, 
-                	0x63, 0xFFFFFF81, 0xFFFFFF8D, // "dc=example,dc=com"
-                		0x04, 0x11, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 
-                		0x0A, 0x01, 0x00, 
-                		0x0A, 0x01, 0x02, 
-                		0x02, 0x01, 0x02, 
-                		0x02, 0x01, 0x03, 
-                		0x01, 0x01, 0xFFFFFFFF, 
-                		0xFFFFFFA1, 0x52, 								// ( | 
-                			0xFFFFFFA3, 0x10, 							// ( uid=akarasulu )
-                				0x04, 0x03, 0x75, 0x69, 0x64, 			
-                				0x04, 0x09, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 
-                			0xFFFFFFA3, 0x09, 							// ( cn=aok )
-                				0x04, 0x02, 0x63, 0x6E, 
-                				0x04, 0x03, 0x61, 0x6F, 0x6B, 
-                			0xFFFFFFA3, 0x15, 							// ( ou = Human Resources )
-                				0x04, 0x02, 0x6F, 0x75, 
-                				0x04, 0x0F, 0x48, 0x75, 0x6D, 0x61, 0x6E, 0x20, 0x52, 0x65, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x73, 
-                			0xFFFFFFA3, 0x10, 
-                				0x04, 0x01, 0x6C, 						// ( l=Santa Clara )
-                				0x04, 0x0B, 0x53, 0x61, 0x6E, 0x74, 0x61, 0x20, 0x43, 0x6C, 0x61, 0x72, 0x61, 
-                			0xFFFFFFA3, 0x0A, 							// ( cn=abok )
-                				0x04, 0x02, 0x63, 0x6E, 
-                				0x04, 0x04, 0x61, 0x62, 0x6F, 0x6B, 
-                		0x30, 0x15,										// Attributes 
-                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 	// attr0
-                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 	// attr1
-                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32	// attr2
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-           ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 33, message.getMessageId() );
-        assertEquals( "dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_BASE_OBJECT, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_FINDING_BASE_OBJ, sr.getDerefAliases() );
-        assertEquals( 2, sr.getSizeLimit() );
-        assertEquals( 3, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (objectclass=t*)
-        OrFilter orFilter = (OrFilter)sr.getFilter();
-        assertNotNull(orFilter);
-
-        // uid=akarasulu
-        AttributeValueAssertion assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(0)).getAssertion();
-        
-        assertEquals("uid", assertion.getAttributeDesc().toString());
-        assertEquals("akarasulu", assertion.getAssertionValue().toString());
-
-        // cn=aok
-        assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(1)).getAssertion();
-        
-        assertEquals("cn", assertion.getAttributeDesc().toString());
-        assertEquals("aok", assertion.getAssertionValue().toString());
-
-        // ou = Human Resources
-        assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(2)).getAssertion();
-        
-        assertEquals("ou", assertion.getAttributeDesc().toString());
-        assertEquals("Human Resources", assertion.getAssertionValue().toString());
-
-        // l=Santa Clara
-        assertion = ((AttributeValueAssertionFilter)orFilter.getOrFilter().get(3)).getAssertion();
-        
-        assertEquals("l", assertion.getAttributeDesc().toString());
-        assertEquals("Santa Clara", assertion.getAssertionValue().toString());
-
-        // cn=abok
-        assertion = (( AttributeValueAssertionFilter )orFilter.getOrFilter().get(4)).getAssertion();
-        
-        assertEquals("cn", assertion.getAttributeDesc().toString());
-        assertEquals("abok", assertion.getAssertionValue().toString());
-
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x96, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x87 ), decodedPdu.substring( 0, 0x87 ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-
-    /**
-     * Tests an search request decode with a simple equality match filter.
-     */
-    public void testDecodeSearchRequestExtensibleMatch()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x63 );
-        stream.put(
-            new byte[]
-            {
-                    0x30, 0x61, 
-                	0x02, 0x01, 0x01, 
-                	0x63, 0x5C, // "dc=example,dc=com"
-                		0x04, 0x11, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 
-                		0x0A, 0x01, 0x00, 
-                		0x0A, 0x01, 0x02, 
-                		0x02, 0x01, 0x02, 
-                		0x02, 0x01, 0x03, 
-                		0x01, 0x01, (byte)0xFF,
-                		(byte)0xA9, 0x21,
-                		  (byte)0x81, 0x02, 'c', 'n',
-                		  (byte)0x82, 0x13, '1', '.', '2', '.', '8', '4', '0',   
-                								  '.', '4', '8', '0', '1', '8', '.',  
-                								  '1', '.', '2', '.', '2',
-                	      (byte)0x83, 0x03, 'a', 'o', 'k',
-                	      (byte)0x84, 0x01, (byte)0xFF,
-                		0x30, 0x15,										// Attributes 
-                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 	// attr0
-                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 	// attr1
-                			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32	// attr2
-            } );
-
-        String decodedPdu = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-           ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_BASE_OBJECT, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_FINDING_BASE_OBJ, sr.getDerefAliases() );
-        assertEquals( 2, sr.getSizeLimit() );
-        assertEquals( 3, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // The attributes
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-        
-        // Check the length
-        assertEquals(0x63, message.computeLength());
-
-        // Check the encoding
-        // We won't check the whole PDU, as it may differs because
-        // attributes may have been reordered
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            
-            String encodedPdu = StringTools.dumpBytes( bb.array() ); 
-            
-            assertEquals(encodedPdu.substring( 0, 0x56 ), decodedPdu.substring( 0, 0x56 ) );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }
-    
-    /**
-    * Test the decoding of a SearchRequest with controls.
-    */
-    public void testDecodeSearchRequestWithControls()
-    {
-       byte[] asn1BER = new byte[]
-       {
-           0x30, 0x7f,
-               0x02, 0x01, 0x04, // messageID
-               0x63, 0x33,
-                   0x04, 0x13,
-                       0x64, 0x63, 0x3d, 0x6d, 0x79, 0x2d, 0x64, 0x6f, 0x6d, 0x61,
-                               0x69, 0x6e, 0x2c, 0x64, 0x63, 0x3d, 0x63, 0x6f, 0x6d, // baseObject: dc=my-domain,dc=com
-                   0x0a, 0x01, 0x02, // scope: subtree
-                   0x0a, 0x01, 0x03, // derefAliases: derefAlways
-                   0x02, 0x01, 0x00, // sizeLimit: 0
-                   0x02, 0x01, 0x00, // timeLimit: 0
-                   0x01, 0x01, 0x00, // typesOnly: false
-                   (byte)0x87, 0x0b,
-                       0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73, 0x73, // filter: (objectClass=*)
-                   0x30, 0x00,
-               (byte)0xa0, 0x45, // controls
-                   0x30, 0x28,
-                       0x04, 0x16,
-                           0x31, 0x2e, 0x32, 0x2e, 0x38, 0x34, 0x30, 0x2e, 0x31, 0x31,
-                                   0x33, 0x35, 0x35, 0x36, 0x2e, 0x31, 0x2e, 0x34, 0x2e, 0x33,
-                                   0x31, 0x39, // control oid: 1.2.840.113556.1.4.319
-                       0x01, 0x01, (byte)0xff, // criticality: false
-                       0x04, 0x0b,
-                           0x30, 0x09, 0x02, 0x01, 0x02, 0x04, 0x04, 0x47, 0x00, 0x00, 0x00, // value: pageSize=2
-                   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 // control oid: 2.16.840.1.113730.3.4.2
-       };
-    
-       Asn1Decoder ldapDecoder = new LdapDecoder();
-    
-       ByteBuffer  stream      = ByteBuffer.allocate( asn1BER.length );
-       stream.put( asn1BER );
-       String decodedPdu       = StringTools.dumpBytes( stream.array() );
-       stream.flip();
-    
-       IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-    
-       try
-       {
-           ldapDecoder.decode( stream, ldapMessageContainer );
-       }
-       catch ( DecoderException de )
-       {
-           de.printStackTrace();
-           fail( de.getMessage() );
-       }
-    
-       LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-       assertEquals( 4, message.getMessageId() );
-       assertEquals( 2, message.getControls().size() );
-    
-       // this is a constant in Java 5 API
-       String pagedResultsControlOID = "1.2.840.113556.1.4.319";
-       Control pagedResultsControl = message.getControls( 0 );
-       assertEquals( pagedResultsControlOID, pagedResultsControl.getControlType() );
-       assertTrue( pagedResultsControl.getCriticality() );
-    
-       // this is a constant in Java 5 API
-       String manageReferralControlOID = "2.16.840.1.113730.3.4.2";
-       Control manageReferralControl = message.getControls( 1 );
-       assertEquals( manageReferralControlOID, manageReferralControl.getControlType() );
-    
-       SearchRequest sr    = message.getSearchRequest();
-       assertEquals( "dc=my-domain,dc=com", sr.getBaseObject() );
-       assertEquals( LdapConstants.SCOPE_WHOLE_SUBTREE, sr.getScope() );
-       assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-       assertEquals( 0, sr.getSizeLimit() );
-       assertEquals( 0, sr.getTimeLimit() );
-       assertEquals( false, sr.isTypesOnly() );
-    
-       assertTrue( sr.getFilter() instanceof PresentFilter );
-       assertEquals ( "objectClass",
-           ( (PresentFilter) sr.getFilter() ).getAttributeDescription().getString());
-    
-       // Check the encoding
-       try
-       {
-           ByteBuffer bb = message.encode( null );
-           String encodedPdu = StringTools.dumpBytes( bb.array() );
-           assertEquals(encodedPdu, decodedPdu );
-       }
-       catch ( EncoderException ee )
-       {
-           ee.printStackTrace();
-           fail( ee.getMessage() );
-       }
-    }    
-
-    /**
-     * Test the decoding of a SearchRequest with no controls but with
-     * oid attributes.
-     * The search filter is : 
-     * (&(|(objectclass=top)(2.5.4.11=contacts))(!(organizationalUnitName=ttt)))
-     */
-    public void testDecodeSearchRequestGlobalNoControlsOidAndAlias()
-    {
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer  stream      = ByteBuffer.allocate( 0xA1 );
-        stream.put(
-            new byte[]
-            {
-                0x30, (byte)0x81, (byte)0x9E, // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	          //        messageID MessageID
-				0x63, (byte)0x81, (byte)0x98,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				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,        	  //    scope           ENUMERATED {
-                					     	  //        baseObject              (0),
-				                         	  //        singleLevel             (1),
-				                         	  //        wholeSubtree            (2) },
-				0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
-									     	  //        neverDerefAliases       (0),
-									     	  //        derefInSearching        (1),
-									     	  //        derefFindingBaseObj     (2),
-									     	  //        derefAlways             (3) },
-				                         	  //    sizeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
-				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, (byte)0xFF,   	  //    typesOnly BOOLEAN, (TRUE)
-				                         	  //    filter    Filter,
-				(byte)0xA0, 0x4D,        	  // Filter ::= CHOICE {
-				                         	  //    and             [0] SET OF Filter,
-				(byte)0xA1, 0x2A,        	  //    or              [1] SET of Filter,
-				(byte)0xA3, 0x12,        	  //    equalityMatch   [3] AttributeValueAssertion,
-									     	  // AttributeValueAssertion ::= SEQUENCE {
-								 	          //    attributeDesc   AttributeDescription (LDAPString),
-				0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
-									          //    assertionValue  AssertionValue (OCTET STRING) }
-				0x04, 0x03, 't', 'o', 'p',
-				(byte)0xA3, 0x14,             //    equalityMatch   [3] AttributeValueAssertion,
-				                              // AttributeValueAssertion ::= SEQUENCE {
-				0x04, 0x08, '2', '.', '5', '.', '4', '.', '1', '1',         //    attributeDesc   AttributeDescription (LDAPString),
-			                                  //    assertionValue  AssertionValue (OCTET STRING) }
-				0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
-				(byte)0xA2, 0x1F,             //    not             [2] Filter,
-				(byte)0xA3, 0x1D,             //    equalityMatch   [3] AttributeValueAssertion,
-			                                  // AttributeValueAssertion ::= SEQUENCE {
-		 	                                  //    attributeDesc   AttributeDescription (LDAPString),
-                0x04, 0x16, 'o', 'r', 'g', 'a', 'n', 'i', 'z', 'a', 't', 'i', 'o', 'n', 'a', 'l', 'U', 'n', 'i', 't', 'N', 'a', 'm', 'e',
-			                                  //    assertionValue  AssertionValue (OCTET STRING) }
-                0x04, 0x03, 't', 't', 't',
-              						          //    attributes      AttributeDescriptionList }
-                0x30, 0x15,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
-                0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
-                0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
-            } );
-
-        stream.flip();
-
-        // Allocate a BindRequest Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-    	
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        SearchRequest sr      = message.getSearchRequest();
-
-        assertEquals( 1, message.getMessageId() );
-        assertEquals( "uid=akarasulu,dc=example,dc=com", sr.getBaseObject().toString() );
-        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 1000, sr.getSizeLimit() );
-        assertEquals( 1000, sr.getTimeLimit() );
-        assertEquals( true, sr.isTypesOnly() );
-        
-        // (& (...
-        AndFilter andFilter = (AndFilter)sr.getFilter();
-        assertNotNull(andFilter);
-        
-        ArrayList andFilters = andFilter.getAndFilter();
-        
-        // (& (| (...
-        assertEquals(2, andFilters.size());
-        OrFilter orFilter = (OrFilter)andFilters.get(0);
-        assertNotNull(orFilter);
-        
-        // (& (| (obectclass=top) (...
-        ArrayList orFilters = orFilter.getOrFilter();
-        assertEquals(2, orFilters.size());
-        AttributeValueAssertionFilter equalityMatch = (AttributeValueAssertionFilter)orFilters.get(0);  
-        assertNotNull(equalityMatch);
-        
-        AttributeValueAssertion assertion = equalityMatch.getAssertion();
-        assertNotNull(assertion);
-        
-        assertEquals("objectclass", assertion.getAttributeDesc().toString());
-        assertEquals("top", assertion.getAssertionValue().toString());
-        
-        // (& (| (objectclass=top) (ou=contacts) ) (...
-        equalityMatch = (AttributeValueAssertionFilter)orFilters.get(1);  
-        assertNotNull(equalityMatch);
-        
-        assertion = equalityMatch.getAssertion();
-        assertNotNull(assertion);
-        
-        assertEquals("ou", assertion.getAttributeDesc().toString());
-        assertEquals("contacts", assertion.getAssertionValue().toString());
-        
-        // (& (| (objectclass=top) (ou=contacts) ) (! ...
-        NotFilter notFilter = ( NotFilter )andFilters.get(1);
-        assertNotNull(notFilter);
-        
-        // (& (| (objectclass=top) (ou=contacts) ) (! (objectclass=ttt) ) )
-        equalityMatch = (AttributeValueAssertionFilter)notFilter.getNotFilter();  
-        assertNotNull(equalityMatch);
-        
-        assertion = equalityMatch.getAssertion();
-        assertNotNull(assertion);
-        
-        assertEquals("ou", assertion.getAttributeDesc().toString());
-        assertEquals("ttt", assertion.getAssertionValue().toString());
-        
-        Attributes attributes = sr.getAttributes();
-        
-        for (int i = 0; i < attributes.size(); i++) 
-        {
-        	assertNotNull( attributes.get( "attr" + i ) );
-        }
-
-        // We won't check the encoding, as it has changed because of 
-        // attributes transformations
-    }
-
-    /**
-     * Test the decoding of a SearchRequest with SubEntry control.
-     */
-    public void testDecodeSearchRequestSubEntryControl()
-    {
-        byte[] asn1BER = new byte[]
-        {
-            0x30, 0x5D,
-                0x02, 0x01, 0x04, // messageID
-                0x63, 0x33,
-                    0x04, 0x13,
-                        0x64, 0x63, 0x3d, 0x6d, 0x79, 0x2d, 0x64, 0x6f, 0x6d, 0x61,
-                                0x69, 0x6e, 0x2c, 0x64, 0x63, 0x3d, 0x63, 0x6f, 0x6d, // baseObject: dc=my-domain,dc=com
-                    0x0a, 0x01, 0x02, // scope: subtree
-                    0x0a, 0x01, 0x03, // derefAliases: derefAlways
-                    0x02, 0x01, 0x00, // sizeLimit: 0
-                    0x02, 0x01, 0x00, // timeLimit: 0
-                    0x01, 0x01, 0x00, // typesOnly: false
-                    (byte)0x87, 0x0b,
-                        0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73, 0x73, // filter: (objectClass=*)
-                    0x30, 0x00,
-                (byte)0xa0, 0x23, // controls
-                    0x30, 0x21,
-                        0x04, 0x17, 
-                          '1', '.', '3', '.', '6', '.', '1', '.',  
-                          '4', '.', '1', '.', '4', '2', '0', '3',  
-                          '.', '1', '.', '1', '0', '.', '1', // SubEntry OID
-                        0x01, 0x01, (byte)0xFF, // criticality: true
-                        0x04, 0x03,
-                            0x01, 0x01, (byte)0xFF // SubEntry visibility
-        };
-     
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-     
-        ByteBuffer  stream      = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        String decodedPdu       = StringTools.dumpBytes( stream.array() );
-        stream.flip();
-     
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-     
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
-     
-        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-        assertEquals( 4, message.getMessageId() );
-        assertEquals( 1, message.getControls().size() );
-     
-        // SubEntry Control
-        String subEntryControlOID = "1.3.6.1.4.1.4203.1.10.1";
-        Control subEntryControl = message.getControls( 0 );
-        assertEquals( subEntryControlOID, subEntryControl.getControlType() );
-        assertTrue( subEntryControl.getCriticality() );
-        assertTrue( ( (SubEntryControl)subEntryControl.getControlValue() ).isVisible() );
-     
-        SearchRequest sr    = message.getSearchRequest();
-        assertEquals( "dc=my-domain,dc=com", sr.getBaseObject() );
-        assertEquals( LdapConstants.SCOPE_WHOLE_SUBTREE, sr.getScope() );
-        assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
-        assertEquals( 0, sr.getSizeLimit() );
-        assertEquals( 0, sr.getTimeLimit() );
-        assertEquals( false, sr.isTypesOnly() );
-     
-        assertTrue( sr.getFilter() instanceof PresentFilter );
-        assertEquals ( "objectClass",
-            ( (PresentFilter) sr.getFilter() ).getAttributeDescription().getString());
-     
-        // Check the encoding
-        try
-        {
-            ByteBuffer bb = message.encode( null );
-            String encodedPdu = StringTools.dumpBytes( bb.array() );
-            assertEquals(encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
-    }    
-
-    // Defensive tests
-    /**
-     * Test the decoding of a SearchRequest with an empty body
-     */
-    public void testDecodeSearchRequestEmptyBody()
-    {
-        byte[] asn1BER = new byte[]
-        {
-            0x30, 0x05,
-              0x02, 0x01, 0x04, // messageID
-              0x63, 0x00
-        };
-      
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-      
-        ByteBuffer  stream      = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-      
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try
-        {
-            ldapDecoder.decode( stream, ldapMessageContainer );
-        }
-        catch ( DecoderException de )
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-         
-        fail( "We should not reach this point" );
-    }    
-
-    /**
-     * Test the decoding of a SearchRequest with an empty baseDN
-     */
-    public void testDecodeSearchRequestEmptyBaseDn() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x07, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x02, 
-                    0x04, 0x00 
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-     }    
-
-    /**
-     * Test the decoding of a SearchRequest with an empty scope
-     */
-    public void testDecodeSearchRequestEmptyScope() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x28, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x23, 
-                    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, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-     }    
-
-    /**
-     * Test the decoding of a SearchRequest with an empty derefAlias
-     */
-    public void testDecodeSearchRequestEmptyDerefAlias() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x2B, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x26, 
-                    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, 0x00,
-                    0x0A, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-     }    
-
-    /**
-     * Test the decoding of a SearchRequest with an empty size limit
-     */
-    public void testDecodeSearchRequestEmptySizeLimit() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x2E, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x29, 
-                    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, 0x00,
-                    0x0A, 0x01, 0x00,
-                    0x02, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-    }    
-    
-    /**
-     * Test the decoding of a SearchRequest with an empty time limit
-     */
-    public void testDecodeSearchRequestEmptyTimeLimit() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x31, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x2C, 
-                    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, 0x00,
-                    0x0A, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x02, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-    }    
-
-    /**
-     * Test the decoding of a SearchRequest with an empty filter
-     */
-    public void testDecodeSearchRequestEmptyTypeOnly() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x34, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x2F, 
-                    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, 0x00,
-                    0x0A, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x01, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-    }    
-
-    /**
-     * Test the decoding of a SearchRequest with an empty filter
-     */
-    public void testDecodeSearchRequestEmptyFilter() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x37, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x32, 
-                    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, 0x00,
-                    0x0A, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x01, 0x01, (byte)0xFF,
-                    (byte)0xA0, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-    }    
-
-    /**
-     * Test the decoding of a SearchRequest with an empty Present filter
-     */
-    public void testDecodeSearchRequestEmptyPresentFilter() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x37, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x32, 
-                    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, 0x00,
-                    0x0A, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x01, 0x01, (byte)0xFF,
-                    (byte)0x87, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-    }    
-
-    /**
-     * Test the decoding of a SearchRequest with an equalityMatch filter
-     */
-    public void testDecodeSearchRequestEmptyEqualityMatchFilter() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x37, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x32, 
-                    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, 0x00,
-                    0x0A, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x02, 0x01, 0x00,
-                    0x01, 0x01, (byte)0xFF,
-                    (byte)0xA3, 0x00
-        };
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
-        stream.put( asn1BER );
-        stream.flip();
-
-        // Allocate a LdapMessage Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode a SearchRequest message
-        try 
-        {
-            ldapDecoder.decode(stream, ldapMessageContainer);
-        } 
-        catch ( DecoderException de ) 
-        {
-            System.out.println( de.getMessage() );
-            assertTrue( true );
-            return;
-        }
-
-        fail( "We should not reach this point" );
-    }    
-
-    /**
-     * Test the decoding of a SearchRequest with a greaterOrEqual filter
-     */
-    public void testDecodeSearchRequestEmptyGreaterOrEqualFilter() 
-    {
-        byte[] asn1BER = new byte[] 
-        { 
-                0x30, 0x37, 
-                  0x02, 0x01, 0x04, // messageID
-                  0x63, 0x32, 
-                    0x04, 0x1F,                   //    baseObject LDAPDN,

[... 1447 lines stripped ...]