directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r264080 - /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
Date Mon, 29 Aug 2005 05:40:54 GMT
Author: elecharny
Date: Sun Aug 28 22:40:51 2005
New Revision: 264080

URL: http://svn.apache.org/viewcvs?rev=264080&view=rev
Log:
- deleted the log4j configuration initialization
- added a testcase to test a null attributes list

Modified:
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java

Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java?rev=264080&r1=264079&r2=264080&view=diff
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
(original)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
Sun Aug 28 22:40:51 2005
@@ -51,11 +51,6 @@
     /** Logger */
     private static Logger log = LoggerFactory.getLogger( SearchRequestTest.class );
 
-    static
-    {
-        PropertyConfigurator.configure( "../../conf/log4j.conf" );
-    }
-
     /**
      * Test the decoding of a SearchRequest with no controls.
      * The search filter is : 
@@ -532,6 +527,107 @@
             String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
             
             Assert.assertEquals(encodedPdu, decodedPdu );
+        }
+        catch ( EncoderException ee )
+        {
+            ee.printStackTrace();
+            Assert.fail( ee.getMessage() );
+        }
+    }
+
+    /**
+     * Test the decoding of a SearchRequest with no attributes.
+     * The search filter is : 
+     * (objectclass=*)
+     */
+    public void testDecodeSearchRequestNoAttributes()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x40 );
+        stream.put(
+            new byte[]
+            {
+                0x30, 0x38,                   // LDAPMessage ::=SEQUENCE {
+				0x02, 0x01, 0x03, 	          //        messageID MessageID
+				0x63, 0x33,                   //	      CHOICE { ..., searchRequest SearchRequest, ...
+                        			     	  // SearchRequest ::= APPLICATION[3] SEQUENCE {
+				0x04, 0x13, 		     	  //    baseObject LDAPDN,
+				'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', ' ', 
+				'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 
+				0x0A, 0x01, 0x00,        	  //    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), (infinite)
+				0x02, 0x01, 0x00, 
+                					     	  //    timeLimit INTEGER (0 .. maxInt), (infinite)
+				0x02, 0x01, 0x00,
+				0x01, 0x01, (byte)0x00,       //    typesOnly BOOLEAN, (FALSE)
+				                         	  //    filter    Filter,
+											  // Filter ::= CHOICE {
+				(byte)0x87, 0x0B,             //    present         [7] AttributeDescription,
+				'o', 'b', 'j', 'e', 'c', 't', 'C', 'l', 'a', 's', 's',
+              						          //    attributes      AttributeDescriptionList }
+                0x30, 0x00,				      // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+                0x00, 0x00,					  // Some trailing 00, useless.
+                0x00, 0x00,
+                0x00, 0x00
+            } );
+
+        String decodedPdu = StringUtils.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a BindRequest Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            Assert.fail( de.getMessage() );
+        }
+    	
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr      = message.getSearchRequest();
+
+        Assert.assertEquals( 3, message.getMessageId() );
+        Assert.assertEquals( "ou=users, ou=system", sr.getBaseObject().toString() );
+        Assert.assertEquals( LdapConstants.SCOPE_BASE_OBJECT, sr.getScope() );
+        Assert.assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
+        Assert.assertEquals( 0, sr.getSizeLimit() );
+        Assert.assertEquals( 0, sr.getTimeLimit() );
+        Assert.assertEquals( false, sr.isTypesOnly() );
+        
+        // (objectClass = *)
+        PresentFilter presentFilter = (PresentFilter)sr.getFilter();
+        Assert.assertNotNull(presentFilter);
+        Assert.assertEquals("objectClass", presentFilter.getAttributeDescription().toString());
+        
+        // The attributes
+        ArrayList attributes = sr.getAttributes();
+        
+        Assert.assertEquals( null, attributes );
+        
+        // Check the length
+        Assert.assertEquals(0x3A, message.computeLength());
+
+        // Check the encoding
+        try
+        {
+            ByteBuffer bb = message.encode( null );
+            
+            String encodedPdu = StringUtils.dumpBytes( bb.array() ); 
+            
+            Assert.assertEquals(encodedPdu, decodedPdu.substring( 0, decodedPdu.length()
- 30) );
         }
         catch ( EncoderException ee )
         {



Mime
View raw message