harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r499684 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/ test/api/java/org/apache/harmony/security/tests/java/security/ test/impl/java/org/apache/harmony/security/tests/java/security/ test/support/...
Date Thu, 25 Jan 2007 06:38:46 GMT
Author: smishura
Date: Wed Jan 24 22:38:45 2007
New Revision: 499684

URL: http://svn.apache.org/viewvc?view=rev&rev=499684
Log:
Apply modified patch for HARMONY-3045:
[classlib][security]MessageDigestSpi.engineDigest(byte[], int, int) returns 0 while RI throws
NPE

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java?view=diff&rev=499684&r1=499683&r2=499684
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java
Wed Jan 24 22:38:45 2007
@@ -106,14 +106,11 @@
             throw new DigestException(Messages.getString("security.1D")); //$NON-NLS-1$
         }
         byte tmp[] = engineDigest();
-        if (tmp != null) {
-            if (len < tmp.length ) {
-                throw new DigestException(Messages.getString("security.1B")); //$NON-NLS-1$
-            }
-            System.arraycopy(tmp, 0, buf, offset, tmp.length);
-            return tmp.length;            
+        if (len < tmp.length) {
+            throw new DigestException(Messages.getString("security.1B")); //$NON-NLS-1$
         }
-        return 0;
+        System.arraycopy(tmp, 0, buf, offset, tmp.length);
+        return tmp.length;            
     }
     
     /**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java?view=diff&rev=499684&r1=499683&r2=499684
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java
Wed Jan 24 22:38:45 2007
@@ -80,9 +80,7 @@
 	 */
 	public void testDigest() {
 		MyMessageDigest1 md = new MyMessageDigest1("ABC");
-		if (md.digest() != null) {
-			fail("incorrect result");
-		}
+        assertEquals("incorrect result", 0,md.digest().length);
 		if (!md.runEngineDigest) {
 			fail("update failed");
 		}
@@ -94,9 +92,7 @@
 	public void testDigestbyteArray() {
 		MyMessageDigest1 md = new MyMessageDigest1("ABC");
 		byte[] b = {1, 2, 3, 4, 5};
-		if (md.digest(b) != null) {
-			fail("incorrect result");
-		}
+        assertEquals("incorrect result", 0, md.digest(b).length);
 		if (!md.runEngineDigest) {
 			fail("update failed");
 		}

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=499684&r1=499683&r2=499684
==============================================================================
--- 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
Wed Jan 24 22:38:45 2007
@@ -67,6 +67,15 @@
 
         assertEquals("incorrect result", DIGEST_LENGHT, md
                 .engineDigest(b, 1, 3));
+        
+        // Regression for HARMONY-3045
+        md = new MyMessageDigest();
+        try {
+            md.engineDigest(b, 0, 1);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java?view=diff&rev=499684&r1=499683&r2=499684
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/MessageDigest_Impl2Test.java
Wed Jan 24 22:38:45 2007
@@ -120,7 +120,7 @@
         assertTrue("update failed", ((MyMessageDigest1) md1).runEngineUpdate1);
         assertTrue("update failed", ((MyMessageDigest1) md1).runEngineUpdate2);
 
-        assertNull("incorrect digest result", md1.digest());
+        assertEquals("incorrect digest result", 0, md1.digest().length);
         assertEquals("getProvider() failed", 0, md1.digest(b, 2, 3));
         assertTrue("digest failed", ((MyMessageDigest1) md1).runEngineDigest);
 
@@ -145,7 +145,7 @@
         assertTrue("update failed", MyMessageDigest2.runEngineUpdate1);
         assertTrue("update failed", MyMessageDigest2.runEngineUpdate2);
 
-        assertNull("incorrect digest result", md2.digest());
+        assertEquals("incorrect digest result", 0, md2.digest().length);
         assertEquals("getProvider() failed", 0, md2.digest(b, 2, 3));
         assertTrue("digest failed", MyMessageDigest2.runEngineDigest);
 

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java?view=diff&rev=499684&r1=499683&r2=499684
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest1.java
Wed Jan 24 22:38:45 2007
@@ -59,7 +59,7 @@
 	 */
 	public byte[] engineDigest() {
 		runEngineDigest = true;
-		return null;
+		return new byte[0];
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java?view=diff&rev=499684&r1=499683&r2=499684
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/MyMessageDigest2.java
Wed Jan 24 22:38:45 2007
@@ -47,7 +47,7 @@
 	 */
 	public byte[] engineDigest() {
 		runEngineDigest = true;
-		return null;
+		return new byte[0];
 	}
 
 	/**



Mime
View raw message