Author: alessio.soldano(a)jboss.com
Date: 2010-06-09 13:23:20 -0400 (Wed, 09 Jun 2010)
New Revision: 12450
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java
Log:
Make sure the smoke tools tests use correct log4j configuration
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java 2010-06-09
11:00:55 UTC (rev 12449)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java 2010-06-09
17:23:20 UTC (rev 12450)
@@ -40,10 +40,13 @@
{
protected Object delegate = null;
protected ClassLoader origClassLoader;
+ protected String origLog4jConf;
protected String oldCPProp;
protected boolean integrationNative = false;
protected boolean integrationMetro = false;
protected boolean integrationCXF = false;
+
+ private static final String LOG4J_CONF = "log4j.configuration";
protected void dispatch(String methodName) throws Exception
{
@@ -111,16 +114,22 @@
List<URL> jarFirstClasspath = new ArrayList<URL>();
- // Replace the ThreadContextLoader to prevent loading from target/classes and
target/test-classes
+ // Replace the ThreadContextLoader to prevent loading from target/classes and
target/test-classes.
+ // We also need to explicitly set the log4j.configuration sys prop to the current
log4j.xml resource url
+ // as changing the current classloader results in a log4j configuration coming from
thirdparty lib being used.
jarFirstClasspath.addAll(jarURLs);
jarFirstClasspath.addAll(classDirUrls);
URLClassLoader jarFirstClassLoader = new URLClassLoader(jarFirstClasspath.toArray(
new URL[] {}), this.origClassLoader);
this.origClassLoader = Thread.currentThread().getContextClassLoader();
+ URL log4jXmlUrl = this.origClassLoader.getResource("log4j.xml");
+ this.origLog4jConf = System.getProperty(LOG4J_CONF);
Thread.currentThread().setContextClassLoader(jarFirstClassLoader);
this.oldCPProp = System.getProperty("java.class.path");
System.setProperty("java.class.path", jarURLString.toString());
+ if (log4jXmlUrl != null)
+ System.setProperty(LOG4J_CONF, log4jXmlUrl.toString());
}
protected abstract boolean filtered(String jarName);
@@ -132,6 +141,14 @@
Thread.currentThread().setContextClassLoader(this.origClassLoader);
this.origClassLoader = null;
System.setProperty("java.class.path", oldCPProp);
+ if (origLog4jConf != null)
+ {
+ System.setProperty(LOG4J_CONF, origLog4jConf);
+ }
+ else
+ {
+ System.clearProperty(LOG4J_CONF);
+ }
}
}