Author: heiko.braun(a)jboss.com
Date: 2008-06-11 17:04:01 -0400 (Wed, 11 Jun 2008)
New Revision: 7500
Modified:
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
Log:
Setup classloader hierarchy for wsprovider tests
Modified:
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java
===================================================================
---
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java 2008-06-11
21:00:07 UTC (rev 7499)
+++
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java 2008-06-11
21:04:01 UTC (rev 7500)
@@ -35,10 +35,11 @@
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
-public class PluginBase extends JBossWSTest
+public abstract class PluginBase extends JBossWSTest
{
protected Object delegate = null;
protected ClassLoader origClassLoader;
+ protected String oldCPProp;
protected void dispatch(String methodName) throws Exception
{
@@ -53,7 +54,7 @@
}
}
- protected void maskClasspath() throws Exception
+ protected void setupClasspath() throws Exception
{
String classpath = System.getProperty("surefire.test.class.path");
List<URL> jarURLs = new LinkedList<URL>();
@@ -68,6 +69,8 @@
String s = st.nextToken();
if(s.endsWith(".jar")) // JBWS-2175: skip target/classes and
target/test-classes
{
+ if( filtered(s) )
+ continue;
jarURLs.add( new File(s).toURL() );
jarURLString.append( s ).append(File.pathSeparator);
}
@@ -89,15 +92,19 @@
this.origClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(jarFirstClassLoader);
+ this.oldCPProp = System.getProperty("java.class.path");
System.setProperty("java.class.path", jarURLString.toString());
}
- protected void unmaskClasspath()
+ protected abstract boolean filtered(String jarName);
+
+ protected void restoreClasspath()
{
if(this.origClassLoader !=null)
{
Thread.currentThread().setContextClassLoader(this.origClassLoader);
this.origClassLoader = null;
+ System.setProperty("java.class.path", oldCPProp);
}
}
}
Modified:
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java
===================================================================
---
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java 2008-06-11
21:00:07 UTC (rev 7499)
+++
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java 2008-06-11
21:04:01 UTC (rev 7500)
@@ -40,7 +40,7 @@
{
// JBWS-2175
- maskClasspath();
+ setupClasspath();
Class wscClass =
Thread.currentThread().getContextClassLoader().loadClass("org.jboss.test.ws.jaxws.smoke.tools.WSConsumerPlugin");
delegate = wscClass.newInstance();
@@ -49,7 +49,7 @@
protected void tearDown() throws Exception
{
- unmaskClasspath();
+ restoreClasspath();
}
/**
@@ -160,4 +160,8 @@
dispatch("testSOAP12Extension");
}
+ protected boolean filtered(String jarName)
+ {
+ return false;
+ }
}
Modified:
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java
===================================================================
---
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java 2008-06-11
21:00:07 UTC (rev 7499)
+++
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java 2008-06-11
21:04:01 UTC (rev 7500)
@@ -48,7 +48,6 @@
// relative to test execution
File outputDirectory;
-
public WSProviderPlugin()
{
// create a new consumer for every test case
@@ -56,16 +55,16 @@
if(toogleMessageOut) provider.setMessageStream(System.out);
// shared output directory, relative to test execution
- outputDirectory = createResourceFile("../test-classes");
+ outputDirectory = createResourceFile("../wsprovide/java");
}
private ClassLoader getArtefactClassLoader() throws Exception {
- /*URLClassLoader loader = new URLClassLoader(new URL[] {
- new
URL("file:"+System.getProperty("user.dir")+"/wsprovide/java/")
}
+ URLClassLoader loader = new URLClassLoader(
+ new URL[] { outputDirectory.toURL() },
+ Thread.currentThread().getContextClassLoader()
);
- return loader;*/
- return Thread.currentThread().getContextClassLoader();
+ return loader;
}
/**
@@ -180,7 +179,7 @@
new
URL("file:"+targetDir+"/test-libs/jaxws-classloading-types.jar"),
new URL("file:"+jdkHome+"/lib/tools.jar")
},
- Thread.currentThread().getContextClassLoader()
+ getArtefactClassLoader()
);
provider.setClassLoader(loader);
Modified:
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
===================================================================
---
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java 2008-06-11
21:00:07 UTC (rev 7499)
+++
framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java 2008-06-11
21:04:01 UTC (rev 7500)
@@ -33,9 +33,8 @@
*/
protected void setUp() throws Exception
{
-
- maskClasspath();
+ setupClasspath();
Class wspClass = Thread.currentThread().getContextClassLoader()
.loadClass("org.jboss.test.ws.jaxws.smoke.tools.WSProviderPlugin");
@@ -45,7 +44,7 @@
protected void tearDown() throws Exception
{
- unmaskClasspath();
+ restoreClasspath();
}
public void testGenerateWsdl() throws Exception
@@ -82,4 +81,17 @@
{
dispatch("testMessageStream");
}
+
+ /**
+ * Filter sun jaxws implementation because it clashes
+ * with the native one (ServiceLoader...)
+ * @param jarName
+ * @return
+ */
+ protected boolean filtered(String jarName)
+ {
+ return (isIntegrationNative() &&
+ (jarName.indexOf("jaxws-rt")!=-1 ||
jarName.indexOf("jaxws-tools")!=-1)
+ );
+ }
}
Show replies by date