directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9366 - in incubator/directory/snickers/trunk/ber/src: java/org/apache/snickers/ber test/org/apache/snickers/ber
Date Thu, 11 Mar 2004 23:49:40 GMT
Author: akarasulu
Date: Thu Mar 11 15:49:39 2004
New Revision: 9366

Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java
Log:
Caught a bug where we lost control over our state because we did not 
return out of the decodeLength function.


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
Thu Mar 11 15:49:39 2004
@@ -300,6 +300,8 @@
                     tlv.clear() ;
                     state = BERDecoderState.TAG ;
                 }
+                
+                return ;
             }
         }
     }

Modified: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java
Thu Mar 11 15:49:39 2004
@@ -18,6 +18,7 @@
 
 
 import org.apache.commons.lang.ArrayUtils ;
+import org.apache.commons.lang.RandomStringUtils ;
 
 
 /**
@@ -38,7 +39,22 @@
     
     public void testPrimitives() throws Exception
     {
+        byte[] bites = null ;
+        Tuple decoded = null ;
         Tuple t = new Tuple( 45, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
         assertTrue( decode( t ).equals( t ) ) ; 
+        
+        t = new Tuple( 45, "Hello world!".getBytes() ) ;
+        decoded = decode( t ) ;
+        assertTrue( decoded.equals( t ) ) ;
+        assertEquals( "Hello world!", new String( (byte[]) 
+                        decoded.getValue() ) ) ;
+
+        String mesg = RandomStringUtils.randomAlphanumeric(1000) ;
+        t = new Tuple( 1234233, mesg.getBytes() ) ;
+        decoded = decode( t ) ;
+        assertTrue( decoded.equals( t ) ) ;
+        assertEquals( mesg, new String( (byte[]) 
+                        decoded.getValue() ) ) ;
     }
 }

Mime
View raw message