You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/06/20 10:11:19 UTC
svn commit: r415555 [9/17] - in
/incubator/harmony/enhanced/classlib/trunk/modules/security: make/common/
src/test/api/java.injected/java/security/acl/
src/test/api/java.injected/java/security/cert/
src/test/api/java.injected/java/security/interfaces/ ...
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXBuilderParametersTest.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/PKIXBuilderParametersTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXBuilderParametersTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXBuilderParametersTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java Tue Jun 20 01:11:04 2006
@@ -1,375 +1,183 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Vladimir N. Molotkov
-* @version $Revision$
-*/
-
-package java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PKIXBuilderParameters</code> fields and methods
- *
- */
-public class PKIXBuilderParametersTest extends TestCase {
- private static final int DEFAULT_MAX_PATH_LEN = 5;
-
- /**
- * Constructor for PKIXBuilderParametersTest.
- * @param name
- */
- public PKIXBuilderParametersTest(String name) {
- super(name);
- }
-
- /**
- * Test #1 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- * @throws InvalidAlgorithmParameterException
- */
- public final void testPKIXBuilderParametersSetCertSelector01()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- // both parameters are valid and non-null
- PKIXParameters p =
- new PKIXBuilderParameters(taSet, new X509CertSelector());
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNotNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #2 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- * @throws InvalidAlgorithmParameterException
- */
- public final void testPKIXBuilderParametersSetCertSelector02()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p = new PKIXBuilderParameters(taSet, null);
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #3 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: ... the <code>Set</code> is copied to protect against
- * subsequent modifications
- * @throws InvalidAlgorithmParameterException
- */
- public final void testPKIXBuilderParametersSetCertSelector03()
- throws InvalidAlgorithmParameterException {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
- HashSet originalSet = (HashSet)taSet;
- HashSet originalSetCopy = (HashSet)originalSet.clone();
- // create test object using originalSet
- PKIXBuilderParameters pp =
- new PKIXBuilderParameters(originalSetCopy, null);
- // modify originalSet
- originalSetCopy.clear();
- // check that test object's internal state
- // has not been affected by the above modification
- Set returnedSet = pp.getTrustAnchors();
- assertEquals(originalSet, returnedSet);
- }
-
- /**
- * Test #4 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>NullPointerException</code> -
- * if the specified <code>Set</code> is null
- */
- public final void testPKIXBuilderParametersSetCertSelector04() throws Exception {
- try {
- // pass null
- new PKIXBuilderParameters((Set)null, null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the specified <code>Set</code> is empty
- * (<code>trustAnchors.isEmpty() == true</code>)
- */
- public final void testPKIXBuilderParametersSetCertSelector05() {
- try {
- // use empty set
- new PKIXBuilderParameters(new HashSet(), null);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test #6 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>ClassCastException</code> -
- * if any of the elements in the <code>Set</code> are not of type
- * <code>java.security.cert.TrustAnchor</code>
- */
- public final void testPKIXBuilderParametersSetCertSelector06() throws Exception {
- Set taSet = TestUtils.getTrustAnchorSet();
- if (taSet == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor set)");
- }
-
- // add wrong object to valid set
- assertTrue(taSet.add(new Object()));
-
- try {
- new PKIXBuilderParameters(taSet, null);
- fail("ClassCastException expected");
- } catch (ClassCastException e) {
- }
- }
-
- /**
- * Test #1 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid and non-null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, new X509CertSelector());
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNotNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #2 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector02()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, null);
- assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
- assertNull("certSelector", p.getTargetCertConstraints());
- }
-
- /**
- * Test #3 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: Only keystore entries that contain trusted
- * <code>X509Certificates</code> are considered; all other
- * certificate types are ignored
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector03()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // both parameters are valid but CertSelector is null
- PKIXParameters p =
- new PKIXBuilderParameters(ks, null);
- assertTrue("instanceof", p instanceof PKIXBuilderParameters);
- assertEquals("size", 1, p.getTrustAnchors().size());
- }
-
- /**
- * Test #4 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>NullPointerException</code> -
- * if the <code>keystore</code> is <code>null</code>
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector04() throws Exception {
- try {
- // pass null
- new PKIXBuilderParameters((KeyStore)null, null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>KeyStoreException</code> -
- * if the <code>keystore</code> has not been initialized
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector05() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(false, 0);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass not initialized KeyStore
- new PKIXBuilderParameters(ks, null);
- fail("KeyStoreException expected");
- } catch (KeyStoreException e) {
- }
- }
-
- /**
- * Test #6 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
- * constructor<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the <code>keystore</code> does not contain at least one
- * trusted certificate entry
- */
- public final void testPKIXBuilderParametersKeyStoreCertSelector06() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- return;
- }
-
- try {
- // pass KeyStore that does not contain trusted certificates
- new PKIXBuilderParameters(ks, null);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
- * Test for <code>getMaxPathLength()</code> method<br>
- * Assertion: The default maximum path length, if not specified, is 5
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- */
- public final void testGetMaxPathLength01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
- assertEquals(DEFAULT_MAX_PATH_LEN, p.getMaxPathLength());
- }
-
- /**
- * Test #1 for <code>setMaxPathLength(int)</code> method<br>
- * Assertion: sets the maximum number of non-self-signed certificates
- * in the cert path
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- */
- public final void testSetMaxPathLength01()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- // all these VALID maxPathLength values must be
- // set (and get) without exceptions
- int[] testPathLength = new int[] {-1, 0, 1, 999, Integer.MAX_VALUE};
- for (int i=0; i<testPathLength.length; i++) {
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
- p.setMaxPathLength(testPathLength[i]);
- assertEquals("i="+i, testPathLength[i], p.getMaxPathLength());
- }
- }
-
- /**
- * Test #2 for <code>setMaxPathLength(int)</code> method<br>
- * Assertion: throws InvalidParameterException if parameter is
- * less than -1
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testSetMaxPathLength02()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null);
-
- try {
- // pass parameter less than -1
- p.setMaxPathLength(Integer.MIN_VALUE);
- fail("InvalidParameterException expected");
- } catch (InvalidParameterException e) {
- }
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: returns string describing this object
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testToString()
- throws KeyStoreException,
- InvalidAlgorithmParameterException {
- KeyStore ks = TestUtils.getKeyStore(true,TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
- PKIXBuilderParameters p =
- new PKIXBuilderParameters(ks, new X509CertSelector());
- String rep = p.toString();
-
- assertNotNull(rep);
- }
-
-}
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyStore;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509CertSelector;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>PKIXBuilderParameters</code> fields and methods
+ *
+ */
+public class PKIXBuilderParametersTest extends TestCase {
+ private static final int DEFAULT_MAX_PATH_LEN = 5;
+
+ /**
+ * Constructor for PKIXBuilderParametersTest.
+ * @param name
+ */
+ public PKIXBuilderParametersTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Test #1 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
+ * constructor<br>
+ * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
+ * @throws InvalidAlgorithmParameterException
+ */
+ public final void testPKIXBuilderParametersSetCertSelector01()
+ throws InvalidAlgorithmParameterException {
+ Set taSet = TestUtils.getTrustAnchorSet();
+ if (taSet == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor set)");
+ }
+ // both parameters are valid and non-null
+ PKIXParameters p =
+ new PKIXBuilderParameters(taSet, new X509CertSelector());
+ assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
+ assertNotNull("certSelector", p.getTargetCertConstraints());
+ }
+
+ /**
+ * Test #2 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
+ * constructor<br>
+ * Assertion: creates an instance of <code>PKIXBuilderParameters</code>
+ * @throws InvalidAlgorithmParameterException
+ */
+ public final void testPKIXBuilderParametersSetCertSelector02()
+ throws InvalidAlgorithmParameterException {
+ Set taSet = TestUtils.getTrustAnchorSet();
+ if (taSet == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor set)");
+ }
+ // both parameters are valid but CertSelector is null
+ PKIXParameters p = new PKIXBuilderParameters(taSet, null);
+ assertTrue("instanceOf", p instanceof PKIXBuilderParameters);
+ assertNull("certSelector", p.getTargetCertConstraints());
+ }
+
+ /**
+ * Test #3 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
+ * constructor<br>
+ * Assertion: ... the <code>Set</code> is copied to protect against
+ * subsequent modifications
+ * @throws InvalidAlgorithmParameterException
+ */
+ public final void testPKIXBuilderParametersSetCertSelector03()
+ throws InvalidAlgorithmParameterException {
+ Set taSet = TestUtils.getTrustAnchorSet();
+ if (taSet == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor set)");
+ }
+ HashSet originalSet = (HashSet)taSet;
+ HashSet originalSetCopy = (HashSet)originalSet.clone();
+ // create test object using originalSet
+ PKIXBuilderParameters pp =
+ new PKIXBuilderParameters(originalSetCopy, null);
+ // modify originalSet
+ originalSetCopy.clear();
+ // check that test object's internal state
+ // has not been affected by the above modification
+ Set returnedSet = pp.getTrustAnchors();
+ assertEquals(originalSet, returnedSet);
+ }
+
+ /**
+ * Test #4 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
+ * constructor<br>
+ * Assertion: <code>NullPointerException</code> -
+ * if the specified <code>Set</code> is null
+ */
+ public final void testPKIXBuilderParametersSetCertSelector04() throws Exception {
+ try {
+ // pass null
+ new PKIXBuilderParameters((Set)null, null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ /**
+ * Test #5 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
+ * constructor<br>
+ * Assertion: <code>InvalidAlgorithmParameterException</code> -
+ * if the specified <code>Set</code> is empty
+ * (<code>trustAnchors.isEmpty() == true</code>)
+ */
+ public final void testPKIXBuilderParametersSetCertSelector05() {
+ try {
+ // use empty set
+ new PKIXBuilderParameters(new HashSet(), null);
+ fail("InvalidAlgorithmParameterException expected");
+ } catch (InvalidAlgorithmParameterException e) {
+ }
+ }
+
+ /**
+ * Test #6 for <code>PKIXBuilderParameters(Set, CertSelector)</code>
+ * constructor<br>
+ * Assertion: <code>ClassCastException</code> -
+ * if any of the elements in the <code>Set</code> are not of type
+ * <code>java.security.cert.TrustAnchor</code>
+ */
+ public final void testPKIXBuilderParametersSetCertSelector06() throws Exception {
+ Set taSet = TestUtils.getTrustAnchorSet();
+ if (taSet == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor set)");
+ }
+
+ // add wrong object to valid set
+ assertTrue(taSet.add(new Object()));
+
+ try {
+ new PKIXBuilderParameters(taSet, null);
+ fail("ClassCastException expected");
+ } catch (ClassCastException e) {
+ }
+ }
+
+ /**
+ * Test #4 for <code>PKIXBuilderParameters(KeyStore, CertSelector)</code>
+ * constructor<br>
+ * Assertion: <code>NullPointerException</code> -
+ * if the <code>keystore</code> is <code>null</code>
+ */
+ public final void testPKIXBuilderParametersKeyStoreCertSelector04() throws Exception {
+ try {
+ // pass null
+ new PKIXBuilderParameters((KeyStore)null, null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathBuilderResultTest.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/PKIXCertPathBuilderResultTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathBuilderResultTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathBuilderResultTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java Tue Jun 20 01:11:04 2006
@@ -1,236 +1,239 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Vladimir N. Molotkov
-* @version $Revision$
-*/
-
-package java.security.cert;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
-
-import org.apache.harmony.security.tests.support.cert.MyCertPath;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PKIXCertPathBuilderResult</code>
- *
- */
-public class PKIXCertPathBuilderResultTest extends TestCase {
- /**
- * Cert path encoding stub
- */
- private static final byte[] testEncoding = new byte[] {
- (byte)1, (byte)2, (byte)3, (byte)4, (byte)5
- };
-
- /**
- * PublicKey stub
- */
- private static PublicKey testPublicKey = new PublicKey() {
- public String getAlgorithm() {
- return "NeverMind";
- }
- public String getFormat() {
- return "NeverMind";
- }
- public byte[] getEncoded() {
- return new byte[] {};
- }
- };
-
-
- /**
- * Constructor for PKIXCertPathBuilderResultTest.
- * @param name
- */
- public PKIXCertPathBuilderResultTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testPKIXCertPathBuilderResult01()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
- assertTrue(r instanceof PKIXCertPathBuilderResult);
- }
-
- /**
- * Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: plicy tree parameter may be <code>null</code>
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testPKIXCertPathBuilderResult02()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- null,
- testPublicKey);
- assertTrue(r instanceof PKIXCertPathBuilderResult);
- }
-
- /**
- * Test #3 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code>
- * if certPath is <code>null</code>
- */
- public final void testPKIXCertPathBuilderResult03() {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- try {
- // pass null
- new PKIXCertPathBuilderResult(
- null,
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code>
- * if trustAnchor is <code>null</code>
- */
- public final void testPKIXCertPathBuilderResult04() {
- try {
- // pass null
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- null,
- TestUtils.getPolicyTree(),
- testPublicKey);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code>
- * if publicKey is <code>null</code>
- */
- public final void testPKIXCertPathBuilderResult05() {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- try {
- // pass null
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- TestUtils.getPolicyTree(),
- null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test for <code>getCertPath()</code> method<br>
- * Assertion: the built and validated <code>CertPath</code>
- * (never <code>null</code>)
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetCertPath() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- CertPath cp = new MyCertPath(testEncoding);
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- cp,
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- // must return the same reference
- // as passed to the constructor
- assertSame(cp, r.getCertPath());
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: the printable representation of this object
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testToString()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- CertPathBuilderResult r =
- new PKIXCertPathBuilderResult(
- new MyCertPath(testEncoding),
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- assertNotNull(r.toString());
- }
-
-}
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.PublicKey;
+import java.security.cert.CertPath;
+import java.security.cert.CertPathBuilderResult;
+import java.security.cert.PKIXCertPathBuilderResult;
+import java.security.cert.TrustAnchor;
+import java.security.spec.InvalidKeySpecException;
+
+import org.apache.harmony.security.tests.support.cert.MyCertPath;
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>PKIXCertPathBuilderResult</code>
+ *
+ */
+public class PKIXCertPathBuilderResultTest extends TestCase {
+ /**
+ * Cert path encoding stub
+ */
+ private static final byte[] testEncoding = new byte[] {
+ (byte)1, (byte)2, (byte)3, (byte)4, (byte)5
+ };
+
+ /**
+ * PublicKey stub
+ */
+ private static PublicKey testPublicKey = new PublicKey() {
+ public String getAlgorithm() {
+ return "NeverMind";
+ }
+ public String getFormat() {
+ return "NeverMind";
+ }
+ public byte[] getEncoded() {
+ return new byte[] {};
+ }
+ };
+
+
+ /**
+ * Constructor for PKIXCertPathBuilderResultTest.
+ * @param name
+ */
+ public PKIXCertPathBuilderResultTest(String name) {
+ super(name);
+ }
+
+ //
+ // Tests
+ //
+
+ /**
+ * Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testPKIXCertPathBuilderResult01()
+ throws InvalidKeySpecException,
+ NoSuchAlgorithmException {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+ CertPathBuilderResult r =
+ new PKIXCertPathBuilderResult(
+ new MyCertPath(testEncoding),
+ ta,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+ assertTrue(r instanceof PKIXCertPathBuilderResult);
+ }
+
+ /**
+ * Test #2 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: plicy tree parameter may be <code>null</code>
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testPKIXCertPathBuilderResult02()
+ throws InvalidKeySpecException,
+ NoSuchAlgorithmException {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+ CertPathBuilderResult r =
+ new PKIXCertPathBuilderResult(
+ new MyCertPath(testEncoding),
+ ta,
+ null,
+ testPublicKey);
+ assertTrue(r instanceof PKIXCertPathBuilderResult);
+ }
+
+ /**
+ * Test #3 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: <code>NullPointerException</code>
+ * if certPath is <code>null</code>
+ */
+ public final void testPKIXCertPathBuilderResult03() {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ try {
+ // pass null
+ new PKIXCertPathBuilderResult(
+ null,
+ ta,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+ fail("NPE expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ /**
+ * Test #4 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: <code>NullPointerException</code>
+ * if trustAnchor is <code>null</code>
+ */
+ public final void testPKIXCertPathBuilderResult04() {
+ try {
+ // pass null
+ new PKIXCertPathBuilderResult(
+ new MyCertPath(testEncoding),
+ null,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+ fail("NPE expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ /**
+ * Test #5 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: <code>NullPointerException</code>
+ * if publicKey is <code>null</code>
+ */
+ public final void testPKIXCertPathBuilderResult05() {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ try {
+ // pass null
+ new PKIXCertPathBuilderResult(
+ new MyCertPath(testEncoding),
+ ta,
+ TestUtils.getPolicyTree(),
+ null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ /**
+ * Test for <code>getCertPath()</code> method<br>
+ * Assertion: the built and validated <code>CertPath</code>
+ * (never <code>null</code>)
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testGetCertPath() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ CertPath cp = new MyCertPath(testEncoding);
+ CertPathBuilderResult r =
+ new PKIXCertPathBuilderResult(
+ cp,
+ ta,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+
+ // must return the same reference
+ // as passed to the constructor
+ assertSame(cp, r.getCertPath());
+ }
+
+ /**
+ * Test for <code>toString()</code> method<br>
+ * Assertion: the printable representation of this object
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testToString()
+ throws InvalidKeySpecException,
+ NoSuchAlgorithmException {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+ CertPathBuilderResult r =
+ new PKIXCertPathBuilderResult(
+ new MyCertPath(testEncoding),
+ ta,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+
+ assertNotNull(r.toString());
+ }
+
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathCheckerTest.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/PKIXCertPathCheckerTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathCheckerTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathCheckerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathCheckerTest.java Tue Jun 20 01:11:04 2006
@@ -1,84 +1,85 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Vladimir N. Molotkov
-* @version $Revision$
-*/
-
-package java.security.cert;
-
-import java.util.HashSet;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PKIXCertPathChecker</code>
- *
- */
-public class PKIXCertPathCheckerTest extends TestCase {
-
- /**
- * Constructor for PKIXCertPathCheckerTest.
- * @param name
- */
- public PKIXCertPathCheckerTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- public final void testClone() {
- PKIXCertPathChecker pc1 = TestUtils.getTestCertPathChecker();
- PKIXCertPathChecker pc2 = (PKIXCertPathChecker) pc1.clone();
- assertNotSame("notSame", pc1, pc2);
- }
-
- //
- // the following tests just call methods
- // that are abstract in <code>PKIXCertPathChecker</code>
- // (So they just like signature tests)
- //
-
- public final void testIsForwardCheckingSupported() {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.isForwardCheckingSupported();
- }
-
- public final void testInit()
- throws CertPathValidatorException {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.init(true);
- }
-
- public final void testGetSupportedExtensions() {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.getSupportedExtensions();
- }
-
- public final void testCheck()
- throws CertPathValidatorException {
- PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
- pc.check(new MyCertificate("", null), new HashSet());
- }
-
-}
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.PKIXCertPathChecker;
+import java.util.HashSet;
+
+import org.apache.harmony.security.tests.support.cert.MyCertificate;
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>PKIXCertPathChecker</code>
+ *
+ */
+public class PKIXCertPathCheckerTest extends TestCase {
+
+ /**
+ * Constructor for PKIXCertPathCheckerTest.
+ * @param name
+ */
+ public PKIXCertPathCheckerTest(String name) {
+ super(name);
+ }
+
+ //
+ // Tests
+ //
+
+ public final void testClone() {
+ PKIXCertPathChecker pc1 = TestUtils.getTestCertPathChecker();
+ PKIXCertPathChecker pc2 = (PKIXCertPathChecker) pc1.clone();
+ assertNotSame("notSame", pc1, pc2);
+ }
+
+ //
+ // the following tests just call methods
+ // that are abstract in <code>PKIXCertPathChecker</code>
+ // (So they just like signature tests)
+ //
+
+ public final void testIsForwardCheckingSupported() {
+ PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
+ pc.isForwardCheckingSupported();
+ }
+
+ public final void testInit()
+ throws CertPathValidatorException {
+ PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
+ pc.init(true);
+ }
+
+ public final void testGetSupportedExtensions() {
+ PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
+ pc.getSupportedExtensions();
+ }
+
+ public final void testCheck()
+ throws CertPathValidatorException {
+ PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
+ pc.check(new MyCertificate("", null), new HashSet());
+ }
+
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathValidatorResultTest.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/PKIXCertPathValidatorResultTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathValidatorResultTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXCertPathValidatorResultTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathValidatorResultTest.java Tue Jun 20 01:11:04 2006
@@ -1,314 +1,316 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Vladimir N. Molotkov
-* @version $Revision$
-*/
-
-package java.security.cert;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.spec.InvalidKeySpecException;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PKIXCertPathValidatorResult</code>
- *
- */
-public class PKIXCertPathValidatorResultTest extends TestCase {
- /**
- * PublicKey stub
- */
- private static PublicKey testPublicKey = new PublicKey() {
- public String getAlgorithm() {
- return "NeverMind";
- }
- public String getFormat() {
- return "NeverMind";
- }
- public byte[] getEncoded() {
- return new byte[] {};
- }
- };
-
- /**
- * Constructor for PKIXCertPathValidatorResultTest.
- * @param name
- */
- public PKIXCertPathValidatorResultTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
-
- /**
- * Test #1 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: creates an instance of
- * <code>PKIXCertPathValidatorResult</code>
- *
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testPKIXCertPathValidatorResult01()
- throws InvalidKeySpecException,
- NoSuchAlgorithmException {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
- }
-
- /**
- * Test #2 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if
- * <code>TrustAnchor</code> parameter is <code>null</code>
- */
- public final void testPKIXCertPathValidatorResult02() {
- try {
- // pass null
- new PKIXCertPathValidatorResult(
- null,
- TestUtils.getPolicyTree(),
- testPublicKey);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #3 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>NullPointerException</code> if
- * <code>PublicKey</code> parameter is <code>null</code>
- */
- public final void testPKIXCertPathValidatorResult03() {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
- try {
- // pass null
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- null);
- fail("NPE expected");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * Test #4 for <code>PKIXCertPathValidatorResult(TrustAnchor,
- * PolicyNode, PublicKey)</code> constructor<br>
- * Assertion: <code>PolicyNode</code>can be <code>null</code>
- */
- public final void testPKIXCertPathValidatorResult04() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
- }
-
- /**
- * Test for <code>getTrustAnchor()</code> method<br>
- * Assertion: returns <code>TrustAnchor</code> (never <code>null</code>)
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetTrustAnchor() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertSame(ta, vr.getTrustAnchor());
- }
-
- /**
- * Test for <code>getPublicKey()</code> method<br>
- * Assertion: returns the subject's public key (never <code>null</code>)
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetPublicKey() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PublicKey pk = testPublicKey;
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- pk);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertSame(pk, vr.getPublicKey());
- }
-
- /**
- * Test for <code>getPolicyTree()</code> method<br>
- * Assertion: returns the root node of the valid
- * policy tree or <code>null</code> if there are
- * no valid policies
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetPolicyTree01() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- // valid policy tree case;
- PolicyNode pn = TestUtils.getPolicyTree();
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- pn,
- testPublicKey);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertSame(pn, vr.getPolicyTree());
- }
-
- /**
- * Test for <code>getPolicyTree()</code> method<br>
- * Assertion: returns the root node of the valid
- * policy tree or <code>null</code> if there are
- * no valid policies
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testGetPolicyTree02() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- // no valid policy tree case (null)
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
-
- // must return the same reference passed
- // as a parameter to the constructor
- assertNull(vr.getPolicyTree());
- }
-
- /**
- * Test for <code>clone()</code> method<br>
- * Assertion: returns a copy of this object
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testClone() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr1 =
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- PKIXCertPathValidatorResult vr2 =
- (PKIXCertPathValidatorResult) vr1.clone();
-
- // check that method makes shallow copy
- assertNotSame("notSame", vr1, vr2);
- assertSame("trustAncor", vr1.getTrustAnchor(), vr2.getTrustAnchor());
- assertSame("policyTree", vr1.getPolicyTree(), vr2.getPolicyTree());
- assertSame("publicKey", vr1.getPublicKey(), vr2.getPublicKey());
- }
-
- /**
- * Test #1 for <code>toString()</code> method<br>
- * Assertion: Returns a formatted string describing this object
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testToString01() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- TestUtils.getPolicyTree(),
- testPublicKey);
-
- assertNotNull(vr.toString());
- }
-
- /**
- * Test #2 for <code>toString()</code> method<br>
- * Assertion: Returns a formatted string describing this object
- * @throws NoSuchAlgorithmException
- * @throws InvalidKeySpecException
- */
- public final void testToString02() throws Exception {
- TrustAnchor ta = TestUtils.getTrustAnchor();
- if (ta == null) {
- fail(getName() + ": not performed (could not create test TrustAnchor)");
- }
-
- PKIXCertPathValidatorResult vr =
- new PKIXCertPathValidatorResult(
- ta,
- null,
- testPublicKey);
-
- assertNotNull(vr.toString());
- }
-
-}
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.PublicKey;
+import java.security.cert.PKIXCertPathValidatorResult;
+import java.security.cert.PolicyNode;
+import java.security.cert.TrustAnchor;
+import java.security.spec.InvalidKeySpecException;
+
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>PKIXCertPathValidatorResult</code>
+ *
+ */
+public class PKIXCertPathValidatorResultTest extends TestCase {
+ /**
+ * PublicKey stub
+ */
+ private static PublicKey testPublicKey = new PublicKey() {
+ public String getAlgorithm() {
+ return "NeverMind";
+ }
+ public String getFormat() {
+ return "NeverMind";
+ }
+ public byte[] getEncoded() {
+ return new byte[] {};
+ }
+ };
+
+ /**
+ * Constructor for PKIXCertPathValidatorResultTest.
+ * @param name
+ */
+ public PKIXCertPathValidatorResultTest(String name) {
+ super(name);
+ }
+
+ //
+ // Tests
+ //
+
+ /**
+ * Test #1 for <code>PKIXCertPathValidatorResult(TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: creates an instance of
+ * <code>PKIXCertPathValidatorResult</code>
+ *
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testPKIXCertPathValidatorResult01()
+ throws InvalidKeySpecException,
+ NoSuchAlgorithmException {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+ new PKIXCertPathValidatorResult(
+ ta,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+ }
+
+ /**
+ * Test #2 for <code>PKIXCertPathValidatorResult(TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: <code>NullPointerException</code> if
+ * <code>TrustAnchor</code> parameter is <code>null</code>
+ */
+ public final void testPKIXCertPathValidatorResult02() {
+ try {
+ // pass null
+ new PKIXCertPathValidatorResult(
+ null,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+ fail("NPE expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ /**
+ * Test #3 for <code>PKIXCertPathValidatorResult(TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: <code>NullPointerException</code> if
+ * <code>PublicKey</code> parameter is <code>null</code>
+ */
+ public final void testPKIXCertPathValidatorResult03() {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+ try {
+ // pass null
+ new PKIXCertPathValidatorResult(
+ ta,
+ TestUtils.getPolicyTree(),
+ null);
+ fail("NPE expected");
+ } catch (NullPointerException e) {
+ }
+ }
+
+ /**
+ * Test #4 for <code>PKIXCertPathValidatorResult(TrustAnchor,
+ * PolicyNode, PublicKey)</code> constructor<br>
+ * Assertion: <code>PolicyNode</code>can be <code>null</code>
+ */
+ public final void testPKIXCertPathValidatorResult04() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ new PKIXCertPathValidatorResult(
+ ta,
+ null,
+ testPublicKey);
+ }
+
+ /**
+ * Test for <code>getTrustAnchor()</code> method<br>
+ * Assertion: returns <code>TrustAnchor</code> (never <code>null</code>)
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testGetTrustAnchor() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ PKIXCertPathValidatorResult vr =
+ new PKIXCertPathValidatorResult(
+ ta,
+ null,
+ testPublicKey);
+
+ // must return the same reference passed
+ // as a parameter to the constructor
+ assertSame(ta, vr.getTrustAnchor());
+ }
+
+ /**
+ * Test for <code>getPublicKey()</code> method<br>
+ * Assertion: returns the subject's public key (never <code>null</code>)
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testGetPublicKey() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ PublicKey pk = testPublicKey;
+ PKIXCertPathValidatorResult vr =
+ new PKIXCertPathValidatorResult(
+ ta,
+ null,
+ pk);
+
+ // must return the same reference passed
+ // as a parameter to the constructor
+ assertSame(pk, vr.getPublicKey());
+ }
+
+ /**
+ * Test for <code>getPolicyTree()</code> method<br>
+ * Assertion: returns the root node of the valid
+ * policy tree or <code>null</code> if there are
+ * no valid policies
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testGetPolicyTree01() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ // valid policy tree case;
+ PolicyNode pn = TestUtils.getPolicyTree();
+ PKIXCertPathValidatorResult vr =
+ new PKIXCertPathValidatorResult(
+ ta,
+ pn,
+ testPublicKey);
+
+ // must return the same reference passed
+ // as a parameter to the constructor
+ assertSame(pn, vr.getPolicyTree());
+ }
+
+ /**
+ * Test for <code>getPolicyTree()</code> method<br>
+ * Assertion: returns the root node of the valid
+ * policy tree or <code>null</code> if there are
+ * no valid policies
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testGetPolicyTree02() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ // no valid policy tree case (null)
+ PKIXCertPathValidatorResult vr =
+ new PKIXCertPathValidatorResult(
+ ta,
+ null,
+ testPublicKey);
+
+ // must return the same reference passed
+ // as a parameter to the constructor
+ assertNull(vr.getPolicyTree());
+ }
+
+ /**
+ * Test for <code>clone()</code> method<br>
+ * Assertion: returns a copy of this object
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testClone() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ PKIXCertPathValidatorResult vr1 =
+ new PKIXCertPathValidatorResult(
+ ta,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+
+ PKIXCertPathValidatorResult vr2 =
+ (PKIXCertPathValidatorResult) vr1.clone();
+
+ // check that method makes shallow copy
+ assertNotSame("notSame", vr1, vr2);
+ assertSame("trustAncor", vr1.getTrustAnchor(), vr2.getTrustAnchor());
+ assertSame("policyTree", vr1.getPolicyTree(), vr2.getPolicyTree());
+ assertSame("publicKey", vr1.getPublicKey(), vr2.getPublicKey());
+ }
+
+ /**
+ * Test #1 for <code>toString()</code> method<br>
+ * Assertion: Returns a formatted string describing this object
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testToString01() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ PKIXCertPathValidatorResult vr =
+ new PKIXCertPathValidatorResult(
+ ta,
+ TestUtils.getPolicyTree(),
+ testPublicKey);
+
+ assertNotNull(vr.toString());
+ }
+
+ /**
+ * Test #2 for <code>toString()</code> method<br>
+ * Assertion: Returns a formatted string describing this object
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public final void testToString02() throws Exception {
+ TrustAnchor ta = TestUtils.getTrustAnchor();
+ if (ta == null) {
+ fail(getName() + ": not performed (could not create test TrustAnchor)");
+ }
+
+ PKIXCertPathValidatorResult vr =
+ new PKIXCertPathValidatorResult(
+ ta,
+ null,
+ testPublicKey);
+
+ assertNotNull(vr.toString());
+ }
+
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXParametersTest.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/PKIXParametersTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXParametersTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PKIXParametersTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXParametersTest.java Tue Jun 20 01:11:04 2006
@@ -19,13 +19,20 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertStore;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.PKIXCertPathChecker;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509CertSelector;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -36,7 +43,6 @@
import junit.framework.TestCase;
-
/**
* Tests for <code>PKIXParameters</code> fields and methods
*
@@ -153,46 +159,6 @@
}
/**
- * Test #1 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: Creates an instance of <code>PKIXParameters</code>
- * that populates the set of most-trusted CAs from the trusted
- * certificate entries contained in the specified <code>KeyStore</code>
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXParametersKeyStore01() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- // use valid parameter - KeyStore containing
- // only trusted X.509 certificates
- CertPathParameters cpp = new PKIXParameters(ks);
- assertTrue(cpp instanceof PKIXParameters);
- }
-
- /**
- * Test #2 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: Only keystore entries that contain trusted
- * <code>X509Certificates</code> are considered; all other
- * certificate types are ignored
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testPKIXParametersKeyStore02() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- // use valid parameter - KeyStore containing
- // both trusted and untrusted X.509 certificates
- PKIXParameters cpp = new PKIXParameters(ks);
- assertEquals("size", 1, cpp.getTrustAnchors().size());
- }
-
- /**
* Test #3 for <code>PKIXParameters(KeyStore)</code> constructor<br>
* Assertion: <code>NullPointerException</code> -
* if the <code>keystore</code> is <code>null</code>
@@ -209,45 +175,6 @@
}
/**
- * Test #4 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: <code>KeyStoreException</code> -
- * if the <code>keystore</code> has not been initialized
- */
- public final void testPKIXParametersKeyStore04() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(false, 0);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass not initialized KeyStore
- new PKIXParameters(ks);
- fail("KeyStoreException expected");
- } catch (KeyStoreException e) {
- }
- }
-
- /**
- * Test #5 for <code>PKIXParameters(KeyStore)</code> constructor<br>
- * Assertion: <code>InvalidAlgorithmParameterException</code> -
- * if the <code>keystore</code> does not contain at least one
- * trusted certificate entry
- */
- public final void testPKIXParametersKeyStore05() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- try {
- // pass KeyStore that does not contain trusted certificates
- new PKIXParameters(ks);
- fail("InvalidAlgorithmParameterException expected");
- } catch (InvalidAlgorithmParameterException e) {
- }
- }
-
- /**
* Test #1 for <code>getPolicyQualifiersRejected()</code> method<br>
* Assertion: When a <code>PKIXParameters</code> object is created,
* this flag is set to <code>true</code><br>
@@ -1350,163 +1277,6 @@
fail("ClassCastException expected");
} catch (ClassCastException e) {
}
- }
-
- /**
- * Test #5 for <code>setTrustAnchors(Set)</code> method<br>
- * Assertion: <code>Set</code> is copied to protect against
- * subsequent modifications
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testSetTrustAnchors05() throws Exception {
- // use several trusted certs in this test
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p = new PKIXParameters(ks);
- // prepare new Set
- HashSet newSet = new HashSet(p.getTrustAnchors());
- HashSet newSetCopy = (HashSet)newSet.clone();
- // set new Set
- p.setTrustAnchors(newSetCopy);
- // modify set - remove one element
- assertTrue("modified", newSetCopy.remove(newSetCopy.iterator().next()));
- // check that set maintained internally has
- // not been changed by the above modification
- assertEquals("isCopied", newSet, p.getTrustAnchors());
- }
-
- /**
- * Test #1 for <code>clone()</code> method<br>
- * Assertion: Makes a copy of this <code>PKIXParameters</code> object
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- * @throws NoSuchAlgorithmException
- */
- public final void testClone01() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p1 = new PKIXParameters(ks);
- // set to some non-default values
- p1.setPolicyQualifiersRejected(false);
- p1.setAnyPolicyInhibited(true);
- p1.setExplicitPolicyRequired(true);
- p1.setPolicyMappingInhibited(true);
- p1.setRevocationEnabled(false);
-
- String sigProviderName = "Some Provider";
- p1.setSigProvider(sigProviderName);
-
- X509CertSelector x509cs = new X509CertSelector();
- p1.setTargetCertConstraints(x509cs);
-
- p1.setCertStores(TestUtils.getCollectionCertStoresList());
-
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p1.setCertPathCheckers(l);
-
- p1.setDate(new Date(555L));
-
- Set s = new HashSet();
- s.add("1.2.3.4.5.6.7");
- s.add("1.2.3.4.5.6.8");
- p1.setInitialPolicies(s);
-
- // TrustAnchors already set
-
- PKIXParameters p2 = (PKIXParameters)p1.clone();
-
- // check that objects match
- assertEquals("check1", p1.getPolicyQualifiersRejected(),
- p2.getPolicyQualifiersRejected());
- assertEquals("check2", p1.isAnyPolicyInhibited(),
- p2.isAnyPolicyInhibited());
- assertEquals("check3", p1.isExplicitPolicyRequired(),
- p2.isExplicitPolicyRequired());
- assertEquals("check4", p1.isPolicyMappingInhibited(),
- p2.isPolicyMappingInhibited());
- assertEquals("check5", p1.isRevocationEnabled(),
- p2.isRevocationEnabled());
- assertEquals("check6", p1.getSigProvider(), p2.getSigProvider());
-
- // just check that not null
- assertNotNull("check7", p2.getTargetCertConstraints());
-
- assertEquals("check8", p1.getCertStores(), p2.getCertStores());
-
- // just check that not empty
- assertFalse("check9", p2.getCertPathCheckers().isEmpty());
-
- assertEquals("check10", p1.getDate(), p2.getDate());
- assertEquals("check11", p1.getInitialPolicies(),
- p2.getInitialPolicies());
- assertEquals("check12", p1.getTrustAnchors(), p2.getTrustAnchors());
- }
-
- /**
- * Test #2 for <code>clone()</code> method<br>
- * Assertion: Changes to the copy will not affect
- * the original and vice versa
- * @throws KeyStoreException
- * @throws InvalidAlgorithmParameterException
- * @throws NoSuchAlgorithmException
- */
- public final void testClone02() throws Exception {
- PKIXParameters[] p = new PKIXParameters[2];
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- for (int i = 0; i<p.length; i++) {
- p[i] = new PKIXParameters(ks);
-
- p[i].setCertStores(TestUtils.getCollectionCertStoresList());
-
- PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker();
- List l = new ArrayList();
- assertTrue("addedOk", l.add(cpc));
- p[i].setCertPathCheckers(l);
-
- p[i].setDate(new Date(555L));
-
- p[(i == 0 ? 1 : 0)] = (PKIXParameters)p[i].clone();
-
- // modify the first object (original or copy)
- p[1].addCertStore(CertStore.getInstance("Collection",
- new CollectionCertStoreParameters()));
- p[1].addCertPathChecker(TestUtils.getTestCertPathChecker());
- // check that the second object has not been affected by
- // above modification
- assertTrue("certStores["+i+"]",
- p[0].getCertStores().size() == 1);
- assertTrue("certPathCheckers["+i+"]",
- p[0].getCertPathCheckers().size() == 1);
- }
- }
-
- /**
- * Test for <code>toString()</code> method<br>
- * Assertion: Returns a formatted string describing the parameters
- * @throws InvalidAlgorithmParameterException
- * @throws KeyStoreException
- */
- public final void testToString() throws Exception {
- KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED);
- if (ks == null) {
- fail(getName() + ": not performed (could not create test KeyStore)");
- }
-
- PKIXParameters p = new PKIXParameters(ks);
- assertNotNull(p.toString());
}
}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PolicyQualifierInfoTest.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/PolicyQualifierInfoTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PolicyQualifierInfoTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/PolicyQualifierInfoTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PolicyQualifierInfoTest.java Tue Jun 20 01:11:04 2006
@@ -18,13 +18,13 @@
* @version $Revision$
*/
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
import java.io.IOException;
+import java.security.cert.PolicyQualifierInfo;
import java.util.Arrays;
import junit.framework.TestCase;
-
/**
* PolicyQualifierInfo test