Author: akarasulu Date: Fri Nov 26 19:55:32 2004 New Revision: 106680 URL: http://svn.apache.org/viewcvs?view=rev&rev=106680 Log: cleanup test case before adding tests to fix length bug Modified: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Length.java incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/LengthTest.java
Modified: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Length.java Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Length.java?view=diff&rev=106680&p1=incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Length.java&r1=106679&p2=incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Length.java&r2=106680 ============================================================================== --- incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Length.java (original) +++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Length.java Fri Nov 26 19:55:32 2004 @@ -185,7 +185,6 @@ int length = 0 ; // calculate tag value w/ long tag format - int shift = 0 ; do { Modified: incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/LengthTest.java Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/LengthTest.java?view=diff&rev=106680&p1=incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/LengthTest.java&r1=106679&p2=incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/LengthTest.java&r2=106680 ============================================================================== --- incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/LengthTest.java (original) +++ incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/LengthTest.java Fri Nov 26 19:55:32 2004 @@ -21,6 +21,8 @@ import java.nio.ByteBuffer ; +import org.apache.commons.codec.DecoderException; + /** * Tests the Length class. @@ -31,27 +33,12 @@ */ public class LengthTest extends TestCase { - - public void testIsFixated() - { - } - - public void testClear() - { - } - - public void testFixate() - { - } - - public void testAdd() - { - } - - /* - * Class to test for int getLength() + /** + * Tests to make sure certain length sizes are not allowed. Basically we + * are capping off the length at 2^32-1 which corresponds to 5 total length + * bytes in the long form or the indeterminate form. */ - public void testGetLength() throws Exception + public void testMaxLength() throws Exception { ByteBuffer list = ByteBuffer.allocate( 8 ) ; list.put( (byte) 0x1 ) ; @@ -62,13 +49,14 @@ list.put( (byte) 0x1 ) ; list.put( (byte) 0x1 ) ; list.put( (byte) 0x1 ) ; - + list.flip(); + try { Length.getLength( list ) ; fail( "should fail before we get here" ) ; } - catch ( Throwable t ) + catch ( DecoderException t ) { assertNotNull( t ) ; } @@ -80,21 +68,13 @@ assertEquals( 7, Length.getLength( list ) ) ; } - public void testSize() - { - } - /* - * Class to test for int getLength(ArrayByteList) + /** + * Makes sure no additions can be made after short form fixation. */ - public void testGetLengthArrayByteList() + public void testShortFixation() throws Exception { - } - - - public void testGetOctets2() throws Exception - { - byte[] bites = { (byte) 0x00, (byte) 0xff } ; + byte[] bites = { (byte) 0x01, (byte) 0xff } ; Length length = new Length() ; length.add( bites[0] ) ; @@ -108,5 +88,7 @@ { assertNotNull( t ) ; } + + assertEquals( 1, length.getLength() ); } }
