directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9763 - in incubator/directory/snickers/branches/chunking: ber ber/src/java/org/apache/snickers/asn ber/src/java/org/apache/snickers/ber ber/src/java/org/apache/snickers/ber/primitives ber/src/test/org/apache/snickers/ber codec-stateful
Date Fri, 26 Mar 2004 22:55:39 GMT
Author: akarasulu
Date: Fri Mar 26 14:55:37 2004
New Revision: 9763

Added:
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/primitives/
      - copied from rev 9762, incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/asn/
Removed:
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/asn/
Modified:
   incubator/directory/snickers/branches/chunking/ber/   (props changed)
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoder.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/Tuple.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleNode.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/primitives/BERDecoderUtils.java
   incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/primitives/Primitive.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTest.java
   incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java
   incubator/directory/snickers/branches/chunking/codec-stateful/   (props changed)
Log:
o Switched to using ByteBuffers instead of byte[] in all decoders and 
  within the tuple
o Introduced a partialValueDecoded(Tuple) method to the handler for emitting
  chunks of the value
o Added value chunking code so any sized input can be handled for the value
o Cleaned up some code and made appropriate changes to the test cases
o Moved primitive package under ber package instead of within an asn package



Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java	Fri Mar 26 14:55:37 2004
@@ -59,7 +59,7 @@
     protected void setUp() throws Exception
     {
         super.setUp() ;
-        decoder = new BERDecoder( 1024 ) ;
+        decoder = new BERDecoder() ;
         decoder.setCallback( this ) ;
         decoder.setDecoderMonitor( this ) ;
     }
