directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: r158144 - in directory/asn1/trunk/ber: ./ src/java/org/apache/asn1/ber/ src/test/org/apache/asn1/ber/ src/test/org/apache/asn1/ber/digester/
Date Fri, 18 Mar 2005 21:46:05 GMT
Author: vtence
Date: Fri Mar 18 13:46:03 2005
New Revision: 158144

URL: http://svn.apache.org/viewcvs?view=rev&rev=158144
Log:
Removed dependency on Snacc by using pre-computed PDUs in tests

Modified:
    directory/asn1/trunk/ber/project.xml
    directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java
    directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/EncodeDecodeTests.java
    directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/LdapMessageTests.java
    directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTreeDecoderTest.java
    directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/BERDigesterTest.java
    directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/TagTreeTest.java

Modified: directory/asn1/trunk/ber/project.xml
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber/project.xml?view=diff&r1=158143&r2=158144
==============================================================================
--- directory/asn1/trunk/ber/project.xml (original)
+++ directory/asn1/trunk/ber/project.xml Fri Mar 18 13:46:03 2005
@@ -58,15 +58,6 @@
     </dependency>
 
     <dependency>
-      <groupId>directory-shared</groupId>
-      <artifactId>ldap-snacc-provider</artifactId>
-      <version>0.9-SNAPSHOT</version>
-      <url>
-        http://directory.apache.org/subprojects/shared/ldap/snacc-provider
-      </url>
-    </dependency>
-
-    <dependency>
       <groupId>regexp</groupId>
       <artifactId>regexp</artifactId>
       <version>1.2</version>
@@ -76,13 +67,6 @@
       </properties>
     </dependency>
 
-     <dependency>
-       <groupId>snacc4j</groupId>
-       <artifactId>snacc</artifactId>
-       <version>2.3</version>
-       <url>http://alphaworks.ibm.com/tech/snaccforjava</url>
-     </dependency>
- 
     <!-- deps in group -->
 
     <dependency>

Modified: directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java?view=diff&r1=158143&r2=158144
==============================================================================
--- directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java (original)
+++ directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java Fri
Mar 18 13:46:03 2005
@@ -17,24 +17,17 @@
 package org.apache.asn1.ber ;
 
 
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Properties;
-import java.util.Stack;
-
 import junit.framework.TestCase;
-
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.codec.binary.BinaryCodec;
 import org.apache.asn1.codec.stateful.DecoderCallback;
 import org.apache.asn1.codec.stateful.DecoderMonitor;
 import org.apache.asn1.codec.stateful.StatefulDecoder;
 import org.apache.commons.lang.exception.ExceptionUtils;
-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.ArrayList;
+import java.util.Stack;
 
 
 /**
@@ -243,38 +236,6 @@
 
     
     /**
-     * BER decodes a byte array.
-     * 
-     * @param bites a byte array to decode
-     * @return a copy of the decoded tuple or the partially decoded current tlv
-     * @throws DecoderException if there are errors while decoding.
-     */
-    public Tuple decode( byte[] bites ) throws DecoderException
-    {
-        try
-        {
-            FileOutputStream out = new FileOutputStream( "./SearchRequest.ber" );
-            out.write( bites );
-        }
-        catch ( IOException e )
-        {
-            e.printStackTrace();
-        }
-
-        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
-        int lastSize = tlvList.size() ;
-        decoder.decode( buf ) ;
-        
-        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
-        {
-            return decoder.getCurrentTuple() ;
-        }
-        
-        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
-    }
-
-    
-    /**
      * BER decodes a byte buffer.
      * 
      * @param bites a byte buffer to decode
@@ -353,49 +314,12 @@
         return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
     }
     
-    
-    /**
-     * Encodes a message using the message framework and the default BERLib
-     * provider which is snacc for now.  Later we shall remove this dependency.
-     * It then decodes encoded output generated.
-     * 
-     * @param msg the BER encoded message
-     * @return the last tuple generated by decoding the encoded message
-     * @throws DecoderException if there are any failures
-     */
-    public Tuple decode( Message msg ) throws DecoderException
+    public Tuple decode( byte[] pdu ) throws DecoderException
     {
-        // @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 );
-        decode( encoder.encodeBlocking( msg ) ) ;
-        
+        decode( ByteBuffer.wrap( pdu ) ) ;
         return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
     }
-    
-    
-    /**
-     * Convenience method used to encode a msg using the Snacc libraries for
-     * the time being.
-     * 
-     * @param msg the message to encode
-     * @return a byte buffer with the encoded message
-     */
-    public ByteBuffer 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 );
-        return encoder.encodeBlocking( msg ) ;
-    }
 
