harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r589772 - in /harmony/enhanced/classlib/trunk/modules/security/src/test: api/java/org/apache/harmony/security/tests/java/security/ api/java/org/apache/harmony/security/tests/java/security/cert/ impl/java.injected/java/security/cert/ impl/ja...
Date Mon, 29 Oct 2007 17:48:35 GMT
Author: odeakin
Date: Mon Oct 29 10:48:25 2007
New Revision: 589772

URL: http://svn.apache.org/viewvc?rev=589772&view=rev
Log:
Let JUnit deal with unexpected Exceptions rather than catching them ourselves - security module.

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
Mon Oct 29 10:48:25 2007
@@ -557,7 +557,7 @@
         try {
             params.init(enc, "DOUGLASMAWSON");
             fail("unsupported format should have raised IOException");
-        } catch (Exception e) {
+        } catch (IOException e) {
             // expected
         }
     }

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?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- 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
Mon Oct 29 10:48:25 2007
@@ -523,32 +523,28 @@
     /**
      * @tests java.security.DigestOutputStream#on(boolean)
      */
-    public void test_onZ() {
+    public void test_onZ() throws Exception {
         // Test for method void java.security.DigestOutputStream.on(boolean)
-        try {
-            DigestOutputStream dos = new DigestOutputStream(
-                    new ByteArrayOutputStream(), MessageDigest
-                            .getInstance("SHA"));
-            dos.on(false);
-            byte digestArray[] = { 23, 43, 44 };
-            dos.write(digestArray, 1, 1);
-            byte digestResult[] = dos.getMessageDigest().digest();
-            byte expected[] = { -38, 57, -93, -18, 94, 107, 75, 13, 50, 85,
-                    -65, -17, -107, 96, 24, -112, -81, -40, 7, 9 };
-            assertTrue("Digest did not return expected result.",
-                    java.util.Arrays.equals(digestResult, expected));
-            // now turn on processing and re-run
-            dos.on(true);
-            dos.write(digestArray, 1, 1);
-            digestResult = dos.getMessageDigest().digest();
-            byte expected1[] = { -87, 121, -17, 16, -52, 111, 106, 54, -33,
-                    107, -118, 50, 51, 7, -18, 59, -78, -30, -37, -100 };
+        DigestOutputStream dos = new DigestOutputStream(
+                new ByteArrayOutputStream(), MessageDigest
+                        .getInstance("SHA"));
+        dos.on(false);
+        byte digestArray[] = { 23, 43, 44 };
+        dos.write(digestArray, 1, 1);
+        byte digestResult[] = dos.getMessageDigest().digest();
+        byte expected[] = { -38, 57, -93, -18, 94, 107, 75, 13, 50, 85,
+                -65, -17, -107, 96, 24, -112, -81, -40, 7, 9 };
+        assertTrue("Digest did not return expected result.",
+                java.util.Arrays.equals(digestResult, expected));
+        // now turn on processing and re-run
+        dos.on(true);
+        dos.write(digestArray, 1, 1);
+        digestResult = dos.getMessageDigest().digest();
+        byte expected1[] = { -87, 121, -17, 16, -52, 111, 106, 54, -33,
+                107, -118, 50, 51, 7, -18, 59, -78, -30, -37, -100 };
 
-            assertTrue("Digest did not return expected result.",
-                    java.util.Arrays.equals(digestResult, expected1));
-        } catch (Exception e) {
-            fail("Caught exception : " + e);
-        }
+        assertTrue("Digest did not return expected result.",
+                java.util.Arrays.equals(digestResult, expected1));
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyFactory2Test.java
Mon Oct 29 10:48:25 2007
@@ -203,7 +203,7 @@
 	 * @tests java.security.KeyFactory#getInstance(java.lang.String,
 	 *        java.lang.String)
 	 */
-	public void test_getInstanceLjava_lang_StringLjava_lang_String() {
+	public void test_getInstanceLjava_lang_StringLjava_lang_String() throws Exception {
 
 		// Test1: Test for method java.security.KeyFactory
 		// java.security.KeyFactory.getInstance(java.lang.String,
@@ -229,8 +229,6 @@
             fail("Expected IllegalArgumentException");
 		} catch (IllegalArgumentException e) {
 			// Expected
-		} catch (Exception e) {
-			fail("Expected IllegalArgumentException, got " + e);
 		}
 	}
 

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
Mon Oct 29 10:48:25 2007
@@ -38,11 +38,7 @@
 	 */
 	public void test_Constructor() {
 		// Test for method java.security.SecureRandom()
-		try {
-			new SecureRandom();
-		} catch (Exception e) {
-			fail("Constructor threw exception : " + e);
-		}
+		new SecureRandom();
 	}
 
 	/**
@@ -50,11 +46,7 @@
 	 */
 	public void test_Constructor$B() {
 		// Test for method java.security.SecureRandom(byte [])
-		try {
-			new SecureRandom(SEED_BYTES);
-		} catch (Exception e) {
-			fail("Constructor threw exception : " + e);
-		}
+		new SecureRandom(SEED_BYTES);
 	}
 
 	/**
@@ -120,11 +112,7 @@
 	public void test_nextBytes$B() {
 		// Test for method void java.security.SecureRandom.nextBytes(byte [])
 		byte[] bytes = new byte[313];
-		try {
 		new SecureRandom().nextBytes(bytes);
-		} catch (Exception e) {
-			fail("next bytes not ok : " + e);
-		}
 	}
 
 	/**
@@ -132,11 +120,7 @@
 	 */
 	public void test_setSeed$B() {
 		// Test for method void java.security.SecureRandom.setSeed(byte [])
-		try {
-			new SecureRandom().setSeed(SEED_BYTES);
-		} catch (Exception e) {
-			fail("seed generation with bytes failed : " + e);
-		}
+		new SecureRandom().setSeed(SEED_BYTES);
 	}
 
 	/**
@@ -144,11 +128,7 @@
 	 */
 	public void test_setSeedJ() {
 		// Test for method void java.security.SecureRandom.setSeed(long)
-		try {
-			new SecureRandom().setSeed(SEED_VALUE);
-		} catch (Exception e) {
-			fail("seed generation with long failed : " + e);
-		}
+		new SecureRandom().setSeed(SEED_VALUE);
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
Mon Oct 29 10:48:25 2007
@@ -145,8 +145,6 @@
             }
             assertEquals("Providers not removed", 0,
                     Security.getProviders().length);
-        } catch (Exception e) {
-            e.printStackTrace();
         } finally {    // restore providers
             for (int i = 0; i < providers.length; i++) {
                 Security.addProvider(providers[i]);

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateEncodingException2Test.java
Mon Oct 29 10:48:25 2007
@@ -37,8 +37,6 @@
 			assertEquals("Initializer failed : " + e.toString(),
 					"java.security.cert.CertificateEncodingException",
 					e.toString());
-		} catch (Exception e) {
-			fail("Unexpected exception during test : " + e);
-		}
+		} 
 	}
 }

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateException2Test.java
Mon Oct 29 10:48:25 2007
@@ -36,8 +36,6 @@
 		} catch (CertificateException e) {
 			assertEquals("Initializer failed : " + e.toString(),
 					"java.security.cert.CertificateException", e.toString());
-		} catch (Exception e) {
-			fail("Unexpected exception during test : " + e);
 		}
 	}
 
