You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/04/20 09:03:20 UTC

svn commit: r395515 - /incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java

Author: smishura
Date: Thu Apr 20 00:03:18 2006
New Revision: 395515

URL: http://svn.apache.org/viewcvs?rev=395515&view=rev
Log:
Utilizing JUnit's exception handling for one more test case

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java?rev=395515&r1=395514&r2=395515&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java Thu Apr 20 00:03:18 2006
@@ -52,52 +52,41 @@
 	 *        java.lang.String)
 	 */
 	public void test_getInstanceLjava_lang_StringLjava_lang_String() {
-		try {
-			Provider[] providers = Security.getProviders("Cipher.DES");
-			if (providers != null) {
-				for (int i = 0; i < providers.length; i++) {
-					Cipher cipher = Cipher.getInstance("DES", providers[i]
-							.getName());
-					assertNotNull("Cipher.getInstance() returned a null value",
-							cipher);
+        Provider[] providers = Security.getProviders("Cipher.DES");
+        if (providers != null) {
+            for (int i = 0; i < providers.length; i++) {
+                Cipher cipher = Cipher.getInstance("DES", providers[i]
+                        .getName());
+                assertNotNull("Cipher.getInstance() returned a null value",
+                        cipher);
 
-					// Exception case
-					try {
-						cipher = Cipher.getInstance("DoBeDoBeDo", providers[i]);
-						fail("Should have thrown an NoSuchAlgorithmException");
-					} catch (NoSuchAlgorithmException e) {
-						// Expected
-					} catch (Exception e) {
-						fail("Expected an NoSuchAlgorithmException but got a "
-								+ e);
-					}
-				}// end for
-			} else {
-				fail("No installed providers support Cipher.DES");
-			}
-		} catch (Exception e) {
-			fail("Unexpected exception finding cipher : " + e);
-		}
+                // Exception case
+                try {
+                    cipher = Cipher.getInstance("DoBeDoBeDo", providers[i]);
+                    fail("Should have thrown an NoSuchAlgorithmException");
+                } catch (NoSuchAlgorithmException e) {
+                    // Expected
+                }
+            }// end for
+        } else {
+            fail("No installed providers support Cipher.DES");
+        }
 
-		// Exception case
-		try {
-			Cipher.getInstance("DES", (String) null);
-			fail("Should have thrown an IllegalArgumentException");
-		} catch (IllegalArgumentException e) {
-			// Expected
-		} catch (Exception e) {
-			fail("Expected an IllegalArgumentException but got a " + e);
-		}
+        // Exception case
+        try {
+            Cipher.getInstance("DES", (String) null);
+            fail("Should have thrown an IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
 
-		// Exception case
-		try {
-			Cipher.getInstance("DES", "IHaveNotBeenConfigured");
-			fail("Should have thrown an NoSuchProviderException");
-		} catch (NoSuchProviderException e) {
-			// Expected
-		} catch (Exception e) {
-			fail("Expected an NoSuchProviderException but got a " + e);
-		}
+        // Exception case
+        try {
+            Cipher.getInstance("DES", "IHaveNotBeenConfigured");
+            fail("Should have thrown an NoSuchProviderException");
+        } catch (NoSuchProviderException e) {
+            // Expected
+        }
 	}
 
 	/**