I'm trying to use cactus to invoke and report junit
tests. These tests all currently work through
junitee. I have added the static suite method
public static Test suite(){
ServletTestSuite suite = new ServletTestSuite();
suite.addTestSuite(ViewConfigTest.class);
return suite;
}
For simple testcases this works fine, but when the
test requires services provided by the container they
fail during initialization. Specifically, the common
logger for my product has this line
final static JMSHelper.DestinationTopic destination =
new
JMSHelper.DestinationTopic(JMSTopicNames.ONEXGENERIC,true,JMSTopicNames.ONEXGENERIC);
And when I try and use cactus to run a testcase that
requires to use of the logger I get the error below
(see stack further down). I believe what is missing
is the onex.properties files:
java.lang.RuntimeException: Failed to locate
onex.properties file at
com.onexchange.util.Config.loadFromFile(Config.java:151)
at com.onexchange.util.Config.<init>(Config.java:176)
at com.onexchange.util.Config.makeMe(Config.java:366)
at com.onexchange.util.Config.get(Config.java:243) at
com.onexchange.util.Config.getString(Config.java:258)
I tried putting the onex.properties file in the
classpath (see classpath below), but that did not
work. How else can I provide a properties file to the
client side of cactus.
___Full stack trace___
Exception in constructor: testExec
(java.lang.ExceptionInInitializerError at
com.onexchange.util.Log.<clinit>(Log.java:333) at
com.onexchange.util.OnexSystemException.<init>(OnexSystemException.java:15)
at
com.onexchange.tools.junit.TestCasePermission.setOnexSubject(TestCasePermission.java:42)
at
com.onexchange.tools.junit.TestCasePermission.<init>(TestCasePermission.java:22)
at
com.onexchange.tools.osh.server.ViewConfigTest.<init>(ViewConfigTest.java:55)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at
org.apache.cactus.internal.AbstractTestSuite.addTestMethod(AbstractTestSuite.java:159)
at
org.apache.cactus.internal.AbstractTestSuite.<init>(AbstractTestSuite.java:95)
at
org.apache.cactus.ServletTestSuite.<init>(ServletTestSuite.java:47)
at
org.apache.cactus.ServletTestSuite.createTestSuite(ServletTestSuite.java:87)
at
org.apache.cactus.internal.AbstractTestSuite.addTestSuite(AbstractTestSuite.java:126)
at
org.apache.cactus.ServletTestSuite.addTestSuite_aroundBody2(ServletTestSuite.java:79)
at
org.apache.cactus.ServletTestSuite.addTestSuite_aroundBody3$advice(ServletTestSuite.java:117)
at
org.apache.cactus.ServletTestSuite.addTestSuite(ServletTestSuite.java)
at
com.onexchange.tools.osh.server.ViewConfigTest.suite(ViewConfigTest.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324) at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:257)
at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:210)
at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:532)
Caused by: java.lang.RuntimeException: Failed to
locate onex.properties file at
com.onexchange.util.Config.loadFromFile(Config.java:151)
at com.onexchange.util.Config.<init>(Config.java:176)
at com.onexchange.util.Config.makeMe(Config.java:366)
at com.onexchange.util.Config.get(Config.java:243) at
com.onexchange.util.Config.getString(Config.java:258)
at
com.onexchange.msg.JMSTopicNames.<clinit>(JMSTopicNames.java:17)
... 25 more )
junit.framework.AssertionFailedError: Exception in
constructor: testExec
(java.lang.ExceptionInInitializerError
at com.onexchange.util.Log.<clinit>(Log.java:333)
at
com.onexchange.util.OnexSystemException.<init>(OnexSystemException.java:15)
at
com.onexchange.tools.junit.TestCasePermission.setOnexSubject(TestCasePermission.java:42)
at
com.onexchange.tools.junit.TestCasePermission.<init>(TestCasePermission.java:22)
at
com.onexchange.tools.osh.server.ViewConfigTest.<init>(ViewConfigTest.java:55)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at
org.apache.cactus.internal.AbstractTestSuite.addTestMethod(AbstractTestSuite.java:159)
at
org.apache.cactus.internal.AbstractTestSuite.<init>(AbstractTestSuite.java:95)
at
org.apache.cactus.ServletTestSuite.<init>(ServletTestSuite.java:47)
at
org.apache.cactus.ServletTestSuite.createTestSuite(ServletTestSuite.java:87)
at
org.apache.cactus.internal.AbstractTestSuite.addTestSuite(AbstractTestSuite.java:126)
at
org.apache.cactus.ServletTestSuite.addTestSuite_aroundBody2(ServletTestSuite.java:79)
at
org.apache.cactus.ServletTestSuite.addTestSuite_aroundBody3$advice(ServletTestSuite.java:117)
at
org.apache.cactus.ServletTestSuite.addTestSuite(ServletTestSuite.java)
at
com.onexchange.tools.osh.server.ViewConfigTest.suite(ViewConfigTest.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Caused by: java.lang.RuntimeException: Failed to
locate onex.properties file
at
com.onexchange.util.Config.loadFromFile(Config.java:151)
at com.onexchange.util.Config.<init>(Config.java:176)
at com.onexchange.util.Config.makeMe(Config.java:366)
at com.onexchange.util.Config.get(Config.java:243)
at
com.onexchange.util.Config.getString(Config.java:258)
at
com.onexchange.msg.JMSTopicNames.<clinit>(JMSTopicNames.java:17)
... 25 more
)
at
org.apache.cactus.internal.AbstractTestSuite$1.runTest(AbstractTestSuite.java:347)
at
org.apache.cactus.internal.AbstractTestSuite.runTest(AbstractTestSuite.java:259)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody0(AbstractTestSuite.java:250)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody1$advice(AbstractTestSuite.java:117)
at
org.apache.cactus.internal.AbstractTestSuite.run(AbstractTestSuite.java)
at
org.apache.cactus.internal.AbstractTestSuite.runTest(AbstractTestSuite.java:259)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody0(AbstractTestSuite.java:250)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody1$advice(AbstractTestSuite.java:117)
at
org.apache.cactus.internal.AbstractTestSuite.run(AbstractTestSuite.java)
___Classpath___
<path id="classpath.servertests">
<pathelement
location="C:\weblogic\weblogic81\config\onexdomain-v3x\onex.properties"/>
<pathelement location="${junit.classes}"/>
<pathelement location="${classes}"/>
<pathelement
location="${junit.lib}/cactus-1.6.1.jar"/>
<pathelement
location="${junit.lib}/cactus-ant-1.6.1.jar"/>
<pathelement
location="${junit.lib}/aspectjrt-1.1.1.jar"/>
<pathelement
location="${junit.lib}/commons-httpclient-2.0.jar"/>
<pathelement
location="${junit.lib}/commons-logging-1.0.3.jar"/>
<pathelement location="${junit.lib}/log4j-1.2.8.jar"/>
<pathelement location="${junit.lib}/junit.jar"/>
<pathelement
location="${mercuryclient}/base_client.jar" />
<pathelement
location="${mercuryclient}/jse_client.jar" />
<pathelement location="${3rdparty}/concurrent.jar"/>
<pathelement location="${3rdparty}/cos.jar"/>
<pathelement location="${3rdparty}/ecs-1.3.3.jar"/>
<pathelement location="${3rdparty}/fixlibs.jar"/>
<pathelement
location="${3rdparty}/jakarta-oro-2.0.6.jar"/>
<pathelement location="${3rdparty}/ant/lib/ant.jar" />
<pathelement location="${3rdparty}/ant/lib/log4j.jar"
/>
<pathelement
location="${3rdparty}/ant/lib/xdoclet.jar" />
<pathelement location="${3rdparty}/jdom.jar" />
<pathelement
location="${onex.weblogic.home}/server/lib/CR189040_810sp3.jar"
/>
<pathelement
location="${onex.weblogic.home}/server/lib/webservices.jar"/>
<pathelement location="${WLJAR}"/>
<pathelement
location="${onex.weblogic.home}/server/lib/ojdbc14.jar"/>
<pathelement
location="${onex.weblogic.home}/javelin/lib/javelin.jar"/>
<pathelement
location="${onex.java.home}/jre/lib/rt.jar"/>
<pathelement
location="${onex.java.home}/lib/tools.jar"/>
<pathelement
location="C:\weblogic\weblogic81\config\onexdomain-v3x\config.xml"/>
<pathelement
location="C:\weblogic\weblogic81\config\onexdomain-v3x\boot.properties"/>
<pathelement
location="C:\weblogic\weblogic81\config\onexdomain-v3x\configNocluster-oracle.xml"/>
<pathelement
location="C:\weblogic\weblogic81\config\onexdomain-v3x\config-oracle.xml"/>
<pathelement
location="C:\weblogic\weblogic81\config\onexdomain-v3x\fixgateway.properties"/>
<pathelement
location="C:\weblogic\weblogic81\config\onexdomain-v3x\fixgateway.properties"/>
</path>
___ant target___
<target name="runtests">
<cactus fork="yes"
earfile="${onex.weblogic.base}/applications/onex.ear"
printsummary="withOutAndErr"
errorProperty="test.failed"
failureProperty="test.failed">
<formatter type="xml" />
<classpath>
<path refid="classpath.servertests"/>
/classpath>
<containerset>
<generic name="localhost" port="7001" />
</containerset>
<!-- Configure the cactus task for logging -->
<cactusproperty server="false"
propertiesFile="${junit.lib}/logging_client.properties"/>
<cactusproperty server="true"
propertiesFile="${junit.lib}/logging_server.properties"/>
<batchtest todir="${junit.home}/reports">
<fileset dir="${junit.classes}">
<include name="**/ViewConfigTest*"/>
</fileset>
</batchtest>
</cactus>
-Fazle Khan
__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]