[jboss-svn-commits] JBL Code SVN: r18885 - in labs/jbosstm/trunk/XTS/WSAS: classes/com/arjuna/mwtests/wsas and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 12 09:57:39 EDT 2008
Author: adinn
Date: 2008-03-12 09:57:39 -0400 (Wed, 12 Mar 2008)
New Revision: 18885
Added:
labs/jbosstm/trunk/XTS/WSAS/tests/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/qa/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/qa/junit/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/qa/junit/WSASTestRunnerServlet.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoHLS.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoSOAPContextImple.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/FailureHLS.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/TestInitialisation.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestSuite.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestUtils.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/
labs/jbosstm/trunk/XTS/WSAS/tests/dd/
labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_application.xml
labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_web-app.xml
Removed:
labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/
labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/common/
labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/hls/
Modified:
labs/jbosstm/trunk/XTS/WSAS/build.xml
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Context.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Hierarchy.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/NestedActivity.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/NullEnd.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Resume.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/StartEnd.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/StatusCheck.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Suspend.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Timeout.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Context1.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Context2.java
labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Service.java
Log:
restored most of the AS tests so they can run under junit. changes for JBTM-339
Modified: labs/jbosstm/trunk/XTS/WSAS/build.xml
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/build.xml 2008-03-12 13:03:25 UTC (rev 18884)
+++ labs/jbosstm/trunk/XTS/WSAS/build.xml 2008-03-12 13:57:39 UTC (rev 18885)
@@ -28,6 +28,13 @@
<!-- Load Build Properties File -->
<property file="${com.arjuna.mw.wsas.properties}"/>
+ <!-- Set hostname and port property defaults -->
+ <property environment="env"/>
+ <property name="jboss.dir" value="${env.JBOSS_HOME}"/>
+ <property name="deploy.dir" value="${jboss.dir}/server/default/deploy"/>
+ <property name="hostname" value="localhost"/>
+ <property name="port" value="8080"/>
+
<property name="com.arjuna.buildsystem.dir" location="../../antbuildsystem"/>
<property name="com.arjuna.jta.install" location="../../install"/>
@@ -51,6 +58,15 @@
<property name="com.arjuna.mwlabs.wsas.jar.dest" value="${com.arjuna.mwlabs.wsas.dest.root}/lib"/>
<property name="com.arjuna.mwlabs.wsas.htdocs.dest" value="build/htdocs"/>
+ <!-- test path names -->
+ <property name="com.arjuna.mwlabs.wsas.tests.src" value="tests/classes"/>
+ <property name="com.arjuna.mwlabs.wsas.tests.dd" value="tests/dd"/>
+ <property name="com.arjuna.mwlabs.wsas.tests.dest.root" value="tests/build"/>
+ <property name="com.arjuna.mwlabs.wsas.tests.dest" value="tests/build/classes"/>
+ <property name="com.arjuna.mwlabs.wsas.tests.dd.dest" value="tests/build/dd"/>
+ <property name="com.arjuna.mwlabs.wsas.tests.webapps.dest" value="tests/build/webapps"/>
+ <property name="com.arjuna.mwlabs.wsas.tests.jar.dest" value="tests/build/lib"/>
+
<!-- class path behaviour -->
<path id="com.arjuna.buildsystem.classpath">
<fileset dir="${com.arjuna.buildsystem.lib}" includes="${com.arjuna.buildsystem.lib.jars}"/>
@@ -64,6 +80,16 @@
<fileset dir="${com.arjuna.jta.install.lib}" includes="${jta.lib.jars}"/>
</path>
+ <!-- tests library and path to library -->
+ <property name="tests.libs" value="junit.jar"/>
+ <property name="tests.depend.libs" value="${tests.libs} ${com.arjuna.mwlabs.ts.modulename}.jar"/>
+ <property name="tests.depend.libs" value="${tests.libs} ${com.arjuna.mwlabs.ts.modulename}.jar"/>
+ <property name="tests.ext.libs" value="servlet.jar"/>
+
+ <path id="com.arjuna.mwlabs.wsas.tests.lib.path">
+ <fileset dir="${com.arjuna.xts.ext}" includes="${tests.libs} ${tests.ext.libs}"/>
+ </path>
+
<!-- Initialisation -->
<target name="com.arjuna.mwlabs.wsas.init">
<!-- Define default build properties -->
@@ -161,6 +187,59 @@
</target>
+ <!-- test targets -->
+ <target name="com.arjuna.mwlabs.wsas.tests.init" depends="com.arjuna.mw.wsas.clean">
+ <!-- make the test destination directories -->
+ <mkdir dir="${com.arjuna.mwlabs.wsas.tests.dest.root}"/>
+ <mkdir dir="${com.arjuna.mwlabs.wsas.tests.dest}"/>
+ <mkdir dir="${com.arjuna.mwlabs.wsas.tests.dd.dest}"/>
+ <mkdir dir="${com.arjuna.mwlabs.wsas.tests.webapps.dest}"/>
+ <mkdir dir="${com.arjuna.mwlabs.wsas.tests.jar.dest}"/>
+ </target>
+
+ <target name="com.arjuna.mwlabs.wsas.tests.compile" depends="com.arjuna.mwlabs.wsas.tests.init, com.arjuna.mw.wsas.jar">
+ <javac destdir="${com.arjuna.mwlabs.wsas.tests.dest}" debug="yes" optimize="no">
+ <classpath>
+ <pathelement path="${com.arjuna.mwlabs.wsas.jar.dest}/${com.arjuna.mwlabs.ts.modulename}.jar"/>
+ <path refid="com.arjuna.mwlabs.wsas.tests.lib.path"/>
+ <path refid="com.arjuna.mwlabs.wsas.lib.classpath"/>
+ </classpath>
+ <src path="${com.arjuna.mwlabs.wsas.tests.src}"/>
+ </javac>
+ </target>
+
+ <target name="com.arjuna.mwlabs.wsas.tests.webapps" depends="com.arjuna.mwlabs.wsas.tests.compile">
+ <copy file="${com.arjuna.mwlabs.wsas.tests.dd}/wsas-tests_web-app.xml" tofile="${com.arjuna.mwlabs.wsas.tests.dd.dest}/web-app.xml">
+ <filterset>
+ <filter token="hostname" value="${hostname}"/>
+ <filter token="port" value="${port}"/>
+ </filterset>
+ </copy>
+ <war warfile="${com.arjuna.mwlabs.wsas.tests.webapps.dest}/wsas-tests.war" webxml="${com.arjuna.mwlabs.wsas.tests.dd.dest}/web-app.xml">
+ <manifest>
+ <attribute name="Class-Path" value="${tests.depend.libs}"/>
+ </manifest>
+ <classes dir="${com.arjuna.mwlabs.wsas.tests.dest}"/>
+ </war>
+ <ear earfile="${com.arjuna.mwlabs.wsas.tests.webapps.dest}/wsas-tests.ear" appxml="${com.arjuna.mwlabs.wsas.tests.dd}/wsas-tests_application.xml">
+ <!-- we only need to deploy the ext test libs (junit) and
+ the tests war in JBoss AS 5.0. the rest of the XTS
+ code is deployed as a sar and the TS code is deployed
+ in the server lib
+ -->
+ <fileset dir="${com.arjuna.xts.ext}" includes="${tests.libs}"/>
+ <fileset dir="${com.arjuna.mwlabs.wsas.tests.webapps.dest}" includes="wsas-tests.war"/>
+ </ear>
+ </target>
+
+ <target name="com.arjuna.mwlabs.wsas.tests.deploy" depends="com.arjuna.mwlabs.wsas.tests.webapps, com.arjuna.mwlabs.wsas.tests.undeploy">
+ <copy file="${com.arjuna.mwlabs.wsas.tests.webapps.dest}/wsas-tests.ear" tofile="${deploy.dir}/wsas-tests.ear"/>
+ </target>
+
+ <target name="com.arjuna.mwlabs.wsas.tests.undeploy">
+ <delete file="${deploy.dir}/wsas-tests.ear"/>
+ </target>
+
<!-- Clean targets -->
<target name="com.arjuna.mw.wsas.clean">
<echo message="Cleaning module"/>
@@ -169,10 +248,15 @@
<delete dir="${com.arjuna.mwlabs.wsas.htdocs.dest}"/>
<delete file="${com.arjuna.mwlabs.wsas.jar.dest}/${com.arjuna.mwlabs.ts.modulename}.jar"/>
<delete file="${com.arjuna.mwlabs.wsas.info.dest}"/>
+ <!-- delete the test destination directories -->
+ <delete dir="${com.arjuna.mwlabs.wsas.tests.dest.root}"/>
</target>
<!-- Short target names -->
<target name="compile" depends="com.arjuna.mw.wsas.compile"/>
<target name="jar" depends="com.arjuna.mw.wsas.jar"/>
<target name="clean" depends="com.arjuna.mw.wsas.clean"/>
+ <target name="tests-webapps" depends="com.arjuna.mwlabs.wsas.tests.webapps"/>
+ <target name="tests-deploy" depends="com.arjuna.mwlabs.wsas.tests.deploy"/>
+ <target name="tests-undeploy" depends="com.arjuna.mwlabs.wsas.tests.undeploy"/>
</project>
Copied: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/qa/junit/WSASTestRunnerServlet.java (from rev 18801, labs/jbosstm/trunk/XTS/WSTX/tests/classes/com/arjuna/qa/junit/WSTXTestRunnerServlet.java)
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/qa/junit/WSASTestRunnerServlet.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/qa/junit/WSASTestRunnerServlet.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,607 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (c) 2002, 2003, Arjuna Technologies Limited.
+ *
+ * WSTXTestRunnerServlet.java
+ */
+
+package com.arjuna.qa.junit;
+
+import java.io.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import junit.framework.*;
+
+public class WSASTestRunnerServlet extends HttpServlet
+{
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+
+ _testSuiteClassName = config.getInitParameter("TestSuiteClassName");
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ try
+ {
+ PrintWriter writer = response.getWriter();
+
+ response.setContentType("text/html");
+ response.setHeader("Cache-Control", "no-cache");
+
+ if (request.getParameter("failednumber") != null)
+ doStatusFailed(writer, request, response);
+ else if (request.getParameter("errornumber") != null)
+ doStatusError(writer, request, response);
+ else
+ doStatus(writer, request, response);
+ }
+ catch (Exception exception)
+ {
+ log("Test Runner: doGet failed", exception);
+
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.toString());
+ }
+ catch (Error error)
+ {
+ log("Test Runner: doGet failed", error);
+
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, error.toString());
+ }
+ }
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ try
+ {
+ PrintWriter writer = response.getWriter();
+
+ response.setContentType("text/html");
+ response.setHeader("Cache-Control", "no-cache");
+
+ if ((_runnerThread == null) || (! _runnerThread.isAlive()))
+ {
+ _runnerThread = new RunnerThread();
+ _runnerThread.start();
+ }
+
+ if (request.getParameter("failednumber") != null)
+ doStatusFailed(writer, request, response);
+ else if (request.getParameter("errornumber") != null)
+ doStatusError(writer, request, response);
+ else
+ doStatus(writer, request, response);
+ }
+ catch (Exception exception)
+ {
+ log("Test Runner: doPost failed", exception);
+
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, exception.toString());
+ }
+ catch (Error error)
+ {
+ log("Test Runner: doPost failed", error);
+
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, error.toString());
+ }
+ }
+
+ public void doStatus(PrintWriter writer, HttpServletRequest request, HttpServletResponse response)
+ throws ServletException
+ {
+ writer.println("<HTML>");
+ writer.println("<HEAD>");
+ writer.println("<TITLE>Test Runner</TITLE>");
+ writer.println("</HEAD>");
+ writer.println("<BODY bgcolor=\"white\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.println("<DIV style=\"font-family: Arial, Helvetica, sans-serif; font-size: large\"> <BR>Test Runner: Status<BR> </DIV>");
+
+ writer.println("<TABLE width=\"100%\">");
+
+ writer.println("<TR><TD colspan=\"3\" align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Status</TD></TR>");
+ writer.println("<TR>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Test suite class:</TD>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif\">" + _testSuiteClassName + "</TD>");
+ writer.println("</TR>");
+
+ if ((_runnerThread == null) || (! _runnerThread.isAlive()))
+ {
+ writer.println("<TR>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Action:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.print("<FORM method=\"POST\" action=\"" + request.getRequestURL() + "\">");
+ writer.print("<INPUT type=\"button\" value=\"run\" onclick=\"this.form.submit()\">");
+ writer.print("</FORM>");
+ writer.println("</TD>");
+ writer.println("</TR>");
+ }
+ else
+ {
+ writer.println("<TR>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Action:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.print("<FORM method=\"GET\" action=\"" + request.getRequestURL() + "\">");
+ writer.print("<INPUT type=\"button\" value=\"reload\" onclick=\"this.form.submit()\">");
+ writer.print("</FORM>");
+ writer.println("</TD>");
+ writer.println("</TR>");
+
+ if (_currentTest != null)
+ {
+ writer.println("<TR>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Current test:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, _currentTest.toString());
+ writer.println("</TD>");
+ writer.println("</TR>");
+ }
+ }
+ writer.println("</TR>");
+ writer.println("<TR>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Passed count:</TD>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif\">" + _passedTests.size() + "</TD>");
+ writer.println("</TR>");
+ writer.println("<TR>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Failed count:</TD>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif\">" + _failedTests.size() + "</TD>");
+ writer.println("</TR>");
+ writer.println("<TR>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Error count:</TD>");
+ writer.println("<TD style=\"font-family: Arial, Helvetica, sans-serif\">" + _errorTests.size() + "</TD>");
+ writer.println("</TR>");
+
+ writer.println("</TABLE>");
+
+ if (! _passedTests.isEmpty())
+ {
+ writer.println("<BR>");
+
+ writer.println("<TABLE width=\"100%\">");
+
+ writer.println("<TR><TD colspan=\"3\" align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Passes</TD></TR>");
+
+ writer.println("<TR>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Test</TD>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Duration</TD>");
+ writer.println("</TR>");
+
+ Iterator passedTestsIterator = _passedTests.iterator();
+ while (passedTestsIterator.hasNext())
+ {
+ PassedTest passedTest = (PassedTest) passedTestsIterator.next();
+ writer.println("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, passedTest.test.toString());
+ writer.println("</TD>");
+ writer.print("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif\">" + passedTest.duration + " ms</TD>");
+ writer.println("</TR>");
+ }
+
+ writer.println("</TABLE>");
+ }
+
+ if (! _failedTests.isEmpty())
+ {
+ writer.println("<BR>");
+
+ writer.println("<TABLE width=\"100%\">");
+
+ writer.println("<TR><TD colspan=\"3\" align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Failures</TD></TR>");
+ writer.println("<TR>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Test</TD>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Duration</TD>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Message</TD>");
+ writer.println("</TR>");
+
+ int failedNumber = 0;
+ Iterator failedTestsIterator = _failedTests.iterator();
+ while (failedTestsIterator.hasNext())
+ {
+ FailedTest failedTest = (FailedTest) failedTestsIterator.next();
+ writer.println("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.print("<A href=\"" + request.getRequestURL() + "?failednumber=" + failedNumber + "\">");
+ encode(writer, failedTest.test.toString());
+ writer.print("</A>");
+ writer.println("</TD>");
+ writer.print("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif\">" + failedTest.duration + " ms</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, failedTest.assertionFailedError.getMessage());
+ writer.println("</TD>");
+ writer.println("</TR>");
+ failedNumber++;
+ }
+
+ writer.println("</TABLE>");
+
+ writer.println("<BR>");
+ }
+
+ if (! _errorTests.isEmpty())
+ {
+ writer.println("<TABLE width=\"100%\">");
+ writer.println("<TR>");
+ writer.println("<TR><TD colspan=\"3\" align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Errors</TD></TR>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Test</TD>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Duration</TD>");
+ writer.println("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Exception/Error</TD>");
+ writer.println("</TR>");
+
+ int errorNumber = 0;
+ Iterator errorTestsIterator = _errorTests.iterator();
+ while (errorTestsIterator.hasNext())
+ {
+ ErrorTest errorTest = (ErrorTest) errorTestsIterator.next();
+ writer.println("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.print("<A href=\"" + request.getRequestURL() + "?errornumber=" + errorNumber + "\">");
+ encode(writer, errorTest.test.toString());
+ writer.print("</A>");
+ writer.println("</TD>");
+ writer.print("<TD align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif\">" + errorTest.duration + " ms</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, errorTest.throwable.toString());
+ writer.println("</TD>");
+ writer.println("</TR>");
+ errorNumber++;
+ }
+
+ writer.println("</TABLE>");
+ }
+
+ writer.println("</BODY>");
+ writer.println("</HTML>");
+ }
+
+ public void doStatusFailed(PrintWriter writer, HttpServletRequest request, HttpServletResponse response)
+ throws ServletException
+ {
+ int failedIndex = 0;
+ FailedTest failedTest = null;
+
+ try
+ {
+ String failedIndexString = (String) request.getParameter("failednumber");
+
+ failedIndex = Integer.parseInt(failedIndexString);
+ failedTest = (FailedTest) _failedTests.get(failedIndex);
+ }
+ catch (Exception exception)
+ {
+ failedTest = null;
+ }
+
+ if (failedTest != null)
+ {
+ writer.println("<HTML>");
+ writer.println("<HEAD>");
+ writer.println("<TITLE>Test Runner</TITLE>");
+ writer.println("</HEAD>");
+ writer.println("<BODY bgcolor=\"white\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.println("<DIV style=\"font-family: Arial, Helvetica, sans-serif; font-size: large\"> <BR>Test Runner: Failed Status<BR> </DIV>");
+
+ writer.println("<TABLE>");
+
+ writer.print("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Test:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, failedTest.test.toString());
+ writer.println("</TD>");
+ writer.println("</TR>");
+
+ writer.println("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Duration:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">" + failedTest.duration + " ms</TD>");
+ writer.println("</TR>");
+
+ writer.println("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Message:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, failedTest.assertionFailedError.getMessage());
+ writer.println("</TD>");
+ writer.println("</TR>");
+
+ writer.print("<TR>");
+ writer.print("<TD colspan=\"2\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Stack trace:</TD>");
+ writer.println("</TR>");
+ writer.println("<TR>");
+ writer.println("<TD colspan=\"2\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.println("<PRE>");
+ CharArrayWriter charArrayWriter = new CharArrayWriter();
+ PrintWriter printWriter = new PrintWriter(charArrayWriter, true);
+ failedTest.assertionFailedError.printStackTrace(printWriter);
+ printWriter.close();
+ charArrayWriter.close();
+ encode(writer, charArrayWriter.toString());
+ writer.println("</PRE>");
+ writer.println("</TD>");
+ writer.println("</TR>");
+
+ writer.println("</TABLE>");
+
+ writer.println("<TABLE width=\"100%\">");
+ writer.println("<TR>");
+ writer.println("<TD align=\"left\" width=\"33%\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ if (failedIndex > 0)
+ writer.println("<A href=\"" + request.getRequestURL() + "?failednumber=" + (failedIndex - 1)+ "\">previous</A>");
+ else
+ writer.print(" ");
+ writer.println("</TD>");
+ writer.println("<TD align=\"center\" width=\"33%\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.println("<A href=\"" + request.getRequestURL() + "\">all</A>");
+ writer.println("</TD>");
+ writer.println("<TD align=\"right\" width=\"33%\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ if (failedIndex < (_failedTests.size() - 1))
+ writer.println("<A href=\"" + request.getRequestURL() + "?failednumber=" + (failedIndex + 1)+ "\">next</A>");
+ else
+ writer.print(" ");
+ writer.println("</TD>");
+ writer.println("</TR>");
+ writer.println("</TABLE>");
+
+ writer.println("</BODY>");
+ writer.println("</HTML>");
+ }
+ else
+ doStatus(writer, request, response);
+ }
+
+ public void doStatusError(PrintWriter writer, HttpServletRequest request, HttpServletResponse response)
+ throws ServletException
+ {
+ int errorIndex = 0;
+ ErrorTest errorTest = null;
+
+ try
+ {
+ String errorIndexString = (String) request.getParameter("errornumber");
+
+ errorIndex = Integer.parseInt(errorIndexString);
+ errorTest = (ErrorTest) _errorTests.get(errorIndex);
+ }
+ catch (Exception exception)
+ {
+ errorTest = null;
+ }
+
+ if (errorTest != null)
+ {
+ writer.println("<HTML>");
+ writer.println("<HEAD>");
+ writer.println("<TITLE>Test Runner</TITLE>");
+ writer.println("</HEAD>");
+ writer.println("<BODY bgcolor=\"white\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.println("<DIV style=\"font-family: Arial, Helvetica, sans-serif; font-size: large\"> <BR>Test Runner: Error Status<BR> </DIV>");
+
+ writer.println("<TABLE>");
+
+ writer.print("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Test:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, errorTest.test.toString());
+ writer.println("</TD>");
+ writer.println("</TR>");
+
+ writer.println("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Duration:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">" + errorTest.duration + " ms</TD>");
+ writer.println("</TR>");
+
+ writer.println("<TR>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Exception/error:</TD>");
+ writer.print("<TD style=\"font-family: Arial, Helvetica, sans-serif\">");
+ encode(writer, errorTest.throwable.toString());
+ writer.println("</TD>");
+ writer.println("</TR>");
+
+ writer.print("<TR>");
+ writer.print("<TD colspan=\"2\" style=\"font-family: Arial, Helvetica, sans-serif; font-weight: bold\">Stack trace:</TD>");
+ writer.println("</TR>");
+ writer.println("<TR>");
+ writer.println("<TD colspan=\"2\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.println("<PRE>");
+ CharArrayWriter charArrayWriter = new CharArrayWriter();
+ PrintWriter printWriter = new PrintWriter(charArrayWriter, true);
+ errorTest.throwable.printStackTrace(printWriter);
+ printWriter.close();
+ charArrayWriter.close();
+ encode(writer, charArrayWriter.toString());
+ writer.println("</PRE>");
+ writer.println("</TD>");
+ writer.println("</TR>");
+
+ writer.println("</TABLE>");
+
+ writer.println("<TABLE width=\"100%\">");
+ writer.println("<TR>");
+ writer.println("<TD align=\"left\" width=\"33%\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ if (errorIndex > 0)
+ writer.println("<A href=\"" + request.getRequestURL() + "?errornumber=" + (errorIndex - 1)+ "\">previous</A>");
+ else
+ writer.print(" ");
+ writer.println("</TD>");
+ writer.println("<TD align=\"center\" width=\"33%\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ writer.println("<A href=\"" + request.getRequestURL() + "\">all</A>");
+ writer.println("</TD>");
+ writer.println("<TD align=\"right\" width=\"33%\" style=\"font-family: Arial, Helvetica, sans-serif\">");
+ if (errorIndex < (_errorTests.size() - 1))
+ writer.println("<A href=\"" + request.getRequestURL() + "?errornumber=" + (errorIndex + 1)+ "\">next</A>");
+ else
+ writer.print(" ");
+ writer.println("</TD>");
+ writer.println("</TR>");
+ writer.println("</TABLE>");
+
+ writer.println("</BODY>");
+ writer.println("</HTML>");
+ }
+ else
+ doStatus(writer, request, response);
+ }
+
+ private class PassedTest
+ {
+ public Test test;
+ public long duration;
+ }
+
+ private class FailedTest
+ {
+ public Test test;
+ public long duration;
+ public AssertionFailedError assertionFailedError;
+ }
+
+ private class ErrorTest
+ {
+ public Test test;
+ public long duration;
+ public Throwable throwable;
+ }
+
+ private class RunnerThread extends Thread
+ {
+ public void run()
+ {
+ try
+ {
+ _passedTests.clear();
+ _failedTests.clear();
+ _errorTests.clear();
+
+ Class testSuiteClass = Class.forName(_testSuiteClassName);
+ TestListener testListener = new BasicTestListener();
+
+ _testResult = new TestResult();
+ _testSuite = (TestSuite) testSuiteClass.newInstance();
+
+ _testResult.addListener(testListener);
+ _testSuite.run(_testResult);
+ _testResult.removeListener(testListener);
+ }
+ catch (Exception exception)
+ {
+ log("Runner Thread: run failed", exception);
+ }
+ catch (Error error)
+ {
+ log("Runner Thread: run failed", error);
+ }
+ }
+ }
+
+ private class BasicTestListener implements TestListener
+ {
+ public void startTest(Test test)
+ {
+ _startTime = System.currentTimeMillis();
+ _failed = false;
+ _error = false;
+ _assertionFailedError = null;
+ _throwable = null;
+ _currentTest = test;
+ }
+
+ public void addError(Test test, Throwable throwable)
+ {
+ _error = true;
+ _throwable = throwable;
+ throwable.printStackTrace(System.out);
+ }
+
+ public void addFailure(Test test, AssertionFailedError assertionFailedError)
+ {
+ _failed = true;
+ _assertionFailedError = assertionFailedError;
+ assertionFailedError.printStackTrace(System.out);
+ }
+
+ public void endTest(Test test)
+ {
+ if (_failed)
+ {
+ FailedTest failedTest = new FailedTest();
+ failedTest.test = test;
+ failedTest.duration = System.currentTimeMillis() - _startTime;
+ failedTest.assertionFailedError = _assertionFailedError;
+ _failedTests.add(failedTest);
+ }
+ else if (_error)
+ {
+ ErrorTest errorTest = new ErrorTest();
+ errorTest.test = test;
+ errorTest.duration = System.currentTimeMillis() - _startTime;
+ errorTest.throwable = _throwable;
+ _errorTests.add(errorTest);
+ }
+ else
+ {
+ PassedTest passedTest = new PassedTest();
+ passedTest.test = test;
+ passedTest.duration = System.currentTimeMillis() - _startTime;
+ _passedTests.add(passedTest);
+ }
+
+ _currentTest = null;
+ }
+
+ private long _startTime = 0;
+ private boolean _failed = false;
+ private boolean _error = false;
+ private AssertionFailedError _assertionFailedError = null;
+ private Throwable _throwable = null;
+ }
+
+ private static void encode(PrintWriter writer, String string)
+ {
+ if (string != null)
+ {
+ char[] chars = string.toCharArray();
+
+ for (int index = 0; index < chars.length; index++)
+ if (chars[index] == '<')
+ writer.print("<");
+ else if (chars[index] == '>')
+ writer.print(">");
+ else if (chars[index] == '&')
+ writer.print("&");
+ else
+ writer.print(chars[index]);
+ }
+ else
+ writer.print("null");
+ }
+
+ private List _passedTests = new LinkedList();
+ private List _failedTests = new LinkedList();
+ private List _errorTests = new LinkedList();
+ private Test _currentTest = null;
+ private String _testSuiteClassName = null;
+ private RunnerThread _runnerThread = null;
+ private TestResult _testResult = null;
+ private TestSuite _testSuite = null;
+
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoHLS.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoHLS.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoHLS.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: DemoHLS.java,v 1.2 2005/05/19 12:13:19 nmcl Exp $
+ */
+
+package com.arjuna.wsas.tests;
+
+import com.arjuna.mw.wsas.context.Context;
+
+import com.arjuna.mw.wsas.UserActivityFactory;
+
+import com.arjuna.mw.wsas.common.GlobalId;
+
+import com.arjuna.mw.wsas.activity.Outcome;
+import com.arjuna.mw.wsas.activity.HLS;
+
+import com.arjuna.mw.wsas.completionstatus.CompletionStatus;
+
+import com.arjuna.mw.wsas.exceptions.*;
+
+/**
+ * @author Mark Little (mark.little at arjuna.com)
+ * @version $Id: DemoHLS.java,v 1.2 2005/05/19 12:13:19 nmcl Exp $
+ * @since 1.0.
+ */
+
+public class DemoHLS implements HLS
+{
+
+ /**
+ * An activity has begun and is active on the current thread.
+ */
+
+ public void begun () throws SystemException
+ {
+ try
+ {
+ GlobalId activityId = UserActivityFactory.userActivity().activityId();
+
+ System.out.println("DemoHLS.begun "+activityId);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * The current activity is completing with the specified completion status.
+ *
+ * @param CompletionStatus cs The completion status to use.
+ *
+ * @return The result of terminating the relationship of this HLS and
+ * the current activity.
+ */
+
+ public Outcome complete (CompletionStatus cs) throws SystemException
+ {
+ try
+ {
+ System.out.println("DemoHLS.complete ( "+cs+" ) "+UserActivityFactory.userActivity().activityId());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /**
+ * The activity has been suspended. How does the HLS know which activity
+ * has been suspended? It must remember what its notion of current is.
+ */
+
+ public void suspended () throws SystemException
+ {
+ System.out.println("DemoHLS.suspended");
+ }
+
+ /**
+ * The activity has been resumed on the current thread.
+ */
+
+ public void resumed () throws SystemException
+ {
+ System.out.println("DemoHLS.resumed");
+ }
+
+ /**
+ * The activity has completed and is no longer active on the current
+ * thread.
+ */
+
+ public void completed () throws SystemException
+ {
+ try
+ {
+ System.out.println("DemoHLS.completed "+UserActivityFactory.userActivity().activityName());
+ }
+ catch (NoActivityException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * The HLS name.
+ */
+
+ public String identity () throws SystemException
+ {
+ return "DemoHLS";
+ }
+
+ /**
+ * The activity service maintains a priority ordered list of HLS
+ * implementations. If an HLS wishes to be ordered based on priority
+ * then it can return a non-negative value: the higher the value,
+ * the higher the priority and hence the earlier in the list of HLSes
+ * it will appear (and be used in).
+ *
+ * @return a positive value for the priority for this HLS, or zero/negative
+ * if the order is not important.
+ */
+
+ public int priority () throws SystemException
+ {
+ return 0;
+ }
+
+ /**
+ * Return the context augmentation for this HLS, if any on the current
+ * activity.
+ *
+ * @return a context object or null if no augmentation is necessary.
+ */
+
+ public Context context () throws SystemException
+ {
+ return new DemoSOAPContextImple(identity());
+ }
+
+}
Added: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoSOAPContextImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoSOAPContextImple.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/DemoSOAPContextImple.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: DemoSOAPContextImple.java,v 1.5.4.1 2005/11/22 10:31:42 kconner Exp $
+ */
+
+package com.arjuna.wsas.tests;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Element;
+
+import com.arjuna.mw.wsas.context.soap.SOAPContext;
+import com.arjuna.mwlabs.wsas.util.XMLUtils;
+
+/**
+ */
+
+public class DemoSOAPContextImple implements SOAPContext
+{
+
+ public DemoSOAPContextImple (String id)
+ {
+ try
+ {
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+
+ org.w3c.dom.Document doc = docBuilder.newDocument();
+
+ _context = doc.createElement(id);
+
+ _context.appendChild(doc.createTextNode("urn:mycomputer.org:"+id+":foo:bar"));
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+
+ _context = null;
+ }
+ }
+
+ public void initialiseContext (Object param)
+ {
+ }
+
+ /**
+ * Serialise the SOAP context into a DOM node.
+ * @param element The element to contain the serialisation.
+ * @return the element added.
+ */
+ public Element serialiseToElement(final Element element)
+ {
+ element.appendChild(_context) ;
+ return _context ;
+ }
+
+ public String identifier ()
+ {
+ return "DemoSOAPContextImple";
+ }
+
+ public String toString ()
+ {
+ return XMLUtils.writeToString(_context) ;
+ }
+
+ private org.w3c.dom.Element _context;
+
+}
Added: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/FailureHLS.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/FailureHLS.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/FailureHLS.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: FailureHLS.java,v 1.2 2005/05/19 12:13:19 nmcl Exp $
+ */
+
+package com.arjuna.wsas.tests;
+
+import com.arjuna.mw.wsas.context.Context;
+
+import com.arjuna.mw.wsas.UserActivityFactory;
+
+import com.arjuna.mw.wsas.common.GlobalId;
+
+import com.arjuna.mw.wsas.activity.Outcome;
+import com.arjuna.mw.wsas.activity.HLS;
+
+import com.arjuna.mw.wsas.completionstatus.CompletionStatus;
+
+import com.arjuna.mw.wsas.exceptions.*;
+
+/**
+ * @author Mark Little (mark.little at arjuna.com)
+ * @version $Id: FailureHLS.java,v 1.2 2005/05/19 12:13:19 nmcl Exp $
+ * @since 1.0.
+ */
+
+public class FailureHLS implements HLS
+{
+
+ public static final int BEGUN_FAIL = 0;
+ public static final int COMPLETE_FAIL = 1;
+ public static final int SUSPENDED_FAIL = 2;
+ public static final int RESUMED_FAIL = 3;
+ public static final int COMPLETED_FAIL = 4;
+ public static final int CONTEXT_FAIL = 5;
+ public static final int NO_FAIL = 10;
+
+ public FailureHLS ()
+ {
+ this(FailureHLS.NO_FAIL);
+ }
+
+ public FailureHLS (int failPoint)
+ {
+ _failPoint = failPoint;
+ }
+
+ /**
+ * An activity has begun and is active on the current thread.
+ */
+
+ public void begun () throws SystemException
+ {
+ if (_failPoint == FailureHLS.BEGUN_FAIL)
+ throw new SystemException();
+
+ try
+ {
+ GlobalId activityId = UserActivityFactory.userActivity().activityId();
+
+ System.out.println("FailureHLS.begun "+activityId);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * The current activity is completing with the specified completion status.
+ *
+ * @param CompletionStatus cs The completion status to use.
+ *
+ * @return The result of terminating the relationship of this HLS and
+ * the current activity.
+ */
+
+ public Outcome complete (CompletionStatus cs) throws SystemException
+ {
+ if (_failPoint == FailureHLS.COMPLETE_FAIL)
+ throw new SystemException();
+
+ try
+ {
+ System.out.println("FailureHLS.complete ( "+cs+" ) "+UserActivityFactory.userActivity().activityId());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /**
+ * The activity has been suspended. How does the HLS know which activity
+ * has been suspended? It must remember what its notion of current is.
+ */
+
+ public void suspended () throws SystemException
+ {
+ if (_failPoint == FailureHLS.SUSPENDED_FAIL)
+ throw new SystemException();
+
+ System.out.println("FailureHLS.suspended");
+ }
+
+ /**
+ * The activity has been resumed on the current thread.
+ */
+
+ public void resumed () throws SystemException
+ {
+ if (_failPoint == FailureHLS.RESUMED_FAIL)
+ throw new SystemException();
+
+ System.out.println("FailureHLS.resumed");
+ }
+
+ /**
+ * The activity has completed and is no longer active on the current
+ * thread.
+ */
+
+ public void completed () throws SystemException
+ {
+ if (_failPoint == FailureHLS.COMPLETED_FAIL)
+ throw new SystemException();
+
+ try
+ {
+ System.out.println("FailureHLS.completed "+UserActivityFactory.userActivity().activityName());
+ }
+ catch (NoActivityException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * The HLS name.
+ */
+
+ public String identity () throws SystemException
+ {
+ return "FailureHLS";
+ }
+
+ /**
+ * The activity service maintains a priority ordered list of HLS
+ * implementations. If an HLS wishes to be ordered based on priority
+ * then it can return a non-negative value: the higher the value,
+ * the higher the priority and hence the earlier in the list of HLSes
+ * it will appear (and be used in).
+ *
+ * @return a positive value for the priority for this HLS, or zero/negative
+ * if the order is not important.
+ */
+
+ public int priority () throws SystemException
+ {
+ return 0;
+ }
+
+ /**
+ * Return the context augmentation for this HLS, if any on the current
+ * activity.
+ *
+ * @param ActivityHierarchy current The handle on the current activity
+ * hierarchy. The HLS may use this when determining what information to
+ * place in its context data.
+ *
+ * @return a context object or null if no augmentation is necessary.
+ */
+
+ public Context context () throws SystemException
+ {
+ if (_failPoint == FailureHLS.CONTEXT_FAIL)
+ throw new SystemException();
+
+ return new DemoSOAPContextImple(identity());
+ }
+
+ private int _failPoint;
+
+}
Copied: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/TestInitialisation.java (from rev 18801, labs/jbosstm/trunk/XTS/WSTX/tests/classes/com/arjuna/wstx/tests/TestInitialisation.java)
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/TestInitialisation.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/TestInitialisation.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,11 @@
+package com.arjuna.wsas.tests;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: adinn
+ * Date: Mar 7, 2008
+ * Time: 1:50:50 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestInitialisation {
+}
\ No newline at end of file
Copied: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestSuite.java (from rev 18878, labs/jbosstm/trunk/XTS/WSTX/tests/classes/com/arjuna/wst/tests/WSTXTestSuite.java)
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestSuite.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestSuite.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008,
+ * @author JBoss Inc.
+ */
+/*
+ * TestSuite.java
+ */
+
+package com.arjuna.wsas.tests;
+
+public class WSASTestSuite extends junit.framework.TestSuite
+{
+ public WSASTestSuite()
+ {
+ // wsas basic tests
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.Context.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.Hierarchy.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.NestedActivity.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.NullEnd.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.Resume.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.StartEnd.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.StatusCheck.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.Suspend.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.basic.Timeout.class));
+ // wsas hls tests
+ // this test fails because the deployment context factory code has changed
+ //addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.hls.Context1.class));
+ // this test fails because the deployment context factory code has changed
+ //addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.hls.Context2.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsas.tests.junit.hls.Service.class));
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestUtils.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestUtils.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/WSASTestUtils.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,23 @@
+package com.arjuna.wsas.tests;
+
+import com.arjuna.mw.wsas.UserActivity;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: adinn
+ * Date: Mar 12, 2008
+ * Time: 11:17:26 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class WSASTestUtils {
+ static public void cleanup(UserActivity ua)
+ {
+ try {
+ while (ua.currentActivity() != null) {
+ ua.end();
+ }
+ } catch (Exception e) {
+ // do nothing -- caller will be dealing with exceptions
+ }
+ }
+}
Copied: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic (from rev 18801, labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic)
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Context.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/Context.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Context.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,14 +29,15 @@
* $Id: Context.java,v 1.2 2005/05/19 12:13:19 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
import com.arjuna.mw.wsas.context.ContextManager;
-import com.arjuna.mw.wsas.exceptions.NoActivityException;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -44,17 +45,16 @@
* @since 1.0.
*/
-public class Context
+public class Context extends TestCase
{
- public static void main (String[] args)
+ public static void testContext()
+ throws Exception
{
- boolean passed = false;
-
+ UserActivity ua = UserActivityFactory.userActivity();
+
try
{
- UserActivity ua = UserActivityFactory.userActivity();
-
ua.start();
System.out.println("Started: "+ua.activityName());
@@ -66,24 +66,11 @@
ContextManager manager = new ContextManager();
com.arjuna.mw.wsas.context.Context[] contexts = manager.contexts();
- if ((contexts == null) || (contexts.length == 0))
- passed = true;
- else
- System.err.println("Contexts not null: "+contexts);
- }
- catch (NoActivityException ex)
- {
- passed = true;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ if ((contexts != null) && (contexts.length != 0)) {
+ fail("Contexts not null: "+contexts);
+ }
+ } finally {
+ WSASTestUtils.cleanup(ua);
}
-
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Hierarchy.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/Hierarchy.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Hierarchy.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,13 +29,15 @@
* $Id: Hierarchy.java,v 1.1 2002/11/25 10:51:46 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
+import com.arjuna.mw.wsas.exceptions.NoActivityException;
import com.arjuna.mw.wsas.activity.ActivityHierarchy;
-import com.arjuna.mw.wsas.exceptions.NoActivityException;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -43,17 +45,16 @@
* @since 1.0.
*/
-public class Hierarchy
+public class Hierarchy extends TestCase
{
- public static void main (String[] args)
+ public static void testHierarchy()
+ throws Exception
{
- boolean passed = false;
-
+ UserActivity ua = UserActivityFactory.userActivity();
+
try
{
- UserActivity ua = UserActivityFactory.userActivity();
-
ua.start();
System.out.println("Started: "+ua.activityName());
@@ -66,35 +67,27 @@
System.out.println("\nHierarchy: "+ctx);
- if (ctx == null)
- passed = false;
- else
- {
- ua.end();
+ if (ctx == null) {
+ fail("current activity should not be null");
+ } else {
+ ua.end();
- System.out.println("\nCurrent: "+ua.activityName());
+ System.out.println("\nCurrent: "+ua.activityName());
- ua.end();
+ ua.end();
- System.out.println("\nCurrent: "+ua.activityName());
-
- if (ua.activityName() == null)
- passed = true;
- }
- }
- catch (NoActivityException ex)
- {
- passed = true;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ try {
+ if (ua.activityName() != null) {
+ fail("activity name should be null but is " + ua.activityName());
+ }
+ } catch (NoActivityException ex) {
+ // ok if we get here
+ }
+ }
+ } catch (Exception ex) {
+ WSASTestUtils.cleanup(ua);
+ throw ex;
}
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/NestedActivity.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/NestedActivity.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/NestedActivity.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,30 +29,31 @@
* $Id: NestedActivity.java,v 1.1 2002/11/25 10:51:46 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
-
import com.arjuna.mw.wsas.exceptions.NoActivityException;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
+
/**
* @author Mark Little (mark.little at arjuna.com)
* @version $Id: NestedActivity.java,v 1.1 2002/11/25 10:51:46 nmcl Exp $
* @since 1.0.
*/
-public class NestedActivity
+public class NestedActivity extends TestCase
{
- public static void main (String[] args)
+ public static void testNestedActivity()
+ throws Exception
{
- boolean passed = false;
-
- try
- {
UserActivity ua = UserActivityFactory.userActivity();
+ try
+ {
ua.start();
System.out.println("Started: "+ua.activityName());
@@ -75,26 +76,21 @@
ua.end();
- System.out.println("\nCurrent: "+ua.activityName());
+ try {
+ if (ua.activityName() != null) {
+ fail("activity name should be null but is " + ua.activityName());
+ }
+ } catch (NoActivityException ex) {
+ // ok if we get here
+ }
- System.out.println("\nEnded.");
-
- if (ua.activityName() == null)
- passed = true;
+ System.out.println("\nEnded.");
+
}
- catch (NoActivityException ex)
- {
- passed = true;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ catch (Exception ex)
+ {
+ WSASTestUtils.cleanup(ua);
+ throw ex;
}
-
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/NullEnd.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/NullEnd.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/NullEnd.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,12 +29,14 @@
* $Id: NullEnd.java,v 1.1 2002/11/25 10:51:46 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
import com.arjuna.mw.wsas.exceptions.NoActivityException;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -42,32 +44,25 @@
* @since 1.0.
*/
-public class NullEnd
+public class NullEnd extends TestCase
{
- public static void main (String[] args)
+ public static void testNullEnd()
+ throws Exception
{
- boolean passed = false;
-
+ UserActivity ua = UserActivityFactory.userActivity();
try
{
- UserActivity ua = UserActivityFactory.userActivity();
-
ua.end();
- }
+ fail("should have thrown NoActivityException");
+ }
catch (NoActivityException ex)
{
- passed = true;
+ // it's ok if we arrive here?
}
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ catch (Exception ex) {
+ WSASTestUtils.cleanup(ua);
+ throw ex;
}
-
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Resume.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/Resume.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Resume.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,7 +29,7 @@
* $Id: Resume.java,v 1.1 2002/11/25 10:51:47 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
@@ -38,7 +38,8 @@
import com.arjuna.mw.wsas.common.GlobalId;
-import com.arjuna.mw.wsas.exceptions.NoActivityException;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -46,16 +47,16 @@
* @since 1.0.
*/
-public class Resume
+public class Resume extends TestCase
{
- public static void main (String[] args)
+ public static void testResume()
+ throws Exception
{
- boolean passed = false;
-
+ UserActivity ua = UserActivityFactory.userActivity();
+
try
{
- UserActivity ua = UserActivityFactory.userActivity();
GlobalId ac1 = null;
GlobalId ac2 = null;
@@ -75,42 +76,25 @@
System.out.println("\nSuspended: "+ctx);
- if (ua.currentActivity() == null)
- {
- ua.resume(ctx);
+ if (ua.currentActivity() != null) {
+ fail("Current activity shoudl be null " + ua.currentActivity());
+ }
+
+ ua.resume(ctx);
- if (ac2.equals(ua.activityId()))
- {
- ua.end();
+ if (!ac2.equals(ua.activityId()))
+ {
+ fail("Current activity id " + ua.activityId() + " should equal " + ac2);
+ }
- if (ac1.equals(ua.activityId()))
- {
- ua.end();
-
- passed = true;
- }
- else
- System.out.println("\nCurrent: "+ua.activityId()+" "+ac1);
- }
- else
- System.out.println("\nCurrent: "+ua.activityId()+" "+ac2);
- }
- else
- System.out.println("\nCurrent: "+ua.currentActivity());
- }
- catch (NoActivityException ex)
- {
- passed = true;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ ua.end();
+
+ if (!ac1.equals(ua.activityId())) {
+ fail("Current activity id " + ua.activityId() + " should equal " + ac1);
+ }
+ } finally {
+ WSASTestUtils.cleanup(ua);
}
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/StartEnd.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/StartEnd.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/StartEnd.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,10 +29,12 @@
* $Id: StartEnd.java,v 1.1 2002/11/25 10:51:47 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -40,32 +42,15 @@
* @since 1.0.
*/
-public class StartEnd
+public class StartEnd extends TestCase
{
- public static void main (String[] args)
+ public static void testStartEnd()
+ throws Exception
{
- boolean passed = false;
-
- try
- {
UserActivity ua = UserActivityFactory.userActivity();
-
ua.start();
ua.end();
-
- passed = true;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
}
-
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/StatusCheck.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/StatusCheck.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/StatusCheck.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,7 +29,7 @@
* $Id: StatusCheck.java,v 1.2 2005/05/19 12:13:19 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
@@ -40,6 +40,7 @@
import com.arjuna.mw.wsas.status.Active;
import com.arjuna.mw.wsas.completionstatus.Failure;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -47,45 +48,27 @@
* @since 1.0.
*/
-public class StatusCheck
+public class StatusCheck extends TestCase
{
- public static void main (String[] args)
+ public static void testStatusCheck()
+ throws Exception
{
- boolean passed = false;
-
- try
- {
UserActivity ua = UserActivityFactory.userActivity();
- if (ua.status() == NoActivity.instance())
- {
- ua.start();
+ if (ua.status() != NoActivity.instance()) {
+ fail("Status should be NoActivity " + ua.status());
+ }
+
+ ua.start();
- if (ua.status() == Active.instance())
- {
- Outcome res = ua.end();
+ if (ua.status() != Active.instance()) {
+ fail("Status should be Active " + ua.status());
+ }
+ Outcome res = ua.end();
- if (res.completedStatus().equals(Failure.instance()))
- passed = true;
- else
- System.out.println("End status: "+res.completedStatus());
- }
- else
- System.out.println("Start status: "+ua.status());
- }
- else
- System.out.println("Create status: "+ua.status());
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ if (!res.completedStatus().equals(Failure.instance())) {
+ fail("Completed status should be Failure " + res.completedStatus());
+ }
}
-
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Suspend.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/Suspend.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Suspend.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,7 +29,7 @@
* $Id: Suspend.java,v 1.1 2002/11/25 10:51:47 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
@@ -37,6 +37,8 @@
import com.arjuna.mw.wsas.activity.ActivityHierarchy;
import com.arjuna.mw.wsas.exceptions.NoActivityException;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -44,17 +46,16 @@
* @since 1.0.
*/
-public class Suspend
+public class Suspend extends TestCase
{
- public static void main (String[] args)
+ public static void testSuspend()
+ throws Exception
{
- boolean passed = false;
-
+ UserActivity ua = UserActivityFactory.userActivity();
+
try
{
- UserActivity ua = UserActivityFactory.userActivity();
-
ua.start();
System.out.println("Started: "+ua.activityName());
@@ -63,24 +64,14 @@
System.out.println("\nSuspended: "+ctx);
- if (ua.currentActivity() == null)
- passed = true;
- else
- System.out.println("\nCurrent: "+ua.currentActivity());
+ if (ua.currentActivity() != null) {
+ fail("Current activity should be null " + ua.currentActivity());
+ }
}
- catch (NoActivityException ex)
- {
- passed = true;
- }
catch (Exception ex)
{
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ WSASTestUtils.cleanup(ua);
+ throw ex;
}
-
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Timeout.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/basic/Timeout.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/basic/Timeout.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,7 +29,7 @@
* $Id: Timeout.java,v 1.2 2005/05/19 12:13:19 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.basic;
+package com.arjuna.wsas.tests.junit.basic;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
@@ -37,6 +37,8 @@
import com.arjuna.mw.wsas.status.*;
import com.arjuna.mw.wsas.completionstatus.*;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -44,42 +46,30 @@
* @since 1.0.
*/
-public class Timeout
+public class Timeout extends TestCase
{
- public static void main (String[] args)
+ public static void testTimeout()
+ throws Exception
{
- boolean passed = false;
-
- try
- {
UserActivity ua = UserActivityFactory.userActivity();
-
+ try {
ua.setTimeout(1);
ua.start();
Thread.currentThread().sleep(2000);
- if (ua.status() instanceof Completed)
- {
- if (ua.getCompletionStatus() instanceof Failure)
- passed = true;
- else
- System.out.println("Activity completed with: "+ua.getCompletionStatus());
- }
- else
+ if (!(ua.status() instanceof Completed)) {
+ ua.end();
+ fail("Activity status should be Completed " + ua.status());
+ }
+ if (!(ua.getCompletionStatus() instanceof Failure)) {
+ fail("Activity completion status should be Failure " + ua.getCompletionStatus());
+ }
System.out.println("Activity status: "+ua.status());
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ } finally {
+ WSASTestUtils.cleanup(ua);
}
-
+ }
}
Copied: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls (from rev 18801, labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/hls)
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Context1.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/hls/Context1.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Context1.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,7 +29,7 @@
* $Id: Context1.java,v 1.2.24.1 2005/11/22 10:31:41 kconner Exp $
*/
-package com.arjuna.mwtests.wsas.hls;
+package com.arjuna.wsas.tests.junit.hls;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -42,7 +42,9 @@
import com.arjuna.mw.wsas.context.DeploymentContextFactory;
import com.arjuna.mw.wsas.context.soap.SOAPContext;
import com.arjuna.mwlabs.wsas.util.XMLUtils;
-import com.arjuna.mwtests.wsas.common.DemoHLS;
+import com.arjuna.wsas.tests.DemoHLS;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -50,17 +52,17 @@
* @since 1.0.
*/
-public class Context1
+public class Context1 extends TestCase
{
- public static void main (String[] args)
+ public static void testContext1()
+ throws Exception
{
- boolean passed = false;
-
- try
+ UserActivity ua = UserActivityFactory.userActivity();
+ DemoHLS demoHLS = new DemoHLS();
+ try
{
- UserActivity ua = UserActivityFactory.userActivity();
- ActivityManagerFactory.activityManager().addHLS(new DemoHLS());
+ ActivityManagerFactory.activityManager().addHLS(demoHLS);
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
org.w3c.dom.Document factory = docBuilder.newDocument();
@@ -74,7 +76,8 @@
System.out.println("Started: "+ua.activityName()+"\n");
- DeploymentContext manager = DeploymentContextFactory.deploymentContext();
+ // this no longer works because DeploymentContextFactory has changed
+ DeploymentContext manager = DeploymentContextFactory.deploymentContext();
Context theContext = manager.context();
((SOAPContext)theContext).serialiseToElement(root);
@@ -113,18 +116,19 @@
doc.appendChild(root);
System.out.println(XMLUtils.writeToString(doc));
-
- passed = true;
}
catch (Exception ex)
{
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ WSASTestUtils.cleanup(ua);
+ throw ex;
+ } finally {
+ try {
+ if (demoHLS != null) {
+ ActivityManagerFactory.activityManager().removeHLS(demoHLS);
+ }
+ } catch (Exception ex) {
+ // ignore this
+ }
}
-
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Context2.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/hls/Context2.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Context2.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,7 +29,7 @@
* $Id: Context2.java,v 1.3.24.1 2005/11/22 10:31:41 kconner Exp $
*/
-package com.arjuna.mwtests.wsas.hls;
+package com.arjuna.wsas.tests.junit.hls;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -42,8 +42,10 @@
import com.arjuna.mw.wsas.context.DeploymentContextFactory;
import com.arjuna.mw.wsas.context.soap.SOAPContext;
import com.arjuna.mwlabs.wsas.util.XMLUtils;
-import com.arjuna.mwtests.wsas.common.DemoHLS;
-import com.arjuna.mwtests.wsas.common.FailureHLS;
+import com.arjuna.wsas.tests.DemoHLS;
+import com.arjuna.wsas.tests.FailureHLS;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
/**
* @author Mark Little (mark.little at arjuna.com)
@@ -51,20 +53,20 @@
* @since 1.0.
*/
-public class Context2
+public class Context2 extends TestCase
{
- public static void main (String[] args)
+ public static void testContext2()
+ throws Exception
{
- boolean passed = false;
-
- try
+ UserActivity ua = UserActivityFactory.userActivity();
+ DemoHLS demoHLS = new DemoHLS();
+ FailureHLS failureHLS = new FailureHLS();
+ try
{
- UserActivity ua = UserActivityFactory.userActivity();
+ ActivityManagerFactory.activityManager().addHLS(demoHLS);
+ ActivityManagerFactory.activityManager().addHLS(failureHLS);
- ActivityManagerFactory.activityManager().addHLS(new DemoHLS());
- ActivityManagerFactory.activityManager().addHLS(new FailureHLS());
-
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
org.w3c.dom.Document factory = docBuilder.newDocument();
@@ -78,6 +80,7 @@
System.out.println("Started: "+ua.activityName()+"\n");
+ // this no longer works because DeploymentContextFactory has changed
DeploymentContext manager = DeploymentContextFactory.deploymentContext();
Context theContext = manager.context();
@@ -117,18 +120,26 @@
doc.appendChild(root);
System.out.println(XMLUtils.writeToString(doc));
-
- passed = true;
}
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ catch (Exception ex)
+ {
+ WSASTestUtils.cleanup(ua);
+ throw ex;
+ } finally {
+ try {
+ if (demoHLS != null) {
+ ActivityManagerFactory.activityManager().removeHLS(demoHLS);
+ }
+ } catch (Exception ex) {
+ // ignore this
+ }
+ try {
+ if (failureHLS != null) {
+ ActivityManagerFactory.activityManager().removeHLS(failureHLS);
+ }
+ } catch (Exception ex) {
+ // ignore this
+ }
}
-
+ }
}
Modified: labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Service.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mwtests/wsas/hls/Service.java 2008-03-10 14:29:58 UTC (rev 18801)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/classes/com/arjuna/wsas/tests/junit/hls/Service.java 2008-03-12 13:57:39 UTC (rev 18885)
@@ -29,36 +29,33 @@
* $Id: Service.java,v 1.1 2002/11/25 10:51:47 nmcl Exp $
*/
-package com.arjuna.mwtests.wsas.hls;
+package com.arjuna.wsas.tests.junit.hls;
import com.arjuna.mw.wsas.UserActivity;
import com.arjuna.mw.wsas.UserActivityFactory;
import com.arjuna.mw.wsas.ActivityManagerFactory;
-import com.arjuna.mw.wsas.ActivityManager;
-import com.arjuna.mw.wsas.activity.ActivityHierarchy;
+import com.arjuna.wsas.tests.DemoHLS;
+import com.arjuna.wsas.tests.WSASTestUtils;
+import junit.framework.TestCase;
-import com.arjuna.mw.wsas.exceptions.NoActivityException;
-
-import com.arjuna.mwtests.wsas.common.DemoHLS;
-
/**
* @author Mark Little (mark.little at arjuna.com)
* @version $Id: Service.java,v 1.1 2002/11/25 10:51:47 nmcl Exp $
* @since 1.0.
*/
-public class Service
+public class Service extends TestCase
{
- public static void main (String[] args)
+ public static void testService()
+ throws Exception
{
- boolean passed = false;
-
+ UserActivity ua = UserActivityFactory.userActivity();
+ DemoHLS demoHLS = new DemoHLS();
try
{
- UserActivity ua = UserActivityFactory.userActivity();
- ActivityManagerFactory.activityManager().addHLS(new DemoHLS());
+ ActivityManagerFactory.activityManager().addHLS(demoHLS);
ua.start();
@@ -71,18 +68,20 @@
ua.end();
ua.end();
-
- passed = true;
}
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- System.out.println("\nPassed.");
- else
- System.out.println("\nFailed.");
+ catch (Exception ex)
+ {
+ WSASTestUtils.cleanup(ua);
+ throw ex;
+ } finally {
+ try {
+ if (demoHLS != null) {
+ ActivityManagerFactory.activityManager().removeHLS(demoHLS);
+ }
+ } catch (Exception ex) {
+ // ignore this
+ }
}
+ }
}
Copied: labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_application.xml (from rev 18801, labs/jbosstm/trunk/XTS/WSTX/tests/dd/wstx-tests_application.xml)
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_application.xml (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_application.xml 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,35 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags.
+ See the copyright.txt in the distribution for a full listing
+ of individual contributors.
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the GNU General Public License, v. 2.0.
+ This program is distributed in the hope that it will be useful, but WITHOUT A
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License,
+ v. 2.0 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+
+<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
+
+<application>
+ <display-name>Arjuna WSAS Tests</display-name>
+
+ <description>Arjuna WSAS Tests</description>
+
+ <module>
+ <web>
+ <web-uri>wsas-tests.war</web-uri>
+ <context-root>/wsas-tests</context-root>
+ </web>
+ </module>
+</application>
Copied: labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_web-app.xml (from rev 18801, labs/jbosstm/trunk/XTS/WSTX/tests/dd/wstx-tests_web-app.xml)
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_web-app.xml (rev 0)
+++ labs/jbosstm/trunk/XTS/WSAS/tests/dd/wsas-tests_web-app.xml 2008-03-12 13:57:39 UTC (rev 18885)
@@ -0,0 +1,53 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags.
+ See the copyright.txt in the distribution for a full listing
+ of individual contributors.
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the GNU General Public License, v. 2.0.
+ This program is distributed in the hope that it will be useful, but WITHOUT A
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License,
+ v. 2.0 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
+
+<web-app>
+ <display-name>Arjuna WSAS Tests</display-name>
+
+ <description>Arjuna WSAS Tests</description>
+
+ <!-- Initialise the tests -->
+ <listener>
+ <listener-class>com.arjuna.wsas.tests.TestInitialisation</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>JUnit Tests Servlet</servlet-name>
+ <servlet-class>com.arjuna.qa.junit.WSASTestRunnerServlet</servlet-class>
+ <init-param>
+ <param-name>TestSuiteClassName</param-name>
+ <param-value>com.arjuna.wsas.tests.WSASTestSuite</param-value>
+ </init-param>
+ <load-on-startup>4</load-on-startup>
+ </servlet>
+
+ <!-- servlet mappings -->
+ <servlet-mapping>
+ <servlet-name>JUnit Tests Servlet</servlet-name>
+ <url-pattern>/index.html</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+</web-app>
More information about the jboss-svn-commits
mailing list