directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r371754 - /directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/search/SearchRequestTest.java
Date Tue, 24 Jan 2006 00:49:48 GMT
Author: elecharny
Date: Mon Jan 23 16:49:44 2006
New Revision: 371754

URL: http://svn.apache.org/viewcvs?rev=371754&view=rev
Log:
Added many tests for SubstringsFilters and MatchingRuleAssertions.
Fixed some other.

Modified:
    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=371754&r1=371753&r2=371754&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 Mon Jan 23 16:49:44 2006
@@ -636,7 +636,7 @@
         // The attributes
         Attributes attributes = sr.getAttributes();
         
-       	assertNull( attributes );
+       	assertEquals( 0, attributes.size() );
 
         // Check the length
         assertEquals(0x39, message.computeLength());
@@ -1716,27 +1716,26 @@
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x65 );
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x63 );
         stream.put(
             new byte[]
             {
-                    0x30, 0x63, 
+                    0x30, 0x61, 
                 	0x02, 0x01, 0x01, 
-                	0x63, 0x5E, // "dc=example,dc=com"
+                	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, 0x23,
-                			0x30, 0x21,
-                				(byte)0x81, 0x02, 'c', 'n',
-                				(byte)0x82, 0x13, '1', '.', '2', '.', '8', '4', '0',   
+                		(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,
+                	      (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
@@ -1779,7 +1778,7 @@
         }
         
         // Check the length
-        assertEquals(0x65, message.computeLength());
+        assertEquals(0x63, message.computeLength());
 
         // Check the encoding
         // We won't check the whole PDU, as it may differs because
@@ -2462,7 +2461,7 @@
     }    
 
     /**
-     * Test the decoding of a SearchRequest with an empty filter
+     * Test the decoding of a SearchRequest with an empty Present filter
      */
     public void testDecodeSearchRequestEmptyPresentFilter() 
     {
@@ -2505,4 +2504,1299 @@
 
         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,
+                      '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)0xA5, 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 lessOrEqual filter
+     */
+    public void testDecodeSearchRequestEmptyLessOrEqualFilter() 
+    {
+        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)0xA6, 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 approxMatch filter
+     */
+    public void testDecodeSearchRequestEmptyApproxMatchFilter() 
+    {
+        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)0xA8, 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 and
+     * an empty attributeDesc 
+     */
+    public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrDesc() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x39, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x34, 
+                    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)0xA5, 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 a greaterOrEqual filter and
+     * an empty attributeValue, and an empty attribute List
+     */
+    public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrValue() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                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)0xA5, 0x08,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x04, 0x00,
+                    0x30, 0x00                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+        };
+
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
+        stream.put( asn1BER );
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a LdapMessage Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        // Decode a SearchRequest message
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+        
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr      = message.getSearchRequest();
+
+        assertEquals( 4, 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( 0, sr.getSizeLimit() );
+        assertEquals( 0, sr.getTimeLimit() );
+        assertEquals( true, sr.isTypesOnly() );
+        
+        // >=
+        AttributeValueAssertionFilter greaterThanFilter = (AttributeValueAssertionFilter)sr.getFilter();
+        assertNotNull( greaterThanFilter );
+        
+        AttributeValueAssertion assertion = greaterThanFilter.getAssertion();
+        
+        assertEquals( "test", assertion.getAttributeDesc().toString());
+        assertEquals( "", assertion.getAssertionValue().toString());
+        
+        Attributes attributes = sr.getAttributes();
+        
+        assertEquals( 0, attributes.size() );
+
+        // 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, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            fail( ee.getMessage() );
+        }
+    }    
+
+    /**
+     * Test the decoding of a SearchRequest with a greaterOrEqual filter and
+     * an empty attributeValue, and an '*' attribute List
+     */
+    public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrValueStar() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x44, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x3F, 
+                    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)0xA5, 0x08,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x04, 0x00,
+                    0x30, 0x03,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      0x04, 0x01, '*'
+        };
+
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( asn1BER.length );
+        stream.put( asn1BER );
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a LdapMessage Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        // Decode a SearchRequest message
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+        
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr      = message.getSearchRequest();
+
+        assertEquals( 4, 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( 0, sr.getSizeLimit() );
+        assertEquals( 0, sr.getTimeLimit() );
+        assertEquals( true, sr.isTypesOnly() );
+        
+        // >=
+        AttributeValueAssertionFilter greaterThanFilter = (AttributeValueAssertionFilter)sr.getFilter();
+        assertNotNull( greaterThanFilter );
+        
+        AttributeValueAssertion assertion = greaterThanFilter.getAssertion();
+        
+        assertEquals( "test", assertion.getAttributeDesc().toString());
+        assertEquals( "", assertion.getAssertionValue().toString());
+        
+        Attributes attributes = sr.getAttributes();
+        
+        assertEquals( 1, attributes.size() );
+        
+        for (int i = 0; i < attributes.size(); i++) 
+        {
+            assertNotNull( attributes.get( "*" ) );
+        }
+
+        // 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, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            fail( ee.getMessage() );
+        }
+    }    
+
+    /**
+     * Test the decoding of a SearchRequest with a greaterOrEqual filter and
+     * an empty attributeValue, and an empty attribute List
+     */
+    public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrValueEmpty() 
+    {
+        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)0xA5, 0x08,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x04, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+        
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr      = message.getSearchRequest();
+
+        assertEquals( 4, 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( 0, sr.getSizeLimit() );
+        assertEquals( 0, sr.getTimeLimit() );
+        assertEquals( true, sr.isTypesOnly() );
+        
+        // >=
+        AttributeValueAssertionFilter greaterThanFilter = (AttributeValueAssertionFilter)sr.getFilter();
+        assertNotNull( greaterThanFilter );
+        
+        AttributeValueAssertion assertion = greaterThanFilter.getAssertion();
+        
+        assertEquals( "test", assertion.getAttributeDesc().toString());
+        assertEquals( "", assertion.getAssertionValue().toString());
+        
+        Attributes attributes = sr.getAttributes();
+        
+        assertEquals( 1, attributes.size() );
+        
+        for (int i = 0; i < attributes.size(); i++) 
+        {
+            assertNotNull( attributes.get( "*" ) );
+        }
+    }    
+
+    /**
+     * Test the decoding of a SearchRequest with an empty And filter
+     */
+    public void testDecodeSearchRequestEmptyAndFilter() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x3B, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x36, 
+                    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)0xA0, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 Or filter
+     */
+    public void testDecodeSearchRequestEmptyOrFilter() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x3B, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x36, 
+                    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)0xA1, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 Not filter
+     */
+    public void testDecodeSearchRequestEmptyNotFilter() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x3B, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x36, 
+                    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)0xA2, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Not filter and an
+     * empty And filter
+     */
+    public void testDecodeSearchRequestNotFilterEmptyAndFilter() 
+    {
+        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)0xA2, 0x02,
+                      (byte)0xA0, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 Substring filter
+     */
+    public void testDecodeSearchRequestEmptySubstringFilter() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x3B, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x36, 
+                    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)0xA4, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Substring filter
+     * and an empty Substring
+     */
+    public void testDecodeSearchRequestSubstringFilterEmptyType() 
+    {
+        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)0xA4, 0x02,
+                      0x04, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Substring filter
+     * and an empty Substring
+     */
+    public void testDecodeSearchRequestSubstringFilterNoSubstrings() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x41, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x3D, 
+                    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)0xA4, 0x06,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Substring filter
+     * and an empty Substring
+     */
+    public void testDecodeSearchRequestSubstringFilterEmptySubstrings() 
+    {
+        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)0xA4, 0x08,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x30, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Substring filter
+     * and an empty Substring Initial
+     */
+    public void testDecodeSearchRequestSubstringFilterEmptyInitial() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x45, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x40, 
+                    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)0xA4, 0x0A,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x30, 0x02,
+                        (byte)0x81, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Substring filter
+     * and an empty Substring Any
+     */
+    public void testDecodeSearchRequestSubstringFilterEmptyAny() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x45, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x40, 
+                    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)0xA4, 0x0A,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x30, 0x02,
+                        (byte)0x80, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Substring filter
+     * and an empty Substring Initial
+     */
+    public void testDecodeSearchRequestSubstringFilterEmptyFinam() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x45, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x40, 
+                    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)0xA4, 0x0A,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x30, 0x02,
+                        (byte)0x81, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 a Substring filter
+     * and an empty Substring Final
+     */
+    public void testDecodeSearchRequestSubstringFilterEmptyFinal() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x45, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x40, 
+                    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)0xA4, 0x0A,
+                      0x04, 0x04, 't', 'e', 's', 't',
+                      0x30, 0x02,
+                        (byte)0x82, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 extensible match
+     */
+    public void testDecodeSearchRequestEmptyExtensibleMatch() 
+    {
+        byte[] asn1BER = new byte[] 
+        { 
+                0x30, 0x3B, 
+                  0x02, 0x01, 0x04, // messageID
+                  0x63, 0x36, 
+                    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, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 extensible match and
+     * an empty matching rule
+     */
+    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)0x80, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 extensible match and
+     * an empty type
+     */
+    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)0x81, 0x00,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 extensible match and
+     * an empty matchValue
+     */
+    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,
+                    0x30, 0x02,                     // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                      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 )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+        
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr      = message.getSearchRequest();
+
+        assertEquals( 4, 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( 0, sr.getSizeLimit() );
+        assertEquals( 0, sr.getTimeLimit() );
+        assertEquals( true, sr.isTypesOnly() );
+        
+        // Extended
+        ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)sr.getFilter();
+        assertNotNull( extensibleMatchFilter );
+        
+        assertEquals( "test", extensibleMatchFilter.getMatchingRule().toString() );
+        assertNull( extensibleMatchFilter.getType() );
+        assertEquals( "", extensibleMatchFilter.getMatchValue().toString());
+        assertFalse( extensibleMatchFilter.isDnAttributes() );
+        
+        Attributes attributes = sr.getAttributes();
+        
+        assertEquals( 1, attributes.size() );
+        
+        for (int i = 0; i < attributes.size(); i++) 
+        {
+            assertNotNull( attributes.get( "*" ) );
+        }
+    }
 }



Mime
View raw message