@@ -55,8 +53,6 @@
 		} catch (CertificateException e) {
 			assertEquals("Initializer failed",
 					"Some error message", e.getMessage());
-		} catch (Exception e) {
-			fail("Unexpected exception during test : " + e);
 		}
 	}
 }

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
Mon Oct 29 10:48:25 2007
@@ -2685,7 +2685,7 @@
     /**
      * toString() method testing.
      */
-    public void testToString() throws IOException {
+    public void testToString() throws Exception {
         BigInteger serial = new BigInteger("10000");
         X500Principal issuer = new X500Principal("O=Issuer Org.");
         X500Principal subject = new X500Principal("O=Subject Org.");
@@ -2698,13 +2698,9 @@
         };
         String pkAlgID = "1.2.840.113549.1.1.4"; // MD5 with RSA encryption (source: http://asn1.elibel.tm.fr)
         PublicKey pkey;
-        try {
-            pkey = new TestKeyPair("RSA").getPublic();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Unexpected Exception was thrown: " + e.getMessage());
-            return;
-        }
+
+        pkey = new TestKeyPair("RSA").getPublic();
+
         boolean[] keyUsage = new boolean[]
                     {true, true, true, true, true, true, true, true, false};
         // OID values was taken from rfc 3280
@@ -2754,7 +2750,7 @@
      * and if the certificate conforming to the multiple matching criteria
      * matches or does not..
      */
-    public void testMatch() throws IOException {
+    public void testMatch() throws Exception {
         BigInteger serial = new BigInteger("10000");
         X500Principal issuer = new X500Principal("O=Issuer Org.");
         X500Principal subject = new X500Principal("O=Subject Org.");
@@ -2767,13 +2763,9 @@
         };
         String pkAlgID = "1.2.840.113549.1.1.1"; // RSA encryption (source: http://asn1.elibel.tm.fr)
         PublicKey pkey;
-        try {
-            pkey = new TestKeyPair("RSA").getPublic();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Unexpected Exception was thrown: " + e.getMessage());
-            return;
-        }
+
+        pkey = new TestKeyPair("RSA").getPublic();
+
         boolean[] keyUsage = new boolean[]
                     {true, true, true, true, true, true, true, true, false};
         // OID values was taken from rfc 3280
@@ -2853,7 +2845,7 @@
     /**
      * clone() method testing.
      */
-    public void testClone() throws IOException {
+    public void testClone() throws Exception {
         BigInteger serial = new BigInteger("10000");
         X500Principal issuer = new X500Principal("O=Issuer Org.");
         X500Principal subject = new X500Principal("O=Subject Org.");
@@ -2866,13 +2858,9 @@
         };
         String pkAlgID = "1.2.840.113549.1.1.1"; // RSA encryption (source: http://asn1.elibel.tm.fr)
         PublicKey pkey;
-        try {
-            pkey = new TestKeyPair("RSA").getPublic();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Unexpected Exception was thrown: " + e.getMessage());
-            return;
-        }
+
+        pkey = new TestKeyPair("RSA").getPublic();
+
         boolean[] keyUsage = new boolean[]
                     {true, true, true, true, true, true, true, true, false};
         // OID values was taken from rfc 3280

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/KSBuilder_ImplTest.java
Mon Oct 29 10:48:25 2007
@@ -342,13 +342,8 @@
 
             while (iter.hasMoreElements()) {
                 aName = (String) iter.nextElement();
-                try {
-                    assertEquals("Incorrect ProtectionParameter", ksB
-                            .getProtectionParameter(aName), pp[i]);
-                } catch (Exception e) {
-                    fail("Unexpected: " + e.toString()
-                            + " was thrown for alias: " + aName);
-                }
+                assertEquals("Incorrect ProtectionParameter", ksB
+                        .getProtectionParameter(aName), pp[i]);
             }
 
             try {

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java
Mon Oct 29 10:48:25 2007
@@ -244,37 +244,32 @@
     
     private static int XXX = 0, counter = 0;
 
-    public void testCreationCRL() {
-        try {
-            byte[] stamp = new byte[10];
-            if ((++counter)%10 != 0) {
-                XXX++;
-            }
-            byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
-            System.arraycopy(tmp, 0, stamp, 0, tmp.length);
-            System.arraycopy(stamp, 0, encoding, 
-                    encoding.length-stamp.length, stamp.length);
+    public void testCreationCRL() throws Exception {
+        byte[] stamp = new byte[10];
+        if ((++counter)%10 != 0) {
+            XXX++;
+        }
+        byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
+        System.arraycopy(tmp, 0, stamp, 0, tmp.length);
+        System.arraycopy(stamp, 0, encoding, 
+                encoding.length-stamp.length, stamp.length);
 
-            stream.reset();
-            java.security.cert.X509CRL c = (java.security.cert.X509CRL)
-                factory.generateCRL(stream);
-            
-            if (counter == 1) {
-                System.out.println("\nUSING: "+ c.getClass());
-            }
-            
-            byte[] enc = c.getEncoded();
-            byte[] stamp_chek = new byte[stamp.length];
-            
-            System.arraycopy(enc, enc.length - stamp.length, 
-                    stamp_chek, 0, stamp.length);
-           
-            if (!Arrays.equals(stamp, stamp_chek)) {
-                fail("Wrong encoding received.");
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Creation of a crl from a stream failed:"+e.getMessage());
+        stream.reset();
+        java.security.cert.X509CRL c = (java.security.cert.X509CRL)
+            factory.generateCRL(stream);
+        
+        if (counter == 1) {
+            System.out.println("\nUSING: "+ c.getClass());
+        }
+        
+        byte[] enc = c.getEncoded();
+        byte[] stamp_chek = new byte[stamp.length];
+        
+        System.arraycopy(enc, enc.length - stamp.length, 
+                stamp_chek, 0, stamp.length);
+       
+        if (!Arrays.equals(stamp, stamp_chek)) {
+            fail("Wrong encoding received.");
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
Mon Oct 29 10:48:25 2007
@@ -352,72 +352,57 @@
 
     private static int XXX = 0, flag = 0;
 
-    public void testCreationCRL() {
-        try {
-            byte[] stamp = new byte[10];
-            if ((++flag)%2 != 0) {
-                XXX++;
-            }
-            byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
-            System.arraycopy(tmp, 0, stamp, 0, tmp.length);
-            System.arraycopy(stamp, 0, certEncoding, 
-                    certEncoding.length-stamp.length, stamp.length);
+    public void testCreationCRL() throws Exception {
+        byte[] stamp = new byte[10];
+        if ((++flag)%2 != 0) {
+            XXX++;
+        }
+        byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
+        System.arraycopy(tmp, 0, stamp, 0, tmp.length);
+        System.arraycopy(stamp, 0, certEncoding, 
+                certEncoding.length-stamp.length, stamp.length);
 
-            stream.reset();
-            java.security.cert.Certificate c = factory.generateCertificate(stream);
+        stream.reset();
+        java.security.cert.Certificate c = factory.generateCertificate(stream);
 
-            byte[] enc = c.getEncoded();
-            byte[] stamp_chek = new byte[stamp.length];
-            
-            System.arraycopy(enc, enc.length - stamp.length, 
-                    stamp_chek, 0, stamp.length);
-           
-            if (!Arrays.equals(stamp, stamp_chek)) {
-                fail("Wrong encoding received.");
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Creation of a certificate from a stream failed:"+e.getMessage());
+        byte[] enc = c.getEncoded();
+        byte[] stamp_chek = new byte[stamp.length];
+        
+        System.arraycopy(enc, enc.length - stamp.length, 
+                stamp_chek, 0, stamp.length);
+       
+        if (!Arrays.equals(stamp, stamp_chek)) {
+            fail("Wrong encoding received.");
         }
     }
     
-    public void testCreation1() {
-        try {
-            byte[] stamp = new byte[10];
-            if ((++flag)%2 != 0) {
-                XXX++;
-            }
-            byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
-            System.arraycopy(tmp, 0, stamp, 0, tmp.length);
-            System.arraycopy(stamp, 0, certEncoding, 
-                    certEncoding.length-stamp.length, stamp.length);
+    public void testCreation1() throws Exception {
+        byte[] stamp = new byte[10];
+        if ((++flag)%2 != 0) {
+            XXX++;
+        }
+        byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
+        System.arraycopy(tmp, 0, stamp, 0, tmp.length);
+        System.arraycopy(stamp, 0, certEncoding, 
+                certEncoding.length-stamp.length, stamp.length);
 
-            stream.reset();
-            java.security.cert.Certificate c = factory.generateCertificate(stream);
+        stream.reset();
+        java.security.cert.Certificate c = factory.generateCertificate(stream);
 
-            byte[] enc = c.getEncoded();
-            byte[] stamp_chek = new byte[stamp.length];
-            
-            System.arraycopy(enc, enc.length - stamp.length, 
-                    stamp_chek, 0, stamp.length);
-           
-            if (!Arrays.equals(stamp, stamp_chek)) {
-                fail("Wrong encoding received.");
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Creation of a certificate from a stream failed:"+e.getMessage());
+        byte[] enc = c.getEncoded();
+        byte[] stamp_chek = new byte[stamp.length];
+        
+        System.arraycopy(enc, enc.length - stamp.length, 
+                stamp_chek, 0, stamp.length);
+       
+        if (!Arrays.equals(stamp, stamp_chek)) {
+            fail("Wrong encoding received.");
         }
     }
     
-    public void testCreation2() {
-        try {
-            stream_b64.reset();
-            factory.generateCertificate(stream_b64);
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Creation of a certificate from a stream failed:"+e.getMessage());
-        }
+    public void testCreation2() throws Exception {
+        stream_b64.reset();
+        factory.generateCertificate(stream_b64);
     }
     
     /**
@@ -635,22 +620,18 @@
     /**
      * getExtendedKeyUsage() method testing.
      */
-    public void testGetExtendedKeyUsage() {
-        try {
-            List exku = certificate.getExtendedKeyUsage();
-            if ((exku == null) 
-                    || (exku.size() != extnExtendedKeyUsage.size())) {
-                fail("Incorrect Extended Key Usage value.");
-            }
-            for (int i=0; i<extnExtendedKeyUsage.size(); i++) {
-                String ku = ObjectIdentifier
-                        .toString((int[]) extnExtendedKeyUsage.get(i));
-                if (!exku.contains(ku)) {
-                    fail("Missing value:" + ku);
-                }
+    public void testGetExtendedKeyUsage() throws Exception {
+        List exku = certificate.getExtendedKeyUsage();
+        if ((exku == null) 
+                || (exku.size() != extnExtendedKeyUsage.size())) {
+            fail("Incorrect Extended Key Usage value.");
+        }
+        for (int i=0; i<extnExtendedKeyUsage.size(); i++) {
+            String ku = ObjectIdentifier
+                    .toString((int[]) extnExtendedKeyUsage.get(i));
+            if (!exku.contains(ku)) {
+                fail("Missing value:" + ku);
             }
-        } catch (Exception e) {
-            fail("Incorrect Key Usage value.");
         }
     }
     
@@ -816,25 +797,17 @@
      * verify(PublicKey key) method testing.
      */
     public void testVerify1() throws Exception {
-        try {
-            certificate.verify(publicKey);
-        } catch (Exception e) {
-            fail("Signature verifying process failed.");
-        }
+        certificate.verify(publicKey);
     }
     
     /**
      * TODO
      * verify(PublicKey key, String sigProvider) method testing.
      */
-    public void testVerify2() {
-        try {
-            certificate.verify(publicKey, 
-                    Signature.getInstance("SHA1withDSA")
-                                    .getProvider().getName());
-        } catch (Exception e) {
-            fail("Signature verifying process failed.");
-        }
+    public void testVerify2() throws Exception {
+        certificate.verify(publicKey, 
+               Signature.getInstance("SHA1withDSA")
+                               .getProvider().getName());
     }
     
     /**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java
Mon Oct 29 10:48:25 2007
@@ -314,13 +314,9 @@
         certificate = new X509CertImpl(cert);
     }
 
-    public void testCreation() {
-        try {
-            ByteArrayInputStream bis = new ByteArrayInputStream(certEncoding);
-            certificate = new X509CertImpl(bis);
-        } catch (Exception e) {
-            fail("Creation of a certificate from a stream failed.");
-        }
+    public void testCreation() throws Exception {
+        ByteArrayInputStream bis = new ByteArrayInputStream(certEncoding);
+        certificate = new X509CertImpl(bis);
     }
     
     /**
@@ -558,22 +554,18 @@
     /**
      * getExtendedKeyUsage() method testing.
      */
-    public void testGetExtendedKeyUsage() {
-        try {
-            List exku = certificate.getExtendedKeyUsage();
-            if ((exku == null) 
-                    || (exku.size() != extnExtendedKeyUsage.size())) {
-                fail("Incorrect Extended Key Usage value.");
+    public void testGetExtendedKeyUsage() throws Exception {
+        List exku = certificate.getExtendedKeyUsage();
+        if ((exku == null) 
+                || (exku.size() != extnExtendedKeyUsage.size())) {
+            fail("Incorrect Extended Key Usage value.");
+        }
+        for (int i=0; i<extnExtendedKeyUsage.size(); i++) {
+            String ku = ObjectIdentifier
+                    .toString((int[]) extnExtendedKeyUsage.get(i));
+            if (!exku.contains(ku)) {
+                fail("Missing value:" + ku);
             }
-            for (int i=0; i<extnExtendedKeyUsage.size(); i++) {
-                String ku = ObjectIdentifier
-                        .toString((int[]) extnExtendedKeyUsage.get(i));
-                if (!exku.contains(ku)) {
-                    fail("Missing value:" + ku);
-                }
-            }
-        } catch (Exception e) {
-            fail("Incorrect Key Usage value.");
         }
     }
     

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
Mon Oct 29 10:48:25 2007
@@ -40,31 +40,26 @@
     /**
      * CertificatePolicies() method testing.
      */
-    public void testCertificatePolicies() {
-        try {
-            String[] policies = new String[] {
-                "0.0.0.0.0.0",
-                "1.1.1.1.1.1",
-                "2.2.2.2.2.2"
-            };
-            CertificatePolicies certificatePolicies = 
-                                            new CertificatePolicies();
-            for (int i=0; i<policies.length; i++) {
-                PolicyInformation policyInformation =
-                                        new PolicyInformation(policies[i]);
-                certificatePolicies.addPolicyInformation(policyInformation);
-            }
-
-            byte[] encoding = certificatePolicies.getEncoded();
-            List policyInformations = ((CertificatePolicies) 
-                    CertificatePolicies.ASN1.decode(encoding))
-                    .getPolicyInformations();
-            Iterator it = policyInformations.iterator();
-            ((PolicyInformation) it.next()).getPolicyIdentifier();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
+    public void testCertificatePolicies() throws Exception {
+        String[] policies = new String[] {
+            "0.0.0.0.0.0",
+            "1.1.1.1.1.1",
+            "2.2.2.2.2.2"
+        };
+        CertificatePolicies certificatePolicies = 
+                                        new CertificatePolicies();
+        for (int i=0; i<policies.length; i++) {
+            PolicyInformation policyInformation =
+                                    new PolicyInformation(policies[i]);
+            certificatePolicies.addPolicyInformation(policyInformation);
         }
+
+        byte[] encoding = certificatePolicies.getEncoded();
+        List policyInformations = ((CertificatePolicies) 
+                CertificatePolicies.ASN1.decode(encoding))
+                .getPolicyInformations();
+        Iterator it = policyInformations.iterator();
+        ((PolicyInformation) it.next()).getPolicyIdentifier();
     }
     
     public static Test suite() {

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
Mon Oct 29 10:48:25 2007
@@ -58,78 +58,75 @@
      */
     public void _testEDIPartyName1() {
         boolean pass = true;
-        try {
-            EDIPartyName ediPN = new EDIPartyName("nameAssigner", "partyName");
-            byte[] encoded = ediPN.getEncoded();
-            // manually derived data:
-            byte[] _encoded = { 
-                (byte) 0x30, (byte) 0x1d, (byte) 0x80, (byte) 0x0e, 
-                (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61, 
-                (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73, 
-                (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e,
-                (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b, 
-                (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61, 
-                (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e, 
-                (byte) 0x61, (byte) 0x6d, (byte) 0x65
-            };
-            if (!Arrays.equals(encoded, _encoded)) {
-                System.out.println("Got encoded form of EDIPartyName is:");
-                printAsHex(16, "", " ", encoded);
-                System.out.println("But should be like this:");
-                printAsHex(16, "", " ", _encoded);
-                System.out.println("");
-                pass = false;
-            }
 
-            GeneralName gName = new GeneralName(ediPN);
-            encoded = gName.getEncoded();
-            // manually derived data:
-            _encoded = new byte[] {
-                (byte) 0xa5, (byte) 0x1d, (byte) 0x80, (byte) 0x0e, 
-                (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61, 
-                (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73, 
-                (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e, 
-                (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b, 
-                (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61, 
-                (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e, 
-                (byte) 0x61, (byte) 0x6d, (byte) 0x65
-            };
-            if (!Arrays.equals(encoded, _encoded)) {
-                System.out.println("Got encoded form of GeneralName is:");
-                printAsHex(16, "", " ", encoded);
-                System.out.println("But should be like this:");
-                printAsHex(16, "", " ", _encoded);
-                System.out.println("");
-                pass = false;
-            }
+        EDIPartyName ediPN = new EDIPartyName("nameAssigner", "partyName");
+        byte[] encoded = ediPN.getEncoded();
+        // manually derived data:
+        byte[] _encoded = { 
+            (byte) 0x30, (byte) 0x1d, (byte) 0x80, (byte) 0x0e, 
+            (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61, 
+            (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73, 
+            (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e,
+            (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b, 
+            (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61, 
+            (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e, 
+            (byte) 0x61, (byte) 0x6d, (byte) 0x65
+        };
+        if (!Arrays.equals(encoded, _encoded)) {
+            System.out.println("Got encoded form of EDIPartyName is:");
+            printAsHex(16, "", " ", encoded);
+            System.out.println("But should be like this:");
+            printAsHex(16, "", " ", _encoded);
+            System.out.println("");
+            pass = false;
+        }
+
+        GeneralName gName = new GeneralName(ediPN);
+        encoded = gName.getEncoded();
+        // manually derived data:
+        _encoded = new byte[] {
+            (byte) 0xa5, (byte) 0x1d, (byte) 0x80, (byte) 0x0e, 
+            (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61, 
+            (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73, 
+            (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e, 
+            (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b, 
+            (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61, 
+            (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e, 
+            (byte) 0x61, (byte) 0x6d, (byte) 0x65
+        };
+        if (!Arrays.equals(encoded, _encoded)) {
+            System.out.println("Got encoded form of GeneralName is:");
+            printAsHex(16, "", " ", encoded);
+            System.out.println("But should be like this:");
+            printAsHex(16, "", " ", _encoded);
+            System.out.println("");
+            pass = false;
+        }
 
-            GeneralNames gNames = new GeneralNames();
-            gNames.addName(gName);
-            encoded = gNames.getEncoded();
-            // manually derived data:
-            _encoded = new byte[] {
-                (byte) 0x30, (byte) 0x1f, (byte) 0xa5, (byte) 0x1d,
-                (byte) 0x80, (byte) 0x0e, (byte) 0x13, (byte) 0x0c,
-                (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
-                (byte) 0x41, (byte) 0x73, (byte) 0x73, (byte) 0x69,
-                (byte) 0x67, (byte) 0x6e, (byte) 0x65, (byte) 0x72,
-                (byte) 0x81, (byte) 0x0b, (byte) 0x13, (byte) 0x09,
-                (byte) 0x70, (byte) 0x61, (byte) 0x72, (byte) 0x74,
-                (byte) 0x79, (byte) 0x4e, (byte) 0x61, (byte) 0x6d,
-                (byte) 0x65
-            };
-            if (!Arrays.equals(encoded, _encoded)) {
-                System.out.println("Got encoded form of GeneralNames is:");
-                printAsHex(16, "", " ", encoded);
-                System.out.println("But should be like this:");
-                printAsHex(16, "", " ", _encoded);
-                System.out.println("");
-                pass = false;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Unexpected Exception was thrown.");
+        GeneralNames gNames = new GeneralNames();
+        gNames.addName(gName);
+        encoded = gNames.getEncoded();
+        // manually derived data:
+        _encoded = new byte[] {
+            (byte) 0x30, (byte) 0x1f, (byte) 0xa5, (byte) 0x1d,
+            (byte) 0x80, (byte) 0x0e, (byte) 0x13, (byte) 0x0c,
+            (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
+            (byte) 0x41, (byte) 0x73, (byte) 0x73, (byte) 0x69,
+            (byte) 0x67, (byte) 0x6e, (byte) 0x65, (byte) 0x72,
+            (byte) 0x81, (byte) 0x0b, (byte) 0x13, (byte) 0x09,
+            (byte) 0x70, (byte) 0x61, (byte) 0x72, (byte) 0x74,
+            (byte) 0x79, (byte) 0x4e, (byte) 0x61, (byte) 0x6d,
+            (byte) 0x65
+        };
+        if (!Arrays.equals(encoded, _encoded)) {
+            System.out.println("Got encoded form of GeneralNames is:");
+            printAsHex(16, "", " ", encoded);
+            System.out.println("But should be like this:");
+            printAsHex(16, "", " ", _encoded);
+            System.out.println("");
+            pass = false;
         }
+
         assertTrue("Some problems occured.", pass);
     }
     

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNameTest.java
Mon Oct 29 10:48:25 2007
@@ -73,20 +73,15 @@
         }
     }
 
-    public void testGeneralName1() {
-        try {
-            OtherName on =
-                new OtherName("1.2.3.4.5", new byte[] {1, 2, 0, 1});
-            byte[] encoding = OtherName.ASN1.encode(on);
-            new GeneralName(0, encoding);
-            OtherName.ASN1.decode(encoding);
-            GeneralName gn = new GeneralName(on);
-            new GeneralName(0, gn.getEncodedName());
-            assertEquals(gn, new GeneralName(0, gn.getEncodedName()));
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
-        }
+    public void testGeneralName1() throws Exception {
+        OtherName on =
+            new OtherName("1.2.3.4.5", new byte[] {1, 2, 0, 1});
+        byte[] encoding = OtherName.ASN1.encode(on);
+        new GeneralName(0, encoding);
+        OtherName.ASN1.decode(encoding);
+        GeneralName gn = new GeneralName(on);
+        new GeneralName(0, gn.getEncodedName());
+        assertEquals(gn, new GeneralName(0, gn.getEncodedName()));
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java?rev=589772&r1=589771&r2=589772&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
Mon Oct 29 10:48:25 2007
@@ -55,28 +55,22 @@
      * ORAddress() method testing.
      */
     public void testORAddress() {
-        try {
-            ORAddress ora = new ORAddress();
-            System.out.println("");
-            System.out.println("ORAddress:");
-            printAsHex(8, "", " ", ora.getEncoded());
-            System.out.println("");
-            
-            GeneralName gName = new GeneralName(ora);
-            System.out.println("GeneralName:");
-            printAsHex(8, "", " ", gName.getEncoded());
-            System.out.println("");
+        ORAddress ora = new ORAddress();
+        System.out.println("");
+        System.out.println("ORAddress:");
+        printAsHex(8, "", " ", ora.getEncoded());
+        System.out.println("");
+        
+        GeneralName gName = new GeneralName(ora);
+        System.out.println("GeneralName:");
+        printAsHex(8, "", " ", gName.getEncoded());
+        System.out.println("");
 
-            GeneralNames gNames = new GeneralNames();
-            gNames.addName(gName);
-            System.out.println("GeneralNames:");
-            printAsHex(8, "", " ", gNames.getEncoded());
-            System.out.println("");
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail("Exception was thrown.");
-        }
+        GeneralNames gNames = new GeneralNames();
+        gNames.addName(gName);
+        System.out.println("GeneralNames:");
+        printAsHex(8, "", " ", gNames.getEncoded());
+        System.out.println("");
     }
     
     public static Test suite() {



Mime
View raw message