harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r432536 - /incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
Date Fri, 18 Aug 2006 09:53:32 GMT
Author: smishura
Date: Fri Aug 18 02:53:30 2006
New Revision: 432536

URL: http://svn.apache.org/viewvc?rev=432536&view=rev
Log:
Utilize JUnit's exception handling + remove logging

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java?rev=432536&r1=432535&r2=432536&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
Fri Aug 18 02:53:30 2006
@@ -23,8 +23,6 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
@@ -32,19 +30,16 @@
 import java.io.ObjectStreamException;
 import java.io.OutputStream;
 import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 
+import junit.framework.TestCase;
+
 import org.apache.harmony.security.tests.support.cert.MyCertificate;
 import org.apache.harmony.security.tests.support.cert.TestUtils;
 import org.apache.harmony.testframework.serialization.SerializationTest;
 
-import junit.framework.TestCase;
-
-
 /**
  * Tests for <code>Certificate</code> serialization
- * 
  */
 public class CertificateTest extends TestCase {
 
@@ -82,16 +77,8 @@
      * 
      * Assertion: ObjectStreamException if a <code>CertPath</code> could not
      * be constructed
-     * 
-     * @throws CertificateException
-     * @throws IOException
-     * @throws ClassNotFoundException
-     */
-    public final void testSerialization03()
-        throws CertificateException,
-               IOException,
-               ClassNotFoundException {
-        boolean passed = false;
+     */
+    public final void testCertificateRep_readResolve() throws Exception {
         // Create object to be serialized
         Certificate c1 = new MyCertificate("DUMMY", new byte[] {(byte)0, (byte)1});
         // This testcase uses ByteArray streams
@@ -101,29 +88,17 @@
         // try to deserialize it
         try {
             deserialize(new ByteArrayInputStream(bos.toByteArray()));
-        } catch (Exception e) {
-        	System.out.println(getName() + ": " + e);
-            if (e instanceof ObjectStreamException) {
-                passed = true;
-            }
+            fail("No expected ObjectStreamException");
+        } catch (ObjectStreamException e) {
         }
-        // check that exception has been thrown
-        assertTrue(passed);
     }
 
     /**
      * Test for <code>writeReplace()</code> method<br>
      * ByteArray streams used.
-     * 
-     * @throws CertificateException
-     * @throws IOException
-     * @throws ClassNotFoundException
-     */
-    public final void testSerialization04()
-        throws CertificateException,
-               IOException,
-               ClassNotFoundException {
-        boolean passed = false;
+     */
+    public final void testWriteReplace() throws Exception
+               {
         // Create object to be serialized
         Certificate c1 = new MyCertificate("DUMMY", null);
         // This testcase uses ByteArray streams
@@ -131,12 +106,10 @@
         // Try to serialize cert
         try {
             serialize(c1, bos);
-        } catch (Exception e) {
-        	System.out.println(getName() + ": " + e);
-            // OSE and NPE are possible
-            passed = true;
+            fail("No exception");
+        } catch (ObjectStreamException e) {
+        } catch (NullPointerException e) {
         }
-        assertTrue(passed);
     }
 
     //
@@ -173,10 +146,8 @@
                    ClassNotFoundException {
         // deserialize our object
         ObjectInputStream ois = new ObjectInputStream(is);
-        Certificate cert = null;
         try {
-            cert = (Certificate)ois.readObject();
-            return cert;
+            return (Certificate)ois.readObject();
         } finally {
             ois.close();
         }



Mime
View raw message