-    
     /* (non-Javadoc)
      * @see org.apache.asn1.ber.BERDecoderCallback#tagDecoded(
      * org.apache.asn1.ber.Tuple)

Modified: directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/EncodeDecodeTests.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/EncodeDecodeTests.java?view=diff&r1=158143&r2=158144
==============================================================================
--- directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/EncodeDecodeTests.java (original)
+++ directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/EncodeDecodeTests.java Fri Mar 18
13:46:03 2005
@@ -17,17 +17,10 @@
 package org.apache.asn1.ber ;
 
 
-import java.nio.ByteBuffer ;
-import java.io.ByteArrayInputStream ;
-import java.util.Properties;
-
-import org.apache.asn1.codec.binary.Hex ;
-import org.apache.ldap.common.message.*;
-import org.apache.ldap.common.message.spi.Provider;
-import org.apache.asn1.codec.binary.Hex;
-import org.apache.asn1.ber.DefaultMutableTupleNode;
+import junit.framework.TestCase;
 
-import junit.framework.TestCase ;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
 
 
 /**
@@ -41,88 +34,34 @@
 {
     public void testAbandonRequest() throws Exception
     {
-        DefaultMutableTupleNode root = null ;
-        ByteBuffer buf = null ;
-        AbandonRequestImpl request = new AbandonRequestImpl( 1 ) ;
-        request.setAbandoned( 3 ) ;
-        
-        // @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 );
-        buf = encoder.encodeBlocking( request );
-        byte[] snaccBytes = new byte[buf.remaining()];
-        buf.get( snaccBytes );
-
-        String snaccEncoded = new String( Hex.encodeHex( snaccBytes ) ) ;
-
-        // @todo replace this with the Snickers encoder or use serialized
-        // PDUs stubs for test cases rather than decoding live.
-        MessageDecoder decoder = new MessageDecoder( env ) ;
-
-        AbandonRequest msg = ( AbandonRequest ) decoder.decode( null,
-                new ByteArrayInputStream( snaccBytes ) ) ;
-        assertTrue( msg.getMessageId() == request.getMessageId() ) ;
-        
-        root = ( DefaultMutableTupleNode )
-            TupleTreeDecoder.treeDecode( ByteBuffer.wrap( snaccBytes ) ) ;
-        
-        if ( root == null )
-        {
-            return ;
-        }
+        byte[] pdu = {0x30, 0x06, 0x02, 0x01, 0x01, 0x50, 0x01, 0x03};
+
+        DefaultMutableTupleNode root = ( DefaultMutableTupleNode )
+            TupleTreeDecoder.treeDecode( ByteBuffer.wrap( pdu ) ) ;
         
-        buf = ByteBuffer.allocate( root.size() ) ;
+        ByteBuffer buf = ByteBuffer.allocate( root.size() ) ;
         root.encode( buf ) ;
-        buf.flip() ;
-        byte[] snickersBytes = new byte[buf.remaining()] ;
-        buf.get( snickersBytes ) ;
+        buf.flip();
+        byte[] actual = new byte[buf.remaining()] ;
+        buf.get( actual ) ;
+
+        assertTrue( Arrays.equals( pdu, actual ) );
     }
 
 
     public void testBindRequest() throws Exception
     {
-        DefaultMutableTupleNode root = null ;
-        ByteBuffer buf = null ;
-        BindRequestImpl request = new BindRequestImpl( 1 ) ;
-        request.setCredentials( "password".getBytes() ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setSimple( true ) ;
-        request.setVersion3( true ) ;
-
-        // @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 );
-        buf = encoder.encodeBlocking( request );
-        byte[] snaccBytes = new byte[buf.remaining()];
-        buf.get( snaccBytes );
-
-        String snaccEncoded = new String( Hex.encodeHex( snaccBytes ) ) ;
-
-        MessageDecoder decoder = new MessageDecoder( env ) ;
-        BindRequest msg = ( BindRequest ) decoder.decode( null,
-                new ByteArrayInputStream( snaccBytes ) ) ;
-        assertTrue( msg.getMessageId() == request.getMessageId() ) ;
-
-        root = ( DefaultMutableTupleNode )
-                TupleTreeDecoder.treeDecode( ByteBuffer.wrap( snaccBytes ) ) ;
-
-        if ( root == null )
-        {
-            return ;
-        }
+        byte[] pdu = {0x30, 0x33, 0x02, 0x01, 0x01, 0x60, 0x2E, 0x02, 0x01, 0x03, 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, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64};
+
+         DefaultMutableTupleNode root =
+                 (DefaultMutableTupleNode) TupleTreeDecoder.treeDecode( ByteBuffer.wrap(
pdu ) );
 
-        buf = ByteBuffer.allocate( root.size() ) ;
+        ByteBuffer buf = ByteBuffer.allocate( root.size() ) ;
         root.encode( buf ) ;
         buf.flip() ;
-        byte[] snickersBytes = new byte[buf.remaining()] ;
-        buf.get( snickersBytes ) ;
+        byte[] actual = new byte[buf.remaining()] ;
+        buf.get( actual ) ;
 
-        StringBuffer sb = new StringBuffer() ;
-        root.printDepthFirst( sb, 0 ) ;
+        assertTrue( Arrays.equals( pdu, actual ) );
     }
 }

Modified: directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/LdapMessageTests.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/LdapMessageTests.java?view=diff&r1=158143&r2=158144
==============================================================================
--- directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/LdapMessageTests.java (original)
+++ directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/LdapMessageTests.java Fri Mar 18
13:46:03 2005
@@ -17,29 +17,9 @@
 package org.apache.asn1.ber ;
 
 
-import java.nio.ByteBuffer ;
-
-import javax.naming.directory.Attributes ;
-
-import org.apache.asn1.codec.stateful.CallbackHistory ;
-
-import org.apache.ldap.common.message.Message ;
-import org.apache.ldap.common.message.ScopeEnum ;
-import org.apache.ldap.common.filter.PresenceNode ;
-import org.apache.ldap.common.message.AddRequestImpl ;
-import org.apache.ldap.common.message.BindRequestImpl ;
-import org.apache.ldap.common.message.DerefAliasesEnum ;
-import org.apache.ldap.common.message.DeleteRequestImpl ;
-import org.apache.ldap.common.message.SearchRequestImpl ;
-import org.apache.ldap.common.message.ModifyRequestImpl ;
-import org.apache.ldap.common.message.AbandonRequestImpl ;
-import org.apache.ldap.common.message.CompareRequestImpl ;
-import org.apache.ldap.common.message.ExtendedRequestImpl ;
-import org.apache.ldap.common.message.ModifyDnRequestImpl ;
-import org.apache.ldap.common.message.LockableAttributesImpl ;
 import org.apache.asn1.codec.stateful.CallbackHistory;
-import org.apache.asn1.ber.AbstractDecoderTestCase;
-import org.apache.asn1.ber.DefaultMutableTupleNode;
+
+import java.nio.ByteBuffer;
 
 
 /**
@@ -89,110 +69,89 @@
     /**
      * Creates a tuple node tree from a message.
      * 
-     * @param msg the message to encode and decode
+     * @param pdu the message to encode and decode
      * @return
      * @throws Exception
      */
