harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r499345 - in /harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security: DigestOutputStream2Test.java DigestOutputStreamTest.java
Date Wed, 24 Jan 2007 10:39:02 GMT
Author: smishura
Date: Wed Jan 24 02:38:58 2007
New Revision: 499345

URL: http://svn.apache.org/viewvc?view=rev&rev=499345
Log:
Merge tests for getMessageDigest() and setMessageDigest()

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java?view=diff&rev=499345&r1=499344&r2=499345
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStream2Test.java
Wed Jan 24 02:38:58 2007
@@ -29,20 +29,6 @@
 	MessageDigest digest;
 
 	/**
-	 * @tests java.security.DigestOutputStream#getMessageDigest()
-	 */
-	public void test_getMessageDigest() {
-		// Test for method java.security.MessageDigest
-		// java.security.DigestOutputStream.getMessageDigest()
-		DigestOutputStream dos = new DigestOutputStream(output1, digest);
-		assertEquals("getMessageDigest did not return expected result", 
-				digest, dos.getMessageDigest());
-		dos = new DigestOutputStream(output1, null);
-		assertNull("getMessageDigest should have returned null", dos
-				.getMessageDigest());
-	}
-
-	/**
 	 * @tests java.security.DigestOutputStream#on(boolean)
 	 */
 	public void test_onZ() {
@@ -69,21 +55,6 @@
 		} catch (Exception e) {
 			fail("Caught exception : " + e);
 		}
-	}
-
-	/**
-	 * @tests java.security.DigestOutputStream#setMessageDigest(java.security.MessageDigest)
-	 */
-	public void test_setMessageDigestLjava_security_MessageDigest() {
-		// Test for method void
-		// java.security.DigestOutputStream.setMessageDigest(java.security.MessageDigest)
-		DigestOutputStream dos = new DigestOutputStream(output1, null);
-		dos.setMessageDigest(digest);
-		assertEquals("getMessageDigest did not return expected result", digest,
-				dos.getMessageDigest());
-		dos.setMessageDigest(null);
-		assertNull("getMessageDigest should have returned null", dos
-				.getMessageDigest());
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java?view=diff&rev=499345&r1=499344&r2=499345
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java
Wed Jan 24 02:38:58 2007
@@ -97,6 +97,45 @@
     }
 
     /**
+     * @tests java.security.DigestOutputStream#getMessageDigest()
+     */
+    public void test_getMessageDigest() {
+
+        MessageDigest digest = new MyMessageDigest1();
+        OutputStream out = new MyOutputStream();
+
+        // non-null parameter
+        DigestOutputStream dos = new DigestOutputStream(out, digest);
+        assertSame(digest, dos.getMessageDigest());
+
+        // null parameter
+        dos = new DigestOutputStream(out, null);
+        assertNull("getMessageDigest should have returned null", dos
+                .getMessageDigest());
+    }
+
+    /**
+     * @tests java.security.DigestOutputStream#setMessageDigest(MessageDigest)
+     */
+    public void test_setMessageDigestLjava_security_MessageDigest() {
+
+        MessageDigest digest = new MyMessageDigest1();
+        OutputStream out = new MyOutputStream();
+
+        DigestOutputStream dos = new DigestOutputStream(out, null);
+
+        // non-null parameter
+        dos.setMessageDigest(digest);
+        assertSame(digest, dos.getMessageDigest());
+
+        // null parameter
+        dos.setMessageDigest(null);
+        assertNull("getMessageDigest should have returned null", dos
+                .getMessageDigest());
+    }
+
+
+    /**
      * Test #1 for <code>write(int)</code> method<br>
      * 
      * Assertion: writes the byte to the output stream<br>
@@ -378,48 +417,6 @@
                 // check that associated digest has not been updated
                 assertTrue("update", Arrays.equals(dos.getMessageDigest().digest(),
                         MDGoldenData.getDigest(algorithmName[k]+"_NU")));
-                return;
-            } catch (NoSuchAlgorithmException e) {
-                // allowed failure
-            }
-        }
-        fail(getName() + ": no MessageDigest algorithms available - test not performed");
-    }
-
-    /**
-     * Test for <code>getMessageDigest()</code> method<br>
-     * 
-     * Assertion: returns associated message digest<br>
-     */
-    public final void testGetMessageDigest() {
-        for (int k=0; k<algorithmName.length; k++) {
-            try {
-                MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
-                DigestOutputStream dos = new DigestOutputStream(null, md);
-                
-                assertTrue(dos.getMessageDigest() == md);
-                return;
-            } catch (NoSuchAlgorithmException e) {
-                // allowed failure
-            }
-        }
-        fail(getName() + ": no MessageDigest algorithms available - test not performed");
-    }
-
-
-    /**
-     * Test for <code>setMessageDigest()</code> method<br>
-     * 
-     * Assertion: set associated message digest<br>
-     */
-    public final void testSetMessageDigest() {
-        for (int k=0; k<algorithmName.length; k++) {
-            try {
-                DigestOutputStream dos = new DigestOutputStream(null, null);
-                MessageDigest md = MessageDigest.getInstance(algorithmName[k]);
-                dos.setMessageDigest(md);
-                
-                assertTrue(dos.getMessageDigest() == md);
                 return;
             } catch (NoSuchAlgorithmException e) {
                 // allowed failure



Mime
View raw message