Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 80933 invoked from network); 29 Oct 2007 17:49:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Oct 2007 17:49:44 -0000 Received: (qmail 97487 invoked by uid 500); 29 Oct 2007 17:49:32 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 97396 invoked by uid 500); 29 Oct 2007 17:49:32 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 97387 invoked by uid 99); 29 Oct 2007 17:49:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2007 10:49:32 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2007 17:49:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D37BB1A9832; Mon, 29 Oct 2007 10:49:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@harmony.apache.org From: odeakin@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071029174914.D37BB1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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