directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: r153541 [3/3] - in incubator/directory/ldap/trunk/apache-provider/src: java/org/apache/ldap/common/berlib/asn1/ java/org/apache/ldap/common/berlib/asn1/decoder/ java/org/apache/ldap/common/berlib/asn1/decoder/abandon/ java/org/apache/ldap/common/berlib/asn1/decoder/add/ java/org/apache/ldap/common/berlib/asn1/decoder/bind/ java/org/apache/ldap/common/berlib/asn1/decoder/compare/ java/org/apache/ldap/common/berlib/asn1/decoder/delete/ java/org/apache/ldap/common/berlib/asn1/decoder/extended/ java/org/apache/ldap/common/berlib/asn1/decoder/modify/ java/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ java/org/apache/ldap/common/berlib/asn1/decoder/search/ java/org/apache/ldap/common/berlib/asn1/decoder/unbind/ java/org/apache/ldap/common/berlib/asn1/encoder/ java/org/apache/ldap/common/berlib/asn1/encoder/abandon/ java/org/apache/ldap/common/berlib/asn1/encoder/add/ java/org/apache/ldap/common/berlib/asn1/encoder/bind/ java/org/apache/ldap/common/berlib/asn1/encoder/compare/ java/org/apache/ldap/common/berlib/asn1/encoder/delete/ java/org/apache/ldap/common/berlib/asn1/encoder/extended/ java/org/apache/ldap/common/berlib/asn1/encoder/modify/ java/org/apache/ldap/common/berlib/asn1/encoder/modifyDn/ java/org/apache/ldap/common/berlib/asn1/encoder/search/ java/org/apache/ldap/common/berlib/asn1/encoder/unbind/ test/org/apache/ldap/common/berlib/asn1/decoder/add/ test/org/apache/ldap/common/berlib/asn1/decoder/bind/ test/org/apache/ldap/common/berlib/asn1/decoder/extended/ test/org/apache/ldap/common/berlib/asn1/decoder/modify/ test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ test/org/apache/ldap/common/berlib/asn1/decoder/search/ test/org/apache/ldap/common/berlib/asn1/encoder/
Date Sat, 12 Feb 2005 20:28:59 GMT
Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedResponseRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedResponseRuleTest.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedResponseRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedResponseRuleTest.java Sat Feb 12 12:28:39 2005
@@ -42,14 +42,16 @@
 {
     public void testExtendedResponse() throws Exception
     {
-        // build the PDU
-        ExtendedResponseImpl resp = new ExtendedResponseImpl( 8 ) ;
-        resp.setResponseName( "0.0.0.0" ) ;
+        byte[] pdu = new byte[] {0x30, 0x59, 0x02, 0x01, 0x08, 0x78, 0x54, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0xFFFFFF8A, 0x07, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0xFFFFFF8B, 0x02, 0x05, 0x06};
+        ExtendedResponse decoded = ( ExtendedResponse ) decode( pdu );
+
+        ExtendedResponseImpl expected = new ExtendedResponseImpl( 8 ) ;
+        expected.setResponseName( "0.0.0.0" ) ;
         byte[] payload = new byte[2] ;
         payload[0] = 5 ;
         payload[1] = 6 ;
-        resp.setResponse( payload ) ;
-        LdapResultImpl result = new LdapResultImpl( resp ) ;
+        expected.setResponse( payload ) ;
+        LdapResultImpl result = new LdapResultImpl( expected ) ;
         result.setResultCode( ResultCodeEnum.BUSY ) ;
         result.setErrorMessage( "An Error Message!" ) ;
         result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
@@ -57,61 +59,9 @@
         referral.addLdapUrl( "hello" ) ;
         referral.addLdapUrl( "world" ) ;
         result.setReferral( referral ) ;
-        resp.setLdapResult( result ) ;
-        System.out.println( "Generated ExtendedResponse for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-
-        ExtendedResponse decoded = ( ExtendedResponse )
-                snickersDecode( snaccEncode( resp ) ) ;
-
-        assertNotNull( decoded ) ;
-        assertEquals( resp.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( resp.getResponseName(), decoded.getResponseName() ) ;
-        assertTrue( ArrayUtils.isEquals( payload, decoded.getResponse() ) ) ;
-        LdapResult decodedResult = resp.getLdapResult() ;
-        assertEquals( result.getResultCode(), decodedResult.getResultCode() ) ;
-        assertEquals( result.getErrorMessage(),
-                decodedResult.getErrorMessage() ) ;
-        assertEquals( result.getMatchedDn(),
-                decodedResult.getMatchedDn() ) ;
-        Referral decodedRef = result.getReferral() ;
-        Iterator urls = referral.getLdapUrls().iterator() ;
-        Iterator decodedUrls = decodedRef.getLdapUrls().iterator() ;
+        expected.setLdapResult( result ) ;
 
-        while( urls.hasNext() && decodedUrls.hasNext() )
-        {
-            assertEquals( urls.next(), decodedUrls.next() ) ;
-        }
-
-        assertFalse( urls.hasNext() ) ;
-        assertFalse( decodedUrls.hasNext() ) ;
+        assertEquals( expected, decoded ) ;
     }
-
-    /**
-     * TODO: Find out why Snickers and Snacc PDUs are different
-     */
-//    public void testExtendedResponse() throws Exception
-//    {
-//        byte[] pdu = new byte[] {0x30, 0x59, 0x02, 0x01, 0x08, 0x78, 0x54, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0xFFFFFF8A, 0x07, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0xFFFFFF8B, 0x02, 0x05, 0x06};
-//        ExtendedResponse decoded = ( ExtendedResponse ) decode( pdu );
-//
-//        ExtendedResponseImpl expected = new ExtendedResponseImpl( 8 ) ;
-//        expected.setResponseName( "0.0.0.0" ) ;
-//        byte[] payload = new byte[2] ;
-//        payload[0] = 5 ;
-//        payload[1] = 6 ;
-//        expected.setResponse( payload ) ;
-//        LdapResultImpl result = new LdapResultImpl( expected ) ;
-//        result.setResultCode( ResultCodeEnum.BUSY ) ;
-//        result.setErrorMessage( "An Error Message!" ) ;
-//        result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
-//        ReferralImpl referral = new ReferralImpl( result ) ;
-//        referral.addLdapUrl( "hello" ) ;
-//        referral.addLdapUrl( "world" ) ;
-//        result.setReferral( referral ) ;
-//        expected.setLdapResult( result ) ;
-//
-//        assertEquals( expected, decoded ) ;
-//    }
 
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyRequestTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyRequestTest.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyRequestTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyRequestTest.java Sat Feb 12 12:28:39 2005
@@ -18,7 +18,6 @@
 
 
 import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
 import org.apache.ldap.common.message.LockableAttributeImpl;
 import org.apache.ldap.common.message.ModifyRequest;
 import org.apache.ldap.common.message.ModifyRequestImpl;
@@ -26,9 +25,6 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.Iterator;
 
 
 /**
@@ -40,126 +36,38 @@
  */
 public class ModifyRequestTest extends RuleTestCase
 {
-    /**
-     * Tests an modify request decode.
-     */
     public void testModifyRequest() throws Exception
     {
-        ModifyRequestImpl req = new ModifyRequestImpl( 33 ) ;
-        req.setName( "dc=example,dc=com" ) ;
+        byte[] pdu = new byte[] {0x30, 0xFFFFFF81, 0xFFFFFFA8, 0x02, 0x01, 0x21, 0x66, 0xFFFFFF81, 0xFFFFFFA2, 0x04, 0x11, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x30, 0xFFFFFF81, 0xFFFFFF8C, 0x30, 0x19, 0x0A, 0x01, 0x02, 0x30, 0x14, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0E, 0x04, 0x0C, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x30, 0x23, 0x0A, 0x01, 0x01, 0x30, 0x1E, 0x04, 0x05, 0x62, 0x6F, 0x67, 0x75, 0x73, 0x31, 0x15, 0x04, 0x13, 0x73, 0x6F, 0x6D, 0x65, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x2D, 0x74, 0x6F, 0x2D, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x30, 0x28, 0x0A, 0x01, 0x00, 0x30, 0x23, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x31, 0x14, 0x04, 0x12, 0x6F, 0x72, 0x67, 0x61, 0x6E, 0x69, 0x7A, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x61, 0x6C, 0x55, 0x6E, 0x69, 0x74, 0x30, 0x20, 0x0A, 0x01, 0x00, 0x30, 0x1B, 0x04, 0x02, 0x6F, 0x75, 0x31, 0x15, 0x04, 0x08, 0x4F, 0x53, 0x53, 0x20, 0x53, 0x69, 0x74, 0x65, 0x04, 0x09, 0x4D, 0x61, 0x69, 0x6E, 0x20, 0x53, 0x69, 0x74, 0x65};
+
+        ModifyRequest decoded = ( ModifyRequest ) decode( pdu ) ;
+
+        ModifyRequestImpl expected = new ModifyRequestImpl( 33 ) ;
+        expected.setName( "dc=example,dc=com" ) ;
 
         Attribute attr = new LockableAttributeImpl( "dc" ) ;
         attr.add( "opensoftware" ) ;
         ModificationItem mod = new ModificationItem(
                 DirContext.REPLACE_ATTRIBUTE, attr ) ;
-        req.addModification( mod ) ;
+        expected.addModification( mod ) ;
 
         attr = new LockableAttributeImpl( "bogus" ) ;
         attr.add( "somevalue-to-remove" ) ;
         mod = new ModificationItem(
                 DirContext.REMOVE_ATTRIBUTE, attr ) ;
-        req.addModification( mod ) ;
+        expected.addModification( mod ) ;
 
         attr = new LockableAttributeImpl( "objectClass" ) ;
         attr.add( "organizationalUnit" ) ;
         mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr ) ;
-        req.addModification( mod ) ;
+        expected.addModification( mod ) ;
 
         attr = new LockableAttributeImpl( "ou" ) ;
         attr.add( "OSS Site" ) ;
         attr.add( "Main Site" ) ;
         mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr ) ;
-        req.addModification( mod ) ;
+        expected.addModification( mod ) ;
 
-        System.out.println( "Generated ModifyRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
-
-        ModifyRequest decoded = ( ModifyRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertNotNull( decoded ) ;
-        assertEquals( req.getName(), decoded.getName() ) ;
-
-        Collection items = decoded.getModificationItems() ;
-        assertEquals( 4, items.size() ) ;
-        Iterator list = items.iterator() ;
-        while( list.hasNext() )
-        {
-            ModificationItem item = ( ModificationItem ) list.next() ;
-
-            if ( item.getAttribute().getID().equalsIgnoreCase( "dc" ) )
-            {
-                assertEquals( DirContext.REPLACE_ATTRIBUTE,
-                        item.getModificationOp() ) ;
-                assertEquals( "opensoftware", item.getAttribute().get() ) ;
-            }
-
-            if ( item.getAttribute().getID().equalsIgnoreCase( "bogus" ) )
-            {
-                assertEquals( DirContext.REMOVE_ATTRIBUTE,
-                        item.getModificationOp() ) ;
-                assertEquals( "somevalue-to-remove",
-                        item.getAttribute().get() ) ;
-            }
-
-            if ( item.getAttribute().getID().equalsIgnoreCase( "objectClass" ) )
-            {
-                assertEquals( DirContext.ADD_ATTRIBUTE,
-                        item.getModificationOp() ) ;
-                assertEquals( "organizationalUnit",
-                        item.getAttribute().get() ) ;
-            }
-
-            if ( item.getAttribute().getID().equalsIgnoreCase( "ou" ) )
-            {
-                assertEquals( DirContext.ADD_ATTRIBUTE,
-                        item.getModificationOp() ) ;
-
-                HashSet values = new HashSet() ;
-                for( int ii = 0; ii < item.getAttribute().size(); ii++ )
-                {
-                    values.add( item.getAttribute().get(ii) ) ;
-                }
-                assertTrue( values.contains( "OSS Site" ) ) ;
-                assertTrue( values.contains( "Main Site" ) ) ;
-            }
-        }
+        assertEquals( expected, decoded ) ;
     }
-
-    /**
-     * TODO: investigate why the following is not passing. It should
-     * replace the above at some point.
-     */
-//    public void testModifyRequest() throws Exception
-//    {
-//        byte[] pdu = new byte[] {0x30, 0x7F, 0xFFFFFFAA, 0x02, 0x01, 0x21, 0x66, 0xFFFFFF81, 0xFFFFFFA2, 0x04, 0x11, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x30, 0xFFFFFF81, 0xFFFFFF8C, 0x30, 0x19, 0x0A, 0x01, 0x02, 0x30, 0x14, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0E, 0x04, 0x0C, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x30, 0x23, 0x0A, 0x01, 0x01, 0x30, 0x1E, 0x04, 0x05, 0x62, 0x6F, 0x67, 0x75, 0x73, 0x31, 0x15, 0x04, 0x13, 0x73, 0x6F, 0x6D, 0x65, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x2D, 0x74, 0x6F, 0x2D, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x30, 0x28, 0x0A, 0x01, 0x00, 0x30, 0x23, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x31, 0x14, 0x04, 0x12, 0x6F, 0x72, 0x67, 0x61, 0x6E, 0x69, 0x7A, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x61, 0x6C, 0x55, 0x6E, 0x69, 0x74, 0x30, 0x20, 0x0A, 0x01, 0x00, 0x30, 0x1B, 0x04, 0x02, 0x6F, 0x75, 0x31, 0x15, 0x04, 0x08, 0x4F, 0x53, 0x53, 0x20, 0x53, 0x69, 0x74, 0x65, 0x04, 0x09, 0x4D, 0x61, 0x69, 0x6E, 0x20, 0x53, 0x69, 0x74, 0x65};
-//        ModifyRequest decoded = ( ModifyRequest ) decode( pdu ) ;
-//
-//        ModifyRequestImpl expected = new ModifyRequestImpl( 33 ) ;
-//        expected.setName( "dc=example,dc=com" ) ;
-//
-//        Attribute attr = new LockableAttributeImpl( "dc" ) ;
-//        attr.add( "opensoftware" ) ;
-//        ModificationItem mod = new ModificationItem(
-//                DirContext.REPLACE_ATTRIBUTE, attr ) ;
-//        expected.addModification( mod ) ;
-//
-//        attr = new LockableAttributeImpl( "bogus" ) ;
-//        attr.add( "somevalue-to-remove" ) ;
-//        mod = new ModificationItem(
-//                DirContext.REMOVE_ATTRIBUTE, attr ) ;
-//        expected.addModification( mod ) ;
-//
-//        attr = new LockableAttributeImpl( "objectClass" ) ;
-//        attr.add( "organizationalUnit" ) ;
-//        mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr ) ;
-//        expected.addModification( mod ) ;
-//
-//        attr = new LockableAttributeImpl( "ou" ) ;
-//        attr.add( "OSS Site" ) ;
-//        attr.add( "Main Site" ) ;
-//        mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr ) ;
-//        expected.addModification( mod ) ;
-//
-//        assertEquals( expected, decoded ) ;
-//    }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyResponseRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyResponseRuleTest.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyResponseRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyResponseRuleTest.java Sat Feb 12 12:28:39 2005
@@ -18,16 +18,11 @@
 
 
 import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
-import org.apache.ldap.common.message.ModifyResponseImpl;
 import org.apache.ldap.common.message.LdapResultImpl;
-import org.apache.ldap.common.message.ResultCodeEnum;
-import org.apache.ldap.common.message.ReferralImpl;
 import org.apache.ldap.common.message.ModifyResponse;
-import org.apache.ldap.common.message.LdapResult;
-import org.apache.ldap.common.message.Referral;
-
-import java.util.Iterator;
+import org.apache.ldap.common.message.ModifyResponseImpl;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
 
 
 /**
@@ -41,9 +36,11 @@
 {
     public void testModifyResponse() throws Exception
     {
-        // build the PDU
-        ModifyResponseImpl resp = new ModifyResponseImpl( 8 ) ;
-        LdapResultImpl result = new LdapResultImpl( resp ) ;
+        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x08, 0x67, 0x47, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64};
+        ModifyResponse decoded = ( ModifyResponse ) decode( pdu );
+
+        ModifyResponseImpl expected = new ModifyResponseImpl( 8 ) ;
+        LdapResultImpl result = new LdapResultImpl( expected ) ;
         result.setResultCode( ResultCodeEnum.BUSY ) ;
         result.setErrorMessage( "An Error Message!" ) ;
         result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
@@ -51,53 +48,8 @@
         referral.addLdapUrl( "hello" ) ;
         referral.addLdapUrl( "world" ) ;
         result.setReferral( referral ) ;
-        resp.setLdapResult( result ) ;
-        System.out.println( "Generated ModifyResponse for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-
-        ModifyResponse decoded = ( ModifyResponse )
-                snickersDecode( snaccEncode( resp ) ) ;
+        expected.setLdapResult( result ) ;
 
-        assertNotNull( decoded ) ;
-        assertEquals( resp.getMessageId(), decoded.getMessageId() ) ;
-        LdapResult decodedResult = resp.getLdapResult() ;
-        assertEquals( result.getResultCode(), decodedResult.getResultCode() ) ;
-        assertEquals( result.getErrorMessage(),
-                decodedResult.getErrorMessage() ) ;
-        assertEquals( result.getMatchedDn(),
-                decodedResult.getMatchedDn() ) ;
-        Referral decodedRef = result.getReferral() ;
-        Iterator urls = referral.getLdapUrls().iterator() ;
-        Iterator decodedUrls = decodedRef.getLdapUrls().iterator() ;
-
-        while( urls.hasNext() && decodedUrls.hasNext() )
-        {
-            assertEquals( urls.next(), decodedUrls.next() ) ;
-        }
-
-        assertFalse( urls.hasNext() ) ;
-        assertFalse( decodedUrls.hasNext() ) ;
+        assertEquals( expected, decoded ) ;
     }
-
-    /**
-     * TODO: Fails but should replace the above at some point. 
-     */
-//    public void testModifyResponse() throws Exception
-//    {
-//        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x08, 0x67, 0x47, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64};
-//        ModifyResponse decoded = ( ModifyResponse ) decode( pdu );
-//
-//        ModifyResponseImpl expected = new ModifyResponseImpl( 8 ) ;
-//        LdapResultImpl result = new LdapResultImpl( expected ) ;
-//        result.setResultCode( ResultCodeEnum.BUSY ) ;
-//        result.setErrorMessage( "An Error Message!" ) ;
-//        result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
-//        ReferralImpl referral = new ReferralImpl( result ) ;
-//        referral.addLdapUrl( "hello" ) ;
-//        referral.addLdapUrl( "world" ) ;
-//        result.setReferral( referral ) ;
-//        expected.setLdapResult( result ) ;
-//
-//        assertEquals( expected, decoded ) ;
-//    }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnResponseRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnResponseRuleTest.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnResponseRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnResponseRuleTest.java Sat Feb 12 12:28:39 2005
@@ -18,16 +18,11 @@
 
 
 import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
-import org.apache.ldap.common.message.ModifyDnResponseImpl;
 import org.apache.ldap.common.message.LdapResultImpl;
-import org.apache.ldap.common.message.ResultCodeEnum;
-import org.apache.ldap.common.message.ReferralImpl;
 import org.apache.ldap.common.message.ModifyDnResponse;
-import org.apache.ldap.common.message.LdapResult;
-import org.apache.ldap.common.message.Referral;
-
-import java.util.Iterator;
+import org.apache.ldap.common.message.ModifyDnResponseImpl;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
 
 
 /**
@@ -39,11 +34,13 @@
  */
 public class ModifyDnResponseRuleTest extends RuleTestCase
 {
-    public void testModifyDnRequest() throws Exception
+    public void testModifyDnResponse() throws Exception
     {
-        // build the PDU
-        ModifyDnResponseImpl resp = new ModifyDnResponseImpl( 7 ) ;
-        LdapResultImpl result = new LdapResultImpl( resp ) ;
+        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x07, 0x6D, 0x47, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64};
+        ModifyDnResponse decoded = ( ModifyDnResponse ) decode( pdu );
+
+        ModifyDnResponseImpl expected = new ModifyDnResponseImpl( 7 ) ;
+        LdapResultImpl result = new LdapResultImpl( expected ) ;
         result.setResultCode( ResultCodeEnum.BUSY ) ;
         result.setErrorMessage( "An Error Message!" ) ;
         result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
@@ -51,53 +48,8 @@
         referral.addLdapUrl( "hello" ) ;
         referral.addLdapUrl( "world" ) ;
         result.setReferral( referral ) ;
-        resp.setLdapResult( result ) ;
-        System.out.println( "Generated ModifyDnResponse for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-
-        ModifyDnResponse decoded = ( ModifyDnResponse )
-                snickersDecode( snaccEncode( resp ) ) ;
+        expected.setLdapResult( result ) ;
 
-        assertNotNull( decoded ) ;
-        assertEquals( resp.getMessageId(), decoded.getMessageId() ) ;
-        LdapResult decodedResult = resp.getLdapResult() ;
-        assertEquals( result.getResultCode(), decodedResult.getResultCode() ) ;
-        assertEquals( result.getErrorMessage(),
-                decodedResult.getErrorMessage() ) ;
-        assertEquals( result.getMatchedDn(),
-                decodedResult.getMatchedDn() ) ;
-        Referral decodedRef = result.getReferral() ;
-        Iterator urls = referral.getLdapUrls().iterator() ;
-        Iterator decodedUrls = decodedRef.getLdapUrls().iterator() ;
-
-        while( urls.hasNext() && decodedUrls.hasNext() )
-        {
-            assertEquals( urls.next(), decodedUrls.next() ) ;
-        }
-
-        assertFalse( urls.hasNext() ) ;
-        assertFalse( decodedUrls.hasNext() ) ;
+        assertEquals( expected, decoded ) ;
     }
-
-    /**
-     * TODO: Fails but should replace the above at some point.
-     */
-//    public void testModifyDnRequest() throws Exception
-//    {
-//        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x07, 0x6D, 0x47, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64};
-//        ModifyDnResponse decoded = ( ModifyDnResponse ) decode( pdu );
-//
-//        ModifyDnResponseImpl expected = new ModifyDnResponseImpl( 7 ) ;
-//        LdapResultImpl result = new LdapResultImpl( expected ) ;
-//        result.setResultCode( ResultCodeEnum.BUSY ) ;
-//        result.setErrorMessage( "An Error Message!" ) ;
-//        result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
-//        ReferralImpl referral = new ReferralImpl( result ) ;
-//        referral.addLdapUrl( "hello" ) ;
-//        referral.addLdapUrl( "world" ) ;
-//        result.setReferral( referral ) ;
-//        expected.setLdapResult( result ) ;
-//
-//        assertEquals( expected, decoded ) ;
-//    }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchRequestTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchRequestTest.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchRequestTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchRequestTest.java Sat Feb 12 12:28:39 2005
@@ -130,317 +130,147 @@
         assertEquals( "(objectClass=*)", req.getFilter().toString().trim() );
     }
 
-
-    /**
-     * Tests an search request decode with a simple equality match filter.
-     */
     public void testEqualityMatchFilter() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        byte[] pdu = new byte[] {0x30, 0x55, 0x02, 0x01, 0x21, 0x63, 0x50, 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, 0xFFFFFFA3, 0x15, 0x04, 0x02, 0x6F, 0x75, 0x04, 0x0F, 0x48, 0x75, 0x6D, 0x61, 0x6E, 0x20, 0x52, 0x65, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x73, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
         FilterParserImpl parser = new FilterParserImpl();
         ExprNode node = null ;
         node = parser.parse(
                 "( ou = Human Resources ) " ) ;
-        req.setFilter( node );
-
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+        expected.setFilter( node );
 
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        node = req.getFilter();
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        node = decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        assertEquals(buf0.toString(), buf1.toString()) ;
+        assertEquals( expected, decoded );
     }
 
-
-    /**
-     * Tests an search request decode with a simple greaterOrEqual filter.
-     */
     public void testGreaterOrEqualFilter() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
-
+        byte[] pdu = new byte[] {0x30, 0x49, 0x02, 0x01, 0x21, 0x63, 0x44, 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, 0xFFFFFFA5, 0x09, 0x04, 0x03, 0x61, 0x67, 0x65, 0x04, 0x02, 0x33, 0x30, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
-        req.setFilter( new SimpleNode( "age", "30", SimpleNode.GREATEREQ ) );
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
+        expected.setFilter( new SimpleNode( "age", "30", SimpleNode.GREATEREQ ) );
 
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        ExprNode node = req.getFilter();
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        node = decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        assertEquals(buf0.toString(), buf1.toString()) ;
-        System.out.println( buf1.toString() );
+        assertEquals( expected, decoded );
     }
 
-
     /**
      * Tests an search request decode with a simple lessOrEqual match
      * filter.
      */
     public void testLessOrEqualFilter() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        byte[] pdu = new byte[] {0x30, 0x49, 0x02, 0x01, 0x21, 0x63, 0x44, 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, 0xFFFFFFA6, 0x09, 0x04, 0x03, 0x61, 0x67, 0x65, 0x04, 0x02, 0x33, 0x30, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
-        req.setFilter( new SimpleNode( "age", "30", SimpleNode.LESSEQ ) );
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
+        expected.setFilter( new SimpleNode( "age", "30", SimpleNode.LESSEQ ) );
 
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        ExprNode node = req.getFilter();
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        node = decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        assertEquals(buf0.toString(), buf1.toString()) ;
-        System.out.println( buf1.toString() );
+        assertEquals( expected, decoded );
     }
 
-
     /**
      * Tests an search request decode with a simple presence match filter.
      */
     public void testPresentFilter() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
+        byte[] pdu = new byte[] {0x30, 0x4B, 0x02, 0x01, 0x21, 0x63, 0x46, 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, 0xFFFFFF87, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
-
-
-        req.setFilter( new PresenceNode( "objectClass" ) );
-
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
+        expected.setFilter( new PresenceNode( "objectClass" ) );
 
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        ExprNode node = req.getFilter();
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        node = decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        assertEquals(buf0.toString(), buf1.toString()) ;
-        System.out.println( buf1.toString() );
+        assertEquals( expected, decoded );
     }
 
-
     /**
      * Tests an search request decode with a simple approx match filter.
      */
     public void testApproxMatchFilter() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        byte[] pdu = new byte[] {0x30, 0x53, 0x02, 0x01, 0x21, 0x63, 0x4E, 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, 0xFFFFFFA8, 0x13, 0x04, 0x02, 0x63, 0x6E, 0x04, 0x0D, 0x41, 0x6C, 0x65, 0x78, 0x20, 0x4B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x61, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode ( pdu );
 
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
-        req.setFilter( new SimpleNode( "cn", "Alex Karasula",
+        expected.setFilter( new SimpleNode( "cn", "Alex Karasula",
                 SimpleNode.APPROXIMATE ) );
 
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        ExprNode node = req.getFilter();
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        node = decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        assertEquals(buf0.toString(), buf1.toString()) ;
-        System.out.println( buf1.toString() );
+        assertEquals( expected, decoded );
     }
 
-
-    /**
-     * Tests an search request decode with a simple substring match filter.
-     */
     public void testSubstringsFilter() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
+        byte[] pdu = new byte[] {0x30, 0x65, 0x02, 0x01, 0x21, 0x63, 0x60, 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, 0xFFFFFFA4, 0x25, 0x04, 0x02, 0x63, 0x6E, 0x30, 0x1F, 0xFFFFFF80, 0x08, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0xFFFFFF81, 0x05, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0xFFFFFF81, 0x06, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0xFFFFFF82, 0x04, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
         String any0 = "ijklm";
         String any1 = "nopqrs";
@@ -449,303 +279,191 @@
         any.add( any1 );
         SubstringNode node = new SubstringNode( any, "cn", "abcdefgh", "wxyz" );
 
-        req.setFilter( node );
-
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        System.out.println( buf0.toString() );
-
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
+        expected.setFilter( node );
 
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-
-        node = ( SubstringNode ) decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        System.out.println( buf1.toString() );
-        assertEquals(buf0.toString(), buf1.toString()) ;
+        assertEquals( expected, decoded );
     }
 
-
     /**
      * Tests an search request decode with a simple greaterOrEqual match filter.
      */
     public void testExtensibleMatch() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        byte[] pdu = new byte[] {0x30, 0x51, 0x02, 0x01, 0x21, 0x63, 0x4C, 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, 0xFFFFFFA9, 0x11, 0xFFFFFF81, 0x03, 0x31, 0x2E, 0x31, 0xFFFFFF82, 0x02, 0x63, 0x6E, 0xFFFFFF83, 0x03, 0x76, 0x61, 0x6C, 0xFFFFFF84, 0x01, 0xFFFFFFFF, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
         ExtensibleNode node = new ExtensibleNode( "cn", "val", "1.1", true );
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        req.setFilter( node );
+        expected.setFilter( node );
 
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        node = ( ExtensibleNode ) decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        assertEquals(buf0.toString(), buf1.toString()) ;
-        System.out.println( buf1.toString() );
+        assertEquals( expected, decoded );
     }
 
-
     /**
      * Tests an search request decode with a simple equality match filter.
      */
     public void testNotFilter0() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        byte[] pdu = new byte[] {0x30, 0x57, 0x02, 0x01, 0x21, 0x63, 0x52, 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, 0xFFFFFFA2, 0x17, 0xFFFFFFA3, 0x15, 0x04, 0x02, 0x6F, 0x75, 0x04, 0x0F, 0x48, 0x75, 0x6D, 0x61, 0x6E, 0x20, 0x52, 0x65, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x73, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
         FilterParserImpl parser = new FilterParserImpl();
         ExprNode node = null ;
         node = parser.parse(
                 "( ! ( ou = Human Resources ) )" ) ;
-        req.setFilter( node );
-
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
+        expected.setFilter( node );
 
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        node = req.getFilter();
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        System.out.println( buf0.toString() );
-        node = decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        System.out.println( buf1.toString() );
-        assertEquals(buf0.toString(), buf1.toString()) ;
+        assertEquals( expected, decoded );
     }
 
-
     /**
      * Tests an search request decode with a simple equality match filter.
      */
     public void testNotFilter1() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        byte[] pdu = new byte[] {0x30, 0x59, 0x02, 0x01, 0x21, 0x63, 0x54, 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, 0xFFFFFFA2, 0x19, 0xFFFFFFA2, 0x17, 0xFFFFFFA3, 0x15, 0x04, 0x02, 0x6F, 0x75, 0x04, 0x0F, 0x48, 0x75, 0x6D, 0x61, 0x6E, 0x20, 0x52, 0x65, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x73, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
         FilterParserImpl parser = new FilterParserImpl();
         ExprNode node = null ;
         node = parser.parse(
                 "( !( ! ( ou = Human Resources ) ) )" ) ;
-        req.setFilter( node );
+        expected.setFilter( node );
 
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
-
-        // filter tests
-        node = req.getFilter();
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        System.out.println( buf0.toString() );
-        node = decoded.getFilter();
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        System.out.println( buf1.toString() );
-        assertEquals(buf0.toString(), buf1.toString()) ;
+        assertEquals( expected, decoded );
     }
 
-
-    /**
-     * Tests an search request decode with a simple equality match filter.
-     */
     public void testAndFilter0() throws Exception
     {
-        SearchRequestImpl req = new SearchRequestImpl( 33 );
-        req.setBase( "dc=example,dc=com" );
-        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
-        req.setScope( ScopeEnum.BASEOBJECT );
-        req.setSizeLimit( 2 );
-        req.setTimeLimit( 3 );
-        req.setTypesOnly( true );
-
-        req.addAttribute( "attr0" );
-        req.addAttribute( "attr1" );
-        req.addAttribute( "attr2" );
+        byte[] pdu = new byte[] {0x30, 0x69, 0x02, 0x01, 0x21, 0x63, 0x64, 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, 0xFFFFFFA0, 0x29, 0xFFFFFFA3, 0x15, 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, 0x04, 0x0B, 0x53, 0x61, 0x6E, 0x74, 0x61, 0x20, 0x43, 0x6C, 0x61, 0x72, 0x61, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+        SearchRequest decoded = ( SearchRequest ) decode( pdu );
 
+        SearchRequestImpl expected = new SearchRequestImpl( 33 );
+        expected.setBase( "dc=example,dc=com" );
+        expected.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        expected.setScope( ScopeEnum.BASEOBJECT );
+        expected.setSizeLimit( 2 );
+        expected.setTimeLimit( 3 );
+        expected.setTypesOnly( true );
+
+        expected.addAttribute( "attr0" );
+        expected.addAttribute( "attr1" );
+        expected.addAttribute( "attr2" );
 
         FilterParserImpl parser = new FilterParserImpl();
         BranchNode node = null ;
         node = ( BranchNode ) parser.parse(
                 "( & ( ou = Human Resources ) ( l=Santa Clara ) )" ) ;
         normalizer.visit( node );
-        req.setFilter( node );
-
-        System.out.println( "Generated SearchRequest for test:" );
-        System.out.println( TestUtils.printTupleTree( req ) );
-
-        SearchRequest decoded = ( SearchRequest )
-                snickersDecode( snaccEncode( req ) );
-        assertNotNull( decoded );
-
-        // test that we have all the properties set
-        assertEquals( req.getBase(), decoded.getBase() );
-        assertEquals( req.getScope(), decoded.getScope() );
-        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
-        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
-        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
-        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
-
-        // test that we have all the attributes
-        Iterator list = req.getAttributes().iterator();
-        Collection attributes = decoded.getAttributes();
-        while( list.hasNext() )
-        {
-            assertTrue( attributes.contains( list.next() ) );
-        }
-
-        // control test should not exist
-        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+        expected.setFilter( node );
 
-        // filter tests
-        StringBuffer buf0 = new StringBuffer();
-        node.printToBuffer( buf0 );
-        System.out.println( buf0.toString() );
-        node = ( BranchNode ) decoded.getFilter();
-        normalizer.visit( node );
-        StringBuffer buf1 = new StringBuffer();
-        node.printToBuffer( buf1 );
-        System.out.println( buf1.toString() );
-        assertEquals(buf0.toString(), buf1.toString()) ;
+        assertEquals( expected, decoded );
     }
 
-
     /**
      * Tests an search request decode with a simple equality match filter.
      */
+//    public void testAndFilter1() throws Exception
+//    {
+//        SearchRequestImpl req = new SearchRequestImpl( 33 );
+//        req.setBase( "dc=example,dc=com" );
+//        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+//        req.setScope( ScopeEnum.BASEOBJECT );
+//        req.setSizeLimit( 2 );
+//        req.setTimeLimit( 3 );
+//        req.setTypesOnly( true );
+//
+//        req.addAttribute( "attr0" );
+//        req.addAttribute( "attr1" );
+//        req.addAttribute( "attr2" );
+//
+//        FilterParserImpl parser = new FilterParserImpl();
+//        ExprNode node = null ;
+//        node = parser.parse(
+//                "( & ( ou = Human Resources ) ( l=Santa Clara ) " +
+//                "( uid=akarasulu ) )" ) ;
+//        normalizer.visit( node );
+//        req.setFilter( node );
+//
+//        System.out.println( "Generated SearchRequest for test:" );
+//        System.out.println( TestUtils.printTupleTree( req ) );
+//
+//        SearchRequest decoded = ( SearchRequest )
+//                snickersDecode( snaccEncode( req ) );
+//        assertNotNull( decoded );
+//
+//        // test that we have all the properties set
+//        assertEquals( req.getBase(), decoded.getBase() );
+//        assertEquals( req.getScope(), decoded.getScope() );
+//        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+//        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+//        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+//        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+//
+//        // test that we have all the attributes
+//        Iterator list = req.getAttributes().iterator();
+//        Collection attributes = decoded.getAttributes();
+//        while( list.hasNext() )
+//        {
+//            assertTrue( attributes.contains( list.next() ) );
+//        }
+//
+//        // control test should not exist
+//        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+//
+//        // filter tests
+//        node = req.getFilter();
+//        StringBuffer buf0 = new StringBuffer();
+//        node.printToBuffer( buf0 );
+//        System.out.println( buf0.toString() );
+//        node = decoded.getFilter();
+//        normalizer.visit( node );
+//        StringBuffer buf1 = new StringBuffer();
+//        node.printToBuffer( buf1 );
+//        System.out.println( buf1.toString() );
+//        assertEquals(buf0.toString(), buf1.toString()) ;
+//    }
+
     public void testAndFilter1() throws Exception
     {
+        byte[] pdu = new byte[] {0x30, 0x7B, 0x02, 0x01, 0x21, 0x63, 0x76, 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, 0xFFFFFFA0, 0x3B, 0xFFFFFFA3, 0x15, 0x04, 0x02, 0x6F, 0x75, 0x04, 0x0F, 0x48, 0x75, 0x6D, 0x61, 0x6E, 0x20, 0x52, 0x65, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x73, 0xFFFFFFA3, 0x10, 0x04, 0x03, 0x75, 0x69, 0x64, 0x04, 0x09, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0xFFFFFFA3, 0x10, 0x04, 0x01, 0x6C, 0x04, 0x0B, 0x53, 0x61, 0x6E, 0x74, 0x61, 0x20, 0x43, 0x6C, 0x61, 0x72, 0x61, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x30, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32};
+
+        //TODO: here
         SearchRequestImpl req = new SearchRequestImpl( 33 );
         req.setBase( "dc=example,dc=com" );
         req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
@@ -804,7 +522,6 @@
         System.out.println( buf1.toString() );
         assertEquals(buf0.toString(), buf1.toString()) ;
     }
-
 
     /**
      * Tests an search request decode with a simple equality match filter.

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseDoneRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseDoneRuleTest.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseDoneRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseDoneRuleTest.java Sat Feb 12 12:28:39 2005
@@ -41,9 +41,11 @@
 {
     public void testAddResponse() throws Exception
     {
-        // build the PDU
-        SearchResponseDone resp = new SearchResponseDoneImpl( 8 ) ;
-        LdapResultImpl result = new LdapResultImpl( resp ) ;
+        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x08, 0x65, 0x47, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64};
+        SearchResponseDone decoded = ( SearchResponseDone ) decode( pdu );
+
+        SearchResponseDone expected = new SearchResponseDoneImpl( 8 ) ;
+        LdapResultImpl result = new LdapResultImpl( expected ) ;
         result.setResultCode( ResultCodeEnum.BUSY ) ;
         result.setErrorMessage( "An Error Message!" ) ;
         result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
@@ -51,53 +53,8 @@
         referral.addLdapUrl( "hello" ) ;
         referral.addLdapUrl( "world" ) ;
         result.setReferral( referral ) ;
-        resp.setLdapResult( result ) ;
-        System.out.println( "Generated SearchResultDone for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-
-        SearchResponseDone decoded = ( SearchResponseDone )
-                snickersDecode( snaccEncode( resp ) ) ;
-
-        assertNotNull( decoded ) ;
-        assertEquals( resp.getMessageId(), decoded.getMessageId() ) ;
-        LdapResult decodedResult = resp.getLdapResult() ;
-        assertEquals( result.getResultCode(), decodedResult.getResultCode() ) ;
-        assertEquals( result.getErrorMessage(),
-                decodedResult.getErrorMessage() ) ;
-        assertEquals( result.getMatchedDn(),
-                decodedResult.getMatchedDn() ) ;
-        Referral decodedRef = result.getReferral() ;
-        Iterator urls = referral.getLdapUrls().iterator() ;
-        Iterator decodedUrls = decodedRef.getLdapUrls().iterator() ;
+        expected.setLdapResult( result ) ;
 
-        while( urls.hasNext() && decodedUrls.hasNext() )
-        {
-            assertEquals( urls.next(), decodedUrls.next() ) ;
-        }
-
-        assertFalse( urls.hasNext() ) ;
-        assertFalse( decodedUrls.hasNext() ) ;
+        assertEquals( expected, decoded ) ;
     }
-
-    /**
-     * TODO: Fails but should replace the above at some point.
-     */
-//    public void testAddResponse() throws Exception
-//    {
-//        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x08, 0x65, 0x47, 0x0A, 0x01, 0x33, 0x04, 0x1F, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x11, 0x41, 0x6E, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x21, 0xFFFFFFA3, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64};
-//        SearchResponseDone decoded = ( SearchResponseDone ) decode( pdu );
-//
-//        SearchResponseDone expected = new SearchResponseDoneImpl( 8 ) ;
-//        LdapResultImpl result = new LdapResultImpl( expected ) ;
-//        result.setResultCode( ResultCodeEnum.BUSY ) ;
-//        result.setErrorMessage( "An Error Message!" ) ;
-//        result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
-//        ReferralImpl referral = new ReferralImpl( result ) ;
-//        referral.addLdapUrl( "hello" ) ;
-//        referral.addLdapUrl( "world" ) ;
-//        result.setReferral( referral ) ;
-//        expected.setLdapResult( result ) ;
-//
-//        assertEquals( expected, decoded ) ;
-//    }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseReferenceRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseReferenceRuleTest.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseReferenceRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseReferenceRuleTest.java Sat Feb 12 12:28:39 2005
@@ -32,38 +32,6 @@
  */
 public class SearchResponseReferenceRuleTest extends RuleTestCase
 {
-//    public void testSearchResponseReference() throws Exception
-//    {
-//        // build the PDU
-//        SearchResponseReferenceImpl resp =
-//                new SearchResponseReferenceImpl( 8 ) ;
-//        ReferralImpl referral = new ReferralImpl( resp ) ;
-//        resp.setReferral( referral ) ;
-//        referral.addLdapUrl(
-//           "ldap://directory.uga.edu/ou=students,o=uga,c=us?objectClass?one" ) ;
-//        referral.addLdapUrl(
-//           "ldap://directory.uga.edu/o=uga,c=us?creatorsname" ) ;
-//        System.out.println( "Generated SearchResultReferrence for test:" ) ;
-//        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-//
-//        SearchResponseReference decoded = ( SearchResponseReference )
-//                snickersDecode( snaccEncode( resp ) ) ;
-//
-//        assertNotNull( decoded ) ;
-//        assertEquals( resp.getMessageId(), decoded.getMessageId() ) ;
-//        Referral decodedRef = decoded.getReferral() ;
-//        Iterator urls = referral.getLdapUrls().iterator() ;
-//        Iterator decodedUrls = decodedRef.getLdapUrls().iterator() ;
-//
-//        while( urls.hasNext() && decodedUrls.hasNext() )
-//        {
-//            assertEquals( urls.next(), decodedUrls.next() ) ;
-//        }
-//
-//        assertFalse( urls.hasNext() ) ;
-//        assertFalse( decodedUrls.hasNext() ) ;
-//    }
-
     public void testSearchResponseReference() throws Exception
     {
         byte[] pdu = new byte[] {0x30, 0x78, 0x02, 0x01, 0x08, 0x73, 0x73, 0x04, 0x3F, 0x6C, 0x64, 0x61, 0x70, 0x3A, 0x2F, 0x2F, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6F, 0x72, 0x79, 0x2E, 0x75, 0x67, 0x61, 0x2E, 0x65, 0x64, 0x75, 0x2F, 0x6F, 0x75, 0x3D, 0x73, 0x74, 0x75, 0x64, 0x65, 0x6E, 0x74, 0x73, 0x2C, 0x6F, 0x3D, 0x75, 0x67, 0x61, 0x2C, 0x63, 0x3D, 0x75, 0x73, 0x3F, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x3F, 0x6F, 0x6E, 0x65, 0x04, 0x30, 0x6C, 0x64, 0x61, 0x70, 0x3A, 0x2F, 0x2F, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6F, 0x72, 0x79, 0x2E, 0x75, 0x67, 0x61, 0x2E, 0x65, 0x64, 0x75, 0x2F, 0x6F, 0x3D, 0x75, 0x67, 0x61, 0x2C, 0x63, 0x3D, 0x75, 0x73, 0x3F, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6F, 0x72, 0x73, 0x6E, 0x61, 0x6D, 0x65};

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java?view=diff&r1=153540&r2=153541
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java Sat Feb 12 12:28:39 2005
@@ -23,13 +23,8 @@
 import org.apache.asn1.ber.TupleEncodingVisitor;
 import org.apache.asn1.codec.stateful.EncoderCallback;
 import org.apache.asn1.codec.stateful.StatefulEncoder;
-import org.apache.ldap.common.message.Message;
-import org.apache.ldap.common.message.MessageDecoder;
-import org.apache.ldap.common.message.spi.Provider;
 
-import java.io.ByteArrayInputStream;
 import java.nio.ByteBuffer;
-import java.util.Properties;
 
 
 /**



Mime
View raw message