directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r226910 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/SearchRequestTest.java
Date Mon, 01 Aug 2005 23:48:59 GMT
Author: elecharny
Date: Mon Aug  1 16:48:55 2005
New Revision: 226910

URL: http://svn.apache.org/viewcvs?rev=226910&view=rev
Log:
- added the encoding test
- changed the boolean value (0x3E) by a valid one (0xFF)

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=226910&r1=226909&r2=226910&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
Mon Aug  1 16:48:55 2005
@@ -20,6 +20,7 @@
 import java.util.ArrayList;
 
 import org.apache.asn1.DecoderException;
+import org.apache.asn1.EncoderException;
 import org.apache.asn1.ber.Asn1Decoder;
 import org.apache.asn1.ber.containers.IAsn1Container;
 import org.apache.asn1.ldap.codec.primitives.LdapString;
@@ -32,6 +33,7 @@
 import org.apache.asn1.ldap.pojo.filters.OrFilter;
 import org.apache.asn1.ldap.pojo.filters.PresentFilter;
 import org.apache.asn1.ldap.pojo.filters.SubstringFilter;
+import org.apache.asn1.util.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 
@@ -85,7 +87,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,   	  //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA0, 0x3C,        	  // Filter ::= CHOICE {
 				                         	  //    and             [0] SET OF Filter,
@@ -115,6 +117,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -196,6 +199,21 @@
             
             Assert.assertEquals("attr" + i, attribute.toString());
         }
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -232,7 +250,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA0, 0x3C,        	  // Filter ::= CHOICE {
 				                         	  //    and             [0] SET OF Filter,
@@ -262,6 +280,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -347,6 +366,21 @@
         
         // Check the length
         Assert.assertEquals(0x90, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -383,7 +417,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA0, 0x29,        	  // Filter ::= CHOICE {
 				                         	  //    and             [0] SET OF Filter,
@@ -408,6 +442,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -486,6 +521,21 @@
         
         // Check the length
         Assert.assertEquals(0x7B, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -521,7 +571,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA4, 0x12,        	  // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
@@ -537,6 +587,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -582,6 +633,21 @@
         
         // Check the length
         Assert.assertEquals(0x64, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -617,7 +683,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA4, 0x12,        	  // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
@@ -633,6 +699,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -680,6 +747,21 @@
         
         // Check the length
         Assert.assertEquals(0x64, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -715,7 +797,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA4, 0x15,        	  // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
@@ -732,6 +814,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -779,6 +862,21 @@
         
         // Check the length
         Assert.assertEquals(0x67, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -814,7 +912,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA4, 0x18,        	  // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
@@ -832,6 +930,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -879,6 +978,21 @@
         
         // Check the length
         Assert.assertEquals(0x6A, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -914,7 +1028,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA4, 0x15,        	  // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
@@ -931,6 +1045,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -977,6 +1092,21 @@
         
         // Check the length
         Assert.assertEquals(0x67, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -1012,7 +1142,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA4, 0x18,        	  // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
@@ -1030,6 +1160,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -1078,6 +1209,21 @@
         
         // Check the length
         Assert.assertEquals(0x6A, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -1113,7 +1259,7 @@
 				0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				0x02, 0x02, 0x03, (byte)0xE8,
-				0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				0x01, 0x01, (byte)0xFF,       //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
 				(byte)0xA4, 0x15,        	  // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
@@ -1130,6 +1276,7 @@
                 0x04, 0x05, 'a', 't', 't', 'r', '2'  // AttributeDescription ::= LDAPString
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -1176,6 +1323,21 @@
         
         // Check the length
         Assert.assertEquals(0x67, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -1198,11 +1360,11 @@
 				    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 {
+				    0x0A, 0x01, 0x01,         //    scope           ENUMERATED {
                 					     	  //        baseObject              (0),
 				                         	  //        singleLevel             (1),
 				                         	  //        wholeSubtree            (2) },
-				    0x0A, 0x01, 0x03,        	  //    derefAliases    ENUMERATED {
+				    0x0A, 0x01, 0x03,         //    derefAliases    ENUMERATED {
 									     	  //        neverDerefAliases       (0),
 									     	  //        derefInSearching        (1),
 									     	  //        derefFindingBaseObj     (2),
@@ -1211,24 +1373,25 @@
 				    0x02, 0x02, 0x03, (byte)0xE8,
                 					     	  //    timeLimit INTEGER (0 .. maxInt), (1000)
 				    0x02, 0x02, 0x03, (byte)0xE8,
-				    0x01, 0x01, 0x3E,        	  //    typesOnly BOOLEAN, (TRUE)
+				    0x01, 0x01, (byte)0xFF,   //    typesOnly BOOLEAN, (TRUE)
 				                         	  //    filter    Filter,
-				    (byte)0xA4, 0x18,        	  // Filter ::= CHOICE {
+				    (byte)0xA4, 0x18,         // Filter ::= CHOICE {
 				                         	  //    substrings      [4] SubstringFilter
 											  // }
 									     	  // SubstringFilter ::= SEQUENCE {
-				      0x04, 0x0B,                   //     type            AttributeDescription,
+				      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',        //
+				        (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 = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -1278,6 +1441,21 @@
         
         // Check the length
         Assert.assertEquals(0x6A, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -1322,6 +1500,7 @@
                 			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32	// attr2
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -1394,6 +1573,21 @@
         
         // Check the length
         Assert.assertEquals(0x96, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 
     /**
@@ -1430,6 +1624,7 @@
                 			0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32	// attr2
             } );
 
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a BindRequest Container
@@ -1466,6 +1661,22 @@
             Assert.assertEquals("attr" + i, attribute.toString());
         }
         
-        // Check the length675, message.computeLength());
+        // Check the length
+        Assert.assertEquals(0x65, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
     }
 }



Mime
View raw message