harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r440583 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization: CertPathTest.java CertificateTest.java
Date Wed, 06 Sep 2006 03:06:07 GMT
Author: smishura
Date: Tue Sep  5 20:06:06 2006
New Revision: 440583

URL: http://svn.apache.org/viewvc?view=rev&rev=440583
Log:
Replace private methods for testing serialization by SerializationTest's method

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java
    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/CertPathTest.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/CertPathTest.java?view=diff&rev=440583&r1=440582&r2=440583
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java
Tue Sep  5 20:06:06 2006
@@ -21,15 +21,8 @@
 
 package org.apache.harmony.security.tests.java.security.cert.serialization;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.io.ObjectStreamException;
-import java.io.OutputStream;
 import java.security.cert.CertPath;
 import java.security.cert.CertificateFactory;
 
@@ -97,13 +90,10 @@
 
         // Create object to be serialized
         CertPath cp1 = new MyCertPath(new byte[] {(byte)0, (byte)1});
-        // This testcase uses ByteArray streams
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        // Serialize cert
-        serialize(cp1, bos);
-        // try to deserialize it
+
+        // try to serialize/deserialize cert
         try {
-            deserialize(new ByteArrayInputStream(bos.toByteArray()));
+            SerializationTest.copySerializable(cp1);
             fail("No expected ObjectStreamException");
         } catch (ObjectStreamException e) {
         }
@@ -117,57 +107,14 @@
         // Create object to be serialized
         // set encoded form to null
         CertPath cp1 = new MyCertPath(null);
-        // This testcase uses ByteArray streams
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
         // Try to serialize cert
         // writeReplace() must fail with exception
         // (both OSE and NPE are possible)
         try {
-            serialize(cp1, bos);
+            SerializationTest.copySerializable(cp1);
             fail("No exception");
         } catch (ObjectStreamException e) {
         } catch (NullPointerException e) {
-        }
-    }
-
-    //
-    // private stuff
-    //
-
-    /**
-     * Test case start template - serialization
-     *
-     * @param cp
-     * <code>CertPath</code> object to be serialized
-     * @param os
-     * Serialization <code>OutputStream</code> for <code>cp</code>
-     */
-    private void serialize(CertPath cp, OutputStream os)
-            throws IOException {
-        ObjectOutputStream oos = new ObjectOutputStream(os);
-        try {
-            // Serialize it to the os
-            oos.writeObject(cp);
-            oos.flush();
-        } finally {
-            oos.close();
-        }
-    }
-    /**
-     * Test case end template - deserialization and checks
-     *
-     * @param os
-     * <code>CertPath</code> deserialization <code>InputStream</code>
-     */
-    private CertPath deserialize(InputStream is)
-            throws IOException,
-                   ClassNotFoundException {
-        // deserialize our object
-        ObjectInputStream ois = new ObjectInputStream(is);
-        try {
-            return (CertPath)ois.readObject();
-        } finally {
-            ois.close();
         }
     }
 }

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?view=diff&rev=440583&r1=440582&r2=440583
==============================================================================
--- 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
Tue Sep  5 20:06:06 2006
@@ -22,13 +22,7 @@
 package org.apache.harmony.security.tests.java.security.cert.serialization;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.io.ObjectStreamException;
-import java.io.OutputStream;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateFactory;
 
@@ -81,13 +75,10 @@
     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
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        // Serialize cert
-        serialize(c1, bos);
-        // try to deserialize it
+
+        // try to serialize/deserialize cert
         try {
-            deserialize(new ByteArrayInputStream(bos.toByteArray()));
+            SerializationTest.copySerializable(c1);
             fail("No expected ObjectStreamException");
         } catch (ObjectStreamException e) {
         }
@@ -101,56 +92,13 @@
                {
         // Create object to be serialized
         Certificate c1 = new MyCertificate("DUMMY", null);
-        // This testcase uses ByteArray streams
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
         // Try to serialize cert
         try {
-            serialize(c1, bos);
+            SerializationTest.copySerializable(c1);
             fail("No exception");
         } catch (ObjectStreamException e) {
         } catch (NullPointerException e) {
         }
     }
-
-    //
-    // private stuff
-    //
-
-    /**
-     * Test case start template - serialization
-     *
-     * @param c
-     * <code>Certificate</code> object to be serialized
-     * @param os
-     * Serialization <code>OutputStream</code> for <code>c</code>
-     */
-    private void serialize(Certificate c, OutputStream os)
-            throws IOException {
-        ObjectOutputStream oos = new ObjectOutputStream(os);
-        try {
-            // Serialize it to the os
-            oos.writeObject(c);
-            oos.flush();
-        } finally {
-            oos.close();
-        }
-    }
-    /**
-     * Test case end template - deserialization and checks
-     *
-     * @param is
-     * <code>Certificate</code> object deserialization <code>InputStream</code>
-     */
-    private Certificate deserialize(InputStream is)
-            throws IOException,
-                   ClassNotFoundException {
-        // deserialize our object
-        ObjectInputStream ois = new ObjectInputStream(is);
-        try {
-            return (Certificate)ois.readObject();
-        } finally {
-            ois.close();
-        }
-    }
-
 }



Mime
View raw message