harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r499286 - in /harmony/enhanced/classlib/trunk/modules/security/src/test: api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java impl/java.injected/java/security/MessageDigestSpi_ImplTest.java
Date Wed, 24 Jan 2007 07:02:35 GMT
Author: smishura
Date: Tue Jan 23 23:02:35 2007
New Revision: 499286

URL: http://svn.apache.org/viewvc?view=rev&rev=499286
Log:
Refactor test for MessageDigestSpi#engineDigest(byte[], int, int). Move it to 'api' tests

Removed:
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/MessageDigestSpi_ImplTest.java
Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java?view=diff&rev=499286&r1=499285&r2=499286
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java
Tue Jan 23 23:02:35 2007
@@ -28,12 +28,46 @@
 
 import junit.framework.TestCase;
 
-
 /**
  * Tests for <code>MessageDigestSpi</code> constructor and methods
- * 
  */
 public class MessageDigestSpiTest extends TestCase {
+
+    /**
+     * java.security.MessageDigestSpi#engineDigest(byte[], int, int)
+     */
+    public void test_engineDigestLB$LILI() throws Exception {
+
+        final int DIGEST_LENGHT = 2;
+
+        MyMessageDigest md = new MyMessageDigest() {
+
+            public int engineGetDigestLength() {
+                return DIGEST_LENGHT;
+            }
+
+            public byte[] engineDigest() {
+                return new byte[DIGEST_LENGHT]; // return non-null value
+            }
+        };
+
+        byte[] b = new byte[5];
+        try {
+            // test: null output buffer
+            md.engineDigest(null, 1, DIGEST_LENGHT);
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {
+        }
+        try {
+            //test: len param < digest length
+            md.engineDigest(b, 1, DIGEST_LENGHT - 1);
+            fail("No expected DigestException");
+        } catch (DigestException e) {
+        }
+
+        assertEquals("incorrect result", DIGEST_LENGHT, md
+                .engineDigest(b, 1, 3));
+    }
 
 	public void testEngineGetDigestLength() {
 		MyMessageDigest md = new MyMessageDigest();



Mime
View raw message