harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r432554 - 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 11:26:30 GMT
Author: smishura
Date: Fri Aug 18 04:26:28 2006
New Revision: 432554

URL: http://svn.apache.org/viewvc?rev=432554&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/CertPathTest.java
      - copied, changed from r432548, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertPathTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.golden.ser
      - copied unchanged from r432548, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/java/security/cert/serialization/CertPath.PkiPath.dat
Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertPathTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/java/security/cert/serialization/CertPath.PkiPath.dat

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java
(from r432548, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/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?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertPathTest.java&r1=432548&r2=432554&rev=432554&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/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
Fri Aug 18 04:26:28 2006
@@ -19,12 +19,11 @@
 * @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;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
@@ -35,25 +34,24 @@
 import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-
 import junit.framework.TestCase;
 
+import org.apache.harmony.security.tests.support.cert.MyCertPath;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+
 
 /**
  * Tests for <code>CertPath</code> serialization
  * 
  */
 public class CertPathTest extends TestCase {
-    /**
-     * <code>Certificate/CertPath</code> type to be created during testing
-     */
+
+    //Certificate/CertPath type to be created during testing
     private static final String certType = "X.509";
-    /**
-     * <code>CertPath</code> encoding name, defines input file names
-     * used during testing
-     */
+
+    // CertPath encoding name, defines input file names used during testing
     private static final String certPathEncoding = "PkiPath";
+
     /**
      * Input file name used for <code>CertPath</code> instance generation
      */
@@ -61,88 +59,35 @@
         org.apache.harmony.security.tests.support.TestUtils.TEST_ROOT +
         "java/security/cert/serialization/CertPath." +
         certPathEncoding;
-    /**
-     * Golden file containing serial <code>CertPath</code> stream
-     */
-    private static final String serializedCertPathFileName =
-        certPathFileName + ".dat";
-
-    /**
-     * Constructor for CertPathTest.
-     * @param name
-     */
-    public CertPathTest(String name) {
-        super(name);
-    }
 
     //
     // Tests
     //
 
     /**
-     * Test #1 for <code>CertPath</code> serialization/deserialization.<br>
-     * ByteArray streams used.
-     *
-     * Assertion: original and deserialized objects must be equal
-     * 
-     * @throws CertificateException
-     * @throws IOException
-     * @throws ClassNotFoundException
+     * @tests serialization/deserialization.
      */
-    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
-        CertPath cp1 = cf.generateCertPath(new FileInputStream(certPathFileName));
-        // This testcase uses ByteArray streams
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        // Serialize cert
-        serialize(cp1, bos);
-        // Deserialize it
-        CertPath cp2 = deserialize(new ByteArrayInputStream(bos.toByteArray()));
-        // compare both Certificates
-        assertTrue(cp1.equals(cp2) && cp2.equals(cp1));
+    public void testSerializationSelf() throws Exception {
+
+        CertificateFactory cf = CertificateFactory.getInstance(certType);
+
+        CertPath certPath = cf.generateCertPath(new FileInputStream(
+                certPathFileName));
+
+        SerializationTest.verifySelf(certPath);
     }
 
     /**
-     * Test #2 for <code>CertPath</code> serialization/deserialization.<br>
-     * File input stream with golden content used.
-     *
-     * Assertion: original and deserialized objects must be equal
-     * 
-     * @throws CertificateException
-     * @throws FileNotFoundException
-     * @throws IOException
-     * @throws ClassNotFoundException
+     * @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
-        CertPath cp1 = cf.generateCertPath(new FileInputStream(certPathFileName));
-        // Deserialize CertPath from golden file
-        CertPath cp2 = deserialize(new FileInputStream(serializedCertPathFileName));
-        // compare both Certificates
-        assertTrue(cp1.equals(cp2) && cp2.equals(cp1));
+    public void testSerializationCompatibility() throws Exception {
+
+        CertificateFactory cf = CertificateFactory.getInstance(certType);
+
+        CertPath certPath = cf.generateCertPath(new FileInputStream(
+                certPathFileName));
+
+        SerializationTest.verifyGolden(this, certPath);
     }
 
     /**



Mime
View raw message