Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 78102 invoked from network); 15 Sep 2006 01:20:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Sep 2006 01:20:53 -0000 Received: (qmail 66047 invoked by uid 500); 15 Sep 2006 01:20:43 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 65911 invoked by uid 500); 15 Sep 2006 01:20:42 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 65818 invoked by uid 99); 15 Sep 2006 01:20:42 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2006 18:20:42 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of ndbeyer@apache.org designates 140.211.166.113 as permitted sender) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2006 18:20:28 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 8E02D1A9860; Thu, 14 Sep 2006 18:18:50 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r443539 [20/29] - in /incubator/harmony/enhanced/classlib/trunk/modules/security: ./ .settings/ META-INF/ make/ src/main/java/common/java/security/ src/main/java/common/java/security/acl/ src/main/java/common/java/security/cert/ src/main/ja... Date: Fri, 15 Sep 2006 01:18:16 -0000 To: harmony-commits@incubator.apache.org From: ndbeyer@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060915011850.8E02D1A9860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.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/CertificateFactorySpiTest.java?view=diff&rev=443539&r1=443538&r2=443539 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java Thu Sep 14 18:17:39 2006 @@ -1,289 +1,289 @@ -/* - * 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 Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.security.tests.java.security.cert; - - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.InputStream; -import java.security.cert.CRL; -import java.security.cert.CRLException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactorySpi; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi; - -import junit.framework.TestCase; - -/** - * Tests for CertificateFactorySpi class constructors and methods - * - */ - -public class CertificateFactorySpiTest extends TestCase { - /** - * Constructor for CertStoreSpiTest. - * - * @param arg0 - */ - public CertificateFactorySpiTest(String arg0) { - super(arg0); - } - - /** - * Test for CertificateFactorySpi constructor - * Assertion: constructs CertificateFactorySpi - */ - public void testCertificateFactorySpi01() throws CertificateException, - CRLException { - CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi(); - ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); - try { - certFactorySpi.engineGenerateCertPath(bais); - fail("UnsupportedOperationException must be thrown"); - } catch (UnsupportedOperationException e) { - } - try { - certFactorySpi.engineGenerateCertPath(bais, ""); - fail("UnsupportedOperationException must be thrown"); - } catch (UnsupportedOperationException e) { - } - try { - List list = null; - certFactorySpi.engineGenerateCertPath(list); - fail("UnsupportedOperationException must be thrown"); - } catch (UnsupportedOperationException e) { - } - try { - certFactorySpi.engineGetCertPathEncodings(); - fail("UnsupportedOperationException must be thrown"); - } catch (UnsupportedOperationException e) { - } - Certificate cc = certFactorySpi - .engineGenerateCertificate(bais); - assertNull("Not null Cerificate", cc); - try { - certFactorySpi.engineGenerateCertificate(null); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - Collection col = certFactorySpi - .engineGenerateCertificates(bais); - assertNull("Not null Collection", col); - try { - certFactorySpi.engineGenerateCertificates(null); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - - CRL ccCRL = certFactorySpi.engineGenerateCRL(bais); - assertNull("Not null CRL", ccCRL); - try { - certFactorySpi.engineGenerateCRL(null); - fail("CRLException must be thrown"); - } catch (CRLException e) { - } - - Collection colCRL = certFactorySpi - .engineGenerateCRLs(bais); - assertNull("Not null CRL", colCRL); - try { - certFactorySpi.engineGenerateCRLs(null); - fail("CRLException must be thrown"); - } catch (CRLException e) { - } - } - - /** - * Test for CertificateFactorySpi constructor - * Assertion: constructs CertificateFactorySpi - */ - public void testCertificateFactorySpi02() throws CertificateException, - CRLException { - CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi(); - MyCertificateFactorySpi.putMode(true); - ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); - DataInputStream dis = new DataInputStream(bais); - try { - certFactorySpi.engineGenerateCertPath(bais); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - certFactorySpi.engineGenerateCertPath(dis); - try { - certFactorySpi.engineGenerateCertPath(bais, "aa"); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - try { - certFactorySpi.engineGenerateCertPath(dis, ""); - fail("IllegalArgumentException must be thrown"); - } catch (IllegalArgumentException e) { - } - certFactorySpi.engineGenerateCertPath(dis, "ss"); - - try { - certFactorySpi.engineGenerateCertificate(bais); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - try { - certFactorySpi.engineGenerateCertificates(null); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - Certificate cert = certFactorySpi - .engineGenerateCertificate(dis); - assertNull("Result must be null", cert); - Collection col = certFactorySpi - .engineGenerateCertificates(dis); - assertNull("Result must be null", col); - - try { - certFactorySpi.engineGenerateCRL(bais); - fail("CRLException must be thrown"); - } catch (CRLException e) { - } - try { - certFactorySpi.engineGenerateCRLs(null); - fail("CRLException must be thrown"); - } catch (CRLException e) { - } - CRL crl = certFactorySpi.engineGenerateCRL(dis); - assertNull("Result must be null", crl); - col = certFactorySpi.engineGenerateCRLs(dis); - assertNull("Result must be null", col); - - List list = null; - try { - certFactorySpi.engineGenerateCertPath(list); - fail("NullPointerException must be thrown"); - } catch (NullPointerException e) { - } - Iterator enc = certFactorySpi.engineGetCertPathEncodings(); - assertTrue("Incorrect Iterator", enc.hasNext()); - } - - /** - * Test for CertificateFactorySpi constructor - * Assertion: constructs CertificateFactorySpi - */ - public void testCertificateFactorySpi03() throws CertificateException, - CRLException { - CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi(); - MyCertificateFactorySpi.putMode(false); - ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); - DataInputStream dis = new DataInputStream(bais); - try { - certFactorySpi.engineGenerateCertPath(bais); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - try { - certFactorySpi.engineGenerateCertPath(dis); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - try { - certFactorySpi.engineGenerateCertPath(bais, "aa"); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - certFactorySpi.engineGenerateCertPath(dis, ""); - certFactorySpi.engineGenerateCertPath(dis, "ss"); - - try { - certFactorySpi.engineGenerateCertificate(bais); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - try { - certFactorySpi.engineGenerateCertificates(null); - fail("CertificateException must be thrown"); - } catch (CertificateException e) { - } - Certificate cert = certFactorySpi - .engineGenerateCertificate(dis); - assertNull("Result must be null", cert); - Collection col = certFactorySpi - .engineGenerateCertificates(dis); - assertNull("Result must be null", col); - - try { - certFactorySpi.engineGenerateCRL(bais); - fail("CRLException must be thrown"); - } catch (CRLException e) { - } - try { - certFactorySpi.engineGenerateCRLs(null); - fail("CRLException must be thrown"); - } catch (CRLException e) { - } - CRL crl = certFactorySpi.engineGenerateCRL(dis); - assertNull("Result must be null", crl); - col = certFactorySpi.engineGenerateCRLs(dis); - assertNull("Result must be null", col); - - List list = null; - certFactorySpi.engineGenerateCertPath(list); - Iterator enc = certFactorySpi.engineGetCertPathEncodings(); - assertFalse("Incorrect Iterator", enc.hasNext()); - } - - - private static class extCertificateFactorySpi extends CertificateFactorySpi { - public Certificate engineGenerateCertificate(InputStream inStream) - throws CertificateException { - if (inStream == null) { - throw new CertificateException("InputStream null"); - } - return null; - } - - public Collection engineGenerateCertificates(InputStream inStream) - throws CertificateException { - if (inStream == null) { - throw new CertificateException("InputStream null"); - } - return null; - } - - public CRL engineGenerateCRL(InputStream inStream) throws CRLException { - if (inStream == null) { - throw new CRLException("InputStream null"); - } - return null; - } - - public Collection engineGenerateCRLs(InputStream inStream) - throws CRLException { - if (inStream == null) { - throw new CRLException("InputStream null"); - } - return null; - } - } -} +/* + * 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 Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.security.tests.java.security.cert; + + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.InputStream; +import java.security.cert.CRL; +import java.security.cert.CRLException; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactorySpi; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi; + +import junit.framework.TestCase; + +/** + * Tests for CertificateFactorySpi class constructors and methods + * + */ + +public class CertificateFactorySpiTest extends TestCase { + /** + * Constructor for CertStoreSpiTest. + * + * @param arg0 + */ + public CertificateFactorySpiTest(String arg0) { + super(arg0); + } + + /** + * Test for CertificateFactorySpi constructor + * Assertion: constructs CertificateFactorySpi + */ + public void testCertificateFactorySpi01() throws CertificateException, + CRLException { + CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi(); + ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); + try { + certFactorySpi.engineGenerateCertPath(bais); + fail("UnsupportedOperationException must be thrown"); + } catch (UnsupportedOperationException e) { + } + try { + certFactorySpi.engineGenerateCertPath(bais, ""); + fail("UnsupportedOperationException must be thrown"); + } catch (UnsupportedOperationException e) { + } + try { + List list = null; + certFactorySpi.engineGenerateCertPath(list); + fail("UnsupportedOperationException must be thrown"); + } catch (UnsupportedOperationException e) { + } + try { + certFactorySpi.engineGetCertPathEncodings(); + fail("UnsupportedOperationException must be thrown"); + } catch (UnsupportedOperationException e) { + } + Certificate cc = certFactorySpi + .engineGenerateCertificate(bais); + assertNull("Not null Cerificate", cc); + try { + certFactorySpi.engineGenerateCertificate(null); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + Collection col = certFactorySpi + .engineGenerateCertificates(bais); + assertNull("Not null Collection", col); + try { + certFactorySpi.engineGenerateCertificates(null); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + + CRL ccCRL = certFactorySpi.engineGenerateCRL(bais); + assertNull("Not null CRL", ccCRL); + try { + certFactorySpi.engineGenerateCRL(null); + fail("CRLException must be thrown"); + } catch (CRLException e) { + } + + Collection colCRL = certFactorySpi + .engineGenerateCRLs(bais); + assertNull("Not null CRL", colCRL); + try { + certFactorySpi.engineGenerateCRLs(null); + fail("CRLException must be thrown"); + } catch (CRLException e) { + } + } + + /** + * Test for CertificateFactorySpi constructor + * Assertion: constructs CertificateFactorySpi + */ + public void testCertificateFactorySpi02() throws CertificateException, + CRLException { + CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi(); + MyCertificateFactorySpi.putMode(true); + ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); + DataInputStream dis = new DataInputStream(bais); + try { + certFactorySpi.engineGenerateCertPath(bais); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + certFactorySpi.engineGenerateCertPath(dis); + try { + certFactorySpi.engineGenerateCertPath(bais, "aa"); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + try { + certFactorySpi.engineGenerateCertPath(dis, ""); + fail("IllegalArgumentException must be thrown"); + } catch (IllegalArgumentException e) { + } + certFactorySpi.engineGenerateCertPath(dis, "ss"); + + try { + certFactorySpi.engineGenerateCertificate(bais); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + try { + certFactorySpi.engineGenerateCertificates(null); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + Certificate cert = certFactorySpi + .engineGenerateCertificate(dis); + assertNull("Result must be null", cert); + Collection col = certFactorySpi + .engineGenerateCertificates(dis); + assertNull("Result must be null", col); + + try { + certFactorySpi.engineGenerateCRL(bais); + fail("CRLException must be thrown"); + } catch (CRLException e) { + } + try { + certFactorySpi.engineGenerateCRLs(null); + fail("CRLException must be thrown"); + } catch (CRLException e) { + } + CRL crl = certFactorySpi.engineGenerateCRL(dis); + assertNull("Result must be null", crl); + col = certFactorySpi.engineGenerateCRLs(dis); + assertNull("Result must be null", col); + + List list = null; + try { + certFactorySpi.engineGenerateCertPath(list); + fail("NullPointerException must be thrown"); + } catch (NullPointerException e) { + } + Iterator enc = certFactorySpi.engineGetCertPathEncodings(); + assertTrue("Incorrect Iterator", enc.hasNext()); + } + + /** + * Test for CertificateFactorySpi constructor + * Assertion: constructs CertificateFactorySpi + */ + public void testCertificateFactorySpi03() throws CertificateException, + CRLException { + CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi(); + MyCertificateFactorySpi.putMode(false); + ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); + DataInputStream dis = new DataInputStream(bais); + try { + certFactorySpi.engineGenerateCertPath(bais); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + try { + certFactorySpi.engineGenerateCertPath(dis); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + try { + certFactorySpi.engineGenerateCertPath(bais, "aa"); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + certFactorySpi.engineGenerateCertPath(dis, ""); + certFactorySpi.engineGenerateCertPath(dis, "ss"); + + try { + certFactorySpi.engineGenerateCertificate(bais); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + try { + certFactorySpi.engineGenerateCertificates(null); + fail("CertificateException must be thrown"); + } catch (CertificateException e) { + } + Certificate cert = certFactorySpi + .engineGenerateCertificate(dis); + assertNull("Result must be null", cert); + Collection col = certFactorySpi + .engineGenerateCertificates(dis); + assertNull("Result must be null", col); + + try { + certFactorySpi.engineGenerateCRL(bais); + fail("CRLException must be thrown"); + } catch (CRLException e) { + } + try { + certFactorySpi.engineGenerateCRLs(null); + fail("CRLException must be thrown"); + } catch (CRLException e) { + } + CRL crl = certFactorySpi.engineGenerateCRL(dis); + assertNull("Result must be null", crl); + col = certFactorySpi.engineGenerateCRLs(dis); + assertNull("Result must be null", col); + + List list = null; + certFactorySpi.engineGenerateCertPath(list); + Iterator enc = certFactorySpi.engineGetCertPathEncodings(); + assertFalse("Incorrect Iterator", enc.hasNext()); + } + + + private static class extCertificateFactorySpi extends CertificateFactorySpi { + public Certificate engineGenerateCertificate(InputStream inStream) + throws CertificateException { + if (inStream == null) { + throw new CertificateException("InputStream null"); + } + return null; + } + + public Collection engineGenerateCertificates(InputStream inStream) + throws CertificateException { + if (inStream == null) { + throw new CertificateException("InputStream null"); + } + return null; + } + + public CRL engineGenerateCRL(InputStream inStream) throws CRLException { + if (inStream == null) { + throw new CRLException("InputStream null"); + } + return null; + } + + public Collection engineGenerateCRLs(InputStream inStream) + throws CRLException { + if (inStream == null) { + throw new CRLException("InputStream null"); + } + return null; + } + } +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactorySpiTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.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/CertificateNotYetValidExceptionTest.java?view=diff&rev=443539&r1=443538&r2=443539 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java Thu Sep 14 18:17:39 2006 @@ -1,114 +1,114 @@ -/* - * 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 Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.security.tests.java.security.cert; - -import java.security.cert.CertificateNotYetValidException; - -import junit.framework.TestCase; - - -/** - * Tests for DigestException class constructors and methods. - * - */ -public class CertificateNotYetValidExceptionTest extends TestCase { - - public static void main(String[] args) { - } - - /** - * Constructor for CertificateNotYetValidExceptionTests. - * - * @param arg0 - */ - public CertificateNotYetValidExceptionTest(String arg0) { - super(arg0); - } - - static String[] msgs = { - "", - "Check new message", - "Check new message Check new message Check new message Check new message Check new message" }; - - static Throwable tCause = new Throwable("Throwable for exception"); - - static String createErr(Exception tE, Exception eE) { - return "CertificateNotYetValidException: ".concat(tE.toString()) - .concat(" is not equal to caught exception: ").concat( - eE.toString()); - } - - /** - * Test for CertificateNotYetValidException() constructor - * Assertion: constructs CertificateNotYetValidException with no detail - * message - */ - public void testCertificateNotYetValidException01() { - CertificateNotYetValidException tE = new CertificateNotYetValidException(); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for CertificateNotYetValidException(String) - * constructor Assertion: constructs CertificateNotYetValidException with - * detail message msg. Parameter msg is not null. - */ - public void testCertificateNotYetValidException02() { - CertificateNotYetValidException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new CertificateNotYetValidException(msgs[i]); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - } - - /** - * Test for CertificateNotYetValidException(String) - * constructor Assertion: constructs CertificateNotYetValidException when - * msg is null - */ - public void testCertificateNotYetValidException03() { - String msg = null; - CertificateNotYetValidException tE = new CertificateNotYetValidException( - msg); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - -} +/* + * 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 Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.security.tests.java.security.cert; + +import java.security.cert.CertificateNotYetValidException; + +import junit.framework.TestCase; + + +/** + * Tests for DigestException class constructors and methods. + * + */ +public class CertificateNotYetValidExceptionTest extends TestCase { + + public static void main(String[] args) { + } + + /** + * Constructor for CertificateNotYetValidExceptionTests. + * + * @param arg0 + */ + public CertificateNotYetValidExceptionTest(String arg0) { + super(arg0); + } + + static String[] msgs = { + "", + "Check new message", + "Check new message Check new message Check new message Check new message Check new message" }; + + static Throwable tCause = new Throwable("Throwable for exception"); + + static String createErr(Exception tE, Exception eE) { + return "CertificateNotYetValidException: ".concat(tE.toString()) + .concat(" is not equal to caught exception: ").concat( + eE.toString()); + } + + /** + * Test for CertificateNotYetValidException() constructor + * Assertion: constructs CertificateNotYetValidException with no detail + * message + */ + public void testCertificateNotYetValidException01() { + CertificateNotYetValidException tE = new CertificateNotYetValidException(); + assertNull("getMessage() must return null.", tE.getMessage()); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + + /** + * Test for CertificateNotYetValidException(String) + * constructor Assertion: constructs CertificateNotYetValidException with + * detail message msg. Parameter msg is not null. + */ + public void testCertificateNotYetValidException02() { + CertificateNotYetValidException tE; + for (int i = 0; i < msgs.length; i++) { + tE = new CertificateNotYetValidException(msgs[i]); + assertEquals("getMessage() must return: ".concat(msgs[i]), tE + .getMessage(), msgs[i]); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + } + + /** + * Test for CertificateNotYetValidException(String) + * constructor Assertion: constructs CertificateNotYetValidException when + * msg is null + */ + public void testCertificateNotYetValidException03() { + String msg = null; + CertificateNotYetValidException tE = new CertificateNotYetValidException( + msg); + assertNull("getMessage() must return null.", tE.getMessage()); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateNotYetValidExceptionTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.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/CertificateParsingExceptionTest.java?view=diff&rev=443539&r1=443538&r2=443539 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java Thu Sep 14 18:17:39 2006 @@ -1,243 +1,243 @@ -/* - * 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 Vera Y. Petrashkova -* @version $Revision$ -*/ - -package org.apache.harmony.security.tests.java.security.cert; - -import java.security.cert.CertificateParsingException; - -import junit.framework.TestCase; - - -/** - * Tests for CertificateParsingException class constructors and - * methods. - * - */ -public class CertificateParsingExceptionTest extends TestCase { - - public static void main(String[] args) { - } - - /** - * Constructor for CertificateParsingExceptionTests. - * - * @param arg0 - */ - public CertificateParsingExceptionTest(String arg0) { - super(arg0); - } - - private static String[] msgs = { - "", - "Check new message", - "Check new message Check new message Check new message Check new message Check new message" }; - - private static Throwable tCause = new Throwable("Throwable for exception"); - - static String createErr(Exception tE, Exception eE) { - return "CertificateParsingException: ".concat(tE.toString()).concat( - " is not equal to caught exception: ").concat(eE.toString()); - } - - /** - * Test for CertificateParsingException() constructor - * Assertion: constructs CertificateParsingException with no detail message - */ - public void testCertificateParsingException01() { - CertificateParsingException tE = new CertificateParsingException(); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for CertificateParsingException(String) constructor - * Assertion: constructs CertificateParsingException with detail message - * msg. Parameter msg is not null. - */ - public void testCertificateParsingException02() { - CertificateParsingException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new CertificateParsingException(msgs[i]); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - } - - /** - * Test for CertificateParsingException(String) constructor - * Assertion: constructs CertificateParsingException when msg - * is null - */ - public void testCertificateParsingException03() { - String msg = null; - CertificateParsingException tE = new CertificateParsingException(msg); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for CertificateParsingException(Throwable) - * constructor Assertion: constructs CertificateParsingException when - * cause is null - */ - public void testCertificateParsingException04() { - Throwable cause = null; - CertificateParsingException tE = new CertificateParsingException(cause); - assertNull("getMessage() must return null.", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for CertificateParsingException(Throwable) - * constructor Assertion: constructs CertificateParsingException when - * cause is not null - */ - public void testCertificateParsingException05() { - CertificateParsingException tE = new CertificateParsingException(tCause); - if (tE.getMessage() != null) { - String toS = tCause.toString(); - String getM = tE.getMessage(); - assertTrue("getMessage() should contain ".concat(toS), (getM - .indexOf(toS) != -1)); - } - assertNotNull("getCause() must not return null", tE.getCause()); - assertEquals("getCause() must return ".concat(tCause.toString()), tE - .getCause(), tCause); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for CertificateParsingException(String, Throwable) - * constructor Assertion: constructs CertificateParsingException when - * cause is null msg is null - */ - public void testCertificateParsingException06() { - CertificateParsingException tE = new CertificateParsingException(null, - null); - assertNull("getMessage() must return null", tE.getMessage()); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for CertificateParsingException(String, Throwable) - * constructor Assertion: constructs CertificateParsingException when - * cause is null msg is not null - */ - public void testCertificateParsingException07() { - CertificateParsingException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new CertificateParsingException(msgs[i], null); - assertEquals("getMessage() must return: ".concat(msgs[i]), tE - .getMessage(), msgs[i]); - assertNull("getCause() must return null", tE.getCause()); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - } - - /** - * Test for CertificateParsingException(String, Throwable) - * constructor Assertion: constructs CertificateParsingException when - * cause is not null msg is null - */ - public void testCertificateParsingException08() { - CertificateParsingException tE = new CertificateParsingException(null, - tCause); - if (tE.getMessage() != null) { - String toS = tCause.toString(); - String getM = tE.getMessage(); - assertTrue("getMessage() must should ".concat(toS), (getM - .indexOf(toS) != -1)); - } - assertNotNull("getCause() must not return null", tE.getCause()); - assertEquals("getCause() must return ".concat(tCause.toString()), tE - .getCause(), tCause); - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - - /** - * Test for CertificateParsingException(String, Throwable) - * constructor Assertion: constructs CertificateParsingException when - * cause is not null msg is not null - */ - public void testCertificateParsingException09() { - CertificateParsingException tE; - for (int i = 0; i < msgs.length; i++) { - tE = new CertificateParsingException(msgs[i], tCause); - String getM = tE.getMessage(); - String toS = tCause.toString(); - if (msgs[i].length() > 0) { - assertTrue("getMessage() must contain ".concat(msgs[i]), getM - .indexOf(msgs[i]) != -1); - if (!getM.equals(msgs[i])) { - assertTrue("getMessage() should contain ".concat(toS), getM - .indexOf(toS) != -1); - } - } - assertNotNull("getCause() must not return null", tE.getCause()); - assertEquals("getCause() must return ".concat(tCause.toString()), - tE.getCause(), tCause); - - try { - throw tE; - } catch (Exception e) { - assertTrue(createErr(tE, e), tE.equals(e)); - } - } - } -} +/* + * 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 Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.security.tests.java.security.cert; + +import java.security.cert.CertificateParsingException; + +import junit.framework.TestCase; + + +/** + * Tests for CertificateParsingException class constructors and + * methods. + * + */ +public class CertificateParsingExceptionTest extends TestCase { + + public static void main(String[] args) { + } + + /** + * Constructor for CertificateParsingExceptionTests. + * + * @param arg0 + */ + public CertificateParsingExceptionTest(String arg0) { + super(arg0); + } + + private static String[] msgs = { + "", + "Check new message", + "Check new message Check new message Check new message Check new message Check new message" }; + + private static Throwable tCause = new Throwable("Throwable for exception"); + + static String createErr(Exception tE, Exception eE) { + return "CertificateParsingException: ".concat(tE.toString()).concat( + " is not equal to caught exception: ").concat(eE.toString()); + } + + /** + * Test for CertificateParsingException() constructor + * Assertion: constructs CertificateParsingException with no detail message + */ + public void testCertificateParsingException01() { + CertificateParsingException tE = new CertificateParsingException(); + assertNull("getMessage() must return null.", tE.getMessage()); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + + /** + * Test for CertificateParsingException(String) constructor + * Assertion: constructs CertificateParsingException with detail message + * msg. Parameter msg is not null. + */ + public void testCertificateParsingException02() { + CertificateParsingException tE; + for (int i = 0; i < msgs.length; i++) { + tE = new CertificateParsingException(msgs[i]); + assertEquals("getMessage() must return: ".concat(msgs[i]), tE + .getMessage(), msgs[i]); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + } + + /** + * Test for CertificateParsingException(String) constructor + * Assertion: constructs CertificateParsingException when msg + * is null + */ + public void testCertificateParsingException03() { + String msg = null; + CertificateParsingException tE = new CertificateParsingException(msg); + assertNull("getMessage() must return null.", tE.getMessage()); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + + /** + * Test for CertificateParsingException(Throwable) + * constructor Assertion: constructs CertificateParsingException when + * cause is null + */ + public void testCertificateParsingException04() { + Throwable cause = null; + CertificateParsingException tE = new CertificateParsingException(cause); + assertNull("getMessage() must return null.", tE.getMessage()); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + + /** + * Test for CertificateParsingException(Throwable) + * constructor Assertion: constructs CertificateParsingException when + * cause is not null + */ + public void testCertificateParsingException05() { + CertificateParsingException tE = new CertificateParsingException(tCause); + if (tE.getMessage() != null) { + String toS = tCause.toString(); + String getM = tE.getMessage(); + assertTrue("getMessage() should contain ".concat(toS), (getM + .indexOf(toS) != -1)); + } + assertNotNull("getCause() must not return null", tE.getCause()); + assertEquals("getCause() must return ".concat(tCause.toString()), tE + .getCause(), tCause); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + + /** + * Test for CertificateParsingException(String, Throwable) + * constructor Assertion: constructs CertificateParsingException when + * cause is null msg is null + */ + public void testCertificateParsingException06() { + CertificateParsingException tE = new CertificateParsingException(null, + null); + assertNull("getMessage() must return null", tE.getMessage()); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + + /** + * Test for CertificateParsingException(String, Throwable) + * constructor Assertion: constructs CertificateParsingException when + * cause is null msg is not null + */ + public void testCertificateParsingException07() { + CertificateParsingException tE; + for (int i = 0; i < msgs.length; i++) { + tE = new CertificateParsingException(msgs[i], null); + assertEquals("getMessage() must return: ".concat(msgs[i]), tE + .getMessage(), msgs[i]); + assertNull("getCause() must return null", tE.getCause()); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + } + + /** + * Test for CertificateParsingException(String, Throwable) + * constructor Assertion: constructs CertificateParsingException when + * cause is not null msg is null + */ + public void testCertificateParsingException08() { + CertificateParsingException tE = new CertificateParsingException(null, + tCause); + if (tE.getMessage() != null) { + String toS = tCause.toString(); + String getM = tE.getMessage(); + assertTrue("getMessage() must should ".concat(toS), (getM + .indexOf(toS) != -1)); + } + assertNotNull("getCause() must not return null", tE.getCause()); + assertEquals("getCause() must return ".concat(tCause.toString()), tE + .getCause(), tCause); + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + + /** + * Test for CertificateParsingException(String, Throwable) + * constructor Assertion: constructs CertificateParsingException when + * cause is not null msg is not null + */ + public void testCertificateParsingException09() { + CertificateParsingException tE; + for (int i = 0; i < msgs.length; i++) { + tE = new CertificateParsingException(msgs[i], tCause); + String getM = tE.getMessage(); + String toS = tCause.toString(); + if (msgs[i].length() > 0) { + assertTrue("getMessage() must contain ".concat(msgs[i]), getM + .indexOf(msgs[i]) != -1); + if (!getM.equals(msgs[i])) { + assertTrue("getMessage() should contain ".concat(toS), getM + .indexOf(toS) != -1); + } + } + assertNotNull("getCause() must not return null", tE.getCause()); + assertEquals("getCause() must return ".concat(tCause.toString()), + tE.getCause(), tCause); + + try { + throw tE; + } catch (Exception e) { + assertTrue(createErr(tE, e), tE.equals(e)); + } + } + } +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateParsingExceptionTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/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?view=diff&rev=443539&r1=443538&r2=443539 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/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 Thu Sep 14 18:17:39 2006 @@ -1,183 +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 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 PKIXBuilderParameters 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 PKIXBuilderParameters(Set, CertSelector) - * constructor
- * Assertion: creates an instance of PKIXBuilderParameters - * @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 PKIXBuilderParameters(Set, CertSelector) - * constructor
- * Assertion: creates an instance of PKIXBuilderParameters - * @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 PKIXBuilderParameters(Set, CertSelector) - * constructor
- * Assertion: ... the Set 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 PKIXBuilderParameters(Set, CertSelector) - * constructor
- * Assertion: NullPointerException - - * if the specified Set 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 PKIXBuilderParameters(Set, CertSelector) - * constructor
- * Assertion: InvalidAlgorithmParameterException - - * if the specified Set is empty - * (trustAnchors.isEmpty() == true) - */ - public final void testPKIXBuilderParametersSetCertSelector05() { - try { - // use empty set - new PKIXBuilderParameters(new HashSet(), null); - fail("InvalidAlgorithmParameterException expected"); - } catch (InvalidAlgorithmParameterException e) { - } - } - - /** - * Test #6 for PKIXBuilderParameters(Set, CertSelector) - * constructor
- * Assertion: ClassCastException - - * if any of the elements in the Set are not of type - * java.security.cert.TrustAnchor - */ - 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 PKIXBuilderParameters(KeyStore, CertSelector) - * constructor
- * Assertion: NullPointerException - - * if the keystore is null - */ - public final void testPKIXBuilderParametersKeyStoreCertSelector04() throws Exception { - try { - // pass null - new PKIXBuilderParameters((KeyStore)null, null); - fail("NPE expected"); - } catch (NullPointerException e) { - } - } - -} +/* + * 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 PKIXBuilderParameters 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 PKIXBuilderParameters(Set, CertSelector) + * constructor
+ * Assertion: creates an instance of PKIXBuilderParameters + * @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 PKIXBuilderParameters(Set, CertSelector) + * constructor
+ * Assertion: creates an instance of PKIXBuilderParameters + * @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 PKIXBuilderParameters(Set, CertSelector) + * constructor
+ * Assertion: ... the Set 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 PKIXBuilderParameters(Set, CertSelector) + * constructor
+ * Assertion: NullPointerException - + * if the specified Set 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 PKIXBuilderParameters(Set, CertSelector) + * constructor
+ * Assertion: InvalidAlgorithmParameterException - + * if the specified Set is empty + * (trustAnchors.isEmpty() == true) + */ + public final void testPKIXBuilderParametersSetCertSelector05() { + try { + // use empty set + new PKIXBuilderParameters(new HashSet(), null); + fail("InvalidAlgorithmParameterException expected"); + } catch (InvalidAlgorithmParameterException e) { + } + } + + /** + * Test #6 for PKIXBuilderParameters(Set, CertSelector) + * constructor
+ * Assertion: ClassCastException - + * if any of the elements in the Set are not of type + * java.security.cert.TrustAnchor + */ + 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 PKIXBuilderParameters(KeyStore, CertSelector) + * constructor
+ * Assertion: NullPointerException - + * if the keystore is null + */ + public final void testPKIXBuilderParametersKeyStoreCertSelector04() throws Exception { + try { + // pass null + new PKIXBuilderParameters((KeyStore)null, null); + fail("NPE expected"); + } catch (NullPointerException e) { + } + } + +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParametersTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java?view=diff&rev=443539&r1=443538&r2=443539 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/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 Thu Sep 14 18:17:39 2006 @@ -1,239 +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 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 PKIXCertPathBuilderResult - * - */ -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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, - * PolicyNode, PublicKey) constructor
- * Assertion: Creates an instance of PKIXCertPathBuilderResult - * @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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, - * PolicyNode, PublicKey) constructor
- * Assertion: plicy tree parameter may be null - * @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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, - * PolicyNode, PublicKey) constructor
- * Assertion: NullPointerException - * if certPath is null - */ - 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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, - * PolicyNode, PublicKey) constructor
- * Assertion: NullPointerException - * if trustAnchor is null - */ - 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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, - * PolicyNode, PublicKey) constructor
- * Assertion: NullPointerException - * if publicKey is null - */ - 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 getCertPath() method
- * Assertion: the built and validated CertPath - * (never null) - * @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 toString() method
- * 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 PKIXCertPathBuilderResult + * + */ +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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, + * PolicyNode, PublicKey) constructor
+ * Assertion: Creates an instance of PKIXCertPathBuilderResult + * @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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, + * PolicyNode, PublicKey) constructor
+ * Assertion: plicy tree parameter may be null + * @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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, + * PolicyNode, PublicKey) constructor
+ * Assertion: NullPointerException + * if certPath is null + */ + 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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, + * PolicyNode, PublicKey) constructor
+ * Assertion: NullPointerException + * if trustAnchor is null + */ + 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 PKIXCertPathBuilderResult(CertPath, TrustAnchor, + * PolicyNode, PublicKey) constructor
+ * Assertion: NullPointerException + * if publicKey is null + */ + 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 getCertPath() method
+ * Assertion: the built and validated CertPath + * (never null) + * @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 toString() method
+ * 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()); + } + +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/PKIXCertPathBuilderResultTest.java ------------------------------------------------------------------------------ svn:eol-style = native