-    public DefaultMutableTupleNode roundTripTest( Message msg ) throws Exception
+    public DefaultMutableTupleNode roundTripTest( byte[] pdu ) throws Exception
     {
         DefaultMutableTupleNode node = null ;
-        ByteBuffer buf1 = encode( msg ) ;
+        ByteBuffer buf1 = ByteBuffer.wrap( pdu ) ;
         ttd.decode( buf1 ) ;
         node = ( DefaultMutableTupleNode ) history.getMostRecent() ;
-        
+
         ByteBuffer buf2 = ByteBuffer.allocate( node.size() ) ;
         node.encode( buf2 ) ;
         assertTrue( buf1.equals( buf2 ) ) ;
-        
+
         return node ;
     }
-    
-    
+
     public void testBindMessage() throws Exception
     {
-        BindRequestImpl request = new BindRequestImpl( 1 ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setSimple( true ) ;
-        request.setCredentials( "password".getBytes() ) ;
-        request.setVersion3( true ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x33, 0x02, 0x01, 0x01, 0x60, 0x2E, 0x02, 0x01, 0x03, 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, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
-
     public void testAddMessage() throws Exception
     {
-        AddRequestImpl request = new AddRequestImpl( 1 ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        
-        Attributes attrs = new LockableAttributesImpl() ;
-        attrs.put( "attr0", "val0" ) ;
-        attrs.put( "attr0", "val1" ) ;
-        attrs.put( "attr0", "val2" ) ;
-        attrs.put( "attr1", "val0" ) ;
-        attrs.put( "attr2", "val0" ) ;
-        attrs.put( "attr2", "val1" ) ;
-        
-        request.setEntry( attrs ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x6D, 0x02, 0x01, 0x01, 0x68, 0x68, 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, 0x45,
0x30, 0x0F, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x31, 0x31, 0x06, 0x04, 0x04, 0x76, 0x61,
0x6C, 0x30, 0x30, 0x15, 0x04, 0x05, 0x61, 0x74, 0x74, 0x72, 0x32, 0x31, 0x0C, 0x04, 0x04,
0x76, 0x61, 0x6C, 0x31, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x30, 0x30, 0x1B, 0x04, 0x05, 0x61,
0x74, 0x74, 0x72, 0x30, 0x31, 0x12, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x30, 0x04, 0x04, 0x76,
0x61, 0x6C, 0x31, 0x04, 0x04, 0x76, 0x61, 0x6C, 0x32};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
 
     public void testDeleteMessage() throws Exception
     {
-        DeleteRequestImpl request = new DeleteRequestImpl( 1 ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x24, 0x02, 0x01, 0x01, 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};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
 
     public void testAbandonMessage() throws Exception
     {
-        AbandonRequestImpl request = new AbandonRequestImpl( 1 ) ;
-        request.setAbandoned( 3 ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = new byte[] {0x30, 0x06, 0x02, 0x01, 0x01, 0x50, 0x01, 0x03};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
 
     public void testCompareMessage() throws Exception
     {
-        CompareRequestImpl request = new CompareRequestImpl( 1 ) ;
-        request.setAssertionValue( "testvalue" ) ;
-        request.setAttributeId( "testattr" ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x3D, 0x02, 0x01, 0x01, 0x6E, 0x38, 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, 0x15,
0x04, 0x08, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x74, 0x72, 0x04, 0x09, 0x74, 0x65, 0x73,
0x74, 0x76, 0x61, 0x6C, 0x75, 0x65};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
 
     public void testExtendedMessage() throws Exception
     {
-        ExtendedRequestImpl request = new ExtendedRequestImpl( 1 ) ;
-        request.setOid( "1234.1234.1324" ) ;
-        request.setPayload( "Hello World".getBytes() ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x22, 0x02, 0x01, 0x01, 0x77, 0x1D, 0xFFFFFF80, 0x0E, 0x31, 0x32,
0x33, 0x34, 0x2E, 0x31, 0x32, 0x33, 0x34, 0x2E, 0x31, 0x33, 0x32, 0x34, 0xFFFFFF81, 0x0B,
0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
 
     public void testModifyDnMessage() throws Exception
     {
-        ModifyDnRequestImpl request = new ModifyDnRequestImpl( 1 ) ;
-        request.setDeleteOldRdn(true) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setNewRdn( "uid=aok" ) ;
-        request.setNewSuperior( "dc=example,dc=com" ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x45, 0x02, 0x01, 0x01, 0x6C, 0x40, 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, 0x07,
0x75, 0x69, 0x64, 0x3D, 0x61, 0x6F, 0x6B, 0x01, 0x01, 0xFFFFFFFF, 0xFFFFFF80, 0x11, 0x64,
0x63, 0x3D, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x63, 0x6F,
0x6D};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
@@ -290,27 +249,20 @@
      ------------------------------------------------------------------------ */
     public void testModifyMessage() throws Exception
     {
-        ModifyRequestImpl request = 
-            new ModifyRequestImpl( 17 ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x28, 0x02, 0x01, 0x11, 0x66, 0x23, 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, 0x00};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 
 
     public void testSearchMessage() throws Exception
     {
-        SearchRequestImpl request = new SearchRequestImpl( 1 ) ;
-        request.setBase( "dc=com" ) ;
-        request.setDerefAliases( DerefAliasesEnum.DEREFALWAYS ) ;
-        PresenceNode node = new PresenceNode( "attrib0" ) ;
-        request.setFilter( node ) ;
-        request.setScope( ScopeEnum.BASEOBJECT ) ;
-        request.setSizeLimit( 0 ) ;
-        request.setTimeLimit( 0 ) ;
-        decode( request ) ;
-        roundTripTest( request ) ;
+        byte[] pdu = {0x30, 0x27, 0x02, 0x01, 0x01, 0x63, 0x22, 0x04, 0x06, 0x64, 0x63, 0x3D,
0x63, 0x6F, 0x6D, 0x0A, 0x01, 0x00, 0x0A, 0x01, 0x03, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00,
0x01, 0x01, 0x00, 0xFFFFFF87, 0x07, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x30, 0x30, 0x00};
+
+        decode( pdu ) ;
+        roundTripTest( pdu ) ;
         assertFalse( tlvList.isEmpty() ) ;
     }
 }

Modified: directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTreeDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTreeDecoderTest.java?view=diff&r1=158143&r2=158144
==============================================================================
--- directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTreeDecoderTest.java (original)
+++ directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TupleTreeDecoderTest.java Fri Mar
18 13:46:03 2005
@@ -17,27 +17,14 @@
 package org.apache.asn1.ber ;
 
 
-import java.io.ByteArrayOutputStream ;
-
-import java.nio.ByteBuffer ;
-import java.util.Collections ;
-import java.util.Properties;
-
-import org.apache.asn1.codec.stateful.DecoderCallback ;
+import junit.framework.TestCase;
+import org.apache.asn1.codec.stateful.DecoderCallback;
 import org.apache.asn1.codec.stateful.DecoderMonitorAdapter;
-import org.apache.asn1.codec.stateful.StatefulDecoder ;
-import org.apache.asn1.codec.stateful.DecoderMonitorAdapter ;
-import org.apache.asn1.ber.DefaultMutableTupleNode;
-import org.apache.asn1.ber.Tuple;
-import org.apache.asn1.ber.TupleTreeDecoder;
-
-import org.apache.commons.lang.time.StopWatch ;
-
-import org.apache.ldap.common.message.MessageEncoder ;
-import org.apache.ldap.common.message.ModifyRequestImpl ;
-import org.apache.ldap.common.message.spi.Provider;
+import org.apache.asn1.codec.stateful.StatefulDecoder;
+import org.apache.commons.lang.time.StopWatch;
 
-import junit.framework.TestCase ;
+import java.nio.ByteBuffer;
+import java.util.Collections;
 
 
 /**
@@ -93,28 +80,14 @@
 
     public void testTTD() throws Exception
     {
-        ByteArrayOutputStream out = new ByteArrayOutputStream() ;
-
         // Setup the bind request
-        ModifyRequestImpl request = new ModifyRequestImpl( 17 ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-
-        // Setup the ASN1 Enoder (Snacc4J for now)
-        // @todo switch once snickers is ready or use pre-existing ber files
-        // for the test cases.
-        Properties env = new Properties();
-        env.setProperty( Provider.BERLIB_PROVIDER,
-                "org.apache.ldap.common.berlib.snacc.SnaccProvider" );
-        MessageEncoder encoder = new MessageEncoder( env );
-
-        // Send encoded request to server
-        encoder.encodeBlocking( null, out, request );
+        byte[] pdu = {0x30, 0x28, 0x02, 0x01, 0x11, 0x66, 0x23, 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, 0x00};
 
         StopWatch watch = new StopWatch() ;
         watch.start() ;
         TupleTreeDecoder decoder = new TupleTreeDecoder() ;
         decoder.setCallback( this ) ;
-        decoder.decode( ByteBuffer.wrap( out.toByteArray() ) ) ;
+        decoder.decode( ByteBuffer.wrap( pdu ) ) ;
         watch.stop() ;
 
         StringBuffer buf = new StringBuffer() ;

Modified: directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/BERDigesterTest.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/BERDigesterTest.java?view=diff&r1=158143&r2=158144
==============================================================================
--- directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/BERDigesterTest.java (original)
+++ directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/BERDigesterTest.java Fri
Mar 18 13:46:03 2005
@@ -17,17 +17,13 @@
 package org.apache.asn1.ber.digester ;
 
 
-import junit.framework.* ;
+import junit.framework.TestCase;
+import org.apache.asn1.ber.TypeClass;
 
-import java.nio.ByteBuffer;
-import java.net.URLClassLoader;
 import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.ByteBuffer;
 import java.util.EmptyStackException;
-
-import org.apache.asn1.ber.TypeClass;
-import org.apache.asn1.ber.digester.AbstractRule;
-import org.apache.asn1.ber.digester.BERDigester;
-import org.apache.asn1.ber.TypeClass;
 
 
 /**

Modified: directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/TagTreeTest.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/TagTreeTest.java?view=diff&r1=158143&r2=158144
==============================================================================
--- directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/TagTreeTest.java (original)
+++ directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/digester/TagTreeTest.java Fri Mar
18 13:46:03 2005
@@ -17,13 +17,12 @@
 package org.apache.asn1.ber.digester ;
 
 
-import java.util.List ;
-import java.util.Stack ;
-import java.util.HashMap ;
+import org.apache.commons.collections.primitives.IntStack;
+import org.apache.commons.test.PrivateTestCase;
 
-import org.apache.commons.collections.primitives.IntStack ;
-import org.apache.commons.test.PrivateTestCase ;
-import org.apache.asn1.ber.digester.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Stack;
 
 
 /**



Mime
View raw message