harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r432532 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src/test: api/java.injected/java/security/cert/serialization/ api/java/org/apache/harmony/security/tests/java/security/cert/ resources/java/security/cert/serialization...
Date Fri, 18 Aug 2006 09:08:42 GMT
Author: smishura
Date: Fri Aug 18 02:08:38 2006
New Revision: 432532

URL: http://svn.apache.org/viewvc?rev=432532&view=rev
Log:
Move sertificate from file to util class

Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/java/security/cert/serialization/Certificate.X.509
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java?rev=432532&r1=432531&r2=432532&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/serialization/CertificateTest.java
Fri Aug 18 02:08:38 2006
@@ -36,6 +36,7 @@
 import java.security.cert.CertificateFactory;
 
 import org.apache.harmony.security.tests.support.cert.MyCertificate;
+import org.apache.harmony.security.tests.support.cert.TestUtils;
 
 import junit.framework.TestCase;
 
@@ -96,7 +97,8 @@
             return;
         }
         // Create object to be serialized
-        Certificate c1 = cf.generateCertificate(new FileInputStream(certFileName));
+        Certificate c1 = cf.generateCertificate(new ByteArrayInputStream(
+                TestUtils.getEncodedX509Certificate()));
         // This testcase uses ByteArray streams
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         // Serialize cert
@@ -132,7 +134,8 @@
             return;
         }
         // Create object to be compared to deserialized one
-        Certificate c1 = cf.generateCertificate(new FileInputStream(certFileName));
+        Certificate c1 = cf.generateCertificate(new ByteArrayInputStream(
+                TestUtils.getEncodedX509Certificate()));
         // Deserialize certificate from golden file
         Certificate c2 = deserialize(new FileInputStream(serializedCertFileName));
         // compare both Certificates

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.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/CertificateFactory3Test.java?rev=432532&r1=432531&r2=432532&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory3Test.java
Fri Aug 18 02:08:38 2006
@@ -21,6 +21,7 @@
 
 package org.apache.harmony.security.tests.java.security.cert;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.security.Provider;
@@ -35,7 +36,7 @@
 import junit.framework.TestCase;
 
 import org.apache.harmony.security.tests.support.SpiEngUtils;