@@ -292,7 +292,9 @@
      */
     public Tuple decode( Tuple tlv, ByteBuffer value ) throws DecoderException
     {
-        ByteBuffer buf = tlv.toEncodedBuffer( value ) ;
+        ArrayList list = new ArrayList() ;
+        list.add( value ) ;
+        ByteBuffer buf = tlv.toEncodedBuffer( list ) ;
         int lastSize = tlvList.size() ;
         decoder.decode( buf ) ;
         
@@ -401,7 +403,7 @@
      */
     public void partialValueDecoded( Tuple tlv )
     {
-        buf.put( tlv.value ) ;
+        buf.put( tlv.valueChunk ) ;
     }
     
 

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoder.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoder.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoder.java	Fri Mar 26 14:55:37 2004
@@ -97,10 +97,8 @@
     
     /**
      * Creates a stateful BER decoder which limits the tuple's value size.
-     * 
-     * @param valueMax the maximum tuple value size handled by this decoder
      */
-    public BERDecoder( int valueMax )
+    public BERDecoder()
     {
         tagDecoder.setCallback( this ) ;
         lengthDecoder.setCallback( this ) ;
@@ -175,7 +173,7 @@
     {
         this.cb = ( BERDecoderCallback ) cb ;
     }
-    
+
 
     /* (non-Javadoc)
      * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
@@ -197,7 +195,7 @@
      * 
      * @param buf the byte byffer containing BER encoded data 
      */
-    private void decodeValue( ByteBuffer buf ) throws DecoderException
+    private void decodeValue( ByteBuffer buf )
     {
         int needToRead = Length.UNDEFINED ;
 
@@ -221,7 +219,7 @@
          */
         if ( buf.remaining() >= needToRead )
         {
-            tlv.value = ( ByteBuffer ) buf.slice().limit( needToRead ) ;
+            tlv.valueChunk = ( ByteBuffer ) buf.slice().limit( needToRead ) ;
             buf.position( buf.position() + needToRead ) ;
             tlv.valueIndex = tlv.length ;
             tlv.index += tlv.length ;
@@ -246,7 +244,7 @@
             }
             
             int remaining = buf.remaining() ;
-            tlv.value = buf.slice() ;
+            tlv.valueChunk = buf.slice() ;
             buf.position( buf.limit() ) ;
             tlv.valueIndex += remaining ;
             tlv.index +=remaining ;
@@ -320,7 +318,7 @@
             else
             {
                 state = BERDecoderState.VALUE ;
-                tlv.value = EMPTY_BUFFER ;
+                tlv.valueChunk = EMPTY_BUFFER ;
                 cb.partialValueDecoded( tlv ) ;
                 fireDecodeOccurred( tlv ) ;
                 state = BERDecoderState.TAG ;
@@ -352,11 +350,11 @@
         {
             cb.tagDecoded( tlv ) ;
         }
-        
+
         if ( monitor != null && monitor instanceof BERDecoderMonitor )
         {
             BERDecoderMonitor berMonitor = ( BERDecoderMonitor ) monitor ;
-            //berMonitor.tagDecoded( tlv, tagDecoder.getOctets() ) ;
+            berMonitor.tagDecoded( tlv ) ;
         }
     }
     
@@ -379,7 +377,7 @@
         if ( monitor != null && monitor instanceof BERDecoderMonitor )
         {
             BERDecoderMonitor berMonitor = ( BERDecoderMonitor ) monitor ;
-            //berMonitor.lengthDecoded( tlv, lengthBuffer.toArray() ) ;
+            berMonitor.lengthDecoded( tlv ) ;
         }
     }
     

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java	Fri Mar 26 14:55:37 2004
@@ -40,9 +40,8 @@
      * </ul>
      * 
      * @param tlv the TLV tuple
-     * @param tagData the tag data collected
      */
-    void tagDecoded( Tuple tlv, byte[] tagData ) ;
+    void tagDecoded( Tuple tlv ) ;
     
     /**
      * Method used to receive notification that a length was decoded.  The 
@@ -55,7 +54,6 @@
      * </ul>
      * 
      * @param tlv the TLV tuple
-     * @param lengthData the length data collected
      */
-    void lengthDecoded( Tuple tlv, byte[] lengthData ) ;
+    void lengthDecoded( Tuple tlv ) ;
 }

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java	Fri Mar 26 14:55:37 2004
@@ -19,14 +19,11 @@
 
 import java.nio.ByteBuffer ;
 
+import java.util.List ;
 import java.util.Iterator ;
 import java.util.ArrayList ;
-import java.util.Enumeration ;
 import java.util.Collections ;
 
-import javax.swing.tree.TreeNode ;
-import javax.swing.tree.MutableTreeNode ;
-
 import org.apache.commons.lang.StringUtils ;
 
 
@@ -37,8 +34,7 @@
  * Apache Directory Project</a>
  * @version $Rev$
  */
-public class DefaultMutableTupleNode 
-    implements MutableTupleNode, MutableTreeNode
+public class DefaultMutableTupleNode implements MutableTupleNode
 {
     /** this node's tuple user object */
     private Tuple tuple ;
@@ -46,8 +42,9 @@
     private ArrayList children = new ArrayList() ;
     /** this node's parent node */
     private DefaultMutableTupleNode parent ;
-    /** this node's value */
-    private ByteBuffer value ;
+    /** this node's accumulated ByteBuffer value chunks */
+    private List valueChunks = new ArrayList( 2 ) ;
+    
     
     /**
      * Creates a node without a parent and without a tuple.
@@ -62,10 +59,21 @@
      * 
      * @param tuple the tuple to set for this node
      */
-    public DefaultMutableTupleNode( Tuple tuple, ByteBuffer value )
+    public DefaultMutableTupleNode( Tuple tuple )
+    {
+        this.tuple = tuple ;
+    }
+    
+
+    /**
+     * Creates a node without a parent.
+     * 
+     * @param tuple the tuple to set for this node
+     */
+    public DefaultMutableTupleNode( Tuple tuple, List valueChunks )
     {
         this.tuple = tuple ;
-        this.value = value ;
+        this.valueChunks.addAll( valueChunks ) ;
     }
     
 
@@ -153,16 +161,6 @@
 
     
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.MutableTupleNode#setTuple(
-     * org.apache.snickers.ber.Tuple)
-     */
-    public void setTuple( Tuple t )
-    {
-        tuple = t ;
-    }
-    
-
-    /* (non-Javadoc)
      * @see org.apache.snickers.ber.TupleNode#getParent()
      */
     public TupleNode getParentTupleNode()
@@ -257,6 +255,51 @@
     }
     
     
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#setTuple(
+     * org.apache.snickers.ber.Tuple)
+     */
+    public void setTuple( Tuple t )
+    {
+        tuple = t ;
+        valueChunks.clear() ;
+    }
+    
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#setTuple(
+     * org.apache.snickers.ber.Tuple, java.util.List)
+     */
+    public void setTuple( Tuple t, List valueChunks )
+    {
+        tuple = t ;
+        this.valueChunks.clear() ;
+        this.valueChunks.addAll( valueChunks ) ;
+    }
+    
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getValueChunks()
+     */
+    public List getValueChunks()
+    {
+        return valueChunks ;
+    }
+    
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#addValueChunk(
+     * java.nio.ByteBuffer)
+     */
+    public void addValueChunk( ByteBuffer valueChunk )
+    {
+        valueChunks.add( valueChunk ) ;
+    }
+
+    
     /**
      * Depth first generation of this tlv tuple node's encoded image.
      * 
@@ -264,7 +307,7 @@
      */
     public void encode( ByteBuffer dest )
     {
-        dest.put( tuple.toEncodedBuffer( this.value ) ) ;
+        dest.put( tuple.toEncodedBuffer( this.valueChunks ) ) ;
         
         if ( tuple.isPrimitive() )
         {
@@ -308,7 +351,7 @@
         buf.append( tuple.getId() ) ;
         buf.append( ' ' ).append( tuple.typeClass ) ;
         buf.append( '[' ).append( tuple.length ).append( ']' ) ;
-        buf.append( '[' ).append( new String( tuple.getValue().array() ) ) ;
+        buf.append( '[' ).append( new String( tuple.getLastValueChunk().array() ) ) ;
         buf.append( ']' ) ;
         
         return buf.toString() ;
@@ -329,18 +372,6 @@
     
     
     /**
-     * Start analyzing the tree rooted at this node.
-     */
-    public void analyze()
-    {
-        /*
-        TupleTreeAnalyzer analyzer = new TupleTreeAnalyzer( this ) ;
-        analyzer.startup() ;
-        */
-    }
-    
-    
-    /**
      * Generates a depth first traversal of this node.
      * 
      * @param buf the buffer to capture the traversal into
@@ -359,8 +390,6 @@
         buf.append( levelTab ).append( tuple.getId() ) ;
         buf.append( ' ' ).append( tuple.typeClass ) ;
         buf.append( '[' ).append( tuple.length ).append( ']' ) ;
-        buf.append( '[' ).append( new String( tuple.getValue().array() ) ) ;
-        buf.append( ']' ) ;
         for ( int ii = 0; ii < children.size(); ii++ )
         {
             child = ( DefaultMutableTupleNode ) children.get( ii ) ;
@@ -370,114 +399,6 @@
     
     
     // ------------------------------------------------------------------------
-    // MutableTreeNode implementations
-    // ------------------------------------------------------------------------
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#children()
-     */
-    public Enumeration children()
-    {
-        return Collections.enumeration( children ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getAllowsChildren()
-     */
-    public boolean getAllowsChildren()
-    {
-        return ! tuple.isPrimitive() ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getChildAt(int)
-     */
-    public TreeNode getChildAt( int childIndex )
-    {
-        return ( TreeNode ) getChildTupleNodeAt( childIndex ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
-     */
-    public int getIndex( TreeNode node )
-    {
-        return getIndex( ( TupleNode ) node ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getParent()
-     */
-    public TreeNode getParent()
-    {
-        return parent ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#insert(
-     * javax.swing.tree.MutableTreeNode, int)
-     */
-    public void insert( MutableTreeNode child, int index )
-    {
-        insert( ( MutableTupleNode ) child, index ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#isLeaf()
-     */
-    public boolean isLeaf()
-    {
-        if ( tuple != null && tuple.isPrimitive() )
-        {    
-            return true ;
-        }
-        
-        if ( children.isEmpty() )
-        {
-            return true ;
-        }
-
-        return false ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#remove(
-     * javax.swing.tree.MutableTreeNode)
-     */
-    public void remove( MutableTreeNode node )
-    {
-        remove( ( MutableTupleNode ) node ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#setParent(
-     * javax.swing.tree.MutableTreeNode)
-     */
-    public void setParent( MutableTreeNode newParent )
-    {
-        parent = ( DefaultMutableTupleNode ) newParent ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#setUserObject(java.lang.Object)
-     */
-    public void setUserObject( Object object )
-    {
-        tuple = ( Tuple ) object ;
-    }
-    
-    
-    // ------------------------------------------------------------------------
     // java.lang.Object overrides & overloads 
     // ------------------------------------------------------------------------
     
@@ -529,8 +450,10 @@
         DefaultMutableTupleNode n2Child = null ;
         for ( int ii = 0; ii < n1.getChildCount() ; ii++ )
         {
-            n1Child = ( DefaultMutableTupleNode  ) n1.getChildAt( ii ) ; 
-            n2Child = ( DefaultMutableTupleNode  ) n2.getChildAt( ii ) ;
+            n1Child = ( DefaultMutableTupleNode  ) 
+                n1.getChildTupleNodeAt( ii ) ; 
+            n2Child = ( DefaultMutableTupleNode  ) 
+                n2.getChildTupleNodeAt( ii ) ;
             
             if ( ! equals( n1Child, n2Child ) )
             {

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java	Fri Mar 26 14:55:37 2004
@@ -16,6 +16,9 @@
  */
 package org.apache.snickers.ber ;
 
+import java.nio.ByteBuffer;
+import java.util.List;
+
 
 /**
  * A mutable TupleNode used for building TLV Tuple trees.
@@ -60,11 +63,27 @@
       */
      void setParent( MutableTupleNode newParent ) ; 
               
+    /**
+     * Resets the Tuple of the receiver object.  Also clears the value chunk 
+     * buffers accumulated for the previous tuple if any.
+     * 
+     * @param t the tuple to set for this node
+     */
+    void setTuple( Tuple t ) ;  
+     
+    /**
+     * Resets the Tuple of the receiver object.  Also clears the value chunk 
+     * buffers accumulated for the previous tuple if any.
+     * 
+     * @param t the tuple to set for this node
+     * @param valueChunks the list of value chunk buffers
+     */
+    void setTuple( Tuple t, List valueChunks ) ;  
+     
      /**
-      * Resets the Tuple of the receiver object.
-      * 
-      * @param t the tuple to set for this node
+      * Adds a buffer containing the entire buffer or a chunked peice of it.
+      *
+      * @param valueChunk a chunk of the value as a byte buffer
       */
-     void setTuple( Tuple t ) ;  
-               
+     void addValueChunk( ByteBuffer valueChunk ) ;
 }

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/Tuple.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/Tuple.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/Tuple.java	Fri Mar 26 14:55:37 2004
@@ -17,6 +17,8 @@
 package org.apache.snickers.ber ;
 
 
+import java.util.List ;
+
 import java.nio.ByteBuffer ;
 
 import org.apache.commons.lang.ArrayUtils ;
@@ -33,6 +35,7 @@
  */
 public class Tuple 
 {
+    /** empty buffer reused for handling null */
     private static final ByteBuffer EMPTY_BUFFER =
         ByteBuffer.wrap( ArrayUtils.EMPTY_BYTE_ARRAY ) ;
     
@@ -44,15 +47,15 @@
     private static final int BIT_7 = 0x80 ;
     
     /** precalculated left shift of 1 by 14 places */
-    static final int BIT_13 = 1 << 14 ;
+    private static final int BIT_13 = 1 << 14 ;
     /** precalculated left shift of 1 by 16 places */
-    static final int BIT_15 = 1 << 16 ;
+    private static final int BIT_15 = 1 << 16 ;
     /** precalculated left shift of 1 by 21 places */
-    static final int BIT_20 = 1 << 21 ;
+    private static final int BIT_20 = 1 << 21 ;
     /** precalculated left shift of 1 by 24 places */
-    static final int BIT_23 = 1 << 24 ;
+    private static final int BIT_23 = 1 << 24 ;
     /** precalculated left shift of 1 by 28 places */
-    static final int BIT_27 = 1 << 28 ;
+    private static final int BIT_27 = 1 << 28 ;
     
     /** the tag id for this TLV tuple */
     int id = 0 ;
@@ -62,8 +65,8 @@
     TypeClass typeClass = TypeClass.APPLICATION ;
     /** the length for this TLV tuple */
     int length = 0 ;
-    /** the value for this TLV tuple */
-    ByteBuffer value = EMPTY_BUFFER ;
+    /** the present value chunk buffer read for this TLV tuple */
+    ByteBuffer valueChunk = EMPTY_BUFFER ;
     
     /** tlv byte index */
     int index = Length.UNDEFINED ;
@@ -112,7 +115,7 @@
     {
         this.id = id ;
         this.length = length ;
-        value = EMPTY_BUFFER ;
+        valueChunk = EMPTY_BUFFER ;
         isPrimitive = false ;
         
         if ( typeClass != null )
@@ -136,7 +139,7 @@
     {
         this.id = id ;
         this.length = length ;
-        value = EMPTY_BUFFER ;
+        valueChunk = EMPTY_BUFFER ;
         isPrimitive = false ;
         
         if ( typeClass != null )
@@ -157,7 +160,7 @@
     {
         this.id = id ;
         this.isPrimitive = false ;
-        value = EMPTY_BUFFER ;
+        valueChunk = EMPTY_BUFFER ;
         length = Length.INDEFINATE ;
         
         if ( typeClass != null )
@@ -242,13 +245,13 @@
 
     
     /**
-     * Gets the value field (V-part) for this TLV Tuple.
+     * Gets the last chunk read for the value field (V-part) for this TLV Tuple.
      * 
-     * @return the value field for this TLV Tuple
+     * @return the last valueChunk field for this TLV Tuple
      */
-    public ByteBuffer getValue()
+    public ByteBuffer getLastValueChunk()
     {
-        return value ;
+        return valueChunk ;
     }
     
     
@@ -287,7 +290,7 @@
         this.isPrimitive = true ;
         this.length = Length.UNDEFINED ;
         this.typeClass = TypeClass.APPLICATION ;
-        this.value = EMPTY_BUFFER ;
+        this.valueChunk = EMPTY_BUFFER ;
         this.valueIndex = Length.UNDEFINED ;
     }
 
@@ -297,7 +300,8 @@
      * checking for equality.  Technically if both are being constructed by
      * the decoder then they should only be equal when these values are equal
      * because the tag, length or value would not be correct.  Plus since this
-     * is a chunking tuple the value may only be a part of the final value.
+     * is a chunking tuple the valueChunk means nothing with respect to the
+     * final value.
      *
      * @see java.lang.Object#equals(java.lang.Object)
      */
@@ -351,7 +355,13 @@
         t.typeClass = typeClass ;
         t.length = length ;
         
-        ByteBuffer bb = ( ByteBuffer ) value ;
+        /* ------------------------------------------------------------------ +/
+         * @todo figure out if we should remove this section
+         * 
+         * Do think we need this anymore since the last valueChunk does not 
+         * factor into the result returned by the equals(Object) method?
+         * ------------------------------------------------------------------ */
+        ByteBuffer bb = ( ByteBuffer ) valueChunk ;
         ByteBuffer cloned = ByteBuffer.allocate( bb.capacity() ) ;
         int oldPos = bb.position() ;
         bb.rewind() ;
@@ -359,7 +369,8 @@
         cloned.limit( bb.limit() ) ;
         bb.position( oldPos ) ;
         cloned.rewind() ;
-        t.value = cloned ;
+        t.valueChunk = cloned ;
+        /* ------------------------------------------------------------------ */
         
         t.index = index ;
         t.valueIndex = valueIndex ;
@@ -374,6 +385,11 @@
     
     
     /**
+     * @todo this should produce chunking output and needs to be removed from
+     * here actually and made into a standalone encoder.  You give it a buffer
+     * and it fills it as much as it can remembering where the encode stopped.
+     * Hence it is stateful as expected from the statemachine.
+     * 
      * If this is a primitive TLV then the valueBytes argument is used to 
      * produce an encoded image of this TLV.  If it is constructed then
      * only the TL part of the tuple is encoded leaving the value to be encoded
@@ -381,16 +397,16 @@
      * 
      * @return partial encoded image if constructed or complete TLV if primitive
      */
-    public ByteBuffer toEncodedBuffer( ByteBuffer valueBytes )
+    public ByteBuffer toEncodedBuffer( List valueChunks )
     {
         ByteBuffer octets = null ;
         int tagLength = getTagLength() ;
         int lengthLength = getLengthLength() ;
         int total = tagLength + lengthLength ;
-
+        
         if ( isPrimitive )
         {
-            total += ( ( ByteBuffer ) valueBytes ).remaining() ;
+            total += length ;
         }
         
         octets = ByteBuffer.allocate( total ) ;
@@ -399,7 +415,10 @@
         
         if ( isPrimitive )
         {
-            octets.put( valueBytes ) ;
+            for ( int ii = 0; ii < valueChunks.size(); ii++ )
+            {    
+                octets.put( ( ByteBuffer ) valueChunks.get(ii) ) ;
+            }
         }
         
         return ( ByteBuffer ) octets.flip() ;

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleNode.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleNode.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleNode.java	Fri Mar 26 14:55:37 2004
@@ -17,7 +17,9 @@
 package org.apache.snickers.ber ;
 
 
+import java.util.List ;
 import java.util.Iterator ;
+
 import java.nio.ByteBuffer ;
 
 
@@ -58,6 +60,13 @@
     TupleNode getChildTupleNodeAt( int index ) ;
     
     /**
+     * Gets the chunked value buffer fragments collected within this node.  
+     * 
+     * @return the value buffer parts for this node
+     */
+    List getValueChunks() ;
+    
+    /**
      * Gets the index of a child if the child node if it exists.  The analog
      * within <code>TreeNode<code> takes a <code>TreeNode</code> instead of a 
      * <code>TupleNode</code>.
@@ -82,7 +91,6 @@
      * @return the number of children
      */
     int size() ;
-    
     
     /**
      * Gets the Tuple this node represents.   This is the analogous to <code>

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java	Fri Mar 26 14:55:37 2004
@@ -17,6 +17,7 @@
 package org.apache.snickers.ber ;
 
 
+import java.util.ArrayList;
 import java.util.Stack ;
 import java.nio.ByteBuffer ;
 
@@ -42,11 +43,13 @@
     /** a stack of nested constructed tuples used to track state */
     Stack stack = new Stack() ;
     /** the underlying BER data stream to TLV stream decoder */
-    BERDecoder decoder = new BERDecoder( 1024 ) ;
+    BERDecoder decoder = new BERDecoder() ;
     /** the callback to use for this StatefulDecoder */
     DecoderCallback cb = null ;
     /** the monitor to use for this StatefulDecoder */
     DecoderMonitor monitor = new DecoderMonitorAdapter() ;
+    /** the value chunks buffer collection */
+    ArrayList valueChunks = new ArrayList() ;
 
     
     /**
@@ -58,7 +61,15 @@
         {
             public void tagDecoded( Tuple tlv ) { }
             
-            public void partialValueDecoded( Tuple tlv ) { }
+            public void partialValueDecoded( Tuple tlv ) 
+            {
+                ByteBuffer copy = ByteBuffer.allocate( 
+                        tlv.getLastValueChunk().remaining() ) ;
+                copy.put( tlv.getLastValueChunk() ) ;
+                tlv.getLastValueChunk().rewind() ;
+                copy.rewind() ;
+                valueChunks.add( copy ) ;
+            }
         
             public void lengthDecoded( Tuple tlv )
             {
@@ -107,7 +118,9 @@
         
         if ( t.isPrimitive )
         {
-            node = new DefaultMutableTupleNode( ( Tuple ) t.clone() ) ;
+            node = new DefaultMutableTupleNode( ( Tuple ) t.clone(), 
+                    valueChunks ) ;
+            valueChunks.clear() ;
                 
             if ( ! stack.isEmpty() )
             {    

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/primitives/BERDecoderUtils.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/asn/BERDecoderUtils.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/primitives/BERDecoderUtils.java	Fri Mar 26 14:55:37 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.snickers.asn;
+package org.apache.snickers.ber.primitives;
 
 
 

Modified: incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/primitives/Primitive.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/asn/Primitive.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/java/org/apache/snickers/ber/primitives/Primitive.java	Fri Mar 26 14:55:37 2004
@@ -1,64 +1,32 @@
 /*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber.primitives;
 
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-
-package org.apache.snickers.asn;
 
 /**
  * Tag values for primitives
  * 
- * @author Wes McKean
- * @author $Author: akarasulu $
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
  * @version $Rev$
  */
-public interface Primitive {
-    public final int RESERVED0 = 1 ;
+public interface Primitive 
+{
+    public final int RESERVED0 = 0 ;
     public final int BOOLEAN = 1 ;
     public final int INTEGER = 2 ;
     public final int BITSTRING = 3 ;

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java	Fri Mar 26 14:55:37 2004
@@ -74,6 +74,11 @@
         adapter.lengthDecoded( null ) ;
     }
 
+    public void testPartialValueDecoded()
+    {
+        adapter.partialValueDecoded( null ) ;
+    }
+
     public void testDecodeOccurred()
     {
         adapter.decodeOccurred( null, null ) ;

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java	Fri Mar 26 14:55:37 2004
@@ -18,13 +18,14 @@
 
 
 import java.nio.ByteBuffer ;
+import java.util.ArrayList ;
 
 import org.apache.commons.lang.ArrayUtils ;
 import org.apache.commons.lang.RandomStringUtils ;
 
-import org.apache.commons.codec.stateful.DecoderCallback;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
 import org.apache.commons.codec.stateful.DecoderMonitorAdapter ;
-import org.apache.commons.codec.stateful.StatefulDecoder;
 
 
 /**
@@ -37,7 +38,10 @@
  */
 public class BERDecoderTest extends AbstractDecoderTestCase
 {
-    private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap( ArrayUtils.EMPTY_BYTE_ARRAY );
+    private static final ByteBuffer EMPTY_BUFFER = 
+        ByteBuffer.wrap( ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+    
+    
     public BERDecoderTest()
     {
         super( BERDecoderTest.class.getName() ) ;
@@ -54,7 +58,6 @@
     
     public void testPrimitives() throws Exception
     {
-        byte[] bites = null ;
         Tuple decoded = null ;
         Tuple t = new Tuple( 45, 0, true, TypeClass.APPLICATION ) ;
         assertTrue( decode( t, EMPTY_BUFFER ).equals( t ) ) ; 
@@ -63,13 +66,13 @@
                 TypeClass.APPLICATION ) ;
         decoded = decode( t, ByteBuffer.wrap( "Hello world!".getBytes() ) ) ;
         assertTrue( decoded.equals( t ) ) ;
-        assertEquals( "Hello world!", toString( decoded.getValue() ) ) ;
+        assertEquals( "Hello world!", toString( decoded.getLastValueChunk() ) ) ;
 
         String mesg = RandomStringUtils.randomAlphanumeric(1000) ;
         t = new Tuple( 1234233, mesg.length(), true, TypeClass.APPLICATION ) ;
         decoded = decode( t, ByteBuffer.wrap( mesg.getBytes() ) ) ;
         assertTrue( decoded.equals( t ) ) ;
-        assertEquals( mesg, toString( decoded.getValue() ) ) ;
+        assertEquals( mesg, toString( decoded.getLastValueChunk() ) ) ;
     }
     
     
@@ -94,11 +97,11 @@
 
         Tuple decoded = decode( t0, ByteBuffer.wrap( "Hello".getBytes() ) ) ; 
         assertTrue( decoded.equals( t0 ) ) ;
-        assertEquals( "Hello", toString( decoded.getValue() ) ) ;
+        assertEquals( "Hello", toString( decoded.getLastValueChunk() ) ) ;
         
         decoded = decode( t1, ByteBuffer.wrap( "World".getBytes() ) ) ; 
         assertTrue( decoded.equals( t1 ) ) ;
-        assertEquals( "World", toString( decoded.getValue() ) ) ;
+        assertEquals( "World", toString( decoded.getLastValueChunk() ) ) ;
         
         decoded = decode( terminator, EMPTY_BUFFER ) ;
         assertTrue( decoded.equals( top ) ) ;
@@ -116,7 +119,7 @@
 
         Tuple decoded = decode( t0, ByteBuffer.wrap( str0.getBytes() ) ) ; 
         assertTrue( decoded.equals( t0 ) ) ;
-        assertEquals( str0, toString( decoded.getValue() ) ) ;
+        assertEquals( str0, toString( decoded.getLastValueChunk() ) ) ;
         
         // automatically set to top because after t1 is delivered top is 
         decoded = decode( t1, ByteBuffer.wrap( str1.getBytes() ) ) ; 
@@ -135,7 +138,7 @@
 
         Tuple decoded = decode( t0, ByteBuffer.wrap( "Hello".getBytes() ) ) ; 
         assertTrue( decoded.equals( t0 ) ) ;
-        assertEquals( "Hello", toString( decoded.getValue() ) ) ;
+        assertEquals( "Hello", toString( decoded.getLastValueChunk() ) ) ;
         
         // automatically set to top because after t1 is delivered top is 
         decoded = decode( t1, ByteBuffer.wrap( "World".getBytes() ) ) ; 
@@ -152,8 +155,9 @@
         Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
         assertTrue( decode( top, EMPTY_BUFFER ).equals( top ) ) ;
 
-        ByteBuffer all = 
-            t0.toEncodedBuffer( ByteBuffer.wrap( str0.getBytes() ) ) ;
+        ArrayList list = new ArrayList() ;
+        list.add( ByteBuffer.wrap( str0.getBytes() ) ) ;
+        ByteBuffer all = t0.toEncodedBuffer( list ) ;
         ByteBuffer[] fragments = fragment( all, 10 ) ;
         Tuple decoded = null ;
         
@@ -200,6 +204,16 @@
         decoded = decode( t1, ByteBuffer.wrap( str1.getBytes() ) ) ; 
         
         assertTrue( decode( top, EMPTY_BUFFER ).equals( top ) ) ;
+        
+        decoder.setDecoderMonitor(null) ;
+        decoded = decode( t0, ByteBuffer.wrap( str0.getBytes() ) ) ; 
+        assertTrue( decoded.equals( t0 ) ) ;
+
+        tlvList.clear() ;
+        decoder.setDecoderMonitor(null) ;
+        decoder.setCallback(null) ;
+        decoded = decode( t0, ByteBuffer.wrap( str0.getBytes() ) ) ;
+        assertTrue(tlvList.isEmpty()) ;
     }
 
 
@@ -229,10 +243,10 @@
         String str1 = RandomStringUtils.randomAlphanumeric(20) ;
         Tuple t1 = new Tuple( 3, str1.length() ) ;
         Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
-        Tuple decoded = decode( t0, ByteBuffer.wrap( str0.getBytes() ) ) ; 
+        decode( t0, ByteBuffer.wrap( str0.getBytes() ) ) ;
         
         // automatically set to top because after t1 is delivered top is 
-        decoded = decode( t1, ByteBuffer.wrap( str1.getBytes() ) ) ; 
+        decode( t1, ByteBuffer.wrap( str1.getBytes() ) ) ; 
         assertTrue( decode( top, EMPTY_BUFFER ).equals( top ) ) ;
     }
 
@@ -246,10 +260,10 @@
         String str1 = RandomStringUtils.randomAlphanumeric(20) ;
         Tuple t1 = new Tuple( 3, str1.length() ) ;
         Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
-        Tuple decoded = decode( t0, ByteBuffer.wrap( str0.getBytes() ) ) ; 
+        decode( t0, ByteBuffer.wrap( str0.getBytes() ) );
         
         // automatically set to top because after t1 is delivered top is 
-        decoded = decode( t1, ByteBuffer.wrap( str1.getBytes() ) ) ; 
+        decode( t1, ByteBuffer.wrap( str1.getBytes() ) ) ;
         assertTrue( decode( top, EMPTY_BUFFER ).equals( top ) ) ;
     }
 
@@ -266,10 +280,10 @@
         
         public void fatalError(StatefulDecoder decoder, Exception exception){}
         
-        public void lengthDecoded(Tuple tlv, byte[] lengthData) { }
+        public void lengthDecoded( Tuple tlv ) { }
         
-        public void tagDecoded(Tuple tlv, byte[] tagData) { }
+        public void tagDecoded( Tuple tlv ) { }
         
-        public void warning(StatefulDecoder decoder, Exception exception) { }
+        public void warning( StatefulDecoder decoder, Exception exception ) { }
     }
 }

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java	Fri Mar 26 14:55:37 2004
@@ -108,8 +108,8 @@
         tlv = decode( "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & tlv.value.get( 0 ) ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 0x0055, 0x00ff & tlv.valueChunk.get( 0 ) ) ;
 
         
         // --------------------------------------------------------------------
@@ -132,8 +132,8 @@
         tlv = decode( "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 2, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & tlv.value.get( 0 ) ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 0x0055, 0x00ff & tlv.valueChunk.get( 0 ) ) ;
 
     
         // --------------------------------------------------------------------
@@ -156,8 +156,8 @@
         tlv = decode( "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 3, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & tlv.value.get( 0 ) ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 0x0055, 0x00ff & tlv.valueChunk.get( 0 ) ) ;
 
         decode( "00000000" ) ;
         decode( "00000000" ) ;

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java	Fri Mar 26 14:55:37 2004
@@ -17,16 +17,10 @@
 package org.apache.snickers.ber ;
 
 
-import java.nio.ByteBuffer ;
-import java.util.ArrayList ;
-import java.util.Enumeration ;
-
-import javax.swing.tree.MutableTreeNode ;
+import java.util.Collections;
+import java.util.Iterator ;
 
-import org.apache.commons.codec.stateful.DecoderCallback ;
-import org.apache.commons.codec.stateful.StatefulDecoder ;
-
-import org.apache.commons.lang.ArrayUtils ;
+import java.nio.ByteBuffer ;
 
 
 /**
@@ -45,22 +39,6 @@
 
 
     /*
-     * Class to test for void DefaultMutableTupleNode()
-     */
-    public void testDefaultMutableTupleNode()
-    {
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        assertNotNull( node ) ;
-    }
-
-    /*
-     * Class to test for void DefaultMutableTupleNode(Tuple)
-     */
-    public void testDefaultMutableTupleNodeTuple()
-    {
-    }
-
-    /*
      * Class to test for void insert(MutableTupleNode, int)
      */
     public void testInsertMutableTupleNodeint()
@@ -92,9 +70,9 @@
         parent.remove( (MutableTupleNode) node ) ;
         assertEquals(0,parent.getChildCount()) ;
 
-        parent.insert( (MutableTreeNode) node, 0 ) ;
+        parent.insert( node, 0 ) ;
         assertEquals(1,parent.getChildCount()) ;
-        parent.remove( (MutableTreeNode) node ) ;
+        parent.remove( node ) ;
         assertEquals(0,parent.getChildCount()) ;
     }
 
@@ -119,9 +97,9 @@
         DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
         parent.insert( (MutableTupleNode) node, 0 ) ;
         node.setParent( (MutableTupleNode) parent) ;
-        assertEquals(parent, node.getParent()) ;
+        assertEquals(parent, node.getParentTupleNode()) ;
         node.setParent((MutableTupleNode)new DefaultMutableTupleNode()) ;
-        assertNotSame(parent, node.getParent()) ;
+        assertNotSame(parent, node.getParentTupleNode()) ;
     }
 
     /*
@@ -131,11 +109,11 @@
     {
         DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTreeNode) node, 0 ) ;
-        node.setParent( (MutableTreeNode) parent) ;
-        assertEquals(parent, node.getParent()) ;
-        node.setParent((MutableTreeNode)new DefaultMutableTupleNode()) ;
-        assertNotSame(parent, node.getParent()) ;
+        parent.insert( node, 0 ) ;
+        node.setParent( parent) ;
+        assertEquals(parent, node.getParentTupleNode()) ;
+        node.setParent( new DefaultMutableTupleNode()) ;
+        assertNotSame( parent, node.getParentTupleNode() ) ;
     }
 
     public void testSetTuple()
@@ -153,7 +131,7 @@
         parent.insert( (MutableTupleNode) node, 0 ) ;
         node.setParent( (MutableTupleNode) parent) ;
         assertSame(parent, node.getParentTupleNode()) ;
-        assertSame(parent, node.getParent()) ;
+        assertSame(parent, node.getParentTupleNode()) ;
     }
 
     public void testGetChildren()
@@ -181,7 +159,7 @@
         parent.insert( (MutableTupleNode) node, 0 ) ;
         node.setParent( (MutableTupleNode) parent) ;
         assertEquals( 0, parent.getIndex((MutableTupleNode)node));
-        assertEquals( 0, parent.getIndex((MutableTreeNode)node));
+        assertEquals( 0, parent.getIndex(node));
     }
 
     public void testGetChildCount()
@@ -195,7 +173,7 @@
         parent.insert( (MutableTupleNode) node, 0 ) ;
         node.setParent( (MutableTupleNode) parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
@@ -212,7 +190,7 @@
         parent.insert( (MutableTupleNode) node, 0 ) ;
         node.setParent( (MutableTupleNode) parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
@@ -234,12 +212,12 @@
         DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
         parent.setTuple( constructed ) ;
-        
         assertEquals(4, parent.size()) ;
-        
         ByteBuffer buf = ByteBuffer.allocate( 4 ) ;
         parent.encode( buf ) ;
 
+        
+        /*
         final ArrayList list = new ArrayList() ;
         TupleTreeDecoder decoder = new TupleTreeDecoder() ;
         decoder.setCallback( new DecoderCallback(){
@@ -252,6 +230,7 @@
         DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
             list.get(0); 
         assertEquals( decoded.getTuple(), parent.getTuple()) ;
+        */
     }
 
     public void testGetTuple()
@@ -266,15 +245,16 @@
     {
         DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        
         DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
         parent.insert( (MutableTupleNode) end, 0 ) ;
         end.setParent( (MutableTupleNode) parent) ;
         parent.insert( (MutableTupleNode) node, 0 ) ;
         node.setParent( (MutableTupleNode) parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        Tuple terminator = new Tuple( 0, 0, true, TypeClass.UNIVERSAL ) ;
         terminator.typeClass = TypeClass.UNIVERSAL ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
@@ -285,6 +265,7 @@
         ByteBuffer buf = ByteBuffer.allocate( 9 ) ;
         parent.encode( buf ) ;
 
+        /**
         final ArrayList list = new ArrayList() ;
         TupleTreeDecoder decoder = new TupleTreeDecoder() ;
         decoder.setCallback( new DecoderCallback(){
@@ -297,6 +278,7 @@
         DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
             list.get(0); 
         assertEquals( decoded.getTuple(), parent.getTuple()) ;
+        */
     }
 
     public void testEncode1() throws Exception
@@ -306,7 +288,7 @@
         parent.insert( (MutableTupleNode) node, 0 ) ;
         node.setParent( (MutableTupleNode) parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
@@ -317,6 +299,7 @@
         ByteBuffer buf = ByteBuffer.allocate( 9 ) ;
         parent.encode( buf ) ;
 
+        /*
         final ArrayList list = new ArrayList() ;
         TupleTreeDecoder decoder = new TupleTreeDecoder() ;
         decoder.setCallback( new DecoderCallback(){
@@ -329,6 +312,7 @@
         DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
             list.get(0); 
         assertEquals( decoded.getTuple(), parent.getTuple()) ;
+        */
     }
 
     public void testEncode2() throws Exception
@@ -343,7 +327,7 @@
         
         Tuple middleTuple = new Tuple( 1, 3, TypeClass.APPLICATION  ) ;
         Tuple topTuple = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
-        Tuple bottomTuple = new Tuple( 3, new byte[1]) ;
+        Tuple bottomTuple = new Tuple( 3, 1, true, TypeClass.APPLICATION ) ;
         
         bottomTuple.typeClass = TypeClass.UNIVERSAL ;
         top.setTuple( topTuple ) ;
@@ -355,6 +339,7 @@
         ByteBuffer buf = ByteBuffer.allocate( 7 ) ;
         top.encode( buf ) ;
 
+        /*
         final ArrayList list = new ArrayList() ;
         TupleTreeDecoder decoder = new TupleTreeDecoder() ;
         decoder.setCallback( new DecoderCallback(){
@@ -367,6 +352,7 @@
         DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
             list.get(0); 
         assertEquals( decoded.getTuple(), top.getTuple()) ;
+        */
     }
 
     
@@ -382,7 +368,7 @@
         
         Tuple middleTuple = new Tuple( 1, 3, TypeClass.APPLICATION  ) ;
         Tuple topTuple = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
-        Tuple bottomTuple = new Tuple( 3, new byte[1]) ;
+        Tuple bottomTuple = new Tuple( 3, 1, true, TypeClass.APPLICATION ) ;
         
         bottomTuple.typeClass = TypeClass.UNIVERSAL ;
         top.setTuple( topTuple ) ;
@@ -409,7 +395,7 @@
         
         Tuple middleTupleClone = new Tuple( 1, 3, TypeClass.APPLICATION  ) ;
         Tuple topTupleClone = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
-        Tuple bottomTupleClone= new Tuple( 3, new byte[1]) ;
+        Tuple bottomTupleClone= new Tuple( 3, 1, true, TypeClass.APPLICATION ) ;
         
         bottomTupleClone.typeClass = TypeClass.UNIVERSAL ;
         topClone.setTuple( topTupleClone ) ;
@@ -434,7 +420,7 @@
         
         Tuple middleTuple = new Tuple( 1, 3, TypeClass.APPLICATION  ) ;
         Tuple topTuple = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
-        Tuple bottomTuple = new Tuple( 3, new byte[1]) ;
+        Tuple bottomTuple = new Tuple( 3, 1, true, TypeClass.APPLICATION ) ;
         
         bottomTuple.typeClass = TypeClass.UNIVERSAL ;
         top.setTuple( topTuple ) ;
@@ -463,7 +449,7 @@
         
         Tuple middleTupleClone = new Tuple( 1, 3, TypeClass.APPLICATION  ) ;
         Tuple topTupleClone = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
-        Tuple bottomTupleClone= new Tuple( 3, new byte[1]) ;
+        Tuple bottomTupleClone= new Tuple( 3, 1, true, TypeClass.APPLICATION ) ;
         
         bottomTupleClone.typeClass = TypeClass.UNIVERSAL ;
         topClone.setTuple( topTupleClone ) ;
@@ -483,11 +469,48 @@
      */
     public void testToString()
     {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
+        parent.insert( end, 0 ) ;
+        end.setParent( parent) ;
+        parent.insert( node, 0 ) ;
+        node.setParent( parent) ;
+        
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        Tuple terminator = new Tuple( 0, 0, true, TypeClass.UNIVERSAL ) ;
+        terminator.typeClass = TypeClass.UNIVERSAL ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        end.setTuple( terminator ) ;
+        
+        assertNotNull( parent.toString() ) ;
     }
 
-    public void testPrintDepthFirst()
+    public void testSetTupleTupleList()
     {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
+        parent.insert( end, 0 ) ;
+        end.setParent( parent) ;
+        parent.insert( node, 0 ) ;
+        node.setParent( parent) ;
         
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        Tuple terminator = new Tuple( 0, 0, true, TypeClass.UNIVERSAL ) ;
+        terminator.typeClass = TypeClass.UNIVERSAL ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive, Collections.EMPTY_LIST ) ;
+        end.setTuple( terminator ) ;
+        
+        assertTrue( node.getValueChunks().isEmpty() ) ;
+
+
+        node.addValueChunk( ByteBuffer.allocate( 3 ) ) ;
+        assertFalse( node.getValueChunks().isEmpty() ) ;
     }
 
     public void testChildren()
@@ -495,27 +518,27 @@
         DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) end, 0 ) ;
-        end.setParent( (MutableTupleNode) parent) ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
+        parent.insert( end, 0 ) ;
+        end.setParent( parent) ;
+        parent.insert( node, 0 ) ;
+        node.setParent( parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        Tuple terminator = new Tuple( 0, 0, true, TypeClass.UNIVERSAL ) ;
         terminator.typeClass = TypeClass.UNIVERSAL ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
+        end.setTuple( terminator ) ;
         
-        Enumeration list = parent.children() ;
+        Iterator list = parent.getChildren() ;
         
-        assertEquals( node, list.nextElement() ) ;
-        assertEquals( end, list.nextElement() ) ;
+        assertEquals( node, list.next() ) ;
+        assertEquals( end, list.next() ) ;
         
         try
         {
-            list.nextElement() ;
+            list.next() ;
             fail( "should never get here due to thrown exception" ) ;
         }
         catch( Throwable t ) 
@@ -529,115 +552,38 @@
         DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) end, 0 ) ;
-        end.setParent( (MutableTupleNode) parent) ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
+        parent.insert( end, 0 ) ;
+        end.setParent( parent) ;
+        parent.insert( node, 0 ) ;
+        node.setParent( parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        Tuple terminator = new Tuple( 0, 0, true, TypeClass.UNIVERSAL ) ;
         terminator.typeClass = TypeClass.UNIVERSAL ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
-        
-        assertFalse( end.getAllowsChildren() ) ;
-        assertFalse( node.getAllowsChildren() ) ;
-        assertTrue( parent.getAllowsChildren() ) ;
-    }
-
-    public void testGetChildAt()
-    {
+        end.setTuple( terminator ) ;
     }
 
-    /*
-     * Class to test for int getIndex(TreeNode)
-     */
-    public void testGetIndexTreeNode()
-    {
-    }
-
-    public void testGetParent()
-    {
-    }
-
-    /*
-     * Class to test for void insert(MutableTreeNode, int)
-     */
-    public void testInsertMutableTreeNodeint()
-    {
-    }
-
-    public void testIsLeaf0()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        assertTrue( parent.isLeaf() ) ;
-    }
-
-    public void testIsLeaf1()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        parent.setTuple(new Tuple()) ;
-        assertTrue( parent.isLeaf() ) ;
-    }
-
-    public void testIsLeaf2()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) end, 0 ) ;
-        end.setParent( (MutableTupleNode) parent) ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
-        terminator.typeClass = TypeClass.UNIVERSAL ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
-        
-        assertFalse( parent.isLeaf() ) ;
-    }
-
-    /*
-     * Class to test for void remove(MutableTreeNode)
-     */
-    public void testRemoveMutableTreeNode()
-    {
-    }
-
-    public void testSetUserObject()
-    {
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        node.setUserObject( new Tuple() ) ;
-    }
-    
-    
     public void testAddFirst()
     {
         DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
         DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
         parent.addFront( end ) ;
-        end.setParent( (MutableTupleNode) parent) ;
+        end.setParent( parent) ;
         parent.addFront( node ) ;
-        node.setParent( (MutableTupleNode) parent) ;
+        node.setParent( parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        Tuple terminator = new Tuple( 0, 0, true, TypeClass.UNIVERSAL ) ;
         terminator.typeClass = TypeClass.UNIVERSAL ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
-
+        end.setTuple( terminator ) ;
         parent.toDepthFirstString() ;
-        parent.analyze() ;
-        assertFalse( parent.isLeaf() ) ;
     }
 
     
@@ -651,14 +597,12 @@
         parent.addLast( end ) ;
         end.setParent( (MutableTupleNode) parent) ;
         
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple primitive = new Tuple( 1, 3, true, TypeClass.APPLICATION ) ;
         Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        Tuple terminator = new Tuple( 0, 0, true, TypeClass.UNIVERSAL ) ;
         terminator.typeClass = TypeClass.UNIVERSAL ;
         parent.setTuple( constructed ) ;
         node.setTuple( primitive ) ;
         end.setTuple(terminator) ;
-
-        assertFalse( parent.isLeaf() ) ;
     }
 }

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java	Fri Mar 26 14:55:37 2004
@@ -61,7 +61,6 @@
         
         root = ( DefaultMutableTupleNode ) 
             TupleTreeDecoder.treeDecode( ByteBuffer.wrap( snaccBytes ) ) ;
-        //root.analyze() ;
         
         if ( root == null )
         {

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java	Fri Mar 26 14:55:37 2004
@@ -27,6 +27,17 @@
  */
 public class MultiByteTagTests extends AbstractDecoderTestCase
 {
+    /** precalculated left shift of 1 by 14 places */
+    private static final int BIT_13 = 1 << 14 ;
+    /** precalculated left shift of 1 by 16 places */
+    private static final int BIT_15 = 1 << 16 ;
+    /** precalculated left shift of 1 by 21 places */
+    private static final int BIT_20 = 1 << 21 ;
+    /** precalculated left shift of 1 by 24 places */
+    private static final int BIT_23 = 1 << 24 ;
+    /** precalculated left shift of 1 by 28 places */
+    private static final int BIT_27 = 1 << 28 ;
+    
 
     /**
      * @param arg0
@@ -140,7 +151,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_13, tlv.id ) ;
+        assertEquals( BIT_13, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -159,7 +170,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "01111111" ) ;
-        assertEquals( Tuple.BIT_13 - 1, tlv.id ) ;
+        assertEquals( BIT_13 - 1, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -182,7 +193,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_13 + 1, tlv.id ) ;
+        assertEquals( BIT_13 + 1, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -209,7 +220,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_20, tlv.id ) ;
+        assertEquals( BIT_20, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -232,7 +243,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "01111111" ) ;
-        assertEquals( Tuple.BIT_20 - 1, tlv.id ) ;
+        assertEquals( BIT_20 - 1, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -259,7 +270,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_20 + 1, tlv.id ) ;
+        assertEquals( BIT_20 + 1, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -290,7 +301,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_27, tlv.id ) ;
+        assertEquals( BIT_27, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -317,7 +328,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "01111111" ) ;
-        assertEquals( Tuple.BIT_27 - 1, tlv.id ) ;
+        assertEquals( BIT_27 - 1, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -348,7 +359,7 @@
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
 
         tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_27 + 1, tlv.id ) ;
+        assertEquals( BIT_27 + 1, tlv.id ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 }

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java	Fri Mar 26 14:55:37 2004
@@ -57,8 +57,8 @@
         tlv = decode( "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & tlv.value.get( 0 ) ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 0x0055, 0x00ff & tlv.valueChunk.get( 0 ) ) ;
     }
 
 
@@ -81,8 +81,8 @@
         tlv = decode( "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & tlv.value.get( 0 ) ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 0x0055, 0x00ff & tlv.valueChunk.get( 0 ) ) ;
 
     
         // decode tag
@@ -102,8 +102,8 @@
         tlv = decode( "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 2, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & tlv.value.get( 0 ) ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 0x0055, 0x00ff & tlv.valueChunk.get( 0 ) ) ;
 
     
         // decode tag
@@ -123,8 +123,8 @@
         tlv = decode( "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 3, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & tlv.value.get( 0 ) ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 0x0055, 0x00ff & tlv.valueChunk.get( 0 ) ) ;
     }
 
 
@@ -152,10 +152,10 @@
                 + "01010101" + "01010101" + "01010101" ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 7, tlv.value.capacity() ) ;
+        assertNotNull( tlv.valueChunk ) ;
+        assertEquals( 7, tlv.valueChunk.capacity() ) ;
         
-        ByteBuffer value = tlv.value.duplicate() ;
+        ByteBuffer value = tlv.valueChunk.duplicate() ;
         for ( int ii = 0 ; ii < 7; ii++ )
         {    
             assertEquals( 0x0055, 0x00ff & value.get( ii ) ) ;

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java	Fri Mar 26 14:55:37 2004
@@ -41,10 +41,10 @@
     {
         Tuple tlv = decode( "00000000" + "01000001" ) ;
         assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( 1, tlvList.size() ) ;
         assertEquals( true, tlv.isPrimitive ) ;
         assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
         assertEquals( 0, tlv.length ) ;
     }
 

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTest.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTest.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTest.java	Fri Mar 26 14:55:37 2004
@@ -18,6 +18,8 @@
 
 
 import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collections;
 
 import org.apache.commons.lang.ArrayUtils ;
 import org.apache.commons.codec.binary.Binary ;
@@ -34,6 +36,18 @@
  */
 public class TupleTest extends TestCase
 {
+    /** precalculated left shift of 1 by 14 places */
+    private static final int BIT_13 = 1 << 14 ;
+    /** precalculated left shift of 1 by 16 places */
+    private static final int BIT_15 = 1 << 16 ;
+    /** precalculated left shift of 1 by 21 places */
+    private static final int BIT_20 = 1 << 21 ;
+    /** precalculated left shift of 1 by 24 places */
+    private static final int BIT_23 = 1 << 24 ;
+    /** precalculated left shift of 1 by 28 places */
+    private static final int BIT_27 = 1 << 28 ;
+
+    /** for convenience in handling nulls */
     private static final ByteBuffer EMPTY_BUFFER =
         ByteBuffer.wrap( ArrayUtils.EMPTY_BYTE_ARRAY ) ;
 
@@ -127,14 +141,14 @@
         assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
         assertEquals( false, t.isPrimitive() ) ;
         assertEquals( Length.INDEFINATE, t.getLength() ) ;
-        assertEquals( EMPTY_BUFFER, t.getValue() ) ;
+        assertEquals( EMPTY_BUFFER, t.getLastValueChunk() ) ;
 
         t = new Tuple( 2, (TypeClass) null ) ;
         assertEquals( 2, t.getId() ) ;
         assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
         assertEquals( false, t.isPrimitive() ) ;
         assertEquals( Length.INDEFINATE, t.getLength() ) ;
-        assertEquals( EMPTY_BUFFER, t.getValue() ) ;
+        assertEquals( EMPTY_BUFFER, t.getLastValueChunk() ) ;
     }
 
     public void testGetId()
@@ -226,13 +240,13 @@
     public void testGetValue()
     {
         Tuple t = new Tuple() ;
-        assertEquals( EMPTY_BUFFER, t.getValue() ) ;
+        assertEquals( EMPTY_BUFFER, t.getLastValueChunk() ) ;
         byte[] bites = {1, 2, 3, 45} ;
-        t.value = ByteBuffer.wrap( bites ) ;
-        assertEquals( ByteBuffer.wrap( bites ), t.getValue() ) ;
+        t.valueChunk = ByteBuffer.wrap( bites ) ;
+        assertEquals( ByteBuffer.wrap( bites ), t.getLastValueChunk() ) ;
         byte[] bites2 = {1, 2, 3, 45} ;
         t.clear() ;
-        assertEquals( EMPTY_BUFFER, t.getValue() ) ;
+        assertEquals( EMPTY_BUFFER, t.getLastValueChunk() ) ;
     }
 
     public void testClear()
@@ -263,10 +277,10 @@
         t.clear() ;
         assertEquals( TypeClass.APPLICATION, t.typeClass ) ;
 
-        t.value = ByteBuffer.allocate( 3 ) ;
-        assertNotNull( t.value ) ;
+        t.valueChunk = ByteBuffer.allocate( 3 ) ;
+        assertNotNull( t.valueChunk ) ;
         t.clear() ;
-        assertEquals( EMPTY_BUFFER, t.value ) ;
+        assertEquals( EMPTY_BUFFER, t.valueChunk ) ;
 
         t.valueIndex = 12 ;
         assertEquals( 12, t.valueIndex ) ;
@@ -281,9 +295,9 @@
     public void testEqualsObject()
     {
         Tuple tnull0 = new Tuple() ;
-        tnull0.value = null ;
+        tnull0.valueChunk = null ;
         Tuple tnull1 = new Tuple() ;
-        tnull1.value = null ;
+        tnull1.valueChunk = null ;
         tnull0.equals( tnull1 ) ;
         
         tnull1.equals( tnull1 ) ;
@@ -329,8 +343,8 @@
         t1 = ( Tuple ) t0.clone() ;
         assertTrue( t0.equals( t1 ) ) ;
 
-        t0.value = ByteBuffer.allocate( 4 ) ;
-        t1.value = null ;
+        t0.valueChunk = ByteBuffer.allocate( 4 ) ;
+        t1.valueChunk = null ;
         
         // The buffer does not factor into equality
         assertTrue( t0.equals( t1 ) ) ;
@@ -357,7 +371,7 @@
         String binary ;
         
         t = new Tuple( 0, 0 ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -365,7 +379,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 2, 0 ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -373,7 +387,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 30, 0 ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -381,7 +395,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 31, 0 ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -390,7 +404,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 128, 0 ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -400,7 +414,9 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 128, 127 ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.allocate( 127 ) ) ;
+        ArrayList list = new ArrayList() ;
+        list.add( ByteBuffer.allocate( 127 ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "01111111" +
@@ -410,7 +426,9 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 128, 128 ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.allocate( 128 ) ) ;
+        list.clear() ;
+        list.add( ByteBuffer.allocate( 128 ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "10000000" +
@@ -421,7 +439,9 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 128, 255 ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.allocate( 255 ) ) ;
+        list.clear() ;
+        list.add( ByteBuffer.allocate( 255 ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "11111111" +
@@ -432,7 +452,9 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 128, 256 ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.allocate( 256 ) ) ;
+        list.clear() ;
+        list.add( ByteBuffer.allocate( 256 ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000001" +
@@ -452,7 +474,7 @@
         String binary ;
         
         t = new Tuple( 0, 0, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -460,7 +482,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 2, 0, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -468,7 +490,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 30, 0, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -476,7 +498,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 31, 0, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -485,7 +507,7 @@
                 , toAsciiString( encoded ) ) ;
 
         t = new Tuple( 128, 0, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( EMPTY_BUFFER ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -496,7 +518,9 @@
 
         data = new byte[1] ;
         t = new Tuple( 128, 1, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.wrap( data ) ) ;
+        ArrayList list = new ArrayList() ;
+        list.add( ByteBuffer.wrap( data ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( 
                 "00000000" +
@@ -508,7 +532,9 @@
 
         data = new byte[127] ;
         t = new Tuple( 128, 127, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.wrap( data ) ) ;
+        list.clear() ;
+        list.add( ByteBuffer.wrap( data ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( Binary.toAsciiString( data ) +
                 "01111111" +
@@ -519,7 +545,9 @@
 
         data = new byte[128] ;
         t = new Tuple( 128, 128, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.wrap( data ) ) ;
+        list.clear() ;
+        list.add( ByteBuffer.wrap( data ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( Binary.toAsciiString( data ) +
                 "10000000" +
@@ -531,7 +559,9 @@
 
         data = new byte[255] ;
         t = new Tuple( 128, 255, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.wrap( data ) ) ;
+        list.clear() ;
+        list.add( ByteBuffer.wrap( data ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( Binary.toAsciiString( data ) +
                 "11111111" +
@@ -543,7 +573,9 @@
 
         data = new byte[256] ;
         t = new Tuple( 128, 256, true, TypeClass.APPLICATION ) ;
-        encoded = t.toEncodedBuffer( ByteBuffer.wrap( data ) ) ;
+        list.clear() ;
+        list.add( ByteBuffer.wrap( data ) ) ;
+        encoded = t.toEncodedBuffer( list ) ;
         binary = toAsciiString( encoded ) ;
         assertEquals( Binary.toAsciiString( data ) + 
                 "00000001" +
@@ -602,7 +634,7 @@
         assertEquals( "00000001" + "10000000" + "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 3 ) ;
-        t = new Tuple( Tuple.BIT_13 - 1, 0 ) ;
+        t = new Tuple( BIT_13 - 1, 0 ) ;
         t.setTag( bites, 3 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "01111111" + 
@@ -610,7 +642,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( Tuple.BIT_13, 0 ) ;
+        t = new Tuple( BIT_13, 0 ) ;
         t.setTag( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -619,7 +651,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( Tuple.BIT_13 + 1, 0 ) ;
+        t = new Tuple( BIT_13 + 1, 0 ) ;
         t.setTag( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -628,7 +660,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( Tuple.BIT_20 - 1, 0 ) ;
+        t = new Tuple( BIT_20 - 1, 0 ) ;
         t.setTag( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "01111111" + 
@@ -637,7 +669,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( Tuple.BIT_20, 0 ) ;
+        t = new Tuple( BIT_20, 0 ) ;
         t.setTag( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -647,7 +679,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( Tuple.BIT_20 + 1, 0 ) ;
+        t = new Tuple( BIT_20 + 1, 0 ) ;
         t.setTag( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -657,7 +689,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( Tuple.BIT_27 - 1, 0 ) ;
+        t = new Tuple( BIT_27 - 1, 0 ) ;
         t.setTag( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "01111111" + 
@@ -667,7 +699,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 6 ) ;
-        t = new Tuple( Tuple.BIT_27, 0 ) ;
+        t = new Tuple( BIT_27, 0 ) ;
         
         try
         {
@@ -720,7 +752,7 @@
         assertEquals( "00000001" + "10000000" + "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 3 ) ;
-        t = new Tuple( Tuple.BIT_13 - 1, 0 ) ;
+        t = new Tuple( BIT_13 - 1, 0 ) ;
         t.setTag( bites, 3 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "01111111" + 
@@ -728,7 +760,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( Tuple.BIT_13, 0 ) ;
+        t = new Tuple( BIT_13, 0 ) ;
         t.setTag( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -737,7 +769,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( Tuple.BIT_13 + 1, 0 ) ;
+        t = new Tuple( BIT_13 + 1, 0 ) ;
         t.setTag( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -746,7 +778,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( Tuple.BIT_20 - 1, 0 ) ;
+        t = new Tuple( BIT_20 - 1, 0 ) ;
         t.setTag( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "01111111" + 
@@ -755,7 +787,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( Tuple.BIT_20, 0 ) ;
+        t = new Tuple( BIT_20, 0 ) ;
         t.setTag( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -765,7 +797,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( Tuple.BIT_20 + 1, 0 ) ;
+        t = new Tuple( BIT_20 + 1, 0 ) ;
         t.setTag( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -775,7 +807,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( Tuple.BIT_27 - 1, 0 ) ;
+        t = new Tuple( BIT_27 - 1, 0 ) ;
         t.setTag( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "01111111" + 
@@ -785,7 +817,7 @@
                       "01111111", binary ) ;
 
         bites = ByteBuffer.allocate( 6 ) ;
-        t = new Tuple( Tuple.BIT_27, 0 ) ;
+        t = new Tuple( BIT_27, 0 ) ;
         
         try
         {
@@ -841,7 +873,7 @@
                       "10000010", binary ) ;
         
         bites = ByteBuffer.allocate( 3 ) ;
-        t = new Tuple( 30, Tuple.BIT_15 - 1 ) ;
+        t = new Tuple( 30, BIT_15 - 1 ) ;
         t.setLength( bites, 3 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "11111111" +
@@ -849,7 +881,7 @@
                       "10000010", binary ) ;
         
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( 30, Tuple.BIT_15 ) ;
+        t = new Tuple( 30, BIT_15 ) ;
         t.setLength( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -858,7 +890,7 @@
                       "10000011", binary ) ;
         
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( 30, Tuple.BIT_15 + 1 ) ;
+        t = new Tuple( 30, BIT_15 + 1 ) ;
         t.setLength( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -867,7 +899,7 @@
                       "10000011", binary ) ;
         
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( 30, Tuple.BIT_23 - 1 ) ;
+        t = new Tuple( 30, BIT_23 - 1 ) ;
         t.setLength( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "11111111" +
@@ -876,7 +908,7 @@
                       "10000011", binary ) ;
         
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( 30, Tuple.BIT_23 ) ;
+        t = new Tuple( 30, BIT_23 ) ;
         t.setLength( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -886,7 +918,7 @@
                       "10000100", binary ) ;
         
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( 30, Tuple.BIT_23 + 1 ) ;
+        t = new Tuple( 30, BIT_23 + 1 ) ;
         t.setLength( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -960,7 +992,7 @@
                       "10000010", binary ) ;
         
         bites = ByteBuffer.allocate( 3 ) ;
-        t = new Tuple( 30, Tuple.BIT_15 - 1 ) ;
+        t = new Tuple( 30, BIT_15 - 1 ) ;
         t.setLength( bites, 3 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "11111111" +
@@ -968,7 +1000,7 @@
                       "10000010", binary ) ;
         
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( 30, Tuple.BIT_15 ) ;
+        t = new Tuple( 30, BIT_15 ) ;
         t.setLength( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -977,7 +1009,7 @@
                       "10000011", binary ) ;
         
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( 30, Tuple.BIT_15 + 1 ) ;
+        t = new Tuple( 30, BIT_15 + 1 ) ;
         t.setLength( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -986,7 +1018,7 @@
                       "10000011", binary ) ;
         
         bites = ByteBuffer.allocate( 4 ) ;
-        t = new Tuple( 30, Tuple.BIT_23 - 1 ) ;
+        t = new Tuple( 30, BIT_23 - 1 ) ;
         t.setLength( bites, 4 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "11111111" +
@@ -995,7 +1027,7 @@
                       "10000011", binary ) ;
         
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( 30, Tuple.BIT_23 ) ;
+        t = new Tuple( 30, BIT_23 ) ;
         t.setLength( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -1005,7 +1037,7 @@
                       "10000100", binary ) ;
         
         bites = ByteBuffer.allocate( 5 ) ;
-        t = new Tuple( 30, Tuple.BIT_23 + 1 ) ;
+        t = new Tuple( 30, BIT_23 + 1 ) ;
         t.setLength( bites, 5 ) ;
         binary = toAsciiString( bites ) ;
         assertEquals( "00000001" +
@@ -1053,24 +1085,24 @@
         t.id = 129 ;
         assertEquals( 3, t.getTagLength() ) ;
 
-        t.id = Tuple.BIT_13 - 1 ;
+        t.id = BIT_13 - 1 ;
         assertEquals( 3, t.getTagLength() ) ;
-        t.id = Tuple.BIT_13 ;
+        t.id = BIT_13 ;
         assertEquals( 4, t.getTagLength() ) ;
-        t.id = Tuple.BIT_13 + 100 ;
+        t.id = BIT_13 + 100 ;
         assertEquals( 4, t.getTagLength() ) ;
         
-        t.id = Tuple.BIT_20 - 1 ;
+        t.id = BIT_20 - 1 ;
         assertEquals( 4, t.getTagLength() ) ;
-        t.id = Tuple.BIT_20 ;
+        t.id = BIT_20 ;
         assertEquals( 5, t.getTagLength() ) ;
-        t.id = Tuple.BIT_20 + 100 ;
+        t.id = BIT_20 + 100 ;
         assertEquals( 5, t.getTagLength() ) ;
 
-        t.id = Tuple.BIT_27 - 1 ;
+        t.id = BIT_27 - 1 ;
         assertEquals( 5, t.getTagLength() ) ;
 
-        t.id = Tuple.BIT_27 ;
+        t.id = BIT_27 ;
         
         try
         {
@@ -1096,18 +1128,18 @@
         t.length = 256 ;
         assertEquals( 3, t.getLengthLength() ) ;
 
-        t.length = Tuple.BIT_15 - 1 ;
+        t.length = BIT_15 - 1 ;
         assertEquals( 3, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_15 ;
+        t.length = BIT_15 ;
         assertEquals( 4, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_15 + 100 ;
+        t.length = BIT_15 + 100 ;
         assertEquals( 4, t.getLengthLength() ) ;
         
-        t.length = Tuple.BIT_23 - 1 ;
+        t.length = BIT_23 - 1 ;
         assertEquals( 4, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_23 ;
+        t.length = BIT_23 ;
         assertEquals( 5, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_23 + 100 ;
+        t.length = BIT_23 + 100 ;
         assertEquals( 5, t.getLengthLength() ) ;
 
         t.length = Integer.MAX_VALUE ;

Modified: incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java
==============================================================================
--- incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java	(original)
+++ incubator/directory/snickers/branches/chunking/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java	Fri Mar 26 14:55:37 2004
@@ -20,6 +20,7 @@
 import java.io.ByteArrayOutputStream ;
 
 import java.nio.ByteBuffer ;
+import java.util.Collections ;
 
 import org.apache.commons.codec.stateful.DecoderCallback ;
 import org.apache.commons.codec.stateful.StatefulDecoder ;
@@ -59,24 +60,32 @@
         decoder.setDecoderMonitor( new DecoderMonitorAdapter() ) ;
     }
     
+
+    /** empty byte buffer used for convenience */
+    private static final ByteBuffer EMPTY_BUFFER = 
+        ByteBuffer.wrap( ArrayUtils.EMPTY_BYTE_ARRAY ) ;
     
     public void testTTD2() throws Exception
     {
         TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.decode(ByteBuffer.wrap( 
-                        new Tuple( 1, ArrayUtils.EMPTY_BYTE_ARRAY ).toEncodedArray())) ;
-        decoder.decode( ByteBuffer.wrap( new Tuple( 1, 
-                                ArrayUtils.EMPTY_BYTE_ARRAY ).toEncodedArray() ) ) ;
+        Tuple t = new Tuple( 1, 0, true, TypeClass.APPLICATION ) ;
+        ByteBuffer encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
+        decoder.decode( encoded ) ;
+        
+        t = new Tuple( 1, 0, true, TypeClass.APPLICATION ) ;
+        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
+        decoder.decode( encoded ) ;
     }    
     
 
     public void testTTD4() throws Exception
     {
-        byte[] bites = new Tuple( 1, ArrayUtils.EMPTY_BYTE_ARRAY ).toEncodedArray() ;
-        byte[] shorter = new byte[bites.length-1] ;
-        System.arraycopy( bites, 0, shorter, 0, shorter.length ) ;
-        
-        assertNull( TupleTreeDecoder.treeDecode( ByteBuffer.wrap( shorter ) ) );
+        Tuple t = new Tuple( 1, 0, true, TypeClass.APPLICATION ) ;
+        ByteBuffer encoded = t.toEncodedBuffer( Collections.EMPTY_LIST ) ;
+
+        ByteBuffer shorter = ByteBuffer.allocate( encoded.capacity() - 1 ) ;
+        shorter.put( ( ByteBuffer ) encoded.limit( shorter.limit() - 1 ) ) ;
+        assertNull( TupleTreeDecoder.treeDecode( shorter ) ) ;
     }    
     
 
@@ -106,8 +115,6 @@
         StringBuffer buf = new StringBuffer() ;
         root.printDepthFirst( buf, 0 ) ;
         System.out.println( "tuple tlv tree =\n" + buf.toString() ) ;
-        TupleTreeAnalyzer analyzer = new TupleTreeAnalyzer( root ) ;
-        analyzer.startup() ;
     }
     
     

Mime
View raw message