directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9322 - in incubator/directory/snickers/trunk/ber/src: java/org/apache/snickers/ber test/org/apache/snickers/ber
Date Wed, 10 Mar 2004 00:59:21 GMT
Author: akarasulu
Date: Tue Mar  9 16:59:20 2004
New Revision: 9322

Added:
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java
Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/   (props changed)
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoderTest.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/OneByteTagTests.java
Log:
Ok got the single and multibyte tests working for the tag handling portion of
the decoder.


Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java
Tue Mar  9 16:59:20 2004
@@ -41,7 +41,7 @@
  * than creating new TLV tuple instances every time a single tuple is reused for
  * primitive types and new tlv tuples are cloned for constructed types.  The 
  * tuple fed to the callback must therefore be used very carefully - its values
- * must be copied to prevent their loss when primitive TLV tuples are returned.
+ * must be copied to prevent their loss.
  * </p>
  * <p>
  * Note that all tuples are not created equal.  Constructed TLVs nesting others
@@ -117,7 +117,7 @@
             monitor.warning( this, new IllegalArgumentException( msg ) ) ;
         }
 
-        if ( buf.remaining() > 0 && monitor != null )
+        if ( buf.remaining() == 0 && monitor != null )
         {
             String msg = "ignoring empty buffer" ;
             monitor.warning( this, new IllegalArgumentException( msg ) ) ;
@@ -197,8 +197,8 @@
                 // its the short form so we get the id, switch state & return
                 tlv.id = id ;
                 tagBuffer.clear() ;
-                state = state.getNext( tlv.isPrimitive ) ;
                 cb.tagDecoded( tlv ) ;
+                state = state.getNext( tlv.isPrimitive ) ;
                 return ;
             }
             
@@ -208,12 +208,12 @@
              * significant bit to flag the end of the train of octets for the 
              * tag id.
              */ 
-            if ( ( octet & Binary.BIT_7 ) == Binary.BIT_7 )
+            if ( ( octet & Binary.BIT_7 ) == 0 )
             {
                 tlv.id = BERUtils.getTagId( tagBuffer ) ;
                 tagBuffer.clear() ;
-                state = state.getNext( tlv.isPrimitive ) ;
                 cb.tagDecoded( tlv ) ;
+                state = state.getNext( tlv.isPrimitive ) ;
                 return ;
             }
         }
@@ -242,6 +242,7 @@
                     lengthOfLength = 0 ;
                     tlv.length = octet ;
                     tlv.valueIndex = UNDEFINED ;
+                    cb.lengthDecoded( tlv ) ;
 
                     if ( tlv.isPrimitive )
                     {
@@ -263,6 +264,7 @@
                     lengthOfLength = INDEFINATE ;
                     tlv.index = INDEFINATE ;
                     tlv.valueIndex = UNDEFINED ;
+                    cb.lengthDecoded( tlv ) ;
                     tlvStack.push( tlv.clone() ) ;
                     tlv.clear() ;
                     state = BERDecoderState.TAG ;
@@ -279,6 +281,7 @@
                 lengthOfLength = 0 ;
                 tlv.length = BERUtils.getLength( lengthBuffer ) ;
                 tlv.valueIndex = UNDEFINED ;
+                cb.lengthDecoded( tlv ) ;
                 
                 if ( tlv.isPrimitive )
                 {

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoderTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoderTest.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoderTest.java
Tue Mar  9 16:59:20 2004
@@ -110,7 +110,7 @@
         byte [] bites = Binary.fromAscii( bitString.getBytes() ) ;
         ByteBuffer buf = ByteBuffer.wrap( bites ) ;
         int lastSize = tlvList.size() ;
-        decoder.decode( buf.flip() ) ;
+        decoder.decode( buf ) ;
         
         if ( tlvList.isEmpty() || tlvList.size() == lastSize )
         {
@@ -127,7 +127,7 @@
      */
     public void tagDecoded( Tuple tlv )
     {
-        assertEquals( decoder.getCurrentTuple(), tlv ) ;
+        assertTrue( decoder.getCurrentTuple().equals( tlv ) ) ;
         assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
     }
 
@@ -138,7 +138,7 @@
      */
     public void lengthDecoded( Tuple tlv )
     {
-        assertEquals( decoder.getCurrentTuple(), tlv ) ;
+        assertTrue( decoder.getCurrentTuple().equals( tlv ) ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 
@@ -165,7 +165,7 @@
     {
         assertEquals( this, cb ) ;
         assertEquals( this.decoder, decoder ) ;
-        assertEquals( this.decoder.getCurrentTuple(), decoded ) ;
+        assertTrue( this.decoder.getCurrentTuple().equals( decoded ) ) ;
     }
 
     

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java	(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java	Tue
Mar  9 16:59:20 2004
@@ -219,7 +219,11 @@
                 return false ;
             }
             
-            if ( ArrayUtils.isEquals( t.value, value ) )
+            if ( t.value == null && value == null )
+            {
+                
+            }
+            else if ( ArrayUtils.isEquals( t.value, value ) )
             {
                 return false ;
             }
@@ -228,6 +232,8 @@
             {
                 return false ;
             }
+            
+            return true ;
         }
         
         return false ;

Added: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java
Tue Mar  9 16:59:20 2004
@@ -0,0 +1,354 @@
+/*
+ *   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 ;
+
+
+/**
+ * Here we test simple 1 byte tag and length values to test the decoder's 
+ * ability to handle these most simple tlvs.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev: 9318 $
+ */
+public class MultiByteTagTests extends BERDecoderTest
+{
+
+    /**
+     * @param arg0
+     */
+    public MultiByteTagTests( String arg0 )
+    {
+        super( arg0 ) ;
+    }
+    
+    
+    public void testId31() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00011111" ) ;
+        assertEquals( 31, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId100() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01100100" ) ;
+        assertEquals( 100, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId127() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( 127, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId128() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( 128, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId129() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( 129, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+
+
+    public void testIdShift14() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.SHIFT_14, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift14Minus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( Tuple.SHIFT_14 - 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift14Plus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.SHIFT_14 + 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+    
+    public void testIdShift21() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.SHIFT_21, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift21Minus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( Tuple.SHIFT_21 - 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift21Plus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.SHIFT_21 + 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift28() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.SHIFT_28, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift28Minus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( Tuple.SHIFT_28 - 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift28Plus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.SHIFT_28 + 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+}

Modified: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/OneByteTagTests.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/OneByteTagTests.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/OneByteTagTests.java
Tue Mar  9 16:59:20 2004
@@ -37,11 +37,402 @@
     }
     
     
-    public void test0() throws Exception
+    public void testAppTypeClass() throws Exception
     {
         Tuple tlv = decode( "01000001" ) ;
         assertEquals( 1, tlv.id ) ;
         assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testPrivTypeClass() throws Exception
+    {
+        Tuple tlv = decode( "11000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.PRIVATE, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testCtxTypeClass() throws Exception
+    {
+        Tuple tlv = decode( "10000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.CONTEXT_SPECIFIC, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+    
+    public void testUniTypeClass() throws Exception
+    {
+        Tuple tlv = decode( "00000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.UNIVERSAL, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId1() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId2() throws Exception
+    {
+        Tuple tlv = decode( "01000010" ) ;
+        assertEquals( 2, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId3() throws Exception
+    {
+        Tuple tlv = decode( "01000011" ) ;
+        assertEquals( 3, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId4() throws Exception
+    {
+        Tuple tlv = decode( "01000100" ) ;
+        assertEquals( 4, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId5() throws Exception
+    {
+        Tuple tlv = decode( "01000101" ) ;
+        assertEquals( 5, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId6() throws Exception
+    {
+        Tuple tlv = decode( "01000110" ) ;
+        assertEquals( 6, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId7() throws Exception
+    {
+        Tuple tlv = decode( "01000111" ) ;
+        assertEquals( 7, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId8() throws Exception
+    {
+        Tuple tlv = decode( "01001000" ) ;
+        assertEquals( 8, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId9() throws Exception
+    {
+        Tuple tlv = decode( "01001001" ) ;
+        assertEquals( 9, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId10() throws Exception
+    {
+        Tuple tlv = decode( "01001010" ) ;
+        assertEquals( 10, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId11() throws Exception
+    {
+        Tuple tlv = decode( "01001011" ) ;
+        assertEquals( 11, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId12() throws Exception
+    {
+        Tuple tlv = decode( "01001100" ) ;
+        assertEquals( 12, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId13() throws Exception
+    {
+        Tuple tlv = decode( "01001101" ) ;
+        assertEquals( 13, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId14() throws Exception
+    {
+        Tuple tlv = decode( "01001110" ) ;
+        assertEquals( 14, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId15() throws Exception
+    {
+        Tuple tlv = decode( "01001111" ) ;
+        assertEquals( 15, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId16() throws Exception
+    {
+        Tuple tlv = decode( "01010000" ) ;
+        assertEquals( 16, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId17() throws Exception
+    {
+        Tuple tlv = decode( "01010001" ) ;
+        assertEquals( 17, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId18() throws Exception
+    {
+        Tuple tlv = decode( "01010010" ) ;
+        assertEquals( 18, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId19() throws Exception
+    {
+        Tuple tlv = decode( "01010011" ) ;
+        assertEquals( 19, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId20() throws Exception
+    {
+        Tuple tlv = decode( "01010100" ) ;
+        assertEquals( 20, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId21() throws Exception
+    {
+        Tuple tlv = decode( "01010101" ) ;
+        assertEquals( 21, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId22() throws Exception
+    {
+        Tuple tlv = decode( "01010110" ) ;
+        assertEquals( 22, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId23() throws Exception
+    {
+        Tuple tlv = decode( "01010111" ) ;
+        assertEquals( 23, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId24() throws Exception
+    {
+        Tuple tlv = decode( "01011000" ) ;
+        assertEquals( 24, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId25() throws Exception
+    {
+        Tuple tlv = decode( "01011001" ) ;
+        assertEquals( 25, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId26() throws Exception
+    {
+        Tuple tlv = decode( "01011010" ) ;
+        assertEquals( 26, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId27() throws Exception
+    {
+        Tuple tlv = decode( "01011011" ) ;
+        assertEquals( 27, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId28() throws Exception
+    {
+        Tuple tlv = decode( "01011100" ) ;
+        assertEquals( 28, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId29() throws Exception
+    {
+        Tuple tlv = decode( "01011101" ) ;
+        assertEquals( 29, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId30() throws Exception
+    {
+        Tuple tlv = decode( "01011110" ) ;
+        assertEquals( 30, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+    
+    
+    public void testIdOverLimit() throws Exception
+    {
+        // this is the long form
+        Tuple tlv = decode( "01011111" ) ;
+        
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        
+        // state did not switch since we are still reading the long tag  
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+    }
+
+    
+    public void testIsConstructed() throws Exception
+    {
+        Tuple tlv = decode( "01111110" ) ;
+        assertEquals( 30, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( false, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
         assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
     }
 }

Mime
View raw message