-import org.apache.harmony.security.tests.support.TestUtils;
+import org.apache.harmony.security.tests.support.cert.TestUtils;
 
 /**
  * Tests for <code>CertificateFactory</code> class methods
@@ -49,8 +50,6 @@
 
     private static String defaultType = CertificateFactory1Test.defaultType;
 
-    public static String fileCertificateX509 = "java/security/cert/serialization/Certificate.X.509";
-
     public static String fileCertPathPki = "java/security/cert/serialization/CertPath.PkiPath";
 
     private static boolean X509Support = false;
@@ -65,12 +64,8 @@
 
         NotSupportMsg = defaultType.concat(" is not supported");
 
-        fileCertificateX509 = SpiEngUtils.getFileName(TestUtils.TEST_ROOT,
-                fileCertificateX509);
-        fileCertificateX509 = fileCertificateX509.replace('/',
-                File.separatorChar);
-
-        fileCertPathPki = SpiEngUtils.getFileName(TestUtils.TEST_ROOT,
+        fileCertPathPki = SpiEngUtils.getFileName(
+                org.apache.harmony.security.tests.support.TestUtils.TEST_ROOT,
                 fileCertPathPki);
         fileCertPathPki = fileCertPathPki.replace('/', File.separatorChar);
 
@@ -97,12 +92,10 @@
     public void testGenerateCertificate() throws Exception {
         CertificateFactory[] certFs = initCertFs();
         assertNotNull("CertificateFactory objects were not created", certFs);
-        FileInputStream fis = null;
         Certificate[] certs = new Certificate[3];
         for (int i = 0; i < certFs.length; i++) {
-            fis = new FileInputStream(fileCertificateX509);
-            certs[i] = certFs[i].generateCertificate(fis);
-            fis.close();
+            certs[i] = certFs[i].generateCertificate(new ByteArrayInputStream(
+                    TestUtils.getEncodedX509Certificate()));
         }
         assertEquals(certs[0], certs[1]);
         assertEquals(certs[0], certs[2]);
@@ -115,14 +108,13 @@
     public void testeGnerateCertificates() throws Exception {
         CertificateFactory[] certFs = initCertFs();
         assertNotNull("CertificateFactory objects were not created", certFs);
-        FileInputStream fis = new FileInputStream(fileCertificateX509);
-        Certificate cert = certFs[0].generateCertificate(fis);
-        fis.close();
+        Certificate cert = certFs[0]
+                .generateCertificate(new ByteArrayInputStream(TestUtils
+                        .getEncodedX509Certificate()));
         for (int i = 0; i < certFs.length; i++) {
             Collection col = null;
-            fis = new FileInputStream(fileCertificateX509);
-            col = certFs[i].generateCertificates(fis);
-            fis.close();
+            col = certFs[i].generateCertificates(new ByteArrayInputStream(
+                    TestUtils.getEncodedX509Certificate()));
             Iterator it = col.iterator();
             assertEquals("Incorrect Collection size", col.size(), 1);
             assertEquals("Incorect Certificate in Collection", cert, it.next());
@@ -137,9 +129,9 @@
         CertificateFactory[] certFs = initCertFs();
         assertNotNull("CertificateFactory objects were not created", certFs);
         // create list of certificates with one certificate
-        FileInputStream fis = new FileInputStream(fileCertificateX509);
-        Certificate cert = certFs[0].generateCertificate(fis);
-        fis.close();
+        Certificate cert = certFs[0]
+                .generateCertificate(new ByteArrayInputStream(TestUtils
+                        .getEncodedX509Certificate()));
         List list = new Vector();
         list.add(cert);
         for (int i = 0; i < certFs.length; i++) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java?rev=432532&r1=432531&r2=432532&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
Fri Aug 18 02:08:38 2006
@@ -22,6 +22,7 @@
 package org.apache.harmony.security.tests.support.cert;
 
 import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -52,10 +53,6 @@
 public class TestUtils {
     // Certificate type used during testing
     private static final String certType = "X.509";
-    // The file name to read certificate from
-    private static final String certFileName =
-        org.apache.harmony.security.tests.support.TestUtils.TEST_ROOT +
-        "java/security/cert/serialization/Certificate." + certType;
     // Key store type used during testing
     private static final String keyStoreType = "BKS";
     // The file name prefix to load keystore from
@@ -97,7 +94,8 @@
         }
         BufferedInputStream bis = null;
         try {
-            bis = new BufferedInputStream(new FileInputStream(certFileName));
+            bis = new BufferedInputStream(new ByteArrayInputStream(
+                    getEncodedX509Certificate()));
             X509Certificate c1 = (X509Certificate)cf.generateCertificate(bis);
 
             return new TrustAnchor(c1, null);
@@ -287,6 +285,27 @@
                 return null;
             }
         };
+    }
+    // X.509 encoded sertificate
+    private static final String ENCODED_X509_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n"
+            + "MIIDHTCCAtsCBEFT72swCwYHKoZIzjgEAwUAMHQxCzAJBgNVBAYTAlJVMQwwCgYDVQQIEwNOU08x\n"
+            + "FDASBgNVBAcTC05vdm9zaWJpcnNrMQ4wDAYDVQQKEwVJbnRlbDEVMBMGA1UECxMMRFJMIFNlY3Vy\n"
+            + "aXR5MRowGAYDVQQDExFWbGFkaW1pciBNb2xvdGtvdjAeFw0wNDA5MjQwOTU2NTlaFw0wNjA1MTcw\n"
+            + "OTU2NTlaMHQxCzAJBgNVBAYTAlJVMQwwCgYDVQQIEwNOU08xFDASBgNVBAcTC05vdm9zaWJpcnNr\n"
+            + "MQ4wDAYDVQQKEwVJbnRlbDEVMBMGA1UECxMMRFJMIFNlY3VyaXR5MRowGAYDVQQDExFWbGFkaW1p\n"
+            + "ciBNb2xvdGtvdjCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3Ujzv\n"
+            + "RADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7\n"
+            + "qdf+t8Yb+DtX58aophUPBPuD9tPFHsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8V\n"
+            + "IwvMspK5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9B4JnUVlXjrrU\n"
+            + "WU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEk\n"
+            + "O8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GFAAKBgQDiNmj9jgWu1ILYqYWcUhNN\n"
+            + "8CjjRitf80yWP/s/565wZz3anb2w72jum63mdShDko9eOOOd1hiVuiBnNhSL7D6JfIYBJvNXr1av\n"
+            + "Gw583BBv12OBgg0eAW/GRWBn2Ak2JjsoBc5x2c1HAEufakep7T6RoC+n3lqbKPKyHWVdfqQ9KTAL\n"
+            + "BgcqhkjOOAQDBQADLwAwLAIUaRS3C9dXcMbrOAhmidFBr7oMvH0CFEC3LUwfLJX5gY8P6uxpkPx3\n"
+            + "JDSM\n" + "-----END CERTIFICATE-----\n";
+
+    public static byte[] getEncodedX509Certificate() {
+        return ENCODED_X509_CERTIFICATE.getBytes();
     }
     
     /**



Mime
View raw message