directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r189847 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchRequestTest.java
Date Thu, 09 Jun 2005 22:54:38 GMT
Author: elecharny
Date: Thu Jun  9 15:54:38 2005
New Revision: 189847

URL: http://svn.apache.org/viewcvs?rev=189847&view=rev
Log:
Extended the test to handle a full SearchRequest message.

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchRequestTest.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchRequestTest.java?rev=189847&r1=189846&r2=189847&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchRequestTest.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchRequestTest.java
Thu Jun  9 15:54:38 2005
@@ -29,6 +29,7 @@
 import org.apache.asn1.ldap.pojo.filters.AttributeValueAssertionFilter;
 import org.apache.asn1.ldap.pojo.filters.NotFilter;
 import org.apache.asn1.ldap.pojo.filters.OrFilter;
+import org.apache.asn1.util.MutableString;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 
@@ -56,53 +57,58 @@
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
-        ByteBuffer  stream      = ByteBuffer.allocate( 0x77 );
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x90 );
         stream.put(
             new byte[]
             {
-                0x30, 0x75,          	 // LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	     //        messageID MessageID
-				0x63, 0x70,              //	      CHOICE { ..., searchRequest SearchRequest, ...
-                        			     // SearchRequest ::= APPLICATION[3] SEQUENCE {
-				0x04, 0x1F, 		     //    baseObject LDAPDN,
+                0x30, (byte)0x81, (byte)0x8D, // LDAPMessage ::=SEQUENCE {
+				0x02, 0x01, 0x01, 	          //        messageID MessageID
+				0x63, (byte)0x81, (byte)0x87,                   //	      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)
+				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)
+                					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        //    typesOnly BOOLEAN, (TRUE)
-				                         //    filter    Filter,
-				(byte)0xA0, 0x3C,        // Filter ::= CHOICE {
-				                         //    and             [0] SET OF Filter,
-				(byte)0xA1, 0x24,        //    or              [1] SET of Filter,
-				(byte)0xA3, 0x12,        //    equalityMatch   [3] AttributeValueAssertion,
-									     // AttributeValueAssertion ::= SEQUENCE {
-								 	     //    attributeDesc   AttributeDescription (LDAPString),
+				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				                         	  //    filter    Filter,
+				(byte)0xA0, 0x3C,        	  // Filter ::= CHOICE {
+				                         	  //    and             [0] SET OF Filter,
+				(byte)0xA1, 0x24,        	  //    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) }
+									          //    assertionValue  AssertionValue (OCTET STRING) }
 				0x04, 0x03, 't', 'o', 'p',
-				(byte)0xA3, 0x0E,        //    equalityMatch   [3] AttributeValueAssertion,
-				                         // AttributeValueAssertion ::= SEQUENCE {
-				0x04, 0x02, 'o', 'u',    //    attributeDesc   AttributeDescription (LDAPString),
-			                             //    assertionValue  AssertionValue (OCTET STRING) }
+				(byte)0xA3, 0x0E,             //    equalityMatch   [3] AttributeValueAssertion,
+				                              // AttributeValueAssertion ::= SEQUENCE {
+				0x04, 0x02, 'o', 'u',         //    attributeDesc   AttributeDescription (LDAPString),
+			                                  //    assertionValue  AssertionValue (OCTET STRING)
}
 				0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
-				(byte)0xA2, 0x14,        //    not             [2] Filter,
-				(byte)0xA3, 0x12,        //    equalityMatch   [3] AttributeValueAssertion,
-			                             // AttributeValueAssertion ::= SEQUENCE {
-		 	                             //    attributeDesc   AttributeDescription (LDAPString),
+				(byte)0xA2, 0x14,             //    not             [2] 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', 't', 't'
+			                                  //    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();
@@ -177,6 +183,15 @@
         
         Assert.assertEquals("objectclass", assertion.getAttributeDesc().toString());
         Assert.assertEquals("[74][74][74]", assertion.getAssertionValue().toString());
+        
+        ArrayList attributes = sr.getAttributes();
+        
+        for (int i = 0; i < attributes.size(); i++) 
+        {
+            MutableString attribute = (MutableString)attributes.get(i);
+            
+            Assert.assertEquals("attr" + i, attribute.toString());
+        }
     }
 
     /**



Mime
View raw message