harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r443539 [26/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 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java Thu Sep 14 18:17:39 2006
@@ -1,308 +1,308 @@
-/*
- *  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.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.CRLSelector;
-import java.security.cert.CertSelector;
-import java.security.cert.CertStore;
-import java.security.cert.CertStoreException;
-import java.security.cert.CertStoreParameters;
-import java.security.cert.X509CRLSelector;
-import java.security.cert.X509CertSelector;
-import java.util.Collection;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
-import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>CertStore</code> class constructors and methods
- * 
- */
-
-public class CertStore_ImplTest extends TestCase {
-    private static final String srvCertStore = "CertStore";
-    private static final String defaultAlg = "CertStore";
-    private static final String CertStoreProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertStoreSpi";
-
-    private static final String[] invalidValues = SpiEngUtils.invalidValues;
-
-    private static final String[] validValues;
-
-    static {
-        validValues = new String[4];
-        validValues[0] = defaultAlg;
-        validValues[1] = defaultAlg.toLowerCase();
-        validValues[2] = "CeRTSTore";
-        validValues[3] = "CERTstore";
-    }
-
-    Provider mProv;
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        mProv = (new SpiEngUtils()).new MyProvider("MyCertStoreProvider",
-                "Provider for testing", srvCertStore
-                        .concat(".").concat(defaultAlg),
-                CertStoreProviderClass);  
-        Security.insertProviderAt(mProv, 1);
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        Security.removeProvider(mProv.getName());
-    }
-
-    private void checkResult(CertStore certS)   throws CertStoreException, 
-            InvalidAlgorithmParameterException {
-        CertSelector certSelector = new X509CertSelector();
-        CRLSelector crlSelector = new X509CRLSelector();
-        Collection collection = certS.getCertificates(certSelector);
-        assertNull("Not null collection", collection);
-        collection = certS.getCRLs(crlSelector);
-        assertNull("Not null collection", collection);
-    }
-
-    /**
-     * Test for method  
-     * <code>getInstance(String type, CertStoreParameters params)</code>  
-     * Assertions:
-     * throws NullPointerException when type is null
-     * throws NoSuchAlgorithmException when type is incorrect; 
-     * throws InvalidAlgorithmParameterException  when params is null 
-     * or has incorrect value; 
-     * returns CertStore object
-     */
-    public void testGetInstance01() throws NoSuchAlgorithmException,
-        InvalidAlgorithmParameterException, CertStoreException {
-        CertStoreParameters p = new MyCertStoreParameters();
-        mPar mp = new mPar("CertStore");
-        try {
-            CertStore.getInstance(null, p);
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertStore.getInstance(invalidValues[i], p);
-                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
-                        invalidValues[i]).concat(")"));
-            } catch (NoSuchAlgorithmException e) {
-            }
-        }
-        for (int i = 0; i < validValues.length; i++) {
-            try {
-                CertStore.getInstance(validValues[i], null);
-                fail("InvalidAlgorithmParameterException must be thrown when params is null");
-            } catch (InvalidAlgorithmParameterException e) {
-            }
-            try {
-                CertStore.getInstance(validValues[i], mp);
-                fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
-            } catch (InvalidAlgorithmParameterException e) {
-            }
-        }
-        
-        CertStore certS;
-        for (int i = 0; i < validValues.length; i++) {
-            certS = CertStore.getInstance(validValues[i], p);      
-            assertEquals("Incorrect type", certS.getType(), validValues[i]);
-            assertEquals("Incorrect provider", certS.getProvider(), mProv);
-            assertTrue("Invalid parameters",certS.getCertStoreParameters() instanceof MyCertStoreParameters);
-            checkResult(certS);
-        }        
-    }
-
-    /**
-     * Test for method
-     * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
-     * Assertions: 
-     * throws NullPointerException when type is null
-     * throws NoSuchAlgorithmException when type is incorrect; 
-     * throws IllegalArgumentException when provider is null or empty; 
-     * throws NoSuchProviderException when provider is available; 
-     * throws InvalidAlgorithmParameterException  when params is null 
-     * returns CertStore object
-     */
-    public void testGetInstance02() throws NoSuchAlgorithmException,
-            NoSuchProviderException, IllegalArgumentException,
-            InvalidAlgorithmParameterException, CertStoreException {
-        CertStoreParameters p = new MyCertStoreParameters();
-        mPar mp = new mPar("CertStore");
-        try {
-            CertStore.getInstance(null, p, mProv.getName());
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertStore.getInstance(invalidValues[i], p, mProv
-                        .getName());
-                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
-                        invalidValues[i]).concat(")"));
-            } catch (NoSuchAlgorithmException e) {
-            }
-        }
-        String prov = null;
-        for (int i = 0; i < validValues.length; i++) {
-            try {
-                CertStore.getInstance(validValues[i], p, prov);
-                fail("IllegalArgumentException must be thrown when provider is null (type: "
-                        .concat(validValues[i]).concat(")"));
-            } catch (IllegalArgumentException e) {
-            }
-            try {
-                CertStore.getInstance(validValues[i], p, "");
-                fail("IllegalArgumentException must be thrown when provider is empty (type: "
-                        .concat(validValues[i]).concat(")"));
-            } catch (IllegalArgumentException e) {
-            }
-        }
-        for (int i = 0; i < validValues.length; i++) {
-            for (int j = 1; j < invalidValues.length; j++) {
-                try {
-                    CertStore.getInstance(validValues[i], p, 
-                            invalidValues[j]);
-                    fail("NoSuchProviderException must be thrown (type: "
-                            .concat(validValues[i]).concat(" provider: ")
-                            .concat(invalidValues[j]).concat(")"));
-                } catch (NoSuchProviderException e) {
-                }
-            }
-        }
-        for (int i = 0; i < validValues.length; i++) {
-            try {
-                CertStore.getInstance(validValues[i], null, mProv.getName()); 
-                fail("InvalidAlgorithmParameterException must be thrown when params is null");
-            } catch (InvalidAlgorithmParameterException e) {
-            }
-            try {
-                CertStore.getInstance(validValues[i], mp, mProv.getName());
-                fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
-            } catch (InvalidAlgorithmParameterException e) {
-            }
-        }
-        CertStore certS;
-        for (int i = 0; i < validValues.length; i++) {
-            certS = CertStore.getInstance(validValues[i], p, mProv
-                    .getName());
-            assertEquals("Incorrect type", certS.getType(), validValues[i]);
-            assertEquals("Incorrect provider", certS.getProvider().getName(),
-                    mProv.getName());
-            assertTrue("Invalid parameters",certS.getCertStoreParameters() instanceof MyCertStoreParameters);
-            checkResult(certS);
-        }
-    }
-
-    /**
-     * Test for method
-     * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
-     * Assertions: 
-     * throws NullPointerException when type is null
-     * throws NoSuchAlgorithmException when type is incorrect; 
-     * throws IllegalArgumentException when provider is null;
-     * throws InvalidAlgorithmParameterException when params is null or has incorrect value 
-     * returns CertStore object
-     */
-    public void testGetInstance03() throws NoSuchAlgorithmException,
-            IllegalArgumentException,
-            InvalidAlgorithmParameterException, CertStoreException {
-        CertStoreParameters p = new MyCertStoreParameters();
-        mPar mp = new mPar("CertStore");
-        try {
-            CertStore.getInstance(null, p, mProv);
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertStore.getInstance(invalidValues[i], p, mProv);
-                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
-                        invalidValues[i]).concat(")"));
-            } catch (NoSuchAlgorithmException e) {
-            }
-        }
-        Provider prov = null;
-        for (int i = 0; i < validValues.length; i++) {
-            try {
-                CertStore.getInstance(validValues[i], p, prov);
-                fail("IllegalArgumentException must be thrown when provider is null (type: "
-                        .concat(validValues[i]).concat(")"));
-            } catch (IllegalArgumentException e) {
-            }
-        }
-        for (int i = 0; i < validValues.length; i++) {
-            try {
-                CertStore.getInstance(validValues[i], null, mProv); 
-                fail("InvalidAlgorithmParameterException must be thrown when params is null");
-            } catch (InvalidAlgorithmParameterException e) {
-            }
-            try {
-                CertStore.getInstance(validValues[i], mp, mProv);
-                fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
-            } catch (InvalidAlgorithmParameterException e) {
-            }
-        }
-        CertStore certS;
-        for (int i = 0; i < validValues.length; i++) {
-            certS = CertStore.getInstance(validValues[i], p, mProv);
-            assertEquals("Incorrect type", certS.getType(), validValues[i]);
-            assertEquals("Incorrect provider", certS.getProvider(), mProv);
-            assertTrue("Invalid parameters",certS.getCertStoreParameters() instanceof MyCertStoreParameters);
-            checkResult(certS);
-        }
-    }
-}
-class mPar implements CertStoreParameters {
-    String par = "";
-    public mPar() {
-        super();
-    }
-    public mPar(String s) {
-        super();
-        par = s;
-    }
-    
-    public Object clone() {
-        if (par == "") {
-            return null;
-        }
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException e) {
-            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.security.InvalidAlgorithmParameterException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.cert.CRLSelector;
+import java.security.cert.CertSelector;
+import java.security.cert.CertStore;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.X509CRLSelector;
+import java.security.cert.X509CertSelector;
+import java.util.Collection;
+
+import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
+import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>CertStore</code> class constructors and methods
+ * 
+ */
+
+public class CertStore_ImplTest extends TestCase {
+    private static final String srvCertStore = "CertStore";
+    private static final String defaultAlg = "CertStore";
+    private static final String CertStoreProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertStoreSpi";
+
+    private static final String[] invalidValues = SpiEngUtils.invalidValues;
+
+    private static final String[] validValues;
+
+    static {
+        validValues = new String[4];
+        validValues[0] = defaultAlg;
+        validValues[1] = defaultAlg.toLowerCase();
+        validValues[2] = "CeRTSTore";
+        validValues[3] = "CERTstore";
+    }
+
+    Provider mProv;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        mProv = (new SpiEngUtils()).new MyProvider("MyCertStoreProvider",
+                "Provider for testing", srvCertStore
+                        .concat(".").concat(defaultAlg),
+                CertStoreProviderClass);  
+        Security.insertProviderAt(mProv, 1);
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        Security.removeProvider(mProv.getName());
+    }
+
+    private void checkResult(CertStore certS)   throws CertStoreException, 
+            InvalidAlgorithmParameterException {
+        CertSelector certSelector = new X509CertSelector();
+        CRLSelector crlSelector = new X509CRLSelector();
+        Collection collection = certS.getCertificates(certSelector);
+        assertNull("Not null collection", collection);
+        collection = certS.getCRLs(crlSelector);
+        assertNull("Not null collection", collection);
+    }
+
+    /**
+     * Test for method  
+     * <code>getInstance(String type, CertStoreParameters params)</code>  
+     * Assertions:
+     * throws NullPointerException when type is null
+     * throws NoSuchAlgorithmException when type is incorrect; 
+     * throws InvalidAlgorithmParameterException  when params is null 
+     * or has incorrect value; 
+     * returns CertStore object
+     */
+    public void testGetInstance01() throws NoSuchAlgorithmException,
+        InvalidAlgorithmParameterException, CertStoreException {
+        CertStoreParameters p = new MyCertStoreParameters();
+        mPar mp = new mPar("CertStore");
+        try {
+            CertStore.getInstance(null, p);
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertStore.getInstance(invalidValues[i], p);
+                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
+                        invalidValues[i]).concat(")"));
+            } catch (NoSuchAlgorithmException e) {
+            }
+        }
+        for (int i = 0; i < validValues.length; i++) {
+            try {
+                CertStore.getInstance(validValues[i], null);
+                fail("InvalidAlgorithmParameterException must be thrown when params is null");
+            } catch (InvalidAlgorithmParameterException e) {
+            }
+            try {
+                CertStore.getInstance(validValues[i], mp);
+                fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
+            } catch (InvalidAlgorithmParameterException e) {
+            }
+        }
+        
+        CertStore certS;
+        for (int i = 0; i < validValues.length; i++) {
+            certS = CertStore.getInstance(validValues[i], p);      
+            assertEquals("Incorrect type", certS.getType(), validValues[i]);
+            assertEquals("Incorrect provider", certS.getProvider(), mProv);
+            assertTrue("Invalid parameters",certS.getCertStoreParameters() instanceof MyCertStoreParameters);
+            checkResult(certS);
+        }        
+    }
+
+    /**
+     * Test for method
+     * <code>getInstance(String type, CertStoreParameters params, String provider)</code>
+     * Assertions: 
+     * throws NullPointerException when type is null
+     * throws NoSuchAlgorithmException when type is incorrect; 
+     * throws IllegalArgumentException when provider is null or empty; 
+     * throws NoSuchProviderException when provider is available; 
+     * throws InvalidAlgorithmParameterException  when params is null 
+     * returns CertStore object
+     */
+    public void testGetInstance02() throws NoSuchAlgorithmException,
+            NoSuchProviderException, IllegalArgumentException,
+            InvalidAlgorithmParameterException, CertStoreException {
+        CertStoreParameters p = new MyCertStoreParameters();
+        mPar mp = new mPar("CertStore");
+        try {
+            CertStore.getInstance(null, p, mProv.getName());
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertStore.getInstance(invalidValues[i], p, mProv
+                        .getName());
+                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
+                        invalidValues[i]).concat(")"));
+            } catch (NoSuchAlgorithmException e) {
+            }
+        }
+        String prov = null;
+        for (int i = 0; i < validValues.length; i++) {
+            try {
+                CertStore.getInstance(validValues[i], p, prov);
+                fail("IllegalArgumentException must be thrown when provider is null (type: "
+                        .concat(validValues[i]).concat(")"));
+            } catch (IllegalArgumentException e) {
+            }
+            try {
+                CertStore.getInstance(validValues[i], p, "");
+                fail("IllegalArgumentException must be thrown when provider is empty (type: "
+                        .concat(validValues[i]).concat(")"));
+            } catch (IllegalArgumentException e) {
+            }
+        }
+        for (int i = 0; i < validValues.length; i++) {
+            for (int j = 1; j < invalidValues.length; j++) {
+                try {
+                    CertStore.getInstance(validValues[i], p, 
+                            invalidValues[j]);
+                    fail("NoSuchProviderException must be thrown (type: "
+                            .concat(validValues[i]).concat(" provider: ")
+                            .concat(invalidValues[j]).concat(")"));
+                } catch (NoSuchProviderException e) {
+                }
+            }
+        }
+        for (int i = 0; i < validValues.length; i++) {
+            try {
+                CertStore.getInstance(validValues[i], null, mProv.getName()); 
+                fail("InvalidAlgorithmParameterException must be thrown when params is null");
+            } catch (InvalidAlgorithmParameterException e) {
+            }
+            try {
+                CertStore.getInstance(validValues[i], mp, mProv.getName());
+                fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
+            } catch (InvalidAlgorithmParameterException e) {
+            }
+        }
+        CertStore certS;
+        for (int i = 0; i < validValues.length; i++) {
+            certS = CertStore.getInstance(validValues[i], p, mProv
+                    .getName());
+            assertEquals("Incorrect type", certS.getType(), validValues[i]);
+            assertEquals("Incorrect provider", certS.getProvider().getName(),
+                    mProv.getName());
+            assertTrue("Invalid parameters",certS.getCertStoreParameters() instanceof MyCertStoreParameters);
+            checkResult(certS);
+        }
+    }
+
+    /**
+     * Test for method
+     * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
+     * Assertions: 
+     * throws NullPointerException when type is null
+     * throws NoSuchAlgorithmException when type is incorrect; 
+     * throws IllegalArgumentException when provider is null;
+     * throws InvalidAlgorithmParameterException when params is null or has incorrect value 
+     * returns CertStore object
+     */
+    public void testGetInstance03() throws NoSuchAlgorithmException,
+            IllegalArgumentException,
+            InvalidAlgorithmParameterException, CertStoreException {
+        CertStoreParameters p = new MyCertStoreParameters();
+        mPar mp = new mPar("CertStore");
+        try {
+            CertStore.getInstance(null, p, mProv);
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when type is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertStore.getInstance(invalidValues[i], p, mProv);
+                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
+                        invalidValues[i]).concat(")"));
+            } catch (NoSuchAlgorithmException e) {
+            }
+        }
+        Provider prov = null;
+        for (int i = 0; i < validValues.length; i++) {
+            try {
+                CertStore.getInstance(validValues[i], p, prov);
+                fail("IllegalArgumentException must be thrown when provider is null (type: "
+                        .concat(validValues[i]).concat(")"));
+            } catch (IllegalArgumentException e) {
+            }
+        }
+        for (int i = 0; i < validValues.length; i++) {
+            try {
+                CertStore.getInstance(validValues[i], null, mProv); 
+                fail("InvalidAlgorithmParameterException must be thrown when params is null");
+            } catch (InvalidAlgorithmParameterException e) {
+            }
+            try {
+                CertStore.getInstance(validValues[i], mp, mProv);
+                fail("InvalidAlgorithmParameterException must be thrown when params is incorrect");
+            } catch (InvalidAlgorithmParameterException e) {
+            }
+        }
+        CertStore certS;
+        for (int i = 0; i < validValues.length; i++) {
+            certS = CertStore.getInstance(validValues[i], p, mProv);
+            assertEquals("Incorrect type", certS.getType(), validValues[i]);
+            assertEquals("Incorrect provider", certS.getProvider(), mProv);
+            assertTrue("Invalid parameters",certS.getCertStoreParameters() instanceof MyCertStoreParameters);
+            checkResult(certS);
+        }
+    }
+}
+class mPar implements CertStoreParameters {
+    String par = "";
+    public mPar() {
+        super();
+    }
+    public mPar(String s) {
+        super();
+        par = s;
+    }
+    
+    public Object clone() {
+        if (par == "") {
+            return null;
+        }
+        try {
+            return super.clone();
+        } catch (CloneNotSupportedException e) {
+            return null;
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/CertStore_ImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java Thu Sep 14 18:17:39 2006
@@ -1,235 +1,235 @@
-/*
- *  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.InvalidParameterException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.cert.PKIXBuilderParameters;
-import java.security.cert.PKIXParameters;
-import java.security.cert.X509CertSelector;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXBuilderParameters</code> fields and methods
- * 
- */
-public class PKIXBuilderParameters_ImplTest extends TestCase {
-    private static final int DEFAULT_MAX_PATH_LEN = 5;
-
-    /**
-     * 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 #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.InvalidParameterException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.PKIXParameters;
+import java.security.cert.X509CertSelector;
+
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>PKIXBuilderParameters</code> fields and methods
+ * 
+ */
+public class PKIXBuilderParameters_ImplTest extends TestCase {
+    private static final int DEFAULT_MAX_PATH_LEN = 5;
+
+    /**
+     * 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 #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);
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXBuilderParameters_ImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java Thu Sep 14 18:17:39 2006
@@ -1,286 +1,286 @@
-/*
- *  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.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertPathParameters;
-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;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PKIXParameters</code> fields and methods
- * 
- */
-public class PKIXParameters_ImplTest extends TestCase {
-   
-    /**
-     * 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 #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 #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());
-    }
-
-}
+/*
+ *  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.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertPathParameters;
+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;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.harmony.security.tests.support.cert.TestUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>PKIXParameters</code> fields and methods
+ * 
+ */
+public class PKIXParameters_ImplTest extends TestCase {
+   
+    /**
+     * 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 #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 #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());
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/cert/PKIXParameters_ImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message