You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2006/03/07 20:03:40 UTC
svn commit: r383960 - in
/xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig:
ClassLoaderTest.java Driver.java
Author: mullan
Date: Tue Mar 7 11:03:39 2006
New Revision: 383960
URL: http://svn.apache.org/viewcvs?rev=383960&view=rev
Log:
JSR 105 ClassLoader test.
Added:
xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/ClassLoaderTest.java
xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/Driver.java
Added: xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/ClassLoaderTest.java
URL: http://svn.apache.org/viewcvs/xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/ClassLoaderTest.java?rev=383960&view=auto
==============================================================================
--- xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/ClassLoaderTest.java (added)
+++ xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/ClassLoaderTest.java Tue Mar 7 11:03:39 2006
@@ -0,0 +1,42 @@
+package javax.xml.crypto.test.dsig;
+
+import java.lang.reflect.Method;
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.*;
+
+/**
+ * This test uses more than one classloader to load a class (Driver) that
+ * invokes the XMLSignature API. It tests that there are not provider class
+ * loading issues with more than one classloader (see 6380953).
+ */
+public class ClassLoaderTest extends TestCase {
+
+ public ClassLoaderTest(String name) {
+ super(name);
+ }
+
+ public void test_multiple_loaders() throws Exception {
+
+ String baseDir = System.getProperty("basedir");
+ String fs = System.getProperty("file.separator");
+ File file0 = new File(baseDir + fs + "build" + fs + "classes" + fs);
+ File file1 = new File(baseDir + fs + "build" + fs + "test" + fs);
+ URL[] urls = new URL[2];
+ urls[0] = file0.toURL();
+ urls[1] = file1.toURL();
+ URLClassLoader uc1 = new URLClassLoader(urls, null);
+ URLClassLoader uc2 = new URLClassLoader(urls, null);
+
+ Class c1 = uc1.loadClass("javax.xml.crypto.test.dsig.Driver");
+ Class c2 = uc2.loadClass("javax.xml.crypto.test.dsig.Driver");
+ Object o1 = c1.newInstance();
+ Object o2 = c2.newInstance();
+ Method m1 = c1.getMethod("dsig");
+ Method m2 = c2.getMethod("dsig");
+ m1.invoke(o1);
+ m2.invoke(o2);
+ }
+}
Added: xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/Driver.java
URL: http://svn.apache.org/viewcvs/xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/Driver.java?rev=383960&view=auto
==============================================================================
--- xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/Driver.java (added)
+++ xml/security/trunk/src_unitTests/javax/xml/crypto/test/dsig/Driver.java Tue Mar 7 11:03:39 2006
@@ -0,0 +1,26 @@
+package javax.xml.crypto.test.dsig;
+
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.XMLSignatureFactory;
+import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
+
+/**
+ * Used by ClassLoaderTest
+ */
+public class Driver {
+
+ public void dsig() throws Exception {
+
+ XMLSignatureFactory fac = XMLSignatureFactory.getInstance
+ ("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
+ long start = System.currentTimeMillis();
+ for (int i=0; i<100; i++) {
+ CanonicalizationMethod cm = fac.newCanonicalizationMethod
+ (CanonicalizationMethod.EXCLUSIVE, (C14NMethodParameterSpec) null);
+ }
+ long end = System.currentTimeMillis();
+ long elapsed = end-start;
+ System.out.println("Elapsed:"+elapsed);
+ System.out.println("dsig succeeded");
+ }
+}