harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r400234 - in /incubator/harmony/enhanced/classlib/trunk: modules/security/make/common/ modules/security/src/test/java/common/tests/api/java/security/cert/ support/src/test/java/tests/support/resource/
Date Sat, 06 May 2006 04:19:04 GMT
Author: smishura
Date: Fri May  5 21:19:00 2006
New Revision: 400234

URL: http://svn.apache.org/viewcvs?rev=400234&view=rev
Log:
Fix for resource files loading to make 4 security tests pass.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateFactoryTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLEntryTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CertificateTest.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml?rev=400234&r1=400233&r2=400234&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml Fri May
 5 21:19:00 2006
@@ -94,6 +94,10 @@
             <!-- to pick up junit.jar -->
             <jvmarg value="-Xbootclasspath/a:${hy.security.bin.test}${path.separator}../../../../${junit.jar}${path.separator}../../../../build/tests"/>
 
+            <classpath>
+                <pathelement path="${hy.security.src.test.resources}"/>
+            </classpath>
+
             <env key="JAVA_HOME" value="${test.jre.home}"/>
 
             <formatter type="xml" />
@@ -118,11 +122,6 @@
                     <exclude name="tests/api/java/security/PermissionCollectionTest.java"/>
                   
                     <!-- No SHA1PRNG implementation yet -->
                     <exclude name="tests/api/java/security/SecureRandomTest.java"/>
-
-                    <exclude name="tests/api/java/security/cert/CertificateFactoryTest.java"/>
-                    <exclude name="tests/api/java/security/cert/X509CertificateTest.java"/>
-                    <exclude name="tests/api/java/security/cert/X509CRLEntryTest.java"/>
-                    <exclude name="tests/api/java/security/cert/X509CRLTest.java"/>
                 </fileset>
             </batchtest>
         </junit>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateFactoryTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateFactoryTest.java?rev=400234&r1=400233&r2=400234&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateFactoryTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateFactoryTest.java
Fri May  5 21:19:00 2006
@@ -72,7 +72,7 @@
 		}
 
 		// Test 2
-		InputStream is = Support_Resources.getStream("hyts_badpem.cer");
+		InputStream is = Support_Resources.getResourceStream("hyts_badpem.cer");
 		boolean caughtException = false;
 		try {
 			CertificateFactory fact = CertificateFactory.getInstance("X.509");

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLEntryTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLEntryTest.java?rev=400234&r1=400233&r2=400234&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLEntryTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLEntryTest.java
Fri May  5 21:19:00 2006
@@ -28,21 +28,14 @@
 
 	private X509Certificate pemCert = null;
 
-	protected void setUp() {
-		try {
-			InputStream is = Support_Resources
-					.getStream("hyts_certificate_PEM.txt");
-			if (is != null) {
-				CertificateFactory certFact = CertificateFactory
-						.getInstance("X509");
-				pemCert = (X509Certificate) certFact.generateCertificate(is);
-			} else {
-				fail("Problem occurred opening hyts_certificate_PEM.txt");
-			}
-		} catch (CertificateException e) {
-			fail("Unexpected CertificateException : " + e);
-		}
-	}
+	protected void setUp() throws Exception {
+
+        InputStream is = Support_Resources
+                .getResourceStream("hyts_certificate_PEM.txt");
+
+        CertificateFactory certFact = CertificateFactory.getInstance("X509");
+        pemCert = (X509Certificate) certFact.generateCertificate(is);
+    }
 
 	/**
 	 * @tests java.security.cert.X509CRLEntry#getExtensionValue(java.lang.String)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLTest.java?rev=400234&r1=400233&r2=400234&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLTest.java
Fri May  5 21:19:00 2006
@@ -28,21 +28,14 @@
 
 	private X509Certificate pemCert = null;
 
-	protected void setUp() {
-		try {
-			InputStream is = Support_Resources
-					.getStream("hyts_certificate_PEM.txt");
-			if (is != null) {
-				CertificateFactory certFact = CertificateFactory
-						.getInstance("X509");
-				pemCert = (X509Certificate) certFact.generateCertificate(is);
-			} else {
-				fail("Problem occurred opening hyts_certificate_PEM.txt");
-			}
-		} catch (CertificateException e) {
-			fail("Unexpected CertificateException : " + e);
-		}
-	}
+	protected void setUp() throws Exception {
+
+        InputStream is = Support_Resources
+                .getResourceStream("hyts_certificate_PEM.txt");
+
+        CertificateFactory certFact = CertificateFactory.getInstance("X509");
+        pemCert = (X509Certificate) certFact.generateCertificate(is);
+    }
 
 	/**
 	 * @tests java.security.cert.X509CRL#getExtensionValue(java.lang.String)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CertificateTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CertificateTest.java?rev=400234&r1=400233&r2=400234&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CertificateTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CertificateTest.java
Fri May  5 21:19:00 2006
@@ -27,21 +27,14 @@
 public class X509CertificateTest extends junit.framework.TestCase {
 	private X509Certificate pemCert = null;
 
-	protected void setUp() {
-		try {
-			InputStream is = Support_Resources
-					.getStream("hyts_certificate_PEM.txt");
-			if (is != null) {
-				CertificateFactory certFact = CertificateFactory
-						.getInstance("X509");
-				pemCert = (X509Certificate) certFact.generateCertificate(is);
-			} else {
-				fail("Problem occurred opening hyts_certificate_PEM.txt");
-			}
-		} catch (CertificateException e) {
-			fail("Unexpected CertificateException : " + e);
-		}
-	}
+	protected void setUp() throws Exception {
+
+        InputStream is = Support_Resources
+                .getResourceStream("hyts_certificate_PEM.txt");
+
+        CertificateFactory certFact = CertificateFactory.getInstance("X509");
+        pemCert = (X509Certificate) certFact.generateCertificate(is);
+    }
 
 	/**
 	 * @tests java.security.cert.X509Certificate#getExtensionValue(java.lang.String)

Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java?rev=400234&r1=400233&r2=400234&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
Fri May  5 21:19:00 2006
@@ -131,4 +131,21 @@
 		return "http://" + Support_Configuration.TestResources + resource;
 	}
 
+    /**
+     * Util method to load resource files
+     * 
+     * @param name - name of resource file
+     * @return - resource input stream
+     */
+    public static InputStream getResourceStream(String name) {
+
+        InputStream is = ClassLoader.getSystemClassLoader()
+                .getResourceAsStream(name);
+
+        if (is == null) {
+            throw new RuntimeException("Failed to load resource: " + name);
+        }
+        
+        return is;
+    }
 }



Mime
View raw message