harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r432533 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src/test: api/java.injected/java/security/cert/serialization/ api/java/org/apache/harmony/security/tests/java/security/cert/serialization/ resources/java/security/cert...
Date Fri, 18 Aug 2006 09:35:43 GMT
Author: smishura
Date: Fri Aug 18 02:35:40 2006
New Revision: 432533

URL: http://svn.apache.org/viewvc?rev=432533&view=rev
Log:
Refactoring serialization tests to use new framework

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
      - copied, changed from r432532, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.golden.ser
      - copied unchanged from r432522, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/java/security/cert/serialization/Certificate.X.509.dat
Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/java/security/cert/serialization/Certificate.X.509.dat

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java
(from r432532, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/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?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java&r1=432532&r2=432533&rev=432533&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/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:35:40 2006
@@ -19,7 +19,7 @@
 * @version $Revision$
 */
 
-package java.security.cert.serialization;
+package org.apache.harmony.security.tests.java.security.cert.serialization;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -37,6 +37,7 @@
 
 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;
 
@@ -46,107 +47,41 @@
  * 
  */
 public class CertificateTest extends TestCase {
-    /**
-     * <code>Certificate</code> type to be created during testing
-     */
+
+    // certificate type to be created during testing
     private static final String certType = "X.509";
-    /**
-     * Input file name used for <code>Certificate</code> instance generation
-     */
-    private static final String certFileName =
-        org.apache.harmony.security.tests.support.TestUtils.TEST_ROOT +
-        "java/security/cert/serialization/Certificate." +
-        certType;
-    /**
-     * Golden file containing serial <code>Certificate</code> stream
-     */
-    private static final String serializedCertFileName = certFileName + ".dat";
 
     /**
-     * Constructor for CertificateTest.
-     * @param name
+     * @tests serialization/deserialization.
      */
-    public CertificateTest(String name) {
-        super(name);
-    }
+    public void testSerializationSelf() throws Exception {
 
-    //
-    // Tests
-    //
+        CertificateFactory cf = CertificateFactory.getInstance(certType);
 
-    /**
-     * Test #1 for <code>Certificate</code> serialization/deserialization.<br>
-     * ByteArray streams used.
-     *
-     * Assertion: deserialized object must match to original one
-     * 
-     * @throws CertificateException
-     * @throws IOException
-     * @throws ClassNotFoundException
-     */
-    public final void testSerialization01()
-        throws CertificateException,
-               IOException,
-               ClassNotFoundException {
-        CertificateFactory cf = null;
-        try {
-            cf = CertificateFactory.getInstance(certType);
-        } catch (CertificateException e) {
-            fail(getName() +
-                    ": PASSED (could not create CertificateFactory): " + e);
-            return;
-        }
-        // Create object to be serialized
-        Certificate c1 = cf.generateCertificate(new ByteArrayInputStream(
+        Certificate cert = cf.generateCertificate(new ByteArrayInputStream(
                 TestUtils.getEncodedX509Certificate()));
-        // This testcase uses ByteArray streams
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        // Serialize cert
-        serialize(c1, bos);
-        // Deserialize it
-        Certificate c2 = deserialize(new ByteArrayInputStream(bos.toByteArray()));
-        // compare both Certificates
-        assertTrue(c1.equals(c2) && c2.equals(c1));
+
+        SerializationTest.verifySelf(cert);
     }
 
     /**
-     * Test #2 for <code>Certificate</code> serialization/deserialization.<br>
-     * File input stream with golden content used.
-     *
-     * Assertion: deserialized object must match to original one
-     * 
-     * @throws CertificateException
-     * @throws FileNotFoundException
-     * @throws ClassNotFoundException
-     * @throws IOException
+     * @tests serialization/deserialization compatibility with RI.
      */
-    public final void testSerialization02()
-        throws CertificateException,
-               FileNotFoundException,
-               IOException,
-               ClassNotFoundException {
-        CertificateFactory cf = null;
-        try {
-            cf = CertificateFactory.getInstance(certType);
-        } catch (CertificateException e) {
-            fail(getName() +
-                    ": PASSED (could not create CertificateFactory): " + e);
-            return;
-        }
-        // Create object to be compared to deserialized one
-        Certificate c1 = cf.generateCertificate(new ByteArrayInputStream(
+    public void testSerializationCompatibility() throws Exception {
+
+        CertificateFactory cf = CertificateFactory.getInstance(certType);
+
+        Certificate cert = cf.generateCertificate(new ByteArrayInputStream(
                 TestUtils.getEncodedX509Certificate()));
-        // Deserialize certificate from golden file
-        Certificate c2 = deserialize(new FileInputStream(serializedCertFileName));
-        // compare both Certificates
-        assertTrue(c1.equals(c2) && c2.equals(c1));
+
+        SerializationTest.verifyGolden(this, cert);
     }
 
     /**
      * Test for <code>Certificate.CertificateRep.readResolve()</code> method<br>
-     *
-     * Assertion: ObjectStreamException if a <code>CertPath</code>
-     * could not be constructed
+     * 
+     * Assertion: ObjectStreamException if a <code>CertPath</code> could not
+     * be constructed
      * 
      * @throws CertificateException
      * @throws IOException



Mime
View raw message