harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r490112 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/cert/ test/api/java/org/apache/harmony/security/tests/java/security/cert/
Date Mon, 25 Dec 2006 07:21:09 GMT
Author: smishura
Date: Sun Dec 24 23:21:08 2006
New Revision: 490112

URL: http://svn.apache.org/viewvc?view=rev&rev=490112
Log:
Apply patch for CertPathBuilder from HARMONY-2785
[classlib][security]CertPathBuilder.getDefaultType fails to get the one specified in security.properties.

Refactor test for CertPathBuilder.getDefaultType()

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPathBuilder.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPathBuilder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPathBuilder.java?view=diff&rev=490112&r1=490111&r2=490112
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPathBuilder.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPathBuilder.java
Sun Dec 24 23:21:08 2006
@@ -47,7 +47,7 @@
     private static Engine engine = new Engine(SERVICE);
 
     // Store default property name
-    private static final String PROPERTYNAME = "certpathbuild.type"; //$NON-NLS-1$
+    private static final String PROPERTYNAME = "certpathbuilder.type"; //$NON-NLS-1$
 
     // Default value of CertPathBuilder type. It returns if certpathbuild.type
     // property is not defined in java.security file

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java?view=diff&rev=490112&r1=490111&r2=490112
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
Sun Dec 24 23:21:08 2006
@@ -32,10 +32,12 @@
 import java.security.cert.CertPathBuilderSpi;
 import java.security.cert.CertificateException;
 
+import junit.framework.TestCase;
+
 import org.apache.harmony.security.tests.support.SpiEngUtils;
 import org.apache.harmony.security.tests.support.cert.MyCertPathBuilderSpi;
 
-import junit.framework.TestCase;
+import tests.support.Support_Exec;
 
 /**
  * Tests for <code>CertPathBuilder</code> class constructors and
@@ -67,6 +69,8 @@
     
     private static String NotSupportMsg = "";
 
+    public static final String DEFAULT_TYPE_PROPERTY = "certpathbuilder.type";
+
     static {
         defaultProvider = SpiEngUtils.isSupport(defaultType,
                 srvCertPathBuilder);
@@ -93,32 +97,30 @@
     }    
     
     /**
-     * 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);            
+     * @tests java.security.cert.CertPathBuilder#getDefaultType()
+     */
+    public void test_getDefaultType() throws Exception {
+
+        // Regression for HARMONY-2785
+
+        // test: default value  
+        assertNull(Security.getProperty(DEFAULT_TYPE_PROPERTY));
+        assertEquals("PKIX", CertPathBuilder.getDefaultType());
+
+        // test: security property. fork new VM to keep testing env. clean
+        Support_Exec.execJava(new String[] { DefaultType.class.getName() },
+                null, true);
+    }
+
+    public static class DefaultType {
+
+        public static void main(String[] args) {
+
+            Security.setProperty(DEFAULT_TYPE_PROPERTY, "MyType");
+            assertEquals("MyType", CertPathBuilder.getDefaultType());
+
+            Security.setProperty(DEFAULT_TYPE_PROPERTY, "AnotherType");
+            assertEquals("AnotherType", CertPathBuilder.getDefaultType());
         }
     }
     

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java?view=diff&rev=490112&r1=490111&r2=490112
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
Sun Dec 24 23:21:08 2006
@@ -33,7 +33,6 @@
 
 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;
 
@@ -90,7 +89,7 @@
             throws InvalidAlgorithmParameterException,
             CertPathBuilderException {
         String dt = CertPathBuilder.getDefaultType();
-        String propName = "certpathbuild.type";
+        String propName = CertPathBuilder1Test.DEFAULT_TYPE_PROPERTY;
         String dtN;
         for (int i = 0; i <invalidValues.length; i++) {
             Security.setProperty(propName, invalidValues[i]);



Mime
View raw message