directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10024 - incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/rules
Date Thu, 15 Apr 2004 03:35:07 GMT
Author: akarasulu
Date: Wed Apr 14 20:35:06 2004
New Revision: 10024

Modified:
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRuleTest.java
Log:
100% test coverage achieved for PrimitiveOctetStringRule

Modified: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRuleTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRuleTest.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRuleTest.java
Wed Apr 14 20:35:06 2004
@@ -21,6 +21,7 @@
 
 import org.apache.snickers.ber.digester.BERDigester ;
 import org.apache.snickers.ber.primitives.UniversalTag;
+import org.apache.snickers.ber.Length;
 
 import java.nio.ByteBuffer;
 
@@ -94,4 +95,46 @@
     }
 
 
+    /**
+     * Tests when the length is indefinate.
+     */
+    public void testIndefinateLength()
+    {
+        rule.tag( UniversalTag.OCTET_STRING.getTagId(), true, null ) ;
+        rule.length( Length.INDEFINATE ) ;
+        rule.finish() ;
+        ByteBuffer buf = ( ByteBuffer ) digester.pop() ;
+        assertFalse( buf.hasRemaining() ) ;
+    }
+
+
+    /**
+     * Tests when the length is indefinate.
+     */
+    public void testNullValue()
+    {
+        rule.tag( UniversalTag.OCTET_STRING.getTagId(), true, null ) ;
+        rule.length( Length.INDEFINATE ) ;
+        rule.value( null ) ;
+        rule.value( ByteBuffer.allocate( 0 ) ) ;
+        rule.finish() ;
+        ByteBuffer buf = ( ByteBuffer ) digester.pop() ;
+        assertFalse( buf.hasRemaining() ) ;
+    }
+
+
+    /**
+     * Tests when the wrong tag is supplied.
+     */
+    public void testWrongTag()
+    {
+        try
+        {
+            rule.tag( UniversalTag.OBJECT_IDENTIFIER.getTagId(), true, null ) ;
+            fail( "should never get here due to an exception" ) ;
+        }
+        catch ( IllegalArgumentException e )
+        {
+        }
+    }
 }

Mime
View raw message