directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: r152980 [1/2] - in incubator/directory/ldap/trunk/apache-provider/src: java/org/apache/ldap/common/berlib/asn1/ java/org/apache/ldap/common/berlib/asn1/encoder/add/ test/org/apache/ldap/common/berlib/asn1/ test/org/apache/ldap/common/berlib/asn1/decoder/abandon/ 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/compare/ test/org/apache/ldap/common/berlib/asn1/decoder/delete/ 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/decoder/testutils/ test/org/apache/ldap/common/berlib/asn1/decoder/unbind/ test/org/apache/ldap/common/berlib/asn1/encoder/ test/org/apache/ldap/common/berlib/asn1/encoder/abandon/ test/org/apache/ldap/common/berlib/asn1/encoder/add/ test/org/apache/ldap/common/berlib/asn1/encoder/bind/ test/org/apache/ldap/common/berlib/asn1/encoder/compare/ test/org/apache/ldap/common/berlib/asn1/encoder/delete/ test/org/apache/ldap/common/berlib/asn1/encoder/extended/ test/org/apache/ldap/common/berlib/asn1/encoder/modify/ test/org/apache/ldap/common/berlib/asn1/encoder/modifyDn/ test/org/apache/ldap/common/berlib/asn1/encoder/search/ test/org/apache/ldap/common/berlib/asn1/encoder/unbind/
Date Wed, 09 Feb 2005 03:33:54 GMT
Author: vtence
Date: Tue Feb  8 19:33:42 2005
New Revision: 152980

URL: http://svn.apache.org/viewcvs?view=rev&rev=152980
Log:
Migrated most of the test cases to use pre-computed PDUs. Need to investigate while the remaining fail on conversion.

Modified:
    incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
    incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java
    incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoder.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/SnickersDecoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/abandon/AbandonRequestRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddRequestTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddResponseRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindNameRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindResponseRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindSimpleCredentialsRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindVersionRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareRequestRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareResponseRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteRequestRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteResponseRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedRequestRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedResponseRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyRequestTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modify/ModifyResponseRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnRequestRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnResponseRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchRequestTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseDoneRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseEntryTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseReferenceRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/testutils/RuleTestCase.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/testutils/TestUtils.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/unbind/UnbindRequestRuleTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/AbstractEncoderTestCase.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/EncoderUtilsTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/abandon/AbandonRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/add/AddResponseEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/bind/BindRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/bind/BindResponseEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/compare/CompareRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/compare/CompareResponseEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/delete/DeleteRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/delete/DeleteResponseEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/extended/ExtendedRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/extended/ExtendedResponseEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modify/ModifyRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modify/ModifyResponseEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modifyDn/ModifyDnRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/modifyDn/ModifyDnResponseEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchRequestEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseDoneEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseEntryEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/search/SearchResponseReferenceEncoderTest.java
    incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/encoder/unbind/UnbindRequestEncoderTest.java

Modified: incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java Tue Feb  8 19:33:42 2005
@@ -17,21 +17,16 @@
 package org.apache.ldap.common.berlib.asn1;
 
 
-import org.apache.ldap.common.message.spi.ProviderDecoder;
-import org.apache.ldap.common.message.spi.ProviderException;
-import org.apache.ldap.common.message.spi.Provider;
-import org.apache.ldap.common.message.Message;
-
 import org.apache.asn1.ber.digester.BERDigester;
-import org.apache.asn1.codec.stateful.DecoderCallback;
-import org.apache.asn1.codec.stateful.StatefulDecoder;
-import org.apache.asn1.codec.stateful.DecoderMonitor;
 import org.apache.asn1.codec.DecoderException;
-import org.apache.ldap.common.berlib.asn1.decoder.LdapDigesterFactory;
-import org.apache.ldap.common.berlib.asn1.decoder.LdapDigesterFactory;
 import org.apache.asn1.codec.stateful.DecoderCallback;
+import org.apache.asn1.codec.stateful.DecoderMonitor;
 import org.apache.asn1.codec.stateful.StatefulDecoder;
-import org.apache.asn1.ber.digester.BERDigester;
+import org.apache.ldap.common.berlib.asn1.decoder.LdapDigesterFactory;
+import org.apache.ldap.common.message.Message;
+import org.apache.ldap.common.message.spi.Provider;
+import org.apache.ldap.common.message.spi.ProviderDecoder;
+import org.apache.ldap.common.message.spi.ProviderException;
 
 import java.io.InputStream;
 import java.nio.ByteBuffer;

Modified: incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersProvider.java Tue Feb  8 19:33:42 2005
@@ -18,8 +18,6 @@
 
 
 import org.apache.ldap.common.message.spi.*;
-import org.apache.ldap.common.berlib.asn1.SnickersDecoder;
-import org.apache.ldap.common.berlib.asn1.SnickersEncoder;
 
 
 /**

Modified: incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoder.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoder.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/encoder/add/AddRequestEncoder.java Tue Feb  8 19:33:42 2005
@@ -17,22 +17,15 @@
 package org.apache.ldap.common.berlib.asn1.encoder.add;
 
 
-import org.apache.asn1.ber.Tuple;
+import org.apache.asn1.ber.DefaultMutableTupleNode;
 import org.apache.asn1.ber.Length;
+import org.apache.asn1.ber.Tuple;
 import org.apache.asn1.ber.TupleNode;
-import org.apache.asn1.ber.DefaultMutableTupleNode;
 import org.apache.asn1.ber.primitives.UniversalTag;
-
-import org.apache.ldap.common.berlib.asn1.encoder.EncoderUtils;
-import org.apache.ldap.common.berlib.asn1.encoder.AttributesEncoder;
 import org.apache.ldap.common.berlib.asn1.LdapTag;
 import org.apache.ldap.common.berlib.asn1.encoder.AttributesEncoder;
-import org.apache.ldap.common.berlib.asn1.LdapTag;
-
+import org.apache.ldap.common.berlib.asn1.encoder.EncoderUtils;
 import org.apache.ldap.common.message.AddRequest;
-import org.apache.asn1.ber.primitives.UniversalTag;
-import org.apache.asn1.ber.DefaultMutableTupleNode;
-import org.apache.asn1.ber.Length;
 
 
 /**

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/SnickersDecoderTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/SnickersDecoderTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/SnickersDecoderTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/SnickersDecoderTest.java Tue Feb  8 19:33:42 2005
@@ -17,19 +17,11 @@
 package org.apache.ldap.common.berlib.asn1;
 
 import junit.framework.TestCase;
-
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.util.Properties;
-import java.nio.ByteBuffer;
-
-import org.apache.ldap.common.message.Message;
-import org.apache.ldap.common.message.MessageEncoder;
-import org.apache.ldap.common.message.BindRequestImpl;
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.ldap.common.message.BindRequest;
 import org.apache.ldap.common.message.spi.Provider;
-import org.apache.ldap.common.berlib.asn1.SnickersDecoder;
-import org.apache.commons.lang.ArrayUtils;
+
+import java.io.ByteArrayInputStream;
 
 
 /**
@@ -41,56 +33,24 @@
  */
 public class SnickersDecoderTest extends TestCase
 {
-    SnickersDecoder decoder = null;
-
+    SnickersDecoder decoder;
 
     protected void setUp() throws Exception
     {
-        super.setUp();
-
         SnickersProvider provider = ( SnickersProvider ) Provider.getProvider();
         decoder = ( SnickersDecoder ) provider.getDecoder();
     }
 
-
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-        decoder = null;
-    }
-
-
     public void testDecoderOnBindRequest()
     {
-        BindRequestImpl req = new BindRequestImpl( 27 );
-        req.setName( "cn=admin,dc=example,dc=com" );
-        req.setSimple( true );
-        req.setVersion3( true );
-        req.setCredentials( "passwd".getBytes() );
-
-        BindRequest decoded = ( BindRequest )
-                decoder.decode( null, encode( req ) );
-
-        assertEquals( req.getMessageId(), decoded.getMessageId() );
-        assertEquals( req.getName(), decoded.getName() );
-        assertTrue( ArrayUtils.isEquals( req.getCredentials(),
-                decoded.getCredentials() ) );
-        assertEquals( req.getSimple(), decoded.getSimple() );
-        assertEquals( req.getVersion3(), decoded.getVersion3() );
-    }
-
+        byte[] bind = {0x30, 0x2C, 0x02, 0x01, 0x1B, 0x60, 0x27, 0x02, 0x01, 0x03, 0x04, 0x1A, 0x63, 0x6E, 0x3D, 0x61, 0x64, 0x6D, 0x69, 0x6E, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0xFFFFFF80, 0x06, 0x70, 0x61, 0x73, 0x73, 0x77, 0x64};
+        BindRequest decoded = ( BindRequest ) decoder.decode( null, new ByteArrayInputStream( bind ) );
 
-    private InputStream encode( Message msg )
-    {
-        // @todo replace this with the Snickers encoder or use serialized
-        // PDUs stubs for test cases rather than decoding live.
-        Properties env = new Properties();
-        env.setProperty( Provider.BERLIB_PROVIDER,
-                "org.apache.ldap.common.berlib.snacc.SnaccProvider" );
-        MessageEncoder encoder = new MessageEncoder( env );
-        ByteBuffer buf = encoder.encodeBlocking( msg );
-        byte[] bites = new byte[buf.remaining()];
-        buf.get( bites );
-        return new ByteArrayInputStream( bites );
+        assertEquals( 27, decoded.getMessageId() );
+        assertEquals( "cn=admin,dc=example,dc=com", decoded.getName() );
+        assertTrue( ArrayUtils.isEquals( "passwd".getBytes(),
+                decoded.getCredentials() ) );
+        assertTrue( decoded.getSimple() );
+        assertTrue( decoded.getVersion3() );
     }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/abandon/AbandonRequestRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/abandon/AbandonRequestRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/abandon/AbandonRequestRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/abandon/AbandonRequestRuleTest.java Tue Feb  8 19:33:42 2005
@@ -16,15 +16,9 @@
  */
 package org.apache.ldap.common.berlib.asn1.decoder.abandon ;
 
-
-import org.apache.ldap.common.message.AbandonRequest ;
-import org.apache.ldap.common.message.AbandonRequestImpl ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
 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.AbandonRequest;
+import org.apache.ldap.common.message.AbandonRequestImpl;
 
 /**
  * Test case used to test the BER Digester with the AbandonRequestRule.
@@ -36,32 +30,17 @@
 public class AbandonRequestRuleTest extends RuleTestCase
 {
     /**
-     * Creates an AbandonRequest for testing.
-     *
-     * @param id the message Id of the AbandonRequest
-     * @param abandonedId the id of the request to abandon
-     * @return the newly constructed AbandonRequest
-     */
-    public AbandonRequest build( int id, int abandonedId ) throws Exception
-    {
-        AbandonRequest req = new AbandonRequestImpl( id ) ;
-        req.setAbandoned( abandonedId ) ;
-        System.out.println( "Generated AbandonRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
-        return req ;
-    }
-
-
-    /**
      * Tests the ability to decode an AbandonRequest with Snickers'
      * BERDigester.
      */
     public void testAbandonRequest() throws Exception
     {
-        AbandonRequest req = build( 44, 11 ) ;
-        AbandonRequest decoded = ( AbandonRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertEquals( req.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( req.getAbandoned(), decoded.getAbandoned() ) ;
+        byte[] pdu = new byte[] {0x30, 0x06, 0x02, 0x01, 0x2C, 0x50, 0x01, 0x0B};
+
+        AbandonRequest expected = new AbandonRequestImpl( 44 );
+        expected.setAbandoned( 11 );
+
+        AbandonRequest decoded = ( AbandonRequest ) decode( pdu ) ;
+        assertEquals( expected, decoded ) ;
     }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddRequestTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddRequestTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddRequestTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddRequestTest.java Tue Feb  8 19:33:42 2005
@@ -17,15 +17,10 @@
 package org.apache.ldap.common.berlib.asn1.decoder.add ;
 
 
-import java.util.HashSet;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.NamingEnumeration;
-
-import org.apache.ldap.common.message.*;
-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.berlib.asn1.decoder.testutils.RuleTestCase;
+import org.apache.ldap.common.message.AddRequest;
+import org.apache.ldap.common.message.AddRequestImpl;
+import org.apache.ldap.common.message.LockableAttributesImpl;
 
 
 /**
@@ -42,38 +37,19 @@
      */
     public void testAddRequest() throws Exception
     {
-        AddRequestImpl req = new AddRequestImpl( 33 ) ;
-        req.setName( "dc=example,dc=com" ) ;
-        LockableAttributesImpl attrs = new LockableAttributesImpl( req ) ;
+        byte[] pdu = {0x30, 0x4E, 0x02, 0x01, 0x21, 0x68, 0x49, 0x04, 0x11, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x30, 0x34, 0x30, 0x1E, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x31, 0x0F, 0x04, 0x03, 0x74, 0x6F, 0x70, 0x04, 0x08, 0x64, 0x63, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x30, 0x12, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0C, 0x04, 0x0A, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65};
+
+        AddRequestImpl expected = new AddRequestImpl( 33 ) ;
+        expected.setName( "dc=example,dc=com" ) ;
+        LockableAttributesImpl attrs = new LockableAttributesImpl( expected ) ;
         attrs.put( "objectClass", "top" ) ;
         attrs.put( "objectClass", "dcObject" ) ;
         attrs.put( "dc", "dc=example" ) ;
-        req.setEntry( attrs ) ;
-        System.out.println( "Generated AddRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
-
-        AddRequest decoded = ( AddRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertNotNull( decoded ) ;
-        assertEquals( req.getName(), decoded.getName() ) ;
-        Attributes decodedAttrs = decoded.getEntry() ;
-        assertEquals( 2, decodedAttrs.size() ) ;
-        Attribute attr = decodedAttrs.get( "dc" ) ;
-        assertNotNull( attr ); ;
-        assertEquals( 1, attr.size() ) ;
-        assertEquals( "dc=example", attr.get() ) ;
-        attr = decodedAttrs.get( "objectClass" ) ;
-        assertEquals( 2, attr.size() ) ;
-
-        NamingEnumeration list = attr.getAll() ;
-        HashSet map = new HashSet() ;
-
-        while( list.hasMore() )
-        {
-            map.add( list.next() ) ;
-        }
+        expected.setEntry( attrs ) ;
 
-        assertTrue( map.contains( "top" ) ) ;
-        assertTrue( map.contains( "dcObject" ) ) ;
+        AddRequest decoded = ( AddRequest ) decode( pdu ) ;
+        assertEquals( expected, decoded ) ;
     }
+
+
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddResponseRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddResponseRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddResponseRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/add/AddResponseRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,14 +17,17 @@
 package org.apache.ldap.common.berlib.asn1.decoder.add ;
 
 
-import java.util.Iterator ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
+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.AddResponse;
+import org.apache.ldap.common.message.AddResponseImpl;
+import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.Referral;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
 
-import org.apache.ldap.common.message.* ;
-import org.apache.commons.lang.ArrayUtils ;
+import java.util.Iterator;
 
 
 /**
@@ -75,4 +78,26 @@
         assertFalse( urls.hasNext() ) ;
         assertFalse( decodedUrls.hasNext() ) ;
     }
+
+    /**
+     * TODO: Fails but should replace the above at some point.
+     */
+//    public void testSamplePDU() throws Exception
+//    {
+//        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x08, 0x69, 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};
+//
+//        AddResponseImpl expected = new AddResponseImpl( 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 ) ;
+//
+//        AddResponse decoded = ( AddResponse ) decode( pdu ) ;
+//        assertEquals( expected, decoded );
+//    }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindNameRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindNameRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindNameRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindNameRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,13 +17,10 @@
 package org.apache.ldap.common.berlib.asn1.decoder.bind ;
 
 
-import junit.framework.TestCase ;
+import junit.framework.TestCase;
 import org.apache.asn1.ber.digester.BERDigester;
-import org.apache.ldap.common.berlib.asn1.decoder.bind.BindNameRule;
-import org.apache.ldap.common.berlib.asn1.decoder.bind.BindNameRule;
-import org.apache.ldap.common.message.BindRequestImpl;
 import org.apache.ldap.common.message.BindRequest;
-import org.apache.asn1.ber.digester.BERDigester;
+import org.apache.ldap.common.message.BindRequestImpl;
 
 import java.nio.ByteBuffer;
 

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,18 +17,12 @@
 package org.apache.ldap.common.berlib.asn1.decoder.bind ;
 
 
-import junit.framework.TestCase ;
-
-import org.apache.ldap.common.berlib.asn1.LdapTag;
-import org.apache.ldap.common.berlib.asn1.decoder.bind.BindRequestRule;
-import org.apache.ldap.common.berlib.asn1.LdapTag;
-import org.apache.asn1.ber.TypeClass ;
-import org.apache.asn1.ber.digester.BERDigester ;
-import org.apache.asn1.ber.primitives.UniversalTag ;
-
-import org.apache.ldap.common.message.BindRequest ;
-import org.apache.asn1.ber.primitives.UniversalTag;
+import junit.framework.TestCase;
 import org.apache.asn1.ber.TypeClass;
+import org.apache.asn1.ber.digester.BERDigester;
+import org.apache.asn1.ber.primitives.UniversalTag;
+import org.apache.ldap.common.berlib.asn1.LdapTag;
+import org.apache.ldap.common.message.BindRequest;
 
 
 /**

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindRequestTest.java Tue Feb  8 19:33:42 2005
@@ -17,10 +17,9 @@
 package org.apache.ldap.common.berlib.asn1.decoder.bind ;
 
 
-import org.apache.ldap.common.message.BindRequest ;
-import org.apache.ldap.common.message.BindRequestImpl ;
-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.berlib.asn1.decoder.testutils.RuleTestCase;
+import org.apache.ldap.common.message.BindRequest;
+import org.apache.ldap.common.message.BindRequestImpl;
 
 
 /**
@@ -32,26 +31,17 @@
  */
 public class BindRequestTest extends RuleTestCase
 {
-    /**
-     * Tests a simple bind request decode.
-     */
     public void testSimple() throws Exception
     {
-        BindRequestImpl req = new BindRequestImpl( 33 ) ;
-        req.setCredentials( "hello".getBytes() ) ;
-        req.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        req.setSimple( true ) ;
-        req.setVersion3( false ) ;
-        System.out.println( "Generated BindRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
+        byte[] pdu = new byte[] {0x30, 0x30, 0x02, 0x01, 0x21, 0x60, 0x2B, 0x02, 0x01, 0x02, 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, 0xFFFFFF80, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F};
+        BindRequest decoded = ( BindRequest ) decode( pdu ) ;
 
+        BindRequestImpl expected = new BindRequestImpl( 33 ) ;
+        expected.setCredentials( "hello".getBytes() ) ;
+        expected.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        expected.setSimple( true ) ;
+        expected.setVersion3( false ) ;
 
-        BindRequest decoded = ( BindRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertNotNull( decoded ) ;
-        assertTrue( "hello".equals( new String( decoded.getCredentials() ) ) ) ;
-        assertEquals( "uid=akarasulu,dc=example,dc=com", decoded.getName() ) ;
-        assertFalse( decoded.getVersion3() ) ;
-        assertTrue( decoded.getSimple() ) ;
+        assertEquals( expected, decoded ) ;
     }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindResponseRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindResponseRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindResponseRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindResponseRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,13 +17,17 @@
 package org.apache.ldap.common.berlib.asn1.decoder.bind ;
 
 
-import java.util.Iterator;
-
 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.berlib.asn1.decoder.testutils.TestUtils;
+import org.apache.ldap.common.message.BindResponse;
+import org.apache.ldap.common.message.BindResponseImpl;
+import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.common.message.Referral;
+import org.apache.ldap.common.message.LdapResult;
 
-import org.apache.ldap.common.message.*;
+import java.util.Iterator;
 
 
 /**
@@ -79,4 +83,27 @@
         assertFalse( urls.hasNext() ) ;
         assertFalse( decodedUrls.hasNext() ) ;
     }
+
+    /**
+     * TODO: somehow, decoded result code is success instead of BUSY. To investigate ...
+     */
+//    public void testAgainstPrecomputedPDU() throws Exception
+//    {
+//        byte[] pdu = new byte[] {0x30, 0x54, 0x02, 0x02, 0x02, 0x1C, 0x61, 0x4E, 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, 0xFFFFFF87, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F};
+//        BindResponse decoded = ( BindResponse ) decode( pdu ) ;
+//
+//        BindResponseImpl expected = new BindResponseImpl( 540 ) ;
+//        expected.setServerSaslCreds( "hello".getBytes() ) ;
+//        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/bind/BindSimpleCredentialsRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindSimpleCredentialsRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindSimpleCredentialsRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindSimpleCredentialsRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,13 +17,10 @@
 package org.apache.ldap.common.berlib.asn1.decoder.bind ;
 
 
-import junit.framework.TestCase ;
+import junit.framework.TestCase;
 import org.apache.asn1.ber.digester.BERDigester;
-import org.apache.ldap.common.berlib.asn1.decoder.bind.BindSimpleCredentialsRule;
-import org.apache.ldap.common.berlib.asn1.decoder.bind.BindSimpleCredentialsRule;
-import org.apache.ldap.common.message.BindRequestImpl;
 import org.apache.ldap.common.message.BindRequest;
-import org.apache.asn1.ber.digester.BERDigester;
+import org.apache.ldap.common.message.BindRequestImpl;
 
 import java.nio.ByteBuffer;
 

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindVersionRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindVersionRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindVersionRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/bind/BindVersionRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,12 +17,10 @@
 package org.apache.ldap.common.berlib.asn1.decoder.bind ;
 
 
-import junit.framework.TestCase ;
+import junit.framework.TestCase;
 import org.apache.asn1.ber.digester.BERDigester;
-import org.apache.ldap.common.berlib.asn1.decoder.bind.BindVersionRule;
-import org.apache.ldap.common.message.BindRequestImpl;
 import org.apache.ldap.common.message.BindRequest;
-import org.apache.asn1.ber.digester.BERDigester;
+import org.apache.ldap.common.message.BindRequestImpl;
 
 import java.nio.ByteBuffer;
 

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareRequestRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareRequestRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareRequestRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareRequestRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,11 +17,9 @@
 package org.apache.ldap.common.berlib.asn1.decoder.compare ;
 
 
-import org.apache.ldap.common.message.* ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
 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.CompareRequest;
+import org.apache.ldap.common.message.CompareRequestImpl;
 
 
 /**
@@ -35,19 +33,15 @@
 {
     public void testCompareRequest() throws Exception
     {
-        // build the PDU
-        CompareRequestImpl req = new CompareRequestImpl( 7 ) ;
-        req.setAttributeId( "hello" ) ;
-        req.setAssertionValue( "world" ) ;
-        req.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        System.out.println( "Generated CompareRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
+        byte[] pdu = new byte[] {0x30, 0x34, 0x02, 0x01, 0x07, 0x6E, 0x31, 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, 0x30, 0x0E, 0x04, 0x05, 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x04, 0x05, 0x77, 0x6F, 0x72, 0x6C, 0x64};
+        CompareRequest decoded = ( CompareRequest ) decode( pdu );
 
-        CompareRequest decoded = ( CompareRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertEquals( req.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( req.getName(), decoded.getName() ) ;
-        assertEquals( req.getAttributeId(), decoded.getAttributeId() ) ;
-        assertEquals( req.getAssertionValue(), decoded.getAssertionValue() ) ;
+        CompareRequestImpl expected = new CompareRequestImpl( 7 ) ;
+        expected.setAttributeId( "hello" ) ;
+        expected.setAssertionValue( "world" ) ;
+        expected.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+
+        assertEquals( expected, decoded ) ;
     }
 }
+

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareResponseRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareResponseRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareResponseRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/compare/CompareResponseRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,12 +17,13 @@
 package org.apache.ldap.common.berlib.asn1.decoder.compare ;
 
 
-import java.util.Iterator;
-
-import org.apache.ldap.common.message.* ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
 import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
+import org.apache.ldap.common.message.CompareResponse;
+import org.apache.ldap.common.message.CompareResponseImpl;
+import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
 
 
 /**
@@ -36,40 +37,19 @@
 {
     public void testCompareRequest() throws Exception
     {
-        // build the PDU
-        CompareResponseImpl resp = new CompareResponseImpl( 7 ) ;
-        LdapResult result = new LdapResultImpl( resp ) ;
-        resp.setLdapResult( result ) ;
+        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x07, 0x6F, 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};
+        CompareResponse decoded = ( CompareResponse ) decode( pdu );
+
+        CompareResponseImpl expected = new CompareResponseImpl( 7 ) ;
+        LdapResult result = new LdapResultImpl( expected ) ;
+        expected.setLdapResult( result ) ;
         result.setReferral( new ReferralImpl( result ) ) ;
         result.setErrorMessage( "An Error Message!" ) ;
         result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
         result.setResultCode( ResultCodeEnum.BUSY ) ;
         result.getReferral().addLdapUrl( "hello" ) ;
         result.getReferral().addLdapUrl( "world" ) ;
-        System.out.println( "Generated CompareResponse for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-
-        CompareResponse decoded = ( CompareResponse )
-                snickersDecode( snaccEncode( resp ) ) ;
-        LdapResult decodedResult = decoded.getLdapResult() ;
-
-        assertEquals( resp.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( result.getErrorMessage(),
-                decodedResult.getErrorMessage() ) ;
-        assertEquals( result.getMatchedDn(), decodedResult.getMatchedDn() ) ;
-        assertEquals( result.getResultCode(), decodedResult.getResultCode() ) ;
-
-        Referral decodedRef = decodedResult.getReferral() ;
-        Referral referral = 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 );
     }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteRequestRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteRequestRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteRequestRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteRequestRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,11 +17,9 @@
 package org.apache.ldap.common.berlib.asn1.decoder.delete ;
 
 
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
-
-import org.apache.ldap.common.message.DeleteRequest ;
-import org.apache.ldap.common.message.DeleteRequestImpl ;
+import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
+import org.apache.ldap.common.message.DeleteRequest;
+import org.apache.ldap.common.message.DeleteRequestImpl;
 
 
 /**
@@ -32,33 +30,13 @@
  */
 public class DeleteRequestRuleTest extends RuleTestCase
 {
-    /**
-     * Creates an DeleteRequest for testing.
-     *
-     * @param id the message Id of the DelRequest
-     * @param name the name of the entry to delete
-     * @return the newly constructed DelRequest
-     */
-    public DeleteRequest build( int id, String name ) throws Exception
-    {
-        DeleteRequest req = new DeleteRequestImpl( id ) ;
-        req.setName( name ) ;
-        System.out.println( "Generated DeleteRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
-        return req ;
-    }
-
-
-    /**
-     * Tests the ability to decode an DelRequest with Snickers'
-     * BERDigester.
-     */
     public void testDelRequest() throws Exception
     {
-        DeleteRequest req = build( 44, "uid=akarasulu,dc=example,dc=com" ) ;
-        DeleteRequest decoded = ( DeleteRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertEquals( req.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( req.getName(), decoded.getName() ) ;
+        byte[] pdu = new byte[] {0x30, 0x24, 0x02, 0x01, 0x2C, 0x4A, 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};
+        DeleteRequest decoded = ( DeleteRequest ) decode ( pdu );
+
+        DeleteRequest expected = new DeleteRequestImpl( 44 ) ;
+        expected.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        assertEquals( expected, decoded ) ;
     }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteResponseRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteResponseRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteResponseRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/delete/DeleteResponseRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,12 +17,13 @@
 package org.apache.ldap.common.berlib.asn1.decoder.delete ;
 
 
-import java.util.Iterator ;
-
-import org.apache.ldap.common.message.* ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
+import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
+import org.apache.ldap.common.message.DeleteResponse;
+import org.apache.ldap.common.message.DeleteResponseImpl;
+import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
 
 
 /**
@@ -33,45 +34,21 @@
  */
 public class DeleteResponseRuleTest extends RuleTestCase
 {
-    /**
-     * Tests the ability to decode an DelResponse with Snickers'
-     * BERDigester.
-     */
     public void testDelResponse() throws Exception
     {
-        DeleteResponse resp = new DeleteResponseImpl( 44 ) ;
-        LdapResult result = new LdapResultImpl( resp ) ;
-        resp.setLdapResult( result ) ;
+        byte[] pdu = new byte[] {0x30, 0x4C, 0x02, 0x01, 0x2C, 0x6B, 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};
+        DeleteResponse decoded = ( DeleteResponse ) decode( pdu );
+
+        DeleteResponse expected = new DeleteResponseImpl( 44 ) ;
+        LdapResult result = new LdapResultImpl( expected ) ;
+        expected.setLdapResult( result ) ;
         result.setReferral( new ReferralImpl( result ) ) ;
         result.setErrorMessage( "An Error Message!" ) ;
         result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
         result.setResultCode( ResultCodeEnum.BUSY ) ;
         result.getReferral().addLdapUrl( "hello" ) ;
         result.getReferral().addLdapUrl( "world" ) ;
-        System.out.println( "Generated DeleteResponse for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-
-        DeleteResponse decoded = ( DeleteResponse )
-                snickersDecode( snaccEncode( resp ) ) ;
-        LdapResult decodedResult = decoded.getLdapResult() ;
-
-        assertEquals( resp.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( result.getErrorMessage(),
-                decodedResult.getErrorMessage() ) ;
-        assertEquals( result.getMatchedDn(), decodedResult.getMatchedDn() ) ;
-        assertEquals( result.getResultCode(), decodedResult.getResultCode() ) ;
-
-        Referral decodedRef = decodedResult.getReferral() ;
-        Referral referral = 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 ) ;
     }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedRequestRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedRequestRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedRequestRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/extended/ExtendedRequestRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,11 +17,9 @@
 package org.apache.ldap.common.berlib.asn1.decoder.extended ;
 
 
-import org.apache.ldap.common.message.* ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
 import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.ldap.common.message.ExtendedRequest;
+import org.apache.ldap.common.message.ExtendedRequestImpl;
 
 
 /**
@@ -35,20 +33,16 @@
 {
     public void testCompareRequest() throws Exception
     {
-        // build the PDU
-        ExtendedRequestImpl req = new ExtendedRequestImpl( 7 ) ;
-        req.setOid( "0.0.0.0" ) ;
+        byte[] pdu = new byte[] {0x30, 0x12, 0x02, 0x01, 0x07, 0x77, 0x0D, 0xFFFFFF80, 0x07, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0xFFFFFF81, 0x02, 0x12, 0x34};
+        ExtendedRequest decoded = ( ExtendedRequest ) decode( pdu );
+
+        ExtendedRequestImpl expected = new ExtendedRequestImpl( 7 ) ;
+        expected.setOid( "0.0.0.0" ) ;
         byte[] payload = new byte[2] ;
         payload[0] = 0x12 ;
         payload[1] = 0x34 ;
-        req.setPayload( payload ) ;
-        System.out.println( "Generated ExtendedRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
+        expected.setPayload( payload ) ;
 
-        ExtendedRequest decoded = ( ExtendedRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertEquals( req.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( req.getOid(), decoded.getOid() ) ;
-        assertTrue( ArrayUtils.isEquals( payload, decoded.getPayload() ) ) ;
+        assertEquals( expected, decoded ) ;
     }
 }

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=152979&r2=152980
==============================================================================
--- 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 Tue Feb  8 19:33:42 2005
@@ -17,14 +17,18 @@
 package org.apache.ldap.common.berlib.asn1.decoder.extended ;
 
 
-import java.util.Iterator ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
+import org.apache.commons.lang.ArrayUtils;
+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.ExtendedResponse;
+import org.apache.ldap.common.message.ExtendedResponseImpl;
+import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.Referral;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
 
-import org.apache.ldap.common.message.* ;
-import org.apache.commons.lang.ArrayUtils ;
+import java.util.Iterator;
 
 
 /**
@@ -82,4 +86,32 @@
         assertFalse( urls.hasNext() ) ;
         assertFalse( decodedUrls.hasNext() ) ;
     }
+
+    /**
+     * 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=152979&r2=152980
==============================================================================
--- 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 Tue Feb  8 19:33:42 2005
@@ -17,19 +17,18 @@
 package org.apache.ldap.common.berlib.asn1.decoder.modify ;
 
 
-import java.util.HashSet ;
-import java.util.Iterator ;
-import java.util.Collection ;
-import javax.naming.directory.Attribute ;
-import javax.naming.directory.DirContext ;
-import javax.naming.directory.ModificationItem ;
-
-import org.apache.ldap.common.message.* ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
 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;
+
+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;
 
 
 /**
@@ -125,4 +124,42 @@
             }
         }
     }
+
+    /**
+     * 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=152979&r2=152980
==============================================================================
--- 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 Tue Feb  8 19:33:42 2005
@@ -17,14 +17,17 @@
 package org.apache.ldap.common.berlib.asn1.decoder.modify ;
 
 
-import java.util.Iterator ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
+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 org.apache.ldap.common.message.* ;
-import org.apache.commons.lang.ArrayUtils ;
+import java.util.Iterator;
 
 
 /**
@@ -75,4 +78,26 @@
         assertFalse( urls.hasNext() ) ;
         assertFalse( decodedUrls.hasNext() ) ;
     }
+
+    /**
+     * 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/ModifyDnRequestRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnRequestRuleTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnRequestRuleTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/modifydn/ModifyDnRequestRuleTest.java Tue Feb  8 19:33:42 2005
@@ -17,11 +17,9 @@
 package org.apache.ldap.common.berlib.asn1.decoder.modifydn ;
 
 
-import org.apache.ldap.common.message.* ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
+import org.apache.ldap.common.message.ModifyDnRequest;
+import org.apache.ldap.common.message.ModifyDnRequestImpl;
 
 
 /**
@@ -35,22 +33,15 @@
 {
     public void testModifyDnRequest() throws Exception
     {
-        // build the PDU
-        ModifyDnRequestImpl req = new ModifyDnRequestImpl( 7 ) ;
-        req.setDeleteOldRdn( true ) ;
-        req.setName( "uid=asulu,dc=example,dc=com" ) ;
-        req.setNewRdn( "uid=akarasulu" ) ;
-        req.setNewSuperior( "dc=bogus,dc=com" ) ;
-        System.out.println( "Generated ModifyDnRequest for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( req ) ) ;
+        byte[] pdu = new byte[] {0x30, 0x45, 0x02, 0x01, 0x07, 0x6C, 0x40, 0x04, 0x1B, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x2C, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x04, 0x0D, 0x75, 0x69, 0x64, 0x3D, 0x61, 0x6B, 0x61, 0x72, 0x61, 0x73, 0x75, 0x6C, 0x75, 0x01, 0x01, 0xFFFFFFFF, 0xFFFFFF80, 0x0F, 0x64, 0x63, 0x3D, 0x62, 0x6F, 0x67, 0x75, 0x73, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D};
+        ModifyDnRequest decoded = (ModifyDnRequest) decode( pdu );
 
-        ModifyDnRequest decoded = ( ModifyDnRequest )
-                snickersDecode( snaccEncode( req ) ) ;
-        assertEquals( req.getMessageId(), decoded.getMessageId() ) ;
-        assertEquals( req.getDeleteOldRdn(), decoded.getDeleteOldRdn() ) ;
+        ModifyDnRequestImpl expected = new ModifyDnRequestImpl( 7 ) ;
+        expected.setDeleteOldRdn( true ) ;
+        expected.setName( "uid=asulu,dc=example,dc=com" ) ;
+        expected.setNewRdn( "uid=akarasulu" ) ;
+        expected.setNewSuperior( "dc=bogus,dc=com" ) ;
 
-        assertEquals( req.getName(), decoded.getName() ) ;
-        assertEquals( req.getNewRdn(), decoded.getNewRdn() ) ;
-        assertEquals( req.getNewSuperior(), decoded.getNewSuperior() ) ;
+        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=152979&r2=152980
==============================================================================
--- 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 Tue Feb  8 19:33:42 2005
@@ -17,11 +17,17 @@
 package org.apache.ldap.common.berlib.asn1.decoder.modifydn ;
 
 
-import java.util.Iterator;
+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 org.apache.ldap.common.message.* ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
+import java.util.Iterator;
 
 
 /**
@@ -72,4 +78,26 @@
         assertFalse( urls.hasNext() ) ;
         assertFalse( decodedUrls.hasNext() ) ;
     }
+
+    /**
+     * 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=152979&r2=152980
==============================================================================
--- 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 Tue Feb  8 19:33:42 2005
@@ -17,22 +17,31 @@
 package org.apache.ldap.common.berlib.asn1.decoder.search;
 
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.nio.ByteBuffer;
-
-import org.apache.ldap.common.message.*;
-import org.apache.ldap.common.filter.*;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
 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.filter.BranchNode;
+import org.apache.ldap.common.filter.BranchNormalizedVisitor;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.ExtensibleNode;
+import org.apache.ldap.common.filter.FilterParserImpl;
+import org.apache.ldap.common.filter.PresenceNode;
+import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.filter.SubstringNode;
+import org.apache.ldap.common.message.DerefAliasesEnum;
+import org.apache.ldap.common.message.MessageTypeEnum;
+import org.apache.ldap.common.message.ScopeEnum;
+import org.apache.ldap.common.message.SearchRequest;
+import org.apache.ldap.common.message.SearchRequestImpl;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 
 
 /**
+ * TODO: migrate to using pre-computed PDUs if possible
+ *
  * Tests the capability to end to end decode a SearchRequest.
  * 
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory

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=152979&r2=152980
==============================================================================
--- 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 Tue Feb  8 19:33:42 2005
@@ -17,14 +17,17 @@
 package org.apache.ldap.common.berlib.asn1.decoder.search ;
 
 
-import java.util.Iterator ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
+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.ReferralImpl;
+import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.SearchResponseDoneImpl;
+import org.apache.ldap.common.message.SearchResponseDone;
+import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.Referral;
 
-import org.apache.ldap.common.message.* ;
-import org.apache.commons.lang.ArrayUtils ;
+import java.util.Iterator;
 
 
 /**
@@ -75,4 +78,26 @@
         assertFalse( urls.hasNext() ) ;
         assertFalse( decodedUrls.hasNext() ) ;
     }
+
+    /**
+     * 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/SearchResponseEntryTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseEntryTest.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseEntryTest.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/search/SearchResponseEntryTest.java Tue Feb  8 19:33:42 2005
@@ -17,15 +17,10 @@
 package org.apache.ldap.common.berlib.asn1.decoder.search ;
 
 
-import java.util.HashSet;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.NamingEnumeration;
-
-import org.apache.ldap.common.message.*;
-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.berlib.asn1.decoder.testutils.RuleTestCase;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.message.SearchResponseEntry;
+import org.apache.ldap.common.message.SearchResponseEntryImpl;
 
 
 /**
@@ -37,43 +32,19 @@
  */
 public class SearchResponseEntryTest extends RuleTestCase
 {
-    /**
-     * Tests a decode.
-     */
     public void testAddRequest() throws Exception
     {
-        SearchResponseEntryImpl resp = new SearchResponseEntryImpl( 33 ) ;
-        resp.setObjectName( "dc=example,dc=com" ) ;
-        LockableAttributesImpl attrs = new LockableAttributesImpl( resp ) ;
+        byte[] pdu = new byte[] {0x30, 0x4E, 0x02, 0x01, 0x21, 0x64, 0x49, 0x04, 0x11, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F, 0x6D, 0x30, 0x34, 0x30, 0x1E, 0x04, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x31, 0x0F, 0x04, 0x03, 0x74, 0x6F, 0x70, 0x04, 0x08, 0x64, 0x63, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x30, 0x12, 0x04, 0x02, 0x64, 0x63, 0x31, 0x0C, 0x04, 0x0A, 0x64, 0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65};
+        SearchResponseEntry decoded = ( SearchResponseEntry ) decode( pdu );
+
+        SearchResponseEntryImpl expected = new SearchResponseEntryImpl( 33 ) ;
+        expected.setObjectName( "dc=example,dc=com" ) ;
+        LockableAttributesImpl attrs = new LockableAttributesImpl( expected ) ;
         attrs.put( "objectClass", "top" ) ;
         attrs.put( "objectClass", "dcObject" ) ;
         attrs.put( "dc", "dc=example" ) ;
-        resp.setAttributes( attrs ); ;
-        System.out.println( "Generated SearchResultEntry for test:" ) ;
-        System.out.println( TestUtils.printTupleTree( resp ) ) ;
-
-        SearchResponseEntry decoded = ( SearchResponseEntry )
-                snickersDecode( snaccEncode( resp ) ) ;
-        assertNotNull( decoded ) ;
-        assertEquals( resp.getObjectName(), decoded.getObjectName() ) ;
-        Attributes decodedAttrs = decoded.getAttributes() ;
-        assertEquals( 2, decodedAttrs.size() ) ;
-        Attribute attr = decodedAttrs.get( "dc" ) ;
-        assertNotNull( attr ); ;
-        assertEquals( 1, attr.size() ) ;
-        assertEquals( "dc=example", attr.get() ) ;
-        attr = decodedAttrs.get( "objectClass" ) ;
-        assertEquals( 2, attr.size() ) ;
-
-        NamingEnumeration list = attr.getAll() ;
-        HashSet map = new HashSet() ;
-
-        while( list.hasMore() )
-        {
-            map.add( list.next() ) ;
-        }
+        expected.setAttributes( attrs ); ;
 
-        assertTrue( map.contains( "top" ) ) ;
-        assertTrue( map.contains( "dcObject" ) ) ;
+        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=152979&r2=152980
==============================================================================
--- 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 Tue Feb  8 19:33:42 2005
@@ -17,13 +17,10 @@
 package org.apache.ldap.common.berlib.asn1.decoder.search ;
 
 
-import java.util.Iterator ;
-
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.TestUtils ;
-import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase ;
 import org.apache.ldap.common.berlib.asn1.decoder.testutils.RuleTestCase;
-
-import org.apache.ldap.common.message.* ;
+import org.apache.ldap.common.message.ReferralImpl;
+import org.apache.ldap.common.message.SearchResponseReference;
+import org.apache.ldap.common.message.SearchResponseReferenceImpl;
 
 
 /**
@@ -35,35 +32,52 @@
  */
 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
     {
-        // build the PDU
-        SearchResponseReferenceImpl resp =
+        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};
+        SearchResponseReference decoded = ( SearchResponseReference ) decode( pdu );
+
+        SearchResponseReferenceImpl expected =
                 new SearchResponseReferenceImpl( 8 ) ;
-        ReferralImpl referral = new ReferralImpl( resp ) ;
-        resp.setReferral( referral ) ;
+        ReferralImpl referral = new ReferralImpl( expected ) ;
+        expected.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() ) ;
+        assertEquals( expected, decoded ) ;
     }
 }

Modified: incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/testutils/RuleTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/testutils/RuleTestCase.java?view=diff&r1=152979&r2=152980
==============================================================================
--- incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/testutils/RuleTestCase.java (original)
+++ incubator/directory/ldap/trunk/apache-provider/src/test/org/apache/ldap/common/berlib/asn1/decoder/testutils/RuleTestCase.java Tue Feb  8 19:33:42 2005
@@ -17,17 +17,16 @@
 package org.apache.ldap.common.berlib.asn1.decoder.testutils ;
 
 
-import java.nio.ByteBuffer ;
-import java.util.Properties;
-
-import junit.framework.TestCase ;
-import org.apache.ldap.common.message.Message ;
-import org.apache.ldap.common.message.MessageEncoder;
-import org.apache.ldap.common.message.spi.Provider;
+import junit.framework.TestCase;
 import org.apache.asn1.ber.digester.BERDigester;
-import org.apache.ldap.common.berlib.asn1.decoder.LdapDigesterFactory;
 import org.apache.asn1.codec.stateful.CallbackHistory;
-import org.apache.asn1.ber.digester.BERDigester;
+import org.apache.ldap.common.berlib.asn1.decoder.LdapDigesterFactory;
+import org.apache.ldap.common.message.Message;
+import org.apache.ldap.common.message.MessageEncoder;
+import org.apache.ldap.common.message.spi.Provider;
+
+import java.nio.ByteBuffer;
+import java.util.Properties;
 
 
 /**
@@ -61,6 +60,13 @@
         return digester ;
     }
 
+    protected Message decode( byte[] pdu ) throws Exception
+    {
+        CallbackHistory history = new CallbackHistory() ;
+        getDigester().setCallback( history ) ;
+        getDigester().decode( ByteBuffer.wrap( pdu ) ) ;
+        return ( Message ) history.getMostRecent() ;
+    }
 
     public Message snickersDecode( ByteBuffer buf ) throws Exception
     {



Mime
View raw message