harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r488923 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/cert/ test/api/java/org/apache/harmony/security/tests/java/security/cert/
Date Wed, 20 Dec 2006 05:33:36 GMT
Author: smishura
Date: Tue Dec 19 21:33:35 2006
New Revision: 488923

URL: http://svn.apache.org/viewvc?view=rev&rev=488923
Log:
Apply modified patch for HARMONY-2786
([classlib][security]PKIXCertPathValidatorResult fails to implement clone.)

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PKIXCertPathValidatorResult.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PKIXCertPathValidatorResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PKIXCertPathValidatorResult.java?view=diff&rev=488923&r1=488922&r2=488923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PKIXCertPathValidatorResult.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/PKIXCertPathValidatorResult.java
Tue Dec 19 21:33:35 2006
@@ -81,8 +81,12 @@
      * @com.intel.drl.spec_ref
      */
     public Object clone() {
-        return new PKIXCertPathValidatorResult(trustAnchor,
-                policyTree, subjectPublicKey);
+        try {
+            return super.clone();
+        } catch (CloneNotSupportedException e) {
+            // Actually, the exception will not be thrown out.
+            throw new Error(e);
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.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/PKIXCertPathBuilderResultTest.java?view=diff&rev=488923&r1=488922&r2=488923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java
Tue Dec 19 21:33:35 2006
@@ -188,6 +188,25 @@
         }
     }
 
+    public final void test_clone() {
+
+        // Regression for HARMONY-2786.
+        TrustAnchor ta = TestUtils.getTrustAnchor();
+        assertNotNull(getName()
+                + ": not performed (could not create test TrustAnchor)", ta);
+
+        PKIXCertPathBuilderResult init = new PKIXCertPathBuilderResult(
+                new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(),
+                testPublicKey);
+
+        PKIXCertPathBuilderResult clone = (PKIXCertPathBuilderResult) init
+                .clone();
+        assertSame(init.getCertPath(), clone.getCertPath());
+        assertSame(init.getPolicyTree(), clone.getPolicyTree());
+        assertSame(init.getPublicKey(), clone.getPublicKey());
+        assertSame(init.getTrustAnchor(), clone.getTrustAnchor());
+    }
+
     /**
      * Test for <code>getCertPath()</code> method<br>
      * Assertion: the built and validated <code>CertPath</code>

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.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/PKIXCertPathValidatorResultTest.java?view=diff&rev=488923&r1=488922&r2=488923
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java
Tue Dec 19 21:33:35 2006
@@ -29,10 +29,10 @@
 import java.security.cert.TrustAnchor;
 import java.security.spec.InvalidKeySpecException;
 
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
 import junit.framework.TestCase;
 
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
 /**
  * Tests for <code>PKIXCertPathValidatorResult</code>
  * 
@@ -270,6 +270,29 @@
         assertSame("trustAncor", vr1.getTrustAnchor(), vr2.getTrustAnchor());
         assertSame("policyTree", vr1.getPolicyTree(), vr2.getPolicyTree());
         assertSame("publicKey", vr1.getPublicKey(), vr2.getPublicKey());
+
+        // Regression for HARMONY-2786.
+        byte[] encoding = { 0x01 };
+        MyPKIXCertPathBuilderResult my = new MyPKIXCertPathBuilderResult(ta,
+                TestUtils.getPolicyTree(), testPublicKey, encoding);
+        MyPKIXCertPathBuilderResult myClone = (MyPKIXCertPathBuilderResult) my
+                .clone();
+        assertSame(my.getPolicyTree(), myClone.getPolicyTree());
+        assertSame(my.getPublicKey(), myClone.getPublicKey());
+        assertSame(my.getTrustAnchor(), myClone.getTrustAnchor());
+        assertSame(my.enc, myClone.enc);
+    }
+
+    class MyPKIXCertPathBuilderResult extends PKIXCertPathValidatorResult {
+
+        public byte[] enc; // byte array is cloneable
+
+        public MyPKIXCertPathBuilderResult(TrustAnchor trustAnchor,
+                PolicyNode policyTree, PublicKey subjectPublicKey, byte[] enc) {
+            super(trustAnchor, policyTree, subjectPublicKey);
+
+            this.enc = enc;
+        }
     }
 
     /**



Mime
View raw message