harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r415555 [3/17] - in /incubator/harmony/enhanced/classlib/trunk/modules/security: make/common/ src/test/api/java.injected/java/security/acl/ src/test/api/java.injected/java/security/cert/ src/test/api/java.injected/java/security/interfaces/ ...
Date Tue, 20 Jun 2006 08:11:19 GMT
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CRLExceptionTest.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/CRLExceptionTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CRLExceptionTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CRLExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLExceptionTest.java Tue Jun 20 01:11:04 2006
@@ -1,237 +1,236 @@
-/*
- *  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 java.security.cert;
-
-import java.security.cert.CRLException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>CRLException</code> class constructors and methods.
- * 
- */
-public class CRLExceptionTest extends TestCase {
-
-    public static void main(String[] args) {
-    }
-
-    /**
-     * Constructor for CRLExceptionTests.
-     * 
-     * @param arg0
-     */
-    public CRLExceptionTest(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 "CRLException: ".concat(tE.toString()).concat(
-                " is not equal to caught exception: ").concat(eE.toString());
-    }
-
-    /**
-     * Test for <code>CRLException()</code> constructor Assertion: constructs
-     * CRLException with no detail message
-     */
-    public void testCRLException01() {
-        CRLException tE = new CRLException();
-        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 <code>CRLException(String)</code> constructor Assertion:
-     * constructs CRLException with detail message msg. Parameter
-     * <code>msg</code> is not null.
-     */
-    public void testCRLException02() {
-        CRLException tE;
-        for (int i = 0; i < msgs.length; i++) {
-            tE = new CRLException(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 <code>CRLException(String)</code> constructor Assertion:
-     * constructs CRLException when <code>msg</code> is null
-     */
-    public void testCRLException03() {
-        String msg = null;
-        CRLException tE = new CRLException(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 <code>CRLException(Throwable)</code> constructor Assertion:
-     * constructs CRLException when <code>cause</code> is null
-     */
-    public void testCRLException04() {
-        Throwable cause = null;
-        CRLException tE = new CRLException(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 <code>CRLException(Throwable)</code> constructor Assertion:
-     * constructs CRLException when <code>cause</code> is not null
-     */
-    public void testCRLException05() {
-        CRLException tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
-     * Assertion: constructs CRLException when <code>cause</code> is null
-     * <code>msg</code> is null
-     */
-    public void testCRLException06() {
-        CRLException tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
-     * Assertion: constructs CRLException when <code>cause</code> is null
-     * <code>msg</code> is not null
-     */
-    public void testCRLException07() {
-        CRLException tE;
-        for (int i = 0; i < msgs.length; i++) {
-            tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
-     * Assertion: constructs CRLException when <code>cause</code> is not null
-     * <code>msg</code> is null
-     */
-    public void testCRLException08() {
-        CRLException tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
-     * Assertion: constructs CRLException when <code>cause</code> is not null
-     * <code>msg</code> is not null
-     */
-    public void testCRLException09() {
-        CRLException tE;
-        for (int i = 0; i < msgs.length; i++) {
-            tE = new CRLException(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.CRLException;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>CRLException</code> class constructors and methods.
+ * 
+ */
+public class CRLExceptionTest extends TestCase {
+
+    public static void main(String[] args) {
+    }
+
+    /**
+     * Constructor for CRLExceptionTests.
+     * 
+     * @param arg0
+     */
+    public CRLExceptionTest(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 "CRLException: ".concat(tE.toString()).concat(
+                " is not equal to caught exception: ").concat(eE.toString());
+    }
+
+    /**
+     * Test for <code>CRLException()</code> constructor Assertion: constructs
+     * CRLException with no detail message
+     */
+    public void testCRLException01() {
+        CRLException tE = new CRLException();
+        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 <code>CRLException(String)</code> constructor Assertion:
+     * constructs CRLException with detail message msg. Parameter
+     * <code>msg</code> is not null.
+     */
+    public void testCRLException02() {
+        CRLException tE;
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new CRLException(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 <code>CRLException(String)</code> constructor Assertion:
+     * constructs CRLException when <code>msg</code> is null
+     */
+    public void testCRLException03() {
+        String msg = null;
+        CRLException tE = new CRLException(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 <code>CRLException(Throwable)</code> constructor Assertion:
+     * constructs CRLException when <code>cause</code> is null
+     */
+    public void testCRLException04() {
+        Throwable cause = null;
+        CRLException tE = new CRLException(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 <code>CRLException(Throwable)</code> constructor Assertion:
+     * constructs CRLException when <code>cause</code> is not null
+     */
+    public void testCRLException05() {
+        CRLException tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
+     * Assertion: constructs CRLException when <code>cause</code> is null
+     * <code>msg</code> is null
+     */
+    public void testCRLException06() {
+        CRLException tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
+     * Assertion: constructs CRLException when <code>cause</code> is null
+     * <code>msg</code> is not null
+     */
+    public void testCRLException07() {
+        CRLException tE;
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
+     * Assertion: constructs CRLException when <code>cause</code> is not null
+     * <code>msg</code> is null
+     */
+    public void testCRLException08() {
+        CRLException tE = new CRLException(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 <code>CRLException(String, Throwable)</code> constructor
+     * Assertion: constructs CRLException when <code>cause</code> is not null
+     * <code>msg</code> is not null
+     */
+    public void testCRLException09() {
+        CRLException tE;
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new CRLException(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));
+            }
+        }
+    }
+}

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CRLTest.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/CRLTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CRLTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CRLTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CRLTest.java Tue Jun 20 01:11:04 2006
@@ -19,12 +19,13 @@
 * @version $Revision$
 */
 
-package java.security.cert;
+package org.apache.harmony.security.tests.java.security.cert;
+
+import java.security.cert.CRL;
 
 import org.apache.harmony.security.tests.support.cert.MyCRL;
 
 import junit.framework.TestCase;
-
 
 /**
  * Tests for <code>java.security.cert.CRL</code> fields and methods

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CertPathBuilder1Test.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/CertPathBuilder1Test.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CertPathBuilder1Test.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CertPathBuilder1Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java Tue Jun 20 01:11:04 2006
@@ -1,380 +1,383 @@
-/*
- *  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 java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-
-/**
- * Tests for <code>CertPathBuilder</code> class constructors and
- * methods.
- * 
- */
-
-public class CertPathBuilder1Test extends TestCase {
-
-    /**
-     * Constructor for CertPathBuilderTests.
-     * @param name
-     */
-    public CertPathBuilder1Test(String name) {
-        super(name);
-    }
-    public static final String srvCertPathBuilder = "CertPathBuilder";
-
-    public static final String defaultType = "PKIX";    
-    public static final String [] validValues = {
-            "PKIX", "pkix", "PkiX", "pKiX" };
-     
-    private static String [] invalidValues = SpiEngUtils.invalidValues;
-    
-    private static boolean PKIXSupport = false;
-
-    private static Provider defaultProvider;
-    private static String defaultProviderName;
-    
-    private static String NotSupportMsg = "";
-
-    static {
-        defaultProvider = SpiEngUtils.isSupport(defaultType,
-                srvCertPathBuilder);
-        PKIXSupport = (defaultProvider != null);
-        defaultProviderName = (PKIXSupport ? defaultProvider.getName() : null);
-        NotSupportMsg = defaultType.concat(" is not supported");
-    }
-    private static CertPathBuilder[] createCPBs() {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return null;
-        }
-        try {
-            CertPathBuilder[] certPBs = new CertPathBuilder[3];
-            certPBs[0] = CertPathBuilder.getInstance(defaultType);
-            certPBs[1] = CertPathBuilder.getInstance(defaultType,
-                    defaultProviderName);
-            certPBs[2] = CertPathBuilder.getInstance(defaultType,
-                    defaultProvider);
-            return certPBs;
-        } catch (Exception e) {
-            return null;
-        }
-    }    
-    
-    /**
-     * Test for <code>getDefaultType()</code> method
-	 * Assertion: 
-	 * returns security property "certpathbuild.type" or "PKIX"
-     */    
-    public void testCertPathBuilder01() {
-        if (!PKIXSupport) {
-            return;
-        }
-        String propName = "certpathbuild.type";
-        String defCPB = Security.getProperty(propName);
-        
-        String dt = CertPathBuilder.getDefaultType();
-        String resType = defCPB; 
-        if (resType == null) {
-            resType = defaultType;
-        }
-        assertNotNull("Default type have not be null", dt);
-        assertEquals("Incorrect default type", dt, resType);
-        
-        if (defCPB == null) {
-            Security.setProperty(propName, defaultType);
-            dt = CertPathBuilder.getDefaultType();
-            resType = Security.getProperty(propName);
-            assertNotNull("Incorrect default type", resType);
-            assertNotNull("Default type have not be null", dt);
-            assertEquals("Incorrect default type", dt, resType);            
-        }
-    }
-    
-    /**
-     * Test for <code>getInstance(String algorithm)</code> method
-	 * Assertion:
-	 * throws NullPointerException when algorithm is null 
-	 * throws NoSuchAlgorithmException when algorithm  is not correct
-	 * or it is not available
-     */
-    public void testCertPathBuilder02() {
-        try {
-            CertPathBuilder.getInstance(null);
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertPathBuilder.getInstance(invalidValues[i]);
-                fail("NoSuchAlgorithmException must be thrown");
-            } catch (NoSuchAlgorithmException e) {
-            }
-        }
-    }
-    
-    /**
-     * Test for <code>getInstance(String algorithm)</code> method
-	 * Assertion: returns CertPathBuilder object
-     */ 
-    public void testCertPathBuilder03() throws NoSuchAlgorithmException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        for (int i = 0; i < validValues.length; i++) {
-            CertPathBuilder cpb = CertPathBuilder.getInstance(validValues[i]);
-            assertEquals("Incorrect algorithm", cpb.getAlgorithm(), validValues[i]);
-        }
-    }
-    /**
-     * Test for <code>getInstance(String algorithm, String provider)</code> method
-	 * Assertion: throws IllegalArgumentException when provider is null or empty
-	 * 
-	 * FIXME: verify what exception will be thrown if provider is empty
-     */  
-    public void testCertPathBuilder04()
-            throws NoSuchAlgorithmException, NoSuchProviderException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        String provider = null;
-        for (int i = 0; i < validValues.length; i++) {        
-            try {
-                CertPathBuilder.getInstance(validValues[i], provider);
-                fail("IllegalArgumentException must be thrown thrown");
-            } catch (IllegalArgumentException e) {
-            }
-            try {
-                CertPathBuilder.getInstance(validValues[i], "");
-                fail("IllegalArgumentException must be thrown thrown");
-            } catch (IllegalArgumentException e) {
-            }
-        }
-    }
-    
-    /**
-     * Test for <code>getInstance(String algorithm, String provider)</code> method
-	 * Assertion: 
-	 * throws NoSuchProviderException when provider has invalid value
-     */
-    public void testCertPathBuilder05()
-            throws NoSuchAlgorithmException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        for (int i = 0; i < validValues.length; i++ ) {
-            for (int j = 1; j < invalidValues.length; j++) {
-                try {
-                    CertPathBuilder.getInstance(validValues[i], invalidValues[j]);
-                    fail("NoSuchProviderException must be hrown");
-                } catch (NoSuchProviderException e1) {
-                }
-            }
-        }        
-    }
-    /**
-     * Test for <code>getInstance(String algorithm, String provider)</code> method
-	 * Assertion: 
-	 * throws NullPointerException when algorithm is null 
-	 * throws NoSuchAlgorithmException when algorithm  is not correct
-     */
-    public void testCertPathBuilder06()
-            throws NoSuchAlgorithmException, NoSuchProviderException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        try {
-            CertPathBuilder.getInstance(null, defaultProviderName);
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertPathBuilder.getInstance(invalidValues[i], defaultProviderName);
-                fail("NoSuchAlgorithmException must be thrown");
-            } catch (NoSuchAlgorithmException e1) {
-            }
-        }        
-    }
-    
-    /**
-     * Test for <code>getInstance(String algorithm, String provider)</code> method
-	 * Assertion: returns CertPathBuilder object
-     */
-    public void testCertPathBuilder07()
-            throws NoSuchAlgorithmException, NoSuchProviderException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        CertPathBuilder certPB;
-        for (int i = 0; i < validValues.length; i++) {
-            certPB = CertPathBuilder.getInstance(validValues[i], defaultProviderName);
-            assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
-            assertEquals("Incorrect provider name", certPB.getProvider().getName(), defaultProviderName);
-        }        
-    }
-
-    /**
-     * Test for <code>getInstance(String algorithm, Provider provider)</code> method
-	 * Assertion: throws IllegalArgumentException when provider is null
-     */
-    public void testCertPathBuilder08()
-            throws NoSuchAlgorithmException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        Provider prov = null;
-        for (int t = 0; t < validValues.length; t++ ) {
-            try {
-                CertPathBuilder.getInstance(validValues[t], prov);
-                fail("IllegalArgumentException must be thrown");
-            } catch (IllegalArgumentException e1) {
-            }
-        }        
-    }
-    
-    /**
-     * Test for <code>getInstance(String algorithm, String provider)</code> method
-	 * Assertion: 
-	 * throws NullPointerException when algorithm is null 
-	 * throws NoSuchAlgorithmException when algorithm  is not correct
-     */
-    public void testCertPathBuilder09()
-            throws NoSuchAlgorithmException, NoSuchProviderException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        try {
-            CertPathBuilder.getInstance(null, defaultProvider);
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertPathBuilder.getInstance(invalidValues[i], defaultProvider);
-                fail("NoSuchAlgorithm must be thrown");
-            } catch (NoSuchAlgorithmException e1) {
-            }
-        }
-    }
-    /**
-     * Test for <code>getInstance(String algorithm, String provider)</code> method
-	 * Assertion: returns CertPathBuilder object
-     */
-    public void testCertPathBuilder10()
-            throws NoSuchAlgorithmException, NoSuchProviderException  {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        CertPathBuilder certPB;
-        for (int i = 0; i < invalidValues.length; i++) {
-            certPB = CertPathBuilder.getInstance(validValues[i], defaultProvider);
-            assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
-            assertEquals("Incorrect provider name", certPB.getProvider(), defaultProvider);
-        }        
-    }
-    /**
-     * Test for <code>build(CertPathParameters params)</code> method
-	 * Assertion: throws InvalidAlgorithmParameterException params is null
-     */
-    public void testCertPathBuilder11()
-            throws NoSuchAlgorithmException, NoSuchProviderException, 
-            CertPathBuilderException {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }        
-        CertPathBuilder [] certPB = createCPBs();
-        assertNotNull("CertPathBuilder objects were not created", certPB);
-        for (int i = 0; i < certPB.length; i++ ){
-            try {
-                certPB[i].build(null);
-                fail("InvalidAlgorithmParameterException must be thrown");
-            } catch(InvalidAlgorithmParameterException e) {
-            }
-        }
-    }
-    /**
-     * Test for 
-     * <code>CertPathBuilder</code> constructor
-     * Assertion: returns CertPathBuilder object
-     */
-    public void testCertPathBuilder12()
-            throws CertificateException, NoSuchProviderException, 
-            NoSuchAlgorithmException, InvalidAlgorithmParameterException,
-            CertPathBuilderException {
-        if (!PKIXSupport) {
-            fail(NotSupportMsg);
-            return;
-        }
-        CertPathBuilderSpi spi = new MyCertPathBuilderSpi();
-        CertPathBuilder certPB = new myCertPathBuilder(spi, 
-                    defaultProvider, defaultType);
-        assertEquals("Incorrect algorithm", certPB.getAlgorithm(), defaultType);
-        assertEquals("Incorrect provider", certPB.getProvider(), defaultProvider);
-        try {
-            certPB.build(null);
-            fail("CertPathBuilderException must be thrown ");
-        } catch (CertPathBuilderException e) {            
-        }
-        certPB = new myCertPathBuilder(null, null, null);
-        assertNull("Incorrect algorithm", certPB.getAlgorithm());
-        assertNull("Incorrect provider", certPB.getProvider());            
-        try {
-            certPB.build(null);
-            fail("NullPointerException must be thrown ");
-        } catch (NullPointerException e) {            
-        }
-    }
-    public static void main(String args[]) {
-        junit.textui.TestRunner.run(CertPathBuilder1Test.class);
-    }  
-    
-}
-/**
- * Addifional class to verify CertPathBuilder constructor
- */
-class myCertPathBuilder extends CertPathBuilder {
-
-    public myCertPathBuilder(CertPathBuilderSpi spi, Provider prov, String type) {
-        super(spi, prov, type);
-    }
-}
+/*
+ *  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.CertPathBuilder;
+import java.security.cert.CertPathBuilderException;
+import java.security.cert.CertPathBuilderSpi;
+import java.security.cert.CertificateException;
+
+import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>CertPathBuilder</code> class constructors and
+ * methods.
+ * 
+ */
+
+public class CertPathBuilder1Test extends TestCase {
+
+    /**
+     * Constructor for CertPathBuilderTests.
+     * @param name
+     */
+    public CertPathBuilder1Test(String name) {
+        super(name);
+    }
+    public static final String srvCertPathBuilder = "CertPathBuilder";
+
+    public static final String defaultType = "PKIX";    
+    public static final String [] validValues = {
+            "PKIX", "pkix", "PkiX", "pKiX" };
+     
+    private static String [] invalidValues = SpiEngUtils.invalidValues;
+    
+    private static boolean PKIXSupport = false;
+
+    private static Provider defaultProvider;
+    private static String defaultProviderName;
+    
+    private static String NotSupportMsg = "";
+
+    static {
+        defaultProvider = SpiEngUtils.isSupport(defaultType,
+                srvCertPathBuilder);
+        PKIXSupport = (defaultProvider != null);
+        defaultProviderName = (PKIXSupport ? defaultProvider.getName() : null);
+        NotSupportMsg = defaultType.concat(" is not supported");
+    }
+    private static CertPathBuilder[] createCPBs() {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return null;
+        }
+        try {
+            CertPathBuilder[] certPBs = new CertPathBuilder[3];
+            certPBs[0] = CertPathBuilder.getInstance(defaultType);
+            certPBs[1] = CertPathBuilder.getInstance(defaultType,
+                    defaultProviderName);
+            certPBs[2] = CertPathBuilder.getInstance(defaultType,
+                    defaultProvider);
+            return certPBs;
+        } catch (Exception e) {
+            return null;
+        }
+    }    
+    
+    /**
+     * Test for <code>getDefaultType()</code> method
+	 * Assertion: 
+	 * returns security property "certpathbuild.type" or "PKIX"
+     */    
+    public void testCertPathBuilder01() {
+        if (!PKIXSupport) {
+            return;
+        }
+        String propName = "certpathbuild.type";
+        String defCPB = Security.getProperty(propName);
+        
+        String dt = CertPathBuilder.getDefaultType();
+        String resType = defCPB; 
+        if (resType == null) {
+            resType = defaultType;
+        }
+        assertNotNull("Default type have not be null", dt);
+        assertEquals("Incorrect default type", dt, resType);
+        
+        if (defCPB == null) {
+            Security.setProperty(propName, defaultType);
+            dt = CertPathBuilder.getDefaultType();
+            resType = Security.getProperty(propName);
+            assertNotNull("Incorrect default type", resType);
+            assertNotNull("Default type have not be null", dt);
+            assertEquals("Incorrect default type", dt, resType);            
+        }
+    }
+    
+    /**
+     * Test for <code>getInstance(String algorithm)</code> method
+	 * Assertion:
+	 * throws NullPointerException when algorithm is null 
+	 * throws NoSuchAlgorithmException when algorithm  is not correct
+	 * or it is not available
+     */
+    public void testCertPathBuilder02() {
+        try {
+            CertPathBuilder.getInstance(null);
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertPathBuilder.getInstance(invalidValues[i]);
+                fail("NoSuchAlgorithmException must be thrown");
+            } catch (NoSuchAlgorithmException e) {
+            }
+        }
+    }
+    
+    /**
+     * Test for <code>getInstance(String algorithm)</code> method
+	 * Assertion: returns CertPathBuilder object
+     */ 
+    public void testCertPathBuilder03() throws NoSuchAlgorithmException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        for (int i = 0; i < validValues.length; i++) {
+            CertPathBuilder cpb = CertPathBuilder.getInstance(validValues[i]);
+            assertEquals("Incorrect algorithm", cpb.getAlgorithm(), validValues[i]);
+        }
+    }
+    /**
+     * Test for <code>getInstance(String algorithm, String provider)</code> method
+	 * Assertion: throws IllegalArgumentException when provider is null or empty
+	 * 
+	 * FIXME: verify what exception will be thrown if provider is empty
+     */  
+    public void testCertPathBuilder04()
+            throws NoSuchAlgorithmException, NoSuchProviderException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        String provider = null;
+        for (int i = 0; i < validValues.length; i++) {        
+            try {
+                CertPathBuilder.getInstance(validValues[i], provider);
+                fail("IllegalArgumentException must be thrown thrown");
+            } catch (IllegalArgumentException e) {
+            }
+            try {
+                CertPathBuilder.getInstance(validValues[i], "");
+                fail("IllegalArgumentException must be thrown thrown");
+            } catch (IllegalArgumentException e) {
+            }
+        }
+    }
+    
+    /**
+     * Test for <code>getInstance(String algorithm, String provider)</code> method
+	 * Assertion: 
+	 * throws NoSuchProviderException when provider has invalid value
+     */
+    public void testCertPathBuilder05()
+            throws NoSuchAlgorithmException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        for (int i = 0; i < validValues.length; i++ ) {
+            for (int j = 1; j < invalidValues.length; j++) {
+                try {
+                    CertPathBuilder.getInstance(validValues[i], invalidValues[j]);
+                    fail("NoSuchProviderException must be hrown");
+                } catch (NoSuchProviderException e1) {
+                }
+            }
+        }        
+    }
+    /**
+     * Test for <code>getInstance(String algorithm, String provider)</code> method
+	 * Assertion: 
+	 * throws NullPointerException when algorithm is null 
+	 * throws NoSuchAlgorithmException when algorithm  is not correct
+     */
+    public void testCertPathBuilder06()
+            throws NoSuchAlgorithmException, NoSuchProviderException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        try {
+            CertPathBuilder.getInstance(null, defaultProviderName);
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertPathBuilder.getInstance(invalidValues[i], defaultProviderName);
+                fail("NoSuchAlgorithmException must be thrown");
+            } catch (NoSuchAlgorithmException e1) {
+            }
+        }        
+    }
+    
+    /**
+     * Test for <code>getInstance(String algorithm, String provider)</code> method
+	 * Assertion: returns CertPathBuilder object
+     */
+    public void testCertPathBuilder07()
+            throws NoSuchAlgorithmException, NoSuchProviderException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        CertPathBuilder certPB;
+        for (int i = 0; i < validValues.length; i++) {
+            certPB = CertPathBuilder.getInstance(validValues[i], defaultProviderName);
+            assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
+            assertEquals("Incorrect provider name", certPB.getProvider().getName(), defaultProviderName);
+        }        
+    }
+
+    /**
+     * Test for <code>getInstance(String algorithm, Provider provider)</code> method
+	 * Assertion: throws IllegalArgumentException when provider is null
+     */
+    public void testCertPathBuilder08()
+            throws NoSuchAlgorithmException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        Provider prov = null;
+        for (int t = 0; t < validValues.length; t++ ) {
+            try {
+                CertPathBuilder.getInstance(validValues[t], prov);
+                fail("IllegalArgumentException must be thrown");
+            } catch (IllegalArgumentException e1) {
+            }
+        }        
+    }
+    
+    /**
+     * Test for <code>getInstance(String algorithm, String provider)</code> method
+	 * Assertion: 
+	 * throws NullPointerException when algorithm is null 
+	 * throws NoSuchAlgorithmException when algorithm  is not correct
+     */
+    public void testCertPathBuilder09()
+            throws NoSuchAlgorithmException, NoSuchProviderException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        try {
+            CertPathBuilder.getInstance(null, defaultProvider);
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertPathBuilder.getInstance(invalidValues[i], defaultProvider);
+                fail("NoSuchAlgorithm must be thrown");
+            } catch (NoSuchAlgorithmException e1) {
+            }
+        }
+    }
+    /**
+     * Test for <code>getInstance(String algorithm, String provider)</code> method
+	 * Assertion: returns CertPathBuilder object
+     */
+    public void testCertPathBuilder10()
+            throws NoSuchAlgorithmException, NoSuchProviderException  {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        CertPathBuilder certPB;
+        for (int i = 0; i < invalidValues.length; i++) {
+            certPB = CertPathBuilder.getInstance(validValues[i], defaultProvider);
+            assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
+            assertEquals("Incorrect provider name", certPB.getProvider(), defaultProvider);
+        }        
+    }
+    /**
+     * Test for <code>build(CertPathParameters params)</code> method
+	 * Assertion: throws InvalidAlgorithmParameterException params is null
+     */
+    public void testCertPathBuilder11()
+            throws NoSuchAlgorithmException, NoSuchProviderException, 
+            CertPathBuilderException {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }        
+        CertPathBuilder [] certPB = createCPBs();
+        assertNotNull("CertPathBuilder objects were not created", certPB);
+        for (int i = 0; i < certPB.length; i++ ){
+            try {
+                certPB[i].build(null);
+                fail("InvalidAlgorithmParameterException must be thrown");
+            } catch(InvalidAlgorithmParameterException e) {
+            }
+        }
+    }
+    /**
+     * Test for 
+     * <code>CertPathBuilder</code> constructor
+     * Assertion: returns CertPathBuilder object
+     */
+    public void testCertPathBuilder12()
+            throws CertificateException, NoSuchProviderException, 
+            NoSuchAlgorithmException, InvalidAlgorithmParameterException,
+            CertPathBuilderException {
+        if (!PKIXSupport) {
+            fail(NotSupportMsg);
+            return;
+        }
+        CertPathBuilderSpi spi = new MyCertPathBuilderSpi();
+        CertPathBuilder certPB = new myCertPathBuilder(spi, 
+                    defaultProvider, defaultType);
+        assertEquals("Incorrect algorithm", certPB.getAlgorithm(), defaultType);
+        assertEquals("Incorrect provider", certPB.getProvider(), defaultProvider);
+        try {
+            certPB.build(null);
+            fail("CertPathBuilderException must be thrown ");
+        } catch (CertPathBuilderException e) {            
+        }
+        certPB = new myCertPathBuilder(null, null, null);
+        assertNull("Incorrect algorithm", certPB.getAlgorithm());
+        assertNull("Incorrect provider", certPB.getProvider());            
+        try {
+            certPB.build(null);
+            fail("NullPointerException must be thrown ");
+        } catch (NullPointerException e) {            
+        }
+    }
+    public static void main(String args[]) {
+        junit.textui.TestRunner.run(CertPathBuilder1Test.class);
+    }  
+    
+}
+/**
+ * Addifional class to verify CertPathBuilder constructor
+ */
+class myCertPathBuilder extends CertPathBuilder {
+
+    public myCertPathBuilder(CertPathBuilderSpi spi, Provider prov, String type) {
+        super(spi, prov, type);
+    }
+}

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CertPathBuilder2Test.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/CertPathBuilder2Test.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CertPathBuilder2Test.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/CertPathBuilder2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java Tue Jun 20 01:11:04 2006
@@ -1,254 +1,258 @@
-/*
- *  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 java.security.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-
-import org.apache.harmony.security.tests.support.SpiEngUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for CertPathBuilder class constructors and methods
- * 
- */
-
-public class CertPathBuilder2Test extends TestCase {
-    private static final String defaultAlg = "CertPB";
-    private static final String CertPathBuilderProviderClass = "java.security.cert.MyCertPathBuilderSpi";
-
-    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] = "CeRtPb";
-        validValues[3] = "cERTpb";
-    }
-
-    Provider mProv;
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        mProv = (new SpiEngUtils()).new MyProvider("MyCertPathBuilderProvider",
-                "Provider for testing", CertPathBuilder1Test.srvCertPathBuilder
-                        .concat(".").concat(defaultAlg),
-                CertPathBuilderProviderClass);
-        Security.insertProviderAt(mProv, 1);
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        Security.removeProvider(mProv.getName());
-    }
-
-    /**
-     * Constructor for CertPathBuilder2Test.
-     * 
-     * @param arg0
-     */
-    public CertPathBuilder2Test(String arg0) {
-        super(arg0);
-    }
-
-    private void checkResult(CertPathBuilder certBuild)
-            throws InvalidAlgorithmParameterException,
-            CertPathBuilderException {
-        String dt = CertPathBuilder.getDefaultType();
-        String propName = "certpathbuild.type";
-        String dtN;
-        for (int i = 0; i <invalidValues.length; i++) {
-            Security.setProperty(propName, invalidValues[i]);
-            dtN = CertPathBuilder.getDefaultType();
-            if (!dtN.equals(invalidValues[i]) && !dtN.equals(dt)) {
-                fail("Incorrect default type: ".concat(dtN));
-            }
-        }
-        Security.setProperty(propName, dt);
-        assertEquals("Incorrect default type", CertPathBuilder.getDefaultType(),
-                dt);
-        try {
-            certBuild.build(null);
-            fail("CertPathBuilderException must be thrown");
-        } catch (CertPathBuilderException e) {
-        }    
-        CertPathBuilderResult cpbResult = certBuild.build(null);
-        assertNull("Not null CertPathBuilderResult", cpbResult);
-    }
-
-    /**
-     * Test for <code>getInstance(String algorithm)</code> method 
-     * Assertions:
-     * throws 
-	 * throws NullPointerException when algorithm is null 
-	 * throws NoSuchAlgorithmException when algorithm  is not correct
-     * returns CertPathBuilder object
-     */
-    public void testGetInstance01() throws NoSuchAlgorithmException,
-            InvalidAlgorithmParameterException, CertPathBuilderException {
-        try {
-            CertPathBuilder.getInstance(null);
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertPathBuilder.getInstance(invalidValues[i]);
-                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
-                        invalidValues[i]).concat(")"));
-            } catch (NoSuchAlgorithmException e) {
-            }
-        }
-        CertPathBuilder cerPB;
-        for (int i = 0; i < validValues.length; i++) {
-            cerPB = CertPathBuilder.getInstance(validValues[i]);
-            assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
-            assertEquals("Incorrect provider", cerPB.getProvider(), mProv);
-            checkResult(cerPB);
-        }
-    }
-
-    /**
-     * Test for <code>getInstance(String algorithm, String provider)</code> method
-     * Assertions: 
-	 * throws NullPointerException when algorithm is null 
-	 * throws NoSuchAlgorithmException when algorithm  is not correct
-     * throws IllegalArgumentException when provider is null or empty; 
-     * throws NoSuchProviderException when provider is available; 
-     * returns CertPathBuilder object
-     */
-    public void testGetInstance02() throws NoSuchAlgorithmException,
-            NoSuchProviderException, IllegalArgumentException,
-            InvalidAlgorithmParameterException, CertPathBuilderException {
-        try {
-            CertPathBuilder.getInstance(null, mProv.getName());
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertPathBuilder.getInstance(invalidValues[i], 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 {
-                CertPathBuilder.getInstance(validValues[i], prov);
-                fail("IllegalArgumentException must be thrown when provider is null (type: "
-                        .concat(validValues[i]).concat(")"));
-            } catch (IllegalArgumentException e) {
-            }
-            try {
-                CertPathBuilder.getInstance(validValues[i], "");
-                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 {
-                    CertPathBuilder.getInstance(validValues[i],
-                            invalidValues[j]);
-                    fail("NoSuchProviderException must be thrown (type: "
-                            .concat(validValues[i]).concat(" provider: ")
-                            .concat(invalidValues[j]).concat(")"));
-                } catch (NoSuchProviderException e) {
-                }
-            }
-        }
-        CertPathBuilder cerPB;
-        for (int i = 0; i < validValues.length; i++) {
-            cerPB = CertPathBuilder.getInstance(validValues[i], mProv
-                    .getName());
-            assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
-            assertEquals("Incorrect provider", cerPB.getProvider().getName(),
-                    mProv.getName());
-            checkResult(cerPB);
-        }
-    }
-
-    /**
-     * Test for <code>getInstance(String algorithm, Provider provider)</code>
-     * method 
-     * Assertions: 
-	 * throws NullPointerException when algorithm is null 
-	 * throws NoSuchAlgorithmException when algorithm  is not correct
-     * returns CertPathBuilder object
-     */
-    public void testGetInstance03() throws NoSuchAlgorithmException,
-            IllegalArgumentException,
-            InvalidAlgorithmParameterException, CertPathBuilderException {
-        try {
-            CertPathBuilder.getInstance(null, mProv);
-            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
-        } catch (NullPointerException e) {
-        } catch (NoSuchAlgorithmException e) {
-        }
-        for (int i = 0; i < invalidValues.length; i++) {
-            try {
-                CertPathBuilder.getInstance(invalidValues[i], 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 {
-                CertPathBuilder.getInstance(validValues[i], prov);
-                fail("IllegalArgumentException must be thrown when provider is null (type: "
-                        .concat(validValues[i]).concat(")"));
-            } catch (IllegalArgumentException e) {
-            }
-        }
-        CertPathBuilder cerPB;
-        for (int i = 0; i < validValues.length; i++) {
-            cerPB = CertPathBuilder.getInstance(validValues[i], mProv);
-            assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
-            assertEquals("Incorrect provider", cerPB.getProvider(), mProv);
-            checkResult(cerPB);
-        }
-    }
-    public static void main(String args[]) {
-        junit.textui.TestRunner.run(CertPathBuilder2Test.class);
-    }  
-    
-
-}
+/*
+ *  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.CertPathBuilder;
+import java.security.cert.CertPathBuilderException;
+import java.security.cert.CertPathBuilderResult;
+
+import org.apache.harmony.security.tests.java.security.cert.CertPathBuilder1Test;
+import org.apache.harmony.security.tests.support.SpiEngUtils;
+import org.apache.harmony.security.tests.support.SpiEngUtils.MyProvider;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for CertPathBuilder class constructors and methods
+ * 
+ */
+
+public class CertPathBuilder2Test extends TestCase {
+    private static final String defaultAlg = "CertPB";
+    private static final String CertPathBuilderProviderClass = "org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi";
+
+    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] = "CeRtPb";
+        validValues[3] = "cERTpb";
+    }
+
+    Provider mProv;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        mProv = (new SpiEngUtils()).new MyProvider("MyCertPathBuilderProvider",
+                "Provider for testing", CertPathBuilder1Test.srvCertPathBuilder
+                        .concat(".").concat(defaultAlg),
+                CertPathBuilderProviderClass);
+        Security.insertProviderAt(mProv, 1);
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        Security.removeProvider(mProv.getName());
+    }
+
+    /**
+     * Constructor for CertPathBuilder2Test.
+     * 
+     * @param arg0
+     */
+    public CertPathBuilder2Test(String arg0) {
+        super(arg0);
+    }
+
+    private void checkResult(CertPathBuilder certBuild)
+            throws InvalidAlgorithmParameterException,
+            CertPathBuilderException {
+        String dt = CertPathBuilder.getDefaultType();
+        String propName = "certpathbuild.type";
+        String dtN;
+        for (int i = 0; i <invalidValues.length; i++) {
+            Security.setProperty(propName, invalidValues[i]);
+            dtN = CertPathBuilder.getDefaultType();
+            if (!dtN.equals(invalidValues[i]) && !dtN.equals(dt)) {
+                fail("Incorrect default type: ".concat(dtN));
+            }
+        }
+        Security.setProperty(propName, dt);
+        assertEquals("Incorrect default type", CertPathBuilder.getDefaultType(),
+                dt);
+        try {
+            certBuild.build(null);
+            fail("CertPathBuilderException must be thrown");
+        } catch (CertPathBuilderException e) {
+        }    
+        CertPathBuilderResult cpbResult = certBuild.build(null);
+        assertNull("Not null CertPathBuilderResult", cpbResult);
+    }
+
+    /**
+     * Test for <code>getInstance(String algorithm)</code> method 
+     * Assertions:
+     * throws 
+	 * throws NullPointerException when algorithm is null 
+	 * throws NoSuchAlgorithmException when algorithm  is not correct
+     * returns CertPathBuilder object
+     */
+    public void testGetInstance01() throws NoSuchAlgorithmException,
+            InvalidAlgorithmParameterException, CertPathBuilderException {
+        try {
+            CertPathBuilder.getInstance(null);
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertPathBuilder.getInstance(invalidValues[i]);
+                fail("NoSuchAlgorithmException must be thrown (type: ".concat(
+                        invalidValues[i]).concat(")"));
+            } catch (NoSuchAlgorithmException e) {
+            }
+        }
+        CertPathBuilder cerPB;
+        for (int i = 0; i < validValues.length; i++) {
+            cerPB = CertPathBuilder.getInstance(validValues[i]);
+            assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
+            assertEquals("Incorrect provider", cerPB.getProvider(), mProv);
+            checkResult(cerPB);
+        }
+    }
+
+    /**
+     * Test for <code>getInstance(String algorithm, String provider)</code> method
+     * Assertions: 
+	 * throws NullPointerException when algorithm is null 
+	 * throws NoSuchAlgorithmException when algorithm  is not correct
+     * throws IllegalArgumentException when provider is null or empty; 
+     * throws NoSuchProviderException when provider is available; 
+     * returns CertPathBuilder object
+     */
+    public void testGetInstance02() throws NoSuchAlgorithmException,
+            NoSuchProviderException, IllegalArgumentException,
+            InvalidAlgorithmParameterException, CertPathBuilderException {
+        try {
+            CertPathBuilder.getInstance(null, mProv.getName());
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertPathBuilder.getInstance(invalidValues[i], 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 {
+                CertPathBuilder.getInstance(validValues[i], prov);
+                fail("IllegalArgumentException must be thrown when provider is null (type: "
+                        .concat(validValues[i]).concat(")"));
+            } catch (IllegalArgumentException e) {
+            }
+            try {
+                CertPathBuilder.getInstance(validValues[i], "");
+                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 {
+                    CertPathBuilder.getInstance(validValues[i],
+                            invalidValues[j]);
+                    fail("NoSuchProviderException must be thrown (type: "
+                            .concat(validValues[i]).concat(" provider: ")
+                            .concat(invalidValues[j]).concat(")"));
+                } catch (NoSuchProviderException e) {
+                }
+            }
+        }
+        CertPathBuilder cerPB;
+        for (int i = 0; i < validValues.length; i++) {
+            cerPB = CertPathBuilder.getInstance(validValues[i], mProv
+                    .getName());
+            assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
+            assertEquals("Incorrect provider", cerPB.getProvider().getName(),
+                    mProv.getName());
+            checkResult(cerPB);
+        }
+    }
+
+    /**
+     * Test for <code>getInstance(String algorithm, Provider provider)</code>
+     * method 
+     * Assertions: 
+	 * throws NullPointerException when algorithm is null 
+	 * throws NoSuchAlgorithmException when algorithm  is not correct
+     * returns CertPathBuilder object
+     */
+    public void testGetInstance03() throws NoSuchAlgorithmException,
+            IllegalArgumentException,
+            InvalidAlgorithmParameterException, CertPathBuilderException {
+        try {
+            CertPathBuilder.getInstance(null, mProv);
+            fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
+        } catch (NullPointerException e) {
+        } catch (NoSuchAlgorithmException e) {
+        }
+        for (int i = 0; i < invalidValues.length; i++) {
+            try {
+                CertPathBuilder.getInstance(invalidValues[i], 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 {
+                CertPathBuilder.getInstance(validValues[i], prov);
+                fail("IllegalArgumentException must be thrown when provider is null (type: "
+                        .concat(validValues[i]).concat(")"));
+            } catch (IllegalArgumentException e) {
+            }
+        }
+        CertPathBuilder cerPB;
+        for (int i = 0; i < validValues.length; i++) {
+            cerPB = CertPathBuilder.getInstance(validValues[i], mProv);
+            assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
+            assertEquals("Incorrect provider", cerPB.getProvider(), mProv);
+            checkResult(cerPB);
+        }
+    }
+    public static void main(String args[]) {
+        junit.textui.TestRunner.run(CertPathBuilder2Test.class);
+    }  
+    
+
+}



Mime
View raw message