[jboss-svn-commits] JBL Code SVN: r24781 - in labs/jbosstm/trunk/XTS/sar: tests and 18 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jan 19 06:20:44 EST 2009
Author: adinn
Date: 2009-01-19 06:20:43 -0500 (Mon, 19 Jan 2009)
New Revision: 24781
Added:
labs/jbosstm/trunk/XTS/sar/tests/
labs/jbosstm/trunk/XTS/sar/tests/README
labs/jbosstm/trunk/XTS/sar/tests/build.xml
labs/jbosstm/trunk/XTS/sar/tests/dd/
labs/jbosstm/trunk/XTS/sar/tests/dd/META-INF/
labs/jbosstm/trunk/XTS/sar/tests/dd/META-INF/jboss-beans.xml
labs/jbosstm/trunk/XTS/sar/tests/dd/WEB-INF/
labs/jbosstm/trunk/XTS/sar/tests/dd/WEB-INF/web.xml
labs/jbosstm/trunk/XTS/sar/tests/dd/build.sh
labs/jbosstm/trunk/XTS/sar/tests/dd/handlers.xml
labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/
labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/HeuristicRecoveryAfterDelayedCommit.txt
labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/ParticipantCrashAndRecover.txt
labs/jbosstm/trunk/XTS/sar/tests/dd/wsdl/
labs/jbosstm/trunk/XTS/sar/tests/dd/wsdl/xtsservicetests.wsdl
labs/jbosstm/trunk/XTS/sar/tests/src/
labs/jbosstm/trunk/XTS/sar/tests/src/org/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/bean/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/bean/XTSServiceTestRunnerBean.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/client/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/client/XTSServiceTestClient.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/CommandsType.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ObjectFactory.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ResultsType.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestPortType.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestService.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/package-info.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/Constants.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestPortTypeImpl.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestServiceManager.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/CoordinatorCompletionTestParticipant.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/DurableTestParticipant.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ParticipantCompletionTestParticipant.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ScriptedTestParticipant.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/VolatileTestParticipant.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestATRecoveryModule.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestBARecoveryModule.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiParticipantPrepareAndCommitTest.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiServicePrepareAndCommitTest.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATSingleParticipantPrepareAndCommitTest.java
labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/XTSServiceTest.java
Log:
Provided:
a simple scriptable AT/BA test service and client to drive it
scriptable recoverable participants for use by this service
a set of tests which use the client to execute a specific AT test
scenario i.e. successful prepare and commit of 1, or more
participants for 1 or more services.
a deployable war which provides a means of running a specific AT/BA
test at AS boot
a TOAST script which can be used in combination with the current
test programs to test crash recovery in a variety of configurations
ranging from a single AS to multiple ASes hosting distributed
client, coordinator and service instances.
What is still to do:
provide more test scenarios (AT rollback, BA complete/close/cancel
with or without participants performing exit/fail/cannotComplete etc).
provide more TOAST scripts which trace and/or pervert the behaviour
of the coordinator and/or participants in each of these scenarios
automate execution of each of these test scenarios in each of the
relevant distributed configurations using each of the relevant TOAST
scritps.
automate collation of the relevant trace output from these test runs
and notification of success/failure of the test.
Added: labs/jbosstm/trunk/XTS/sar/tests/README
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/README (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/README 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,196 @@
+XTS Service Tests
+-----------------
+
+This directory contains code which supports testing of the XTS sar
+deployment. The build process produces a web archive which can be
+deployed into a JBoss AS 5.0. The deployed code is highly configurable
+allowing it to support a variety of different tests
+
+A system property can set to configure automatic execution of a
+specific WSAT or WSBA client/service test once the AS has booted the
+XTS service. Several test programs are included which implement a
+variety of common test scenarios. For example, in one scenario the
+client invokes a single WSBA service which registers multiple
+participants each of which will prepare and commit without error.
+
+System property settings specific to each of the test programs can be
+employed to enable the client, service and coordinator instances
+employed by teh test to be located in one, two or more AS
+instances. Thus each test program can be used to test a variety of
+distributed configurations. In the example cited above the client and
+service might be located in one AS while the coordinator might be
+located in another AS. System properties would be used to specify the
+URL of the client and the URL of the remote coordinator service.
+
+Finally, the test code is expected to be used in conjunction with the
+TOAST test automation tool in order to i) trace subsequent execution
+of the test and ii) force the available standard WSAT or WSBA
+execution scenarios to follow error paths or suffer delays or
+crashes. So, continuing the example above a TOAST script might be used
+to crash the coordinator AS at commit. Another script might be used to
+trace execution of the coordinator host at reboot, detecting whether
+or not the recovery code successfully completes the transaction. A
+more complicated script might be used to foil initial attempts at
+recovery, ensuring that the recovery system retries the commit the
+next time it is woken up.
+
+Note that the test suite currently only provides client and service
+classes to exercise the WSAT and WSBA 1.0 APIs. This will be remedied
+in the near future.
+
+XTS Service Test Service and Test Client
+----------------------------------------
+
+The code includes a generic, scriptable web service and client for use
+in all WSBAT and WSAT tests. The web service implements a single
+remote operation which accepts a list of strings, representing a set
+of commands and associated data values. The operation returns a list
+of strings representing a set of results and associated data
+values. The commands understood by the service can be used to request
+the service to enlist WSAT or WSBA participants and to script how
+those participants respond to incoming coordination messages such as
+prepare, abort, complete, close etc. Commands are also available to
+allow the client to drive dispatch of participant-led requests in the
+WSBA protocol such as completed, cannotComplete etc.
+
+3 instances of the web service are started up by the AS during
+bootstrap. They are located at URLS
+
+ http://<host>:<port>/xtstest/xtsservice<n>
+
+where
+
+host is the value supplied to the AS using the -b option (defaults to
+localhost)
+
+port is the value configured as the web service http port (defaults to
+8080)
+
+n is either 1, 2 or 3.
+
+Relevant classes:
+
+org.jboss.jbossts.xts.servicetests.client.XTSServiceTestClient
+org.jboss.jbossts.xts.servicetests.service.XTSServiceTestPortTypeImpl
+
+XTS Service Test Runner
+-----------------------
+
+The code includes a deployment mechanism which automates running
+individual Service Tests as part of JBoss bootstrap. Class
+XTSServiceTestRunnerBean tests the value of System property
+
+ org.jboss.jbossts.xts.servicetests.XTSServiceTestName
+
+during AS boot. If the value of this property names a class which
+implements interface XTSServiceTest then an instance of the class is
+created and run() in a new thread. The implementing class is expected
+to exercise the WSAT or WSBA code by creating an instance of
+XTSServiceTestClient and invoking its serve() method inside a WSAT or
+WSBA transaction the calling commit/rollback or complete/close/cancel
+as appropriate.
+
+Relevant classes:
+
+org.jboss.jbossts.xts.servicetests.bean.XTSServiceTestRunnerBean
+org.jboss.jbossts.xts.servicetests.client.XTSServiceTestClient
+org.jboss.jbossts.xts.servicetests.test.XTSServiceTest
+
+XTS Service Tests
+-----------------
+
+Specific test scenarios are provided by classes which implement
+interface XTSServiceTest. These are located in package
+
+ org.jboss.jbossts.xts.servicetests.test
+
+TOAST Scripts
+-------------
+
+TOAST Scripts which can be used in conjunction with the XTS Service
+Tests are located in directory
+
+ dd/scripts
+
+Individual scripts may work with more than one XTS Service Test and
+may work with more than one AS configuration. For example, script
+
+ dd/scripts/HeuristicRecoveryAfterDelayedCommit.txt
+
+provides a set of rules which modify and trace the operation of the
+WSAT coordinator service. The rules cause the coordinator AS to crash
+between prepare and commit. At reboot of this AS the rules cause the
+coordinator to drop committed messages during the first replay
+attempt. Finally, they allow committed messages to be received once a
+second replay is attempted.
+
+These rules can be used with the three standard scenarios which employ
+a succsessful WSAT prepare and commit i.e. with test classes
+
+ org.jboss.jbossts.xts.servicetests.test.ATSingleParticipantPrepareAndCommitTest
+ org.jboss.jbossts.xts.servicetests.test.ATMultiParticipantPrepareAndCommitTest
+ org.jboss.jbossts.xts.servicetests.test.ATMultiServicePrepareAndCommitTest
+
+(n.b. at present a bug in the one phase commit code means that the
+first test will fail -- but that's ok :-)
+
+This script will also work correctly irrespective of whether the
+coordinator is colocated with the client and services in one AS or
+located in a separate AS (in the latter case the client and services
+may also be in a single AS or distributed across separate AS
+instances).
+
+See the comments in each of the scripts for details of how it can be
+used.
+
+Build, Deploy and Use
+---------------------
+
+The xtstest war can be built and deployed by executing
+
+ ant deploy
+
+in this directory. The rest of the XTS code needs to have been built
+first (run ant in the root dir of the XTS tree). The build script
+expects environment variable JBOSS_HOME to point to the install directory for an instance of JBoss AS 5.0 (GA).
+
+A specific test scenario can be executed by setting System property
+
+ org.jboss.jbossts.xts.servicetests.XTSServiceTestName
+
+to name a class implementing interface XTSServiceTest and then booting
+the AS. The easiest way to achieve this is to set
+
+ export JAVAOPTS="-Dorg.jboss.jbossts.xts.servicetests.XTSServiceTestName=org.jboss.jbossts.xts.servicetests.test.<xxx>"
+
+and then invoke the AS run.sh script.
+
+Note that when performing a distributed test it is only necessary to
+set this property in the host AS which is executing the client
+code.
+
+Note also that where the client is colocated with the coordinator or
+participant when testing coordinator or participant crash recovery it
+is usually necessary to *unset* this property when rebooting the
+crashed AS. (Re-)running the client while the recovery code is doing
+its stuff is usually inappropriate, especially if TOAST is still
+configured to cause a crash when the client tries to commit.
+
+The TOAST agent needs to be deployed as a JVM agent supplied with a
+handle on the relevant script file. This is done by supplying the
+relevant command line option to teh JVM when starting the AS.
+
+ export JAVA_OPTS="$JAVA_OPTS -javaagent:${TOASTSVN}/workspace/adinn/orchestration/build/lib/orchestration.jar=script:${JBOSSTSSVN}/XTS/trunk/sar/tests/dd/scripts/<script>"
+
+where ${TOASTSVN} and ${JBOSSTSSVN} identify the directories into
+which the svn tree for the TOAST/jbossts code have been checked out
+and <script> shoudl be substituted witht the relevant script name.
+
+Other command line properties configuring the operation of TOAST which
+may be of use are:
+
+ -Dorg.jboss.jbossts.orchestration.dump.generated.classes=yes
+ -Dorg.jboss.jbossts.orchestration.dump.generated.classes.directory=<dir>
+ -Dorg.jboss.jbossts.orchestration.verbose=<any_value_will_do>
+
+See the TOAST manual for more details.
Added: labs/jbosstm/trunk/XTS/sar/tests/build.xml
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/build.xml (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/build.xml 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,111 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ 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 Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+
+ (C) 2009,
+ @author JBoss Inc.
+-->
+
+<project name="XTSTestService" default="jar" basedir=".">
+ <!-- build a JBoss service which runs a specific test of the XTS service according to an environment setting -->
+ <!-- the tests will normally be run in a JVM employing a TOAST agent and suitable configured TOAST rule set -->
+
+ <property environment="env"/>
+ <!-- we need JBOSS_HOME for deployment -->
+ <condition property="jbossas.home" value="${env.JBOSS_HOME}">
+ <isset property="env.JBOSS_HOME"/>
+ </condition>
+
+ <fail unless="jbossas.home">
+ The JBoss installation directory must be specified with the JBOSS_HOME environment variable or the jboss.home property.
+ </fail>
+
+ <!-- ================================================================== -->
+ <!-- build and install the XTS Test Service Jar -->
+ <!-- ================================================================== -->
+
+ <property name="src.dir" value="src"/>
+ <property name="dd.dir" value="dd"/>
+ <property name="wsdl.dir" value="${dd.dir}/wsdl"/>
+ <property name="meta.inf.dir" value="dd/META-INF"/>
+ <property name="web.inf.dir" value="dd/WEB-INF"/>
+ <property name="build.dir" value="build"/>
+ <property name="build.classes.dir" value="${build.dir}/classes"/>
+ <property name="build.meta.inf.dir" value="${build.dir}/META-INF"/>
+ <property name="build.lib.dir" value="${build.dir}/lib"/>
+ <property name="build.webapps.dir" value="${build.dir}/webapps"/>
+
+ <!-- the directory in which XTS resides -->
+ <property name="xts.home" value="../../xts-install"/>
+ <!-- the directory in which the XTS library code resides -->
+ <property name="xts.lib.dir" value="${xts.home}/lib"/>
+ <!-- the list of jars containing the XTS API classes -->
+ <property name="xts.lib.jars" value="wstx10.jar wstx11.jar"/>
+
+ <property name="jboss.client.lib.dir" value="${jbossas.home}/client"/>
+ <property name="jboss.client.lib.jars" value="jaxb-api.jar jboss-javaee.jar jbossws-native-jaxws.jar jbossws-client.jar stax-api.jar jbossws-native-saaj.jar
+ jbossws-native-jaxws-ext.jar jbossws-native-core.jar jbossws-common.jar jboss-jaxws.jar jboss-logging-spi.jar"/>
+
+ <target name="init">
+ <delete dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.meta.inf.dir}"/>
+ <mkdir dir="${build.webapps.dir}"/>
+ </target>
+
+ <!-- install ther META-INF data -->
+ <target name="metainf">
+ <copy todir="${build.meta.inf.dir}">
+ <fileset dir="${meta.inf.dir}" includes="*"/>
+ </copy>
+ </target>
+
+ <!-- compile the XTSTestService -->
+
+ <target name="compile" depends="init">
+ <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="yes">
+ <classpath>
+ <fileset dir="${xts.lib.dir}" includes="${xts.lib.jars}"/>
+ <fileset dir="${jboss.client.lib.dir}" includes="${jboss.client.lib.jars}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <!-- build a war containing the compiled XTSTestService and the jboss-beans.xml -->
+
+ <target name="war" depends="compile,metainf">
+ <mkdir dir="${build.classes.dir}/org/jboss/jbossts/xts/servicetests/generated/wsdl/"/>
+ <copy toDir="${build.classes.dir}/org/jboss/jbossts/xts/servicetests/generated/wsdl/" file="${wsdl.dir}/xtsservicetests.wsdl"/>
+ <copy toDir="${build.classes.dir}/org/jboss/jbossts/xts/servicetests/service/" file="${dd.dir}/handlers.xml"/>
+ <war warfile="${build.webapps.dir}/xtstest.war" webxml="${web.inf.dir}/web.xml">
+ <classes dir="${build.classes.dir}" includes="**/*"/>
+ <metainf dir="${build.meta.inf.dir}"/>
+ <webinf dir="${dd.dir}" includes="wsdl/**"/>
+ </war>
+ </target>
+
+ <!-- convenience target to build and deploy the service archive -->
+ <target name="deploy" depends="undeploy, war">
+ <copy file="${build.webapps.dir}/xtstest.war" todir="${jbossas.home}/server/default/deploy"/>
+ </target>
+
+ <target name="undeploy">
+ <delete file="${jbossas.home}/server/default/deploy/xtstest.war"/>
+ </target>
+
+</project>
Added: labs/jbosstm/trunk/XTS/sar/tests/dd/META-INF/jboss-beans.xml
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/dd/META-INF/jboss-beans.xml (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/dd/META-INF/jboss-beans.xml 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ 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 Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+
+ (C) 2009,
+ @author JBoss Inc.
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- a bean which creates a thread to run one of the various XTS integration tests -->
+ <bean name="XTSServiceTestRunner" class="org.jboss.jbossts.xts.servicetests.bean.XTSServiceTestRunnerBean">
+ <depends>jboss.xts:service=XTSService</depends>
+ </bean>
+</deployment>
Added: labs/jbosstm/trunk/XTS/sar/tests/dd/WEB-INF/web.xml
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/dd/WEB-INF/web.xml (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/dd/WEB-INF/web.xml 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,70 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ 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 Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+
+ (C) 2009,
+ @author JBoss Inc.
+-->
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+ <display-name>XTS Service Tests Service</display-name>
+
+ <description>XTS Service Tests Service</description>
+
+ <!-- Initialise test services -->
+ <!--
+ -->
+ <listener>
+ <listener-class>org.jboss.jbossts.xts.servicetests.bean.XTSServiceTestRunnerBean</listener-class>
+ </listener>
+
+ <!-- Define Server endpoints and implementation classes -->
+ <servlet>
+ <servlet-name>XTS Service Test Service One</servlet-name>
+ <servlet-class>org.jboss.jbossts.xts.servicetests.service.XTSServiceTestPortTypeImpl</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>XTS Service Test Service Two</servlet-name>
+ <servlet-class>org.jboss.jbossts.xts.servicetests.service.XTSServiceTestPortTypeImpl</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>XTS Service Test Service Three</servlet-name>
+ <servlet-class>org.jboss.jbossts.xts.servicetests.service.XTSServiceTestPortTypeImpl</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Define Server Endpoint Mappings -->
+ <servlet-mapping>
+ <servlet-name>XTS Service Test Service One</servlet-name>
+ <url-pattern>/xtsservicetest1</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>XTS Service Test Service Two</servlet-name>
+ <url-pattern>/xtsservicetest2</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>XTS Service Test Service Three</servlet-name>
+ <url-pattern>/xtsservicetest3</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: labs/jbosstm/trunk/XTS/sar/tests/dd/build.sh
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/dd/build.sh (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/dd/build.sh 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,47 @@
+#
+# JBoss, Home of Professional Open Source
+# Copyright 2009, 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 Lesser General Public License, v. 2.1.
+# 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 Lesser General Public License for more details.
+# You should have received a copy of the GNU Lesser General Public License,
+# v.2.1 along with this distribution; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+#
+# (C) 2009,
+# @author JBoss Inc.
+#
+#
+#
+
+if [ ! -d tmp ] ; then
+ mkdir tmp
+fi
+
+if [ ! -d tmp/classes ] ; then
+ mkdir tmp/classes
+fi
+
+if [ ! -d tmp/src ] ; then
+ mkdir tmp/src
+fi
+
+# delete old generated versions -- any changes should be made to a copy!
+
+rm -rf tmp/classes/* tmp/src/*
+
+# $JBOSS_HOME/bin/wsconsume.sh -v -k -p org.jboss.jbossts.xts.servicetests -w wsdl/xtsservicetests.wsdl -o tmp/classes -s tmp/src wsdl/xtsservicetests.wsdl
+
+# $JBOSS_HOME/bin/wsconsume.sh -v -k -w wsdl/xtsservicetests.wsdl -o tmp/classes -s tmp/src wsdl/xtsservicetests.wsdl
+
+# $GF_HOME/bin/wsimport -verbose -keep -wsdllocation wsdl/xtsservicetests.wsdl -d tmp/classes -s tmp/src -target 2.1 wsdl/xtsservicetests.wsdl
+
+$GF_HOME/bin/wsimport -verbose -keep -target 2.0 -wsdllocation wsdl/xtsservicetests.wsdl -d tmp/classes -s tmp/src wsdl/xtsservicetests.wsdl
Added: labs/jbosstm/trunk/XTS/sar/tests/dd/handlers.xml
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/dd/handlers.xml (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/dd/handlers.xml 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ 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 Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+
+ (C) 2009,
+ @author JBoss Inc.
+-->
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <handler>
+ <handler-name>WS Addressing Server Handler</handler-name>
+ <handler-class>com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor</handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
Added: labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/HeuristicRecoveryAfterDelayedCommit.txt
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/HeuristicRecoveryAfterDelayedCommit.txt (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/HeuristicRecoveryAfterDelayedCommit.txt 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,360 @@
+##############################################################################
+# JBoss, Home of Professional Open Source
+# Copyright 2008-9, Red Hat Middleware LLC, and individual contributors
+# by the @authors tag. See the copyright.txt in the distribution for a
+# full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+# @authors Andrew Dinn
+#
+# Heuristic Recovery After Delayed Commit
+#
+# This script automates testing of a specific recovery scenario for the
+# JBossTS XTS implementation of the WS-AT 1.1 protocol using orchestration
+# rules. The basic scenario employs a coordinator and 3 web services
+# running in a single JVM but other variants are possible (see below). The
+# scenario is as follows (** indicates intercession by a TOAST rule):
+#
+# AS boots
+# Cient starts a WS-AT transaction
+# Client invokes web service 1
+# Web service 1 registers participant P1
+# Client invokes web service 2
+# Web service 2 registers participant P2
+# Client invokes web service 3
+# Web service 3 registers participant P3
+# Client commits WS-AT transaction
+# Coordinator initiates commit of participant P1
+# ** Rule system intercepts commit and crahses JVM
+#
+# AS reboots
+# Recovery system starts after 2 minutes
+# Recovery system recreates PREPARED WS-AT transaction coordinator
+# Recovery system recreates participant stub for P1
+# ** Rule system adds countdown(2) for P1
+# Recovery system recreates participant stub for P2
+# ** Rule system adds countdown for P2
+# Recovery system recreates participant stub for P3
+# ** Rule system adds countdown for P3
+# Recovery system calls replay of PREPARED transaction
+# ** Rule system traces PREPARED replay invocation
+#
+# Coordinator sends commit to P1
+# ** Rule system decrements P1's countdown to 1
+#
+# P1 replies with committed
+# ** Rule system intercepts committed message handler and aborts thread
+# (last 2 steps repeated while countdown is active)
+#
+# Coordinator sends commit to P2
+# ** Rule system decrements P2's countdown to 1
+#
+# P2 replies with committed
+# ** Rule system intercepts committed message handler and aborts thread
+# (last 2 steps repeated while countdown is active)
+#
+# Coordinator sends commit to P3
+# ** Rule system decrements P3's countdown to 1
+#
+# P3 replies with committed
+# ** Rule system intercepts committed message handler and aborts thread
+# (last 2 steps repeated while countdown is active)
+#
+# Coordinator times out commit and writes heuristic transaction to log
+# Recovery system sleeps
+
+# Recovery system restarts after 2 minutes
+# Recovery system recreates HEURISTIC WS-AT transaction coordinator
+# Recovery system detects existing participant stub for P1
+# Recovery system detects existing participant stub for P2
+# Recovery system detects existing participant stub for P3
+#
+# Coordinator sends commit to P1
+# ** Rule system decrements P1's countdown to 0 and removes countdown
+# P1 replies with committed
+# Coordinator sends commit to P2
+# ** Rule system decrements P2's countdown to 0 and removes countdown
+# P2 replies with committed
+# Coordinator sends commit to P3
+# ** Rule system decrements P3's countdown to 0 and removes countdown
+# P3 replies with committed
+# Coordinator clears heuristic log record and copletes commit
+# ** Rule system detects completed commit and kills JVM
+#
+# Use of this script
+#
+# The default way of exercising this test is to deploy the xtstest war
+# to a single AS and configure it to run the relevant XTS Service Test.
+# The web services and coordinator will be located with the client.
+# The number of participants can actually be 1, 2, 3 or more. The
+# web service(s), client (i.e. the XTS Service Test which drives
+# the test) and coordinator service can optionally be located in separate
+# ASs. It possible to use just a single web service and have the client
+# register multiple participants. The coordinator AS should crash when
+# the client commits. At reboot the rest of the test should run
+# automatically and the server should be killed after a the heuristic
+# transaction is successfuly replayed.
+#
+# This script needs to be passed to a TOAST agent in the JVM running
+# the coordinator service both at first boot and at reboot. Output will be
+# written to file testlog in the working directory of the AS. n.b. the rules in
+# this script only refer to code executed by the coordinator. If the client
+# (the selected XTS Service Test) or the web services are located in another
+# AS/JVM then the other JVM does not require a TOAST agent or script.
+#
+# XTS Service tests which can operate with this scenario can be selected for
+# execution at AS boot by the XTSServiceTestRunnerBean by setting system
+# property
+# org.jboss.jbossts.xts.servicetests.XTSServiceTestName
+# to the name of a class which will execute the test. This property must
+# be defined in the JVM running the AS to which the xtstest war is deployed
+# i.e. the client AS. n.b. if the client is colocated with the coordinator then
+# this property must be left undefined at AS reboot otherwise the client
+# will run again, starting a new TX which may interfere with recovery of the
+# crashed TX.
+#
+# Available tests include:
+#
+# org.jboss.jbossts.xts.servicetests.test.ATSingleParticipantPrepareAndCommitTest
+# this test invokes a single service registering 1 client
+# the location of service is defined by defining a system property:
+# org.jboss.jbossts.xts.servicetests.ServiceURL
+# if this is not set the value used defaults to
+# http://localhost:8080/xtstest/xtsservicetest1
+#
+# org.jboss.jbossts.xts.servicetests.test.ATMultiParticipantPrepareAndCommitTest
+# this test invokes a single service registering 3 clients
+# the location of service is defined by defining a system property:
+# org.jboss.jbossts.xts.servicetests.ServiceURL
+# if this is not set the value used defaults to
+# http://localhost:8080/xtstest/xtsservicetest1
+#
+# org.jboss.jbossts.xts.servicetests.test.ATMultiServicePrepareAndCommitTest
+# this test invokes 3 separate services registering a client with each service
+# the location of service is defined by defining by system properties:
+# org.jboss.jbossts.xts.servicetests.ServiceURL1
+# org.jboss.jbossts.xts.servicetests.ServiceURL2
+# org.jboss.jbossts.xts.servicetests.ServiceURL3
+# if these are not set the values used default to
+# http://localhost:8080/xtstest/xtsservicetest1
+# http://localhost:8080/xtstest/xtsservicetest2
+# http://localhost:8080/xtstest/xtsservicetest3
+#
+# If the client is run in a different AS to the coordinator then the client
+# AS needs to be pointed at the coordinator AS. The easiest
+# way to do this is to define the system property
+#
+# org.jboss.jbossts.xts11.coordinatorURL
+#
+# to something like
+#
+# http://foo.bar.org:8080/ws-c11/soap/ActivationCoordinator
+#
+# or alternatively to redefine one or more of the component properties
+#
+# org.jboss.jbossts.xts11.coordinator.host
+# org.jboss.jbossts.xts11.coordinator.port
+# org.jboss.jbossts.xts11.coordinator.path
+#
+# (you probably only need to reset the host component)
+#
+# Expected output
+#
+# After the first boot the JVM should exit leaving the following in file testlog
+#
+# JVM exit
+#
+# After reboot the JVM should exit leaving output in the following format in file
+# testlog. Clearly the ids for the TX/participants may vary and the number of
+# countdown completed lines will depend upon the number of participants employed.
+#
+# JVM exit
+# replay commit for prepared transaction 7f000001:cebc:496f3b83:6e
+# replay commit for heuristic committed transaction 7f000001:cebc:496f3b83:6e
+# countdown completed for D7f000001:cebc:496f3b83:70
+# countdown completed for D7f000001:cebc:496f3b83:73
+# countdown completed for D7f000001:cebc:496f3b83:76
+# removed committed transaction
+
+#######################################################################
+# This rule opens a file for the trace output during XTS startup
+# It will be opened for append at reboot so messages from both runs
+# will go to this file
+#
+RULE open trace file
+CLASS org.jboss.jbossts.XTSService
+METHOD start()
+BIND NOTHING
+IF TRUE
+DO openTrace("log", "testlog")
+ENDRULE
+
+#######################################################################
+## rules for first run of AS
+
+#######################################################################
+# This rule is triggered when a non-recovered participant stub
+# (CoordinatorEngine) is sent a commit message i.e. immediately
+# after a successful prepare. It exits the JVM, simulating a crash.
+# The trigger location is set to follow the write of recovered,
+# ensuring that the property is avaialable for test in the rule
+# condition.
+
+RULE kill JVM
+CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
+METHOD commit
+AT SYNCHRONIZE
+BIND engine:CoordinatorEngine = $0,
+ recovered:boolean = engine.isRecovered(),
+ identifier:String = engine.getId()
+IF (NOT recovered)
+ AND
+ debug("commit on non-recovered engine " + identifier)
+DO traceln("log", "JVM exit"),
+ debug("!!!killing JVM!!!"),
+ killJVM()
+ENDRULE
+
+#######################################################################
+## rules for reboot run of AS
+
+#######################################################################
+# This rule is triggered when a participant stub (CoordinatorEngine) is
+# created from details located in the log record. It adds a countdown
+# which is tripped each time a commit is tried on the participant.
+# While the countdown is active committed messages will be blocked.
+# Note that it calls isRecovered() to detect that the stub has been
+# recreated from the log. The trigger location is set to follow the
+# write of recovered, ensuring that the property is avaialable for
+# test in the rule condition.
+
+RULE add coordinator engine countdown
+CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
+METHOD <init>(String, boolean, W3CEndpointReference, boolean, State)
+AFTER WRITE recovered
+BIND engine:CoordinatorEngine = $0,
+ recovered:boolean = engine.isRecovered(),
+ identifier:String = engine.getId()
+IF recovered
+DO debug("adding countdown for " + identifier),
+ addCountDown(identifier, 1)
+ENDRULE
+
+#######################################################################
+# This rule is triggered when a recovered participant stub
+# (CoordinatorEngine) is sent a commit message. This happens during
+# replay of a prepared TX from the log. It decrements the countdown. First
+# time round this takes it from 1 to 0 but leaves it in place. Second
+# time round it removes it allowing committed messages to flow.
+
+RULE countdown at commit
+CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
+METHOD commit
+AFTER SYNCHRONIZE
+BIND engine:CoordinatorEngine = $0,
+ recovered:boolean = engine.isRecovered(),
+ identifier:String = engine.getId()
+IF recovered
+ AND
+ debug("commit on recovered engine " + identifier)
+ AND
+ debug("counting down")
+ AND
+ countDown(identifier)
+DO debug("countdown completed for " + identifier),
+ traceln("log", "countdown completed for " + identifier)
+ENDRULE
+
+#######################################################################
+# This rule is triggered when a recovered participant stub
+# (CoordinatorEngine) is sent a committed message i.e. in the handler
+# thread which responds to a COMMITTED message from a participant.
+# If it detects a countdown registered using the participant id it
+# forces an early return stopping delivery of the COMMITTED message.
+
+RULE drop committed message
+CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
+METHOD committed(Notification, AddressingProperties, ArjunaContext)
+AT ENTRY
+BIND engine:CoordinatorEngine = $0,
+ recovered:boolean = engine.isRecovered(),
+ identifier:String = engine.getId()
+IF recovered
+ AND
+ debug("committed on recovered engine " + identifier)
+ AND
+ getCountDown(identifier)
+DO debug("dropping committed message for " + identifier),
+ return
+ENDRULE
+
+#######################################################################
+# This rule is triggered when the recovery system finds the PREPARED
+# transaction in the log and reruns the phase 2 commit operation.
+# It prints a message which can be used to verify that the test has
+# progressed as expected.
+
+RULE trace prepared replay
+CLASS org.jboss.jbossts.xts.recovery.coordinator.at.RecoverACCoordinator
+METHOD replayPhase2
+AT INVOKE phase2Commit
+BIND coordinator = $0,
+ uid : Uid = coordinator.identifier(),
+ status : int = coordinator.status()
+IF (status == com.arjuna.ats.arjuna.coordinator.ActionStatus.PREPARED)
+ OR
+ (status == com.arjuna.ats.arjuna.coordinator.ActionStatus.COMMITTING)
+DO debug("replaying commit for prepared transaction " + uid),
+ traceln("log", "replay commit for prepared transaction " + uid)
+ENDRULE
+
+#######################################################################
+# This rule is triggered when the recovery system finds the COMMITTED
+# transaction in the log and reruns the phase 2 commit operation.
+# It prints a message which can be used to verify that the test has
+# progressed as expected.
+
+RULE trace heuristic committed replay
+CLASS org.jboss.jbossts.xts.recovery.coordinator.at.RecoverACCoordinator
+METHOD replayPhase2
+AT INVOKE phase2Commit
+BIND coordinator = $0,
+ uid : Uid = coordinator.identifier(),
+ status : int = coordinator.status()
+IF status == com.arjuna.ats.arjuna.coordinator.ActionStatus.COMMITTED
+DO debug("replaying commit for heuristic committed transaction " + uid),
+ traceln("log", "replay commit for heuristic committed transaction " + uid)
+ENDRULE
+
+#######################################################################
+# This rule is triggered when the recovery system deletes the COMMITTED
+# transaction from the log. It prints a message which can be used to
+# verify that the test has completed. As a convenience itt also kills
+# the JVM to halt the test.
+
+RULE trace remove committed state
+CLASS com.arjuna.ats.arjuna.coordinator.BasicAction
+METHOD updateState
+AFTER CALL remove_committed
+BIND action : BasicAction = $0,
+ uid = action.get_uid()
+IF TRUE
+DO traceln("log", "removed committed transaction " + uid),
+ debug("removed committed transaction " + uid),
+ debug("!!!killing JVM!!!"),
+ killJVM()
+ENDRULE
Added: labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/ParticipantCrashAndRecover.txt
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/ParticipantCrashAndRecover.txt (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/dd/scripts/ParticipantCrashAndRecover.txt 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,295 @@
+##############################################################################
+# JBoss, Home of Professional Open Source
+# Copyright 2008-9, Red Hat Middleware LLC, and individual contributors
+# by the @authors tag. See the copyright.txt in the distribution for a
+# full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+# @authors Andrew Dinn
+#
+# Participant Recovery with Remote Coordinator
+#
+# This script automates testing of a specific recovery scenario for the
+# JBossTS XTS implementation of the WS-AT 1.1 protocol using orchestration
+# rules. The basic scenario employs a client (XTS Service Test program)
+# and 2 web services located in one JVM/AS and a coordinator located in another
+# JVM/AS but it is possible for the lcinet and web services to be lcoated in
+# separate JVMs/ASs. The scenario is as follows (note ** AS<n> indicates
+# intercession by a TOAST rule executed in a specific AS):
+#
+# AS1 boots
+# AS2 boots
+# AS1 Client starts a WS-AT transaction talking to coordinator in AS2
+# AS1 Client invokes web service 1
+# AS1 Web service 1 registers as participant P1
+# AS1 Client invokes web service 2
+# AS1 Web service 2 registers as participant P2
+# AS1 Client commits WS-AT transaction
+#
+# AS2 Coordinator initiates commit of participant P1
+# AS2 Coordinator sends commit to P1
+#
+# AS1 P1 receives commit
+# ** AS1 Rule system intercepts commit and crashes JVM
+#
+# AS2 Coordinator attempts to resend message
+# ** AS2 Rule system suspends coordinator waiting on incoming prepared
+# message from P1
+# (commit messages continue to be resent in the meantime)
+#
+# AS1 reboots
+# AS1 Recovery system starts after 2 minutes
+# AS1 Recovery system recreates PREPARED WS-AT participant P1
+# ** AS1 Rule system traces recreate
+# AS1 Participant P1 resends prepared
+# AS1 Participant P1 receives commit for P1
+# AS1 Participant P1 sends committed
+#
+# AS2 Participant stub receives committed message for P1
+# ** AS2 Rule system signals coordinator clearing wait
+# ** AS2 rule system traces receipt of committed message for P1
+#
+# AS2 Coordinator detects committed from P1
+# AS2 Coordinator sends commit for P2
+# AS2 Coordinator receives committed from P2
+# AS2 Coordinator completes transaction
+# ** AS2 Rule system traces successful completion
+#
+# Use of this script
+#
+# The default way of exercising this test is to deploy the xtstest war
+# to AS1 and configure it to run the relevant XTS Service Test. It is
+# actually possible to use 1, 2, 3 or more participants and multiple
+# participants may be registered by a single web service or by independent
+# web services. If required the web service(s) may be located in a a separate
+# AS to the one running the XTS Service test.
+#
+# The test should crash AS1 at the point of commit. At AS1 reboot the rest of
+# the test should run automatically. AS2 should be killed after the
+# transaction is successfuly terminated. Still need to work out how to
+# automatically terminate AS1 automatically but exit of AS2 is a signal
+# that AS1 can be killed.
+#
+# !!! N.B. this test currently fails because JBossWS Native fails to cope
+# !!! with requests for services while they are bootstrapping
+#
+# The JVMs hosting AS1 and AS2 both need to be configured to run a TOAST
+# agent supplied with this script. If the web service(s) is relocated
+# to AS3 then it needs to be configured to run the TOAST agent instead of
+# AS1 (rules only refer to participant and coordinator code, not to the
+# XTS service test code).
+#
+# The client AS (AS1) needs to be pointed at the coordinator AS (AS2). The easiest
+# way to do this is to define the system property
+#
+# org.jboss.jbossts.xts11.coordinatorURL
+#
+# to something like
+#
+# http://foo.bar.org:8080/ws-c11/soap/ActivationCoordinator
+#
+# or alternatively to redefine one or more of the component properties
+#
+# org.jboss.jbossts.xts11.coordinator.host
+# org.jboss.jbossts.xts11.coordinator.port
+# org.jboss.jbossts.xts11.coordinator.path
+#
+# (you probably only need to reset the host component)
+#
+# XTS Service tests which can operate with this scenario can be selected for
+# execution at AS boot by the XTSServiceTestRunnerBean by setting system
+# property
+# org.jboss.jbossts.xts.servicetests.XTSServiceTestName
+# to the name of a class which will execute the test. This property must
+# be defined in AS1, the client AS. n.b. if the client is colocated with
+# the seb service(s) then this property must be left undefined at AS1 reboot
+# otherwise the client will run again, starting a new TX which may interfere
+# with recovery of the crashed participants.
+#
+# Available tests include:
+#
+# org.jboss.jbossts.xts.servicetests.test.ATSingleParticipantPrepareAndCommitTest
+# this test invokes a single web service registering 1 participant
+# the location of service is defined by defining a system property:
+# org.jboss.jbossts.xts.servicetests.ServiceURL
+# which should be set to something like
+# http://baz.bar.org:8080/xtstest/xtsservicetest1
+#
+# org.jboss.jbossts.xts.servicetests.test.ATMultiParticipantPrepareAndCommitTest
+# this test invokes a single service registering 3 participants
+# the location of service is defined by defining a system property:
+# org.jboss.jbossts.xts.servicetests.ServiceURL
+# which should be set to something like
+# http://baz.bar.org:8080/xtstest/xtsservicetest1
+#
+# org.jboss.jbossts.xts.servicetests.test.ATMultiServicePrepareAndCommitTest
+# this test invokes 3 separate services registering a participant for each service
+# the location of service is defined by defining by system properties:
+# org.jboss.jbossts.xts.servicetests.ServiceURL1
+# org.jboss.jbossts.xts.servicetests.ServiceURL2
+# org.jboss.jbossts.xts.servicetests.ServiceURL3
+# which should be set to something like
+# http://mumble.bar.org:8080/xtstest/xtsservicetest1
+# http://mumble.bar.org:8080/xtstest/xtsservicetest2
+# http://mumble.bar.org:8080/xtstest/xtsservicetest3
+# if you are feeling really adventurous you can host the services
+# in different ASs
+# http://mumble.bar.org:8080/xtstest/xtsservicetest1
+# http://grumble.bar.org:8080/xtstest/xtsservicetest1
+# http://bletch.bar.org:8080/xtstest/xtsservicetest1
+#
+# Expected output AS1
+# -------------------
+#
+# After the first boot AS1 should exit leaving the following in file testlog1
+#
+# JVM exit
+#
+# After reboot AS1 should add output in the following format in file testlog1.
+# Clearly the ids for the TX/participants may vary and the number of
+# ??? lines will depend upon the number of participants employed.
+#
+# JVM exit
+# replay commit for prepared transaction 7f000001:cebc:496f3b83:6e
+# replay commit for heuristic committed transaction 7f000001:cebc:496f3b83:6e
+# countdown completed for D7f000001:cebc:496f3b83:70
+# countdown completed for D7f000001:cebc:496f3b83:73
+# countdown completed for D7f000001:cebc:496f3b83:76
+# removed committed transaction
+#
+# Expected output AS2
+# -------------------
+# ???
+
+######################################################################
+# AS1 Rule set
+#######################################################################
+# This rule opens a file for the trace output during XTS startup
+# It will be opened for append at reboot so messages from both runs
+# will go to this file
+
+RULE open trace file
+CLASS org.jboss.jbossts.XTSService
+METHOD start()
+BIND NOTHING
+IF TRUE
+DO openTrace("log1", "testlog1")
+ENDRULE
+
+
+#######################################################################
+# This rule is triggered in the AS1 when a non-recovered WS-AT
+# participant receives a commit message. It causes the JVM to crash.
+# The trigger point is the start of the method.
+RULE crash unrecovered participant at commit
+CLASS com.arjuna.wst11.messaging.engines.ParticipantEngine
+METHOD commit
+AT ENTRY
+BIND engine:ParticipantEngine = $0,
+ recovered:boolean = engine.isRecovered(),
+ identifier:String = engine.getId()
+IF (NOT recovered)
+ AND
+ debug("commit on non-recovered participant engine " + identifier)
+DO debug("!!!killing JVM!!!"),
+ killJVM()
+ENDRULE
+
+#######################################################################
+# This rule is triggered in the AS1 when a recovered WS-AT participant
+# is recreated from the log. It traces the call to allow success of the
+# test to be detected.
+# The trigger point is the end of the constructor so that the rule can
+# safely read all the fields.
+
+RULE trace recovered participant recreate
+CLASS com.arjuna.wst11.messaging.engines.ParticipantEngine
+METHOD <init>(Participant, id, State, W3CEndpointReference, boolean)
+AFTER WRITE persisted
+BIND engine:ParticipantEngine = $0,
+ recovered:boolean = engine.isRecovered(),
+ identifier:String = engine.getId()
+IF recovered
+DO debug("recreated recovered participant engine " + identifier)
+ENDRULE
+
+
+######################################################################
+# AS2 Rule set
+#######################################################################
+# This rule opens a file for the trace output during XTS startup
+
+RULE open trace file
+CLASS org.jboss.jbossts.XTSService
+METHOD start()
+BIND NOTHING
+IF TRUE
+DO openTrace("log2", "testlog2")
+ENDRULE
+
+######################################################################
+# This rule is triggered in AS2 when a participant stub
+# (CoordinatorEngine) first posts a commit message to the participant.
+# The coordinator thread suspends until a committed message is received
+# from the participant. This ensures that it waits until AS1
+# has restarted allowing the transaction to then complete. The
+# condition tests whether a flag with key "firstCommit" has been set.
+# By default this is clear so the condition is true first time the
+# rule is called. The action sets te flag causing the condition to
+# evaluate to false on subsequent commit calls.
+# The trigger point is just before calling waitForState.
+
+RULE suspend coordinator after sending first commit
+CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
+METHOD commit
+LINE 330
+BIND engine:CoordinatorEngine = $0,
+ identifier:String = engine.getId()
+IF (NOT flagged("firstCommit"))
+DO debug("coordinator waiting for participant to resend prepare" + identifier),
+ flag("firstCommit"),
+ waitFor(identifier)
+ENDRULE
+
+#######################################################################
+
+# This rule is triggered when a committed message is received from P1.
+# This indicates that the participant has been recreated and
+# successfully responded to a commit message after reboot of AS1. The
+# rule uses a call to signal to wake up the coordinator which was
+# suspended when the first commit was sent. This call only returns true
+# if the identifier is for P1 and the coordinator has not already been
+# signalled. Note that the call to signal is made in the condition to
+# avoid a race between threads handling successive committed messages.
+# If instead the condition called waiting() and the action called
+# signal() then, depending upon scheduling, both threads might find the
+# condition to be true before one of them could execute signal().
+# Although this would be harmless in this case it could be significant
+# when using other rules.
+# The triogger point is at the sttart of the method.
+
+RULE signal waiting coordinator
+CLASS com.arjuna.wst11.messaging.engines.CoordinatorEngine
+METHOD committed
+AT ENTRY
+BIND engine : CoordinatorEngine = $0,
+ identifier:String = engine.getId()
+IF debug("received committed for participant " + identifier)
+ AND
+ signal(identifier)
+DO debug("signalled coordinator waiting on " + identifier)
+ENDRULE
Added: labs/jbosstm/trunk/XTS/sar/tests/dd/wsdl/xtsservicetests.wsdl
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/dd/wsdl/xtsservicetests.wsdl (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/dd/wsdl/xtsservicetests.wsdl 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ 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 Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+
+ (C) 2009,
+ @author JBoss Inc.
+--><!--
+ a specification for a service which can be used to dispatch a SOAP 1.1 SoapFault
+ to an arbitrary client
+-->
+<definitions
+ targetNamespace="http://jbossts.jboss.org/xts/servicetests/generated"
+ xmlns:s="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://jbossts.jboss.org/xts/servicetests/generated"
+ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsaw="http://www.w3.org/2006/02/addressing/wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/" >
+ <types>
+ <s:schema
+ targetNamespace="http://jbossts.jboss.org/xts/servicetests/generated"
+ xmlns="http://jbossts.jboss.org/xts/servicetests/generated">
+ <s:simpleType name="commandList">
+ <s:list itemType="s:string"/>
+ </s:simpleType>
+
+ <s:simpleType name="resultList">
+ <s:list itemType="s:string">
+ </s:list>
+ </s:simpleType>
+
+ <s:complexType name="commandsType">
+ <s:sequence>
+ <s:element name="commandList" type="commandList"/>
+ </s:sequence>
+ </s:complexType>
+
+ <s:complexType name="resultsType">
+ <s:sequence>
+ <s:element name="resultList" type="resultList"/>
+ </s:sequence>
+ </s:complexType>
+
+ <s:element name="commands" type="commandsType"/>
+
+ <s:element name="results" type="resultsType"/>
+
+ <!--
+ <s:import namespace="http://schemas.xmlsoap.org/soap/envelope/"
+ schemaLocation="http://schemas.xmlsoap.org/soap/envelope"/>
+ -->
+ </s:schema>
+ </types>
+
+ <message name="Commands">
+ <part name="commands" element="tns:commands" />
+ </message>
+
+ <message name="Results">
+ <part name="results" element="tns:results" />
+ </message>
+
+ <portType name="XTSServiceTestPortType">
+ <operation name="serve">
+ <input name="Commands" message="tns:Commands" />
+ <output name="Results" message="tns:Results" />
+ </operation>
+ </portType>
+
+ <binding name="XTSServiceTestPort_SOAPBinding" type="tns:XTSServiceTestPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="serve">
+ <input message="tns:Commands">
+ <soap:body use="literal"/>
+ </input>
+ <output message="tns:Commands">
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="XTSServiceTestService">
+ <port binding="tns:XTSServiceTestPort_SOAPBinding" name="XTSServiceTestPortType">
+ <wsaw:UsingAddressing required="true"/>
+ <soap:address location="http://localhost:9000/xtsservicetests/XTSServiceTestService"/>
+ </port>
+ </service>
+</definitions>
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/bean/XTSServiceTestRunnerBean.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/bean/XTSServiceTestRunnerBean.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/bean/XTSServiceTestRunnerBean.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.bean;
+
+import org.jboss.logging.Logger;
+import org.jboss.jbossts.xts.servicetests.test.XTSServiceTest;
+import org.jboss.jbossts.xts.servicetests.service.recovery.TestATRecoveryModule;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * A service bean used to run XTS service tests at JBoss startup. A specific test is configurerd by setting an
+ * environment variable. It will normally execute in a JVM configured to use the TOAST agent and an appropriately
+ * defined TOAST rule set.
+ */
+
+public class XTSServiceTestRunnerBean
+ implements ServletContextListener // since we ahve toi use a war and web.xml wee
+ // run this as a listener rather than as via jboss-beans.xml
+{
+ /**
+ * The context has been initialized.
+ * @param servletContextEvent The servlet context event.
+ */
+ public void contextInitialized(final ServletContextEvent servletContextEvent)
+ {
+ try {
+ start();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ /**
+ * The context is about to be destroyed.
+ * @param servletContextEvent The servlet context event.
+ */
+ public void contextDestroyed(final ServletContextEvent servletContextEvent)
+ {
+ try {
+ stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ public XTSServiceTestRunnerBean()
+ {
+ testName = System.getProperty(TEST_NAME_KEY);
+ testInstance = null;
+ }
+
+ /**
+ * the service start method which adds a thread to run the current test
+ * @throws Exception
+ */
+ public void start() throws Exception
+ {
+ log.info("Starting XTSServiceTestRunner");
+
+ // ensure that the xts service test AT recovery helper module is registered
+
+ TestATRecoveryModule.register();
+
+ if (testName != null) {
+ log.info("Starting XTS Service Test " + testName);
+ Class testClass;
+ ClassLoader cl = XTSServiceTestRunnerBean.class.getClassLoader();
+
+ try {
+ testClass = cl.loadClass(testName);
+ } catch (ClassNotFoundException cnfe) {
+ log.warn("XTSServiceTestRunner : cannot find test class " + testName, cnfe);
+ throw new Exception("XTSServiceTestRunner : cannot find test class " + testName, cnfe);
+ }
+
+ try {
+ testInstance = (XTSServiceTest)testClass.newInstance();
+ } catch (InstantiationException ie) {
+ log.warn("XTSServiceTestRunner : cannot instantiate test class " + testName, ie);
+ throw new Exception("XTSServiceTestRunner : cannot instantiate test class " + testName, ie);
+ } catch (IllegalAccessException iae) {
+ log.warn("XTSServiceTestRunner : cannot access constructor for test class " + testName, iae);
+ throw new Exception("XTSServiceTestRunner : cannot access constructor for test class " + testName, iae);
+ }
+
+ // since we are running in the AS startup thread we need a separate thread for the test
+
+ testThread = new Thread() {
+ private XTSServiceTest test = testInstance;
+ public void run()
+ {
+ testInstance.run();
+ }
+ };
+
+ testThread.start();
+ }
+
+ log.info("Started XTSServiceTestRunner");
+ }
+
+ /**
+ * teh service stop method which joins the thread running the current test if it exists
+ * @throws Exception
+ */
+ public void stop() throws Exception
+ {
+ log.info("Stopping XTSServiceTestRunner");
+
+ if (testThread != null) {
+ log.info("Joining test thread " + testName);
+
+ testThread.join();
+
+ log.info("Joined test thread " + testName);
+ }
+
+ // ensure that the xts service test AT recovery helper module is unregistered
+
+ TestATRecoveryModule.unregister();
+
+ log.info("Stopped XTSServiceTestRunner");
+ }
+
+ private final Logger log = org.jboss.logging.Logger.getLogger(XTSServiceTestRunnerBean.class);
+
+ private final String testName;
+
+ private XTSServiceTest testInstance;
+
+ private Thread testThread;
+
+ private final static String TEST_NAME_KEY = "org.jboss.jbossts.xts.servicetests.XTSServiceTestName";
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/client/XTSServiceTestClient.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/client/XTSServiceTestClient.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/client/XTSServiceTestClient.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.client;
+
+import org.jboss.jbossts.xts.servicetests.generated.XTSServiceTestPortType;
+import org.jboss.jbossts.xts.servicetests.generated.CommandsType;
+import org.jboss.jbossts.xts.servicetests.generated.ResultsType;
+import org.jboss.jbossts.xts.servicetests.generated.XTSServiceTestService;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.handler.Handler;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+
+import com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor;
+
+/**
+ * A convenience class used to invoke the XTS ServiceTest Service.
+ *
+ * The client can use the server's single web method to invoke a variety of behaviours. Method serve accepts
+ * a list of Strings which serve as commands to the service and/or its enlisted partiicpants. It returns a
+ * list of strings indicating the outcome of the request, possibly including the name of any enlisted
+ * participants Available commands include enlist of AT or BA participants (this also supplies a set of
+ * suib-commands which are passed to the participant in order to script its behaviour, update of a
+ * participant's command list and invocation of the service-driven operations associated with a business
+ * agreement participant such as completed, fail etc. The full list of available commands and associated
+ * return values is
+ *
+ * enlistDureable (ATParticipantCommand)* ==> DurableId
+ * enlistVolatile (ATParticipantCommand)* ==> VolatileId
+ * enlistCoordinatorCompletion (BACoordinatorCompletionCommand)* ==> BACoordinatorCompletionId
+ * enlistParticipantCompletion (BAParticipantCompletionCommand)* ==> BAParticipantCompletionId
+ * commands ((ATParticipantCommand)* | (BACoordinatorCompletionCommand)*) ==> "ok"
+ * fail (BAParticipantCompletionId | BACoordinatorCompletionId) ==> "ok"
+ * exit (BAParticipantCompletionId | BACoordinatorCompletionId) ==> "ok"
+ * cannotComplete BAParticipantCompletionId ==> "ok"
+ * completed BAParticipantCompletionId ==> "ok"
+ *
+ * where
+ *
+ * ATParticipantCommand is selected from the following list
+ * "prepare"
+ * "prepareSystemException"
+ * "prepareWrongStateException"
+ * "commit"
+ * "commitSystemException"
+ * "commitWrongStateException"
+ *
+ * BAParticipantCompletionCommand is selected from the following list
+ * "close"
+ * "closeSystemException"
+ * "closeWrongStateException"
+ * "cancel"
+ * "cancelSystemException"
+ * "cancelWrongStateException"
+ * "cancelFaultedException"
+ * "compensate"
+ * "compensateSystemException"
+ * "compensateWrongStateException"
+ * "compensateFaultedException"
+ *
+ * BAParticipantCompletionCommand is selected from the list above or the following list
+ * "complete"
+ * "completeSystemException"
+ * "completeWrongStateException"
+ *
+ * DurableId is a String of the form
+ * "org.jboss.jbossts.xts.servicetests.DurableTestParticipant.NNNNNNNN"
+ * VolatileId is a String of the form
+ * "org.jboss.jbossts.xts.servicetests.VolatileTestParticipant.NNNNNNNN"
+ * BACoordinatorCompletionId is a String of the form
+ * "org.jboss.jbossts.xts.servicetests.CoordinatorCompletionTestParticipant.NNNNNNNN"
+ * BAParticipantCompletionId is a String of the form
+ * "org.jboss.jbossts.xts.servicetests.ParticipantCompletionTestParticipant.NNNNNNNN"
+ *
+ * where NNNNNNNNN is a sequence of base 10 digits.
+ */
+
+public class XTSServiceTestClient
+{
+ /**
+ * all Clients employ a single service instance from which to clone port instances
+ */
+ final private static XTSServiceTestService service = new XTSServiceTestService();
+
+ /**
+ * each Client caches a ready-configured port
+ */
+ private XTSServiceTestPortType port;
+
+ /**
+ * create a client which can be used to make repeated invocations of the test web service methods
+ */
+ public XTSServiceTestClient()
+ {
+ // create a port and configure it with the WS context handler
+ port = service.getXTSServiceTestPortType();
+ List<Handler> handlerChain = new ArrayList<Handler>();
+ handlerChain.add(new JaxWSHeaderContextProcessor());
+ ((BindingProvider)port).getBinding().setHandlerChain(handlerChain);
+ }
+
+ /**
+ * invoke a web service at a specified URL
+ * @param serverURL
+ * @param commands a list of operations to be performed by the web service
+ * @return a list of zero or more results identifying the outcomes of the operations
+ */
+ public synchronized ResultsType serve(String serverURL, CommandsType commands)
+ {
+
+ Map<String, Object> requestProperties = ((BindingProvider)port).getRequestContext();
+ requestProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serverURL);
+
+ CommandsType commandsType = new CommandsType();
+ return port.serve(commands);
+ }
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/CommandsType.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/CommandsType.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/CommandsType.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,71 @@
+
+package org.jboss.jbossts.xts.servicetests.generated;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlList;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for commandsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="commandsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="commandList" type="{http://jbossts.jboss.org/xts/servicetests/generated}commandList"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "commandsType", propOrder = {
+ "commandList"
+})
+public class CommandsType {
+
+ @XmlList
+ @XmlElement(required = true)
+ protected List<String> commandList;
+
+ /**
+ * Gets the value of the commandList property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the commandList property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getCommandList().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getCommandList() {
+ if (commandList == null) {
+ commandList = new ArrayList<String>();
+ }
+ return this.commandList;
+ }
+
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ObjectFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ObjectFactory.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ObjectFactory.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,71 @@
+
+package org.jboss.jbossts.xts.servicetests.generated;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.jboss.jbossts.xts.servicetests.generated package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+ at XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _Commands_QNAME = new QName("http://jbossts.jboss.org/xts/servicetests/generated", "commands");
+ private final static QName _Results_QNAME = new QName("http://jbossts.jboss.org/xts/servicetests/generated", "results");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.jboss.jbossts.xts.servicetests.generated
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link CommandsType }
+ *
+ */
+ public CommandsType createCommandsType() {
+ return new CommandsType();
+ }
+
+ /**
+ * Create an instance of {@link ResultsType }
+ *
+ */
+ public ResultsType createResultsType() {
+ return new ResultsType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CommandsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://jbossts.jboss.org/xts/servicetests/generated", name = "commands")
+ public JAXBElement<CommandsType> createCommands(CommandsType value) {
+ return new JAXBElement<CommandsType>(_Commands_QNAME, CommandsType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ResultsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://jbossts.jboss.org/xts/servicetests/generated", name = "results")
+ public JAXBElement<ResultsType> createResults(ResultsType value) {
+ return new JAXBElement<ResultsType>(_Results_QNAME, ResultsType.class, null, value);
+ }
+
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ResultsType.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ResultsType.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/ResultsType.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,71 @@
+
+package org.jboss.jbossts.xts.servicetests.generated;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlList;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for resultsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="resultsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="resultList" type="{http://jbossts.jboss.org/xts/servicetests/generated}resultList"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "resultsType", propOrder = {
+ "resultList"
+})
+public class ResultsType {
+
+ @XmlList
+ @XmlElement(required = true)
+ protected List<String> resultList;
+
+ /**
+ * Gets the value of the resultList property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the resultList property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getResultList().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getResultList() {
+ if (resultList == null) {
+ resultList = new ArrayList<String>();
+ }
+ return this.resultList;
+ }
+
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestPortType.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestPortType.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestPortType.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,34 @@
+
+package org.jboss.jbossts.xts.servicetests.generated;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+
+/**
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.2-hudson-182-RC1
+ * Generated source version: 2.0
+ *
+ */
+ at WebService(name = "XTSServiceTestPortType", targetNamespace = "http://jbossts.jboss.org/xts/servicetests/generated")
+ at SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface XTSServiceTestPortType {
+
+
+ /**
+ *
+ * @param commands
+ * @return
+ * returns org.jboss.jbossts.xts.servicetests.generated.ResultsType
+ */
+ @WebMethod
+ @WebResult(name = "results", targetNamespace = "http://jbossts.jboss.org/xts/servicetests/generated", partName = "results")
+ public ResultsType serve(
+ @WebParam(name = "commands", targetNamespace = "http://jbossts.jboss.org/xts/servicetests/generated", partName = "commands")
+ CommandsType commands);
+
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestService.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestService.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/XTSServiceTestService.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,58 @@
+
+package org.jboss.jbossts.xts.servicetests.generated;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+
+
+/**
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.2-hudson-182-RC1
+ * Generated source version: 2.0
+ *
+ */
+ at WebServiceClient(name = "XTSServiceTestService", targetNamespace = "http://jbossts.jboss.org/xts/servicetests/generated", wsdlLocation = "wsdl/xtsservicetests.wsdl")
+public class XTSServiceTestService
+ extends Service
+{
+
+ private final static URL XTSSERVICETESTSERVICE_WSDL_LOCATION;
+ private final static Logger logger = Logger.getLogger(org.jboss.jbossts.xts.servicetests.generated.XTSServiceTestService.class.getName());
+
+ static {
+ URL url = null;
+ try {
+ URL baseUrl;
+ baseUrl = org.jboss.jbossts.xts.servicetests.generated.XTSServiceTestService.class.getResource(".");
+ url = new URL(baseUrl, "wsdl/xtsservicetests.wsdl");
+ } catch (MalformedURLException e) {
+ logger.warning("Failed to create URL for the wsdl Location: 'wsdl/xtsservicetests.wsdl', retrying as a local file");
+ logger.warning(e.getMessage());
+ }
+ XTSSERVICETESTSERVICE_WSDL_LOCATION = url;
+ }
+
+ public XTSServiceTestService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public XTSServiceTestService() {
+ super(XTSSERVICETESTSERVICE_WSDL_LOCATION, new QName("http://jbossts.jboss.org/xts/servicetests/generated", "XTSServiceTestService"));
+ }
+
+ /**
+ *
+ * @return
+ * returns XTSServiceTestPortType
+ */
+ @WebEndpoint(name = "XTSServiceTestPortType")
+ public XTSServiceTestPortType getXTSServiceTestPortType() {
+ return super.getPort(new QName("http://jbossts.jboss.org/xts/servicetests/generated", "XTSServiceTestPortType"), XTSServiceTestPortType.class);
+ }
+
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/package-info.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/package-info.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/generated/package-info.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,2 @@
+ at javax.xml.bind.annotation.XmlSchema(namespace = "http://jbossts.jboss.org/xts/servicetests/generated")
+package org.jboss.jbossts.xts.servicetests.generated;
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/Constants.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/Constants.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/Constants.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,9 @@
+package org.jboss.jbossts.xts.servicetests.service;
+
+/**
+ * Constant values used by the test code
+ */
+public class Constants
+{
+ public static final String PARTICIPANT_ID_PREFIX = "org.jboss.jbossts.xts.servicetests.";
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestPortTypeImpl.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestPortTypeImpl.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestPortTypeImpl.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,300 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.service;
+
+import org.jboss.jbossts.xts.servicetests.generated.ObjectFactory;
+import org.jboss.jbossts.xts.servicetests.generated.ResultsType;
+import org.jboss.jbossts.xts.servicetests.generated.CommandsType;
+import org.jboss.jbossts.xts.servicetests.generated.XTSServiceTestPortType;
+import org.jboss.jbossts.xts.servicetests.service.participant.*;
+import org.jboss.jbossts.xts.servicetests.service.recovery.TestATRecoveryModule;
+
+import javax.jws.*;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.namespace.QName;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.HashMap;
+
+import com.arjuna.mw.wst11.TransactionManager;
+import com.arjuna.mw.wst11.TransactionManagerFactory;
+import com.arjuna.mw.wst11.BusinessActivityManager;
+import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
+import com.arjuna.wst11.BAParticipantManager;
+import com.arjuna.wst.WrongStateException;
+import com.arjuna.wst.UnknownTransactionException;
+import com.arjuna.wst.SystemException;
+
+
+/**
+ * A general purpose web service used to test the WSAT and WSBA services. It implements
+ * a single service method which accepts a command list and returns a reesult list. This
+ * can be used to register participants and script their behaviour.
+ */
+ at WebService(targetNamespace = "http://jbossts.jboss.org/xts/servicetests/generated",
+ wsdlLocation = "WEB-INF/wsdl/xtsservicetests.wsdl",
+ serviceName = "XTSServiceTest",
+ portName = "XTSServiceTestPortType",
+ name = "XTSServiceTestPortType"
+ )
+ at SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+// @EndpointConfig(configName = "Standard WSAddressing Endpoint")
+ at HandlerChain(file="handlers.xml")
+ at XmlSeeAlso({
+ ObjectFactory.class
+})
+public class XTSServiceTestPortTypeImpl implements XTSServiceTestPortType
+{
+ @Resource
+ private WebServiceContext wsc;
+
+ @PostConstruct
+ public void postContruct()
+ {
+ System.out.println("XTSServiceTestPortTypeImpl postContruct");
+ }
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ System.out.println("XTSServiceTestPortTypeImpl preDestroy");
+ }
+ /**
+ *
+ * @param commands
+ * @return
+ * returns org.jboss.jbossts.xts.servicetests.generated.ResultsType
+ */
+ @WebMethod
+ @WebResult(name = "results", targetNamespace = "http://jbossts.jboss.org/xts/servicetests/generated", partName = "results")
+ public ResultsType serve(
+ @WebParam(name = "commands", targetNamespace = "http://jbossts.jboss.org/xts/servicetests/generated", partName = "commands")
+ CommandsType commands)
+ {
+ ResultsType results = new ResultsType();
+ List<String> resultsList = results.getResultList();
+ List<String> commandList = commands.getCommandList();
+
+ for (String s : commandList)
+ {
+ System.out.println("service " + this + " : command " + s);
+ }
+
+ int size = commandList.size();
+ int idx = 0;
+
+ String command = commandList.get(idx);
+
+ // check against each of the possible commands
+
+
+ if (command.equals("enlistDurable")) {
+// enlistment commands
+ String id = participantId("DurableTestParticipant");
+ DurableTestParticipant participant = new DurableTestParticipant(id);
+ TransactionManager txman = TransactionManagerFactory.transactionManager();
+ try {
+ txman.enlistForDurableTwoPhase(participant, id);
+ } catch (Exception e) {
+ throw new WebServiceException("enlistDurable failed ", e);
+ }
+ for (idx = 1; idx < size; idx++) {
+ participant.addCommand(commandList.get(idx));
+ }
+ participantMap.put(id, participant);
+ resultsList.add(id);
+ } else if (command.equals("enlistVolatile")) {
+ String id = participantId("VolatileTestParticipant");
+ VolatileTestParticipant participant = new VolatileTestParticipant(id);
+ TransactionManager txman = TransactionManagerFactory.transactionManager();
+ try {
+ txman.enlistForVolatileTwoPhase(participant, id);
+ } catch (Exception e) {
+ throw new WebServiceException("enlistVolatile failed ", e);
+ }
+ for (;idx < size; idx++) {
+ participant.addCommand(commandList.get(idx));
+ }
+ participantMap.put(id, participant);
+ resultsList.add(id);
+ } else if (command.equals("enlistCoordinatorCompletion")) {
+ String id = participantId("CoordinatorCompletionParticipant");
+ CoordinatorCompletionTestParticipant participant = new CoordinatorCompletionTestParticipant(id);
+ BusinessActivityManager baman = BusinessActivityManagerFactory.businessActivityManager();
+ try {
+ BAParticipantManager partMan;
+ partMan = baman.enlistForBusinessAgreementWithCoordinatorCompletion(participant, id);
+ managerMap.put(id, partMan);
+ } catch (Exception e) {
+ throw new WebServiceException("enlistCoordinatorCompletion failed ", e);
+ }
+ for (;idx < size; idx++) {
+ participant.addCommand(commandList.get(idx));
+ }
+ participantMap.put(id, participant);
+ resultsList.add(id);
+ } else if (command.equals("enlistParticipantCompletion")) {
+ String id = participantId("ParticipantCompletionParticipant");
+ ParticipantCompletionTestParticipant participant = new ParticipantCompletionTestParticipant(id);
+ BusinessActivityManager baman = BusinessActivityManagerFactory.businessActivityManager();
+ try {
+ BAParticipantManager partMan;
+ partMan = baman.enlistForBusinessAgreementWithParticipantCompletion(participant, id);
+ managerMap.put(id, partMan);
+ } catch (Exception e) {
+ throw new WebServiceException("enlistParticipantCompletion failed ", e);
+ }
+ for (;idx < size; idx++) {
+ participant.addCommand(commandList.get(idx));
+ }
+ participantMap.put(id, participant);
+ resultsList.add(id);
+ } else if (command.equals("commands")) {
+// add extra commands
+ String id = commandList.get(1);
+ ScriptedTestParticipant participant = participantMap.get(id);
+ if (participant != null) {
+ for (idx = 2; idx < size; idx++)
+ {
+ participant.addCommand(commandList.get(idx));
+ }
+ resultsList.add("ok");
+ } else {
+ throw new WebServiceException("addCommands failed to find participant " + id);
+ }
+ } else if (command.equals("exit")) {
+// initiate BA manager activities
+ String id = commandList.get(1);
+ ScriptedTestParticipant participant = participantMap.get(id);
+ if (participant != null ) {
+ if (participant instanceof ParticipantCompletionTestParticipant) {
+ ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
+ BAParticipantManager manager = managerMap.get(id);
+ try {
+ manager.exit();
+ } catch (Exception e) {
+ throw new WebServiceException("exit " + id + " failed with exception " + e);
+ }
+ resultsList.add("ok");
+ } else {
+ throw new WebServiceException("exit invalid participant type " + id);
+ }
+ } else {
+ throw new WebServiceException("exit unknown participant " + id);
+ }
+ } else if (command.equals("completed")) {
+ String id = commandList.get(1);
+ ScriptedTestParticipant participant = participantMap.get(id);
+ if (participant != null ) {
+ if (participant instanceof ParticipantCompletionTestParticipant) {
+ ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
+ BAParticipantManager manager = managerMap.get(id);
+ try {
+ manager.completed();
+ resultsList.add("ok");
+ } catch (Exception e) {
+ throw new WebServiceException("completed " + id + " failed with exception " + e);
+ }
+ } else {
+ throw new WebServiceException("completed invalid participant type " + id);
+ }
+ } else {
+ throw new WebServiceException("completed unknown participant " + id);
+ }
+ } else if (command.equals("fail")) {
+ String id = commandList.get(1);
+ ScriptedTestParticipant participant = participantMap.get(id);
+ if (participant != null ) {
+ if (participant instanceof ParticipantCompletionTestParticipant) {
+ ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
+ BAParticipantManager manager = managerMap.get(id);
+ QName qname = new QName("http://jbossts.jboss.org/xts/servicetests/", "fail");
+ try {
+ manager.fail(qname);
+ resultsList.add("ok");
+ } catch (Exception e) {
+ throw new WebServiceException("fail " + id + " failed with exception " + e);
+ }
+ } else {
+ throw new WebServiceException("fail invalid participant type " + id);
+ }
+ } else {
+ throw new WebServiceException("fail unknown participant " + id);
+ }
+ } else if (command.equals("cannotComplete")) {
+ String id = commandList.get(1);
+ ScriptedTestParticipant participant = participantMap.get(id);
+ if (participant != null ) {
+ if (participant instanceof ParticipantCompletionTestParticipant) {
+ ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
+ BAParticipantManager manager = managerMap.get(id);
+ try {
+ manager.cannotComplete();
+ resultsList.add("ok");
+ } catch (Exception e) {
+ throw new WebServiceException("cannotComplete " + id + " failed with exception " + e);
+ }
+ } else {
+ throw new WebServiceException("cannotComplete invalid participant type " + id);
+ }
+ } else {
+ throw new WebServiceException("cannotComplete unknown participant " + id);
+ }
+ }
+
+ return results;
+ }
+
+ /**
+ * counter used to conjure up participant names
+ */
+
+ private static int nextId = 0;
+
+ /**
+ * obtain a new participant name starting with a prefix recognised by the recovery code and terminated
+ * with the supplied suffix and a unique trailing number
+ * @param suffix a component to be added to the name before the counter identifying the type of
+ * participant
+ * @return
+ */
+ private synchronized String participantId(String suffix)
+ {
+ return Constants.PARTICIPANT_ID_PREFIX + suffix + "." + nextId++;
+ }
+
+ /**
+ * a table used ot retain a handle on enlisted participants so that they can be driven by the client to
+ * perform actions not contained in the original command script.
+ */
+ private HashMap<String, ScriptedTestParticipant> participantMap = new HashMap<String, ScriptedTestParticipant>();
+
+ /**
+ * a table used ot retain a handle on managers for enlisted BA participants.
+ */
+ private HashMap<String, BAParticipantManager> managerMap = new HashMap<String, BAParticipantManager>();
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestServiceManager.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestServiceManager.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/XTSServiceTestServiceManager.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.service;
+
+import javax.xml.ws.Endpoint;
+
+/**
+ * A convenience class used to dynamically deploy XTS ServiceTest Service instances
+ *
+ * Unfortunately, this cannot be used because JBossWS does not support the Endpoint API
+ */
+public class XTSServiceTestServiceManager
+{
+ public static void publish(String url)
+ {
+ Endpoint.publish(url, new XTSServiceTestPortTypeImpl());
+ }
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/CoordinatorCompletionTestParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/CoordinatorCompletionTestParticipant.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/CoordinatorCompletionTestParticipant.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,44 @@
+package org.jboss.jbossts.xts.servicetests.service.participant;
+
+import com.arjuna.wst.*;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.io.Serializable;
+
+/**
+ * A scriptable coordinator completion participant for use by the XTSServiceTest service.
+ */
+
+public class CoordinatorCompletionTestParticipant extends ParticipantCompletionTestParticipant
+ implements BusinessAgreementWithCoordinatorCompletionParticipant, Serializable
+{
+ // constructor for recovery only
+ protected CoordinatorCompletionTestParticipant()
+ {
+ }
+
+ public CoordinatorCompletionTestParticipant(String id)
+ {
+ super(id);
+ }
+
+ public void complete() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("complete")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("completeWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("CoordinatorCompletionTestParticipant complete : " + id);
+ } else if (s.equals("completeSystemException")) {
+ commands.remove(s);
+ throw new SystemException("CoordinatorCompletionTestParticipant complete : " + id);
+ }
+ }
+
+ // default behaviour is just to complete
+
+ return;
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/DurableTestParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/DurableTestParticipant.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/DurableTestParticipant.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,95 @@
+package org.jboss.jbossts.xts.servicetests.service.participant;
+
+import com.arjuna.wst.*;
+
+import java.io.Serializable;
+
+/**
+ * A scriptable durable participant for use by the XTSServiceTest service.
+ */
+
+public class DurableTestParticipant
+ extends ScriptedTestParticipant
+ implements Durable2PCParticipant, Serializable
+{
+ // constructor for recovery only
+ protected DurableTestParticipant()
+ {
+ }
+
+ public DurableTestParticipant(String id)
+ {
+ super(id);
+ }
+
+ public Vote prepare() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("prepare")) {
+ commands.remove(s);
+ return new Prepared();
+ } else if (s.equals("prepareReadOnly")) {
+ commands.remove(s);
+ return new ReadOnly();
+ } else if (s.equals("prepareAbort")) {
+ commands.remove(s);
+ return new Aborted();
+ } else if (s.equals("prepareWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("DurableTestParticipant prepare : " + id);
+ } else if (s.equals("prepareSystemException")) {
+ commands.remove(s);
+ throw new SystemException("DurableTestParticipant prepare : " + id);
+ }
+ }
+
+ // default behaviour is just to prepare
+
+ return new Prepared();
+ }
+
+ public void commit() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("commit")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("commitWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("DurableTestParticipant commit : " + id);
+ } else if (s.equals("commitSystemException")) {
+ commands.remove(s);
+ throw new SystemException("DurableTestParticipant commit : " + id);
+ }
+ }
+
+ // default behaviour is just to commit
+
+ return;
+ }
+
+ public void rollback() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("rollback")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("rollbackWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("DurableTestParticipant rollback : " + id);
+ } else if (s.equals("rollbackSystemException")) {
+ commands.remove(s);
+ throw new SystemException("DurableTestParticipant rollback : " + id);
+ }
+ }
+
+ // default behaviour is just to rollback
+
+ return;
+ }
+
+ public void unknown() throws SystemException {
+ // do nothing
+ }
+
+ public void error() throws SystemException {
+ // do nothing
+ }
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ParticipantCompletionTestParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ParticipantCompletionTestParticipant.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ParticipantCompletionTestParticipant.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,106 @@
+package org.jboss.jbossts.xts.servicetests.service.participant;
+
+import com.arjuna.wst.*;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.io.Serializable;
+
+/**
+ * A scriptable participant completion participant for use by the XTSServiceTest service.
+ */
+
+public class ParticipantCompletionTestParticipant
+ extends ScriptedTestParticipant
+ implements BusinessAgreementWithParticipantCompletionParticipant, Serializable
+{
+ // constructor for recovery only
+ protected ParticipantCompletionTestParticipant()
+ {
+ }
+
+ public ParticipantCompletionTestParticipant(String id)
+ {
+ super(id);
+ }
+
+ public void addCommand(String command)
+ {
+ commands.add(command);
+ }
+
+ public void close() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("close")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("closeWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("ParticipantCompletionTestParticipant close : " + id);
+ } else if (s.equals("closeSystemException")) {
+ commands.remove(s);
+ throw new SystemException("ParticipantCompletionTestParticipant close : " + id);
+ }
+ }
+
+ // default behaviour is just to complete
+
+ return;
+ }
+
+ public void cancel() throws FaultedException, WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("cancel")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("cancelFaultedException")) {
+ commands.remove(s);
+ throw new FaultedException("ParticipantCompletionTestParticipant cancel : " + id);
+ } else if (s.equals("cancelWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("ParticipantCompletionTestParticipant cancel : " + id);
+ } else if (s.equals("cancelSystemException")) {
+ commands.remove(s);
+ throw new SystemException("ParticipantCompletionTestParticipant cancel : " + id);
+ }
+ }
+
+ // default behaviour is just to complete
+
+ return;
+ }
+
+ public void compensate() throws FaultedException, WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("compensate")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("compensateFaultedException")) {
+ commands.remove(s);
+ throw new FaultedException("ParticipantCompletionTestParticipant compensate : " + id);
+ } else if (s.equals("compensateWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("ParticipantCompletionTestParticipant compensate : " + id);
+ } else if (s.equals("compensateSystemException")) {
+ commands.remove(s);
+ throw new SystemException("ParticipantCompletionTestParticipant compensate : " + id);
+ }
+ }
+
+ // default behaviour is just to complete
+
+ return;
+ }
+
+ public String status() throws SystemException {
+ return null;
+ }
+
+ public void unknown() throws SystemException {
+ // do nothing for now
+ }
+
+ public void error() throws SystemException {
+ // do nothing for now
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ScriptedTestParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ScriptedTestParticipant.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/ScriptedTestParticipant.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,36 @@
+package org.jboss.jbossts.xts.servicetests.service.participant;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.io.Serializable;
+
+/**
+ * Generic participant class which enables scripting of participant behaviour via a list of commands
+ */
+
+public class ScriptedTestParticipant implements Serializable {
+
+ protected String id;
+ protected List<String> commands;
+
+ // constructor for recovery only
+ protected ScriptedTestParticipant()
+ {
+ }
+
+ protected ScriptedTestParticipant(String id)
+ {
+ this.id = id;
+ commands = new ArrayList<String>();
+ }
+
+ public void addCommand(String command)
+ {
+ commands.add(command);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/VolatileTestParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/VolatileTestParticipant.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/participant/VolatileTestParticipant.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,95 @@
+package org.jboss.jbossts.xts.servicetests.service.participant;
+
+import com.arjuna.wst.*;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A scriptable non-durable participant for use by the XTSServiceTest service.
+ */
+public class VolatileTestParticipant
+ extends ScriptedTestParticipant
+ implements Volatile2PCParticipant
+{
+ public VolatileTestParticipant(String id)
+ {
+ super(id);
+ }
+
+ public void addCommand(String command)
+ {
+ commands.add(command);
+ }
+
+ public Vote prepare() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("prepare")) {
+ commands.remove(s);
+ return new Prepared();
+ } else if (s.equals("prepareReadOnly")) {
+ commands.remove(s);
+ return new ReadOnly();
+ } else if (s.equals("prepareAbort")) {
+ commands.remove(s);
+ return new Aborted();
+ } else if (s.equals("prepareWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("DurableTestParticipant prepare : " + id);
+ } else if (s.equals("prepareSystemException")) {
+ commands.remove(s);
+ throw new SystemException("DurableTestParticipant prepare : " + id);
+ }
+ }
+
+ // default behaviour is just to prepare
+
+ return new Prepared();
+ }
+
+ public void commit() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("commit")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("commitWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("DurableTestParticipant commit : " + id);
+ } else if (s.equals("commitSystemException")) {
+ commands.remove(s);
+ throw new SystemException("DurableTestParticipant commit : " + id);
+ }
+ }
+
+ // default behaviour is just to commit
+
+ return;
+ }
+
+ public void rollback() throws WrongStateException, SystemException {
+ for (String s : commands) {
+ if (s.equals("rollback")) {
+ commands.remove(s);
+ return;
+ } else if (s.equals("rollbackWrongStateException")) {
+ commands.remove(s);
+ throw new WrongStateException("DurableTestParticipant rollback : " + id);
+ } else if (s.equals("rollbackSystemException")) {
+ commands.remove(s);
+ throw new SystemException("DurableTestParticipant rollback : " + id);
+ }
+ }
+
+ // default behaviour is just to rollback
+
+ return;
+ }
+
+ public void unknown() throws SystemException {
+ // do nothing
+ }
+
+ public void error() throws SystemException {
+ // do nothing
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestATRecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestATRecoveryModule.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestATRecoveryModule.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,101 @@
+package org.jboss.jbossts.xts.servicetests.service.recovery;
+
+import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryModule;
+import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryManager;
+import org.jboss.jbossts.xts.servicetests.service.Constants;
+import org.jboss.jbossts.xts.servicetests.service.participant.DurableTestParticipant;
+import com.arjuna.wst.Durable2PCParticipant;
+
+import java.io.ObjectInputStream;
+
+/**
+ * Application-specific WS-AT participant recovery manager for demo application, This class
+ * is responsible for recreating application-specific durable participants from records
+ * logged at prepare time.
+ */
+public class TestATRecoveryModule implements XTSATRecoveryModule
+{
+ /**
+ * the singleton recovery module
+ */
+ private static TestATRecoveryModule theRecoveryModule = null;
+
+ /**
+ * a count of how many xts demo services are currently installed
+ */
+ private static int serviceCount = 0;
+
+ /**
+ * called during deployment of an xts-demo web service to ensure the recovery module for the
+ * demo is installed whenever any of the services is active
+ */
+ public static void register()
+ {
+ if (theRecoveryModule == null) {
+ theRecoveryModule = new TestATRecoveryModule();
+ }
+ if (serviceCount == 0) {
+ XTSATRecoveryManager.getRecoveryManager().registerRecoveryModule(theRecoveryModule);
+ }
+ serviceCount++;
+ }
+
+ /**
+ * called during undeployment of an xts-demo web service to ensure the recovery module for
+ * the demo is deinstalled once none of the services is active
+ */
+ public static void unregister()
+ {
+ if (serviceCount > 0) {
+ serviceCount--;
+ if (serviceCount == 0) {
+ XTSATRecoveryManager.getRecoveryManager().unregisterRecoveryModule(theRecoveryModule);
+ }
+ }
+ }
+
+ /**
+ * called during recovery processing to allow an application to identify a participant id
+ * belonging to one of its participants and recreate the participant by deserializing
+ * it from the supplied object input stream. n.b. this is only appropriate in case the
+ * participant was originally saved using serialization.
+ *
+ * @param id the id used when the participant was created
+ * @param stream a stream from which the application should deserialise the participant
+ * if it recognises that the id belongs to the module's application
+ * @return
+ * @throws Exception if an error occurs deserializing the durable participant
+ */
+ public Durable2PCParticipant deserialize(String id, ObjectInputStream stream) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX + "DurableTestParticipant")) {
+ System.out.println("xts service test : attempting to deserialize WS-AT participant " + id);
+ DurableTestParticipant participant = (DurableTestParticipant)stream.readObject();
+ System.out.println("xts service test : deserialized WS-AT participant " + id);
+ return participant;
+ }
+
+ return null;
+ }
+
+ /**
+ * called during recovery processing to allow an application to identify a participant id
+ * belonging to one of its participants and use the saved recovery state to recreate the
+ * participant. n.b. this is only appropriate in case the participant was originally saved
+ * after being converted to a byte array using the PersistibleATParticipant interface.
+ *
+ * @param id the id used when the participant was created
+ * @param recoveryState a byte array returned form the original participant via a call to
+ * method getRecoveryState of interface PersistableATParticipant
+ * @return
+ * @throws Exception if an error occurs converting the recoveryState back to a
+ * durable participant
+ */
+ public Durable2PCParticipant recreate(String id, byte[] recoveryState) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX)) {
+ // this should not get called -- test WS-AT participants are saved and restored
+ // using serialization
+ throw new Exception("xts service test : invalid request to recreate() WS-AT participant " + id);
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestBARecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestBARecoveryModule.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/service/recovery/TestBARecoveryModule.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,149 @@
+package org.jboss.jbossts.xts.servicetests.service.recovery;
+
+import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryModule;
+import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryManager;
+import org.jboss.jbossts.xts.recovery.participant.ba.XTSBARecoveryModule;
+import org.jboss.jbossts.xts.recovery.participant.ba.XTSBARecoveryManager;
+import org.jboss.jbossts.xts.servicetests.service.Constants;
+import org.jboss.jbossts.xts.servicetests.service.participant.DurableTestParticipant;
+import com.arjuna.wst.Durable2PCParticipant;
+import com.arjuna.wst.BusinessAgreementWithParticipantCompletionParticipant;
+import com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant;
+
+import java.io.ObjectInputStream;
+
+/**
+ * Application-specific WS-AT participant recovery manager for demo application, This class
+ * is responsible for recreating application-specific durable participants from records
+ * logged at prepare time.
+ */
+public class TestBARecoveryModule implements XTSBARecoveryModule
+{
+ /**
+ * the singleton recovery module
+ */
+ private static TestBARecoveryModule theRecoveryModule = null;
+
+ /**
+ * a count of how many xts demo services are currently installed
+ */
+ private static int serviceCount = 0;
+
+ /**
+ * called during deployment of an xts-demo web service to ensure the recovery module for the
+ * demo is installed whenever any of the services is active
+ */
+ public static void register()
+ {
+ if (theRecoveryModule == null) {
+ theRecoveryModule = new TestBARecoveryModule();
+ }
+ if (serviceCount == 0) {
+ XTSBARecoveryManager.getRecoveryManager().registerRecoveryModule(theRecoveryModule);
+ }
+ serviceCount++;
+ }
+
+ /**
+ * called during undeployment of an xts-demo web service to ensure the recovery module for
+ * the demo is deinstalled once none of the services is active
+ */
+ public static void unregister()
+ {
+ if (serviceCount > 0) {
+ serviceCount--;
+ if (serviceCount == 0) {
+ XTSBARecoveryManager.getRecoveryManager().unregisterRecoveryModule(theRecoveryModule);
+ }
+ }
+ }
+
+ /**
+ * called during recovery processing to allow an application to identify a participant id
+ * belonging to one of its participants and recreate the participant by deserializing
+ * it from the supplied object input stream. n.b. this is only appropriate in case the
+ * participant was originally saved using serialization.
+ *
+ * @param id the id used when the participant was created
+ * @param stream a stream from which the application should deserialise the participant
+ * if it recognises that the id belongs to the module's application
+ * @return
+ * @throws Exception if an error occurs deserializing the durable participant
+ */
+ public Durable2PCParticipant deserialize(String id, ObjectInputStream stream) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX + "DurableTestParticipant")) {
+ System.out.println("xts service test : attempting to deserialize WS-AT participant " + id);
+ DurableTestParticipant participant = (DurableTestParticipant)stream.readObject();
+ System.out.println("xts service test : deserialized WS-AT participant " + id);
+ return participant;
+ }
+
+ return null;
+ }
+
+ /**
+ * called during recovery processing to allow an application to identify a participant id
+ * belonging to one of its participants and use the saved recovery state to recreate the
+ * participant. n.b. this is only appropriate in case the participant was originally saved
+ * after being converted to a byte array using the PersistibleATParticipant interface.
+ *
+ * @param id the id used when the participant was created
+ * @param recoveryState a byte array returned form the original participant via a call to
+ * method getRecoveryState of interface PersistableATParticipant
+ * @return
+ * @throws Exception if an error occurs converting the recoveryState back to a
+ * durable participant
+ */
+ public Durable2PCParticipant recreate(String id, byte[] recoveryState) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX)) {
+ // this should not get called -- test WS-AT participants are saved and restored
+ // using serialization
+ throw new Exception("xts service test : invalid request to recreate() WS-AT participant " + id);
+ }
+ return null;
+ }
+
+ public BusinessAgreementWithParticipantCompletionParticipant deserializeParticipantCompletionParticipant(String id, ObjectInputStream stream) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX + "ParticipantCompletionParticipant")) {
+ System.out.println("xts service test : attempting to deserialize WS-BA participant completion participant " + id);
+ BusinessAgreementWithParticipantCompletionParticipant participant
+ = (BusinessAgreementWithParticipantCompletionParticipant)stream.readObject();
+ System.out.println("xts service test : deserialized WS-BA participant completion participant " + id);
+ return participant;
+ }
+
+ return null;
+ }
+
+ public BusinessAgreementWithParticipantCompletionParticipant recreateParticipantCompletionParticipant(String id, byte[] recoveryState) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX + "ParticipantCompletionParticipant")) {
+ // this should not get called -- test WS-BA participants are saved and restored
+ // using serialization
+ throw new Exception("xts service test : invalid request to recreate() WS-BA participant completion participant " + id);
+ }
+
+ return null;
+ }
+
+ public BusinessAgreementWithCoordinatorCompletionParticipant deserializeCoordinatorCompletionParticipant(String id, ObjectInputStream stream) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX + "CoordinatorCompletionParticipant")) {
+ System.out.println("xts service test : attempting to deserialize WS-BA participant completion participant " + id);
+ BusinessAgreementWithCoordinatorCompletionParticipant participant
+ = (BusinessAgreementWithCoordinatorCompletionParticipant)stream.readObject();
+ System.out.println("xts service test : deserialized WS-BA coordinator completion participant " + id);
+ return participant;
+ }
+
+ return null;
+ }
+
+ public BusinessAgreementWithCoordinatorCompletionParticipant recreateCoordinatorCompletionParticipant(String id, byte[] recoveryState) throws Exception {
+ if (id.startsWith(Constants.PARTICIPANT_ID_PREFIX + "ParticipantCompletionParticipant")) {
+ // this should not get called -- test WS-BA participants are saved and restored
+ // using serialization
+ throw new Exception("xts service test : invalid request to recreate() WS-BA coordinator completion participant " + id);
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiParticipantPrepareAndCommitTest.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiParticipantPrepareAndCommitTest.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiParticipantPrepareAndCommitTest.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.test;
+
+import org.jboss.jbossts.xts.servicetests.service.XTSServiceTestServiceManager;
+import org.jboss.jbossts.xts.servicetests.client.XTSServiceTestClient;
+import org.jboss.jbossts.xts.servicetests.generated.CommandsType;
+import org.jboss.jbossts.xts.servicetests.generated.ResultsType;
+import com.arjuna.mw.wst11.UserTransactionFactory;
+import com.arjuna.mw.wst11.UserTransaction;
+import com.arjuna.wst.WrongStateException;
+import com.arjuna.wst.SystemException;
+import com.arjuna.wst.TransactionRolledBackException;
+import com.arjuna.wst.UnknownTransactionException;
+
+/**
+ * Starts a transaction and enlist several participants for the same web service with instructions to
+ * prepare and commit without error
+ */
+public class ATMultiParticipantPrepareAndCommitTest implements XTSServiceTest
+{
+ private boolean isSuccessful = false;
+ private Exception exception;
+
+ public void run() {
+
+ // wait a while so the service has time to start
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
+ UserTransaction tx = UserTransactionFactory.userTransaction();
+
+
+ // invoke the service via the client
+
+ XTSServiceTestClient client = new XTSServiceTestClient();
+ CommandsType commands = new CommandsType();
+ ResultsType results = null;
+
+ // start the transaction
+
+ try {
+ tx.begin();
+ } catch (WrongStateException e) {
+ exception = e;
+ } catch (SystemException e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : txbegin failure " + exception);
+ return;
+ }
+
+ // invoke the service and tell it to prepare and commit
+ commands = new CommandsType();
+ commands.getCommandList().add("enlistDurable");
+ commands.getCommandList().add("prepare");
+ commands.getCommandList().add("commit");
+
+ // call the same web service multiple times -- it's ok to use the samew commands list
+
+ try {
+ results = client.serve("http://localhost:8080/xtstest/xtsservicetest1", commands);
+ } catch (Exception e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : server failure " + exception);
+ return;
+ }
+
+ for (String s : results.getResultList()) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : enlistDurable " + s);
+ }
+
+ try {
+ results = client.serve("http://localhost:8080/xtstest/xtsservicetest1", commands);
+ } catch (Exception e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : server failure " + exception);
+ return;
+ }
+
+ for (String s : results.getResultList()) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : enlistDurable " + s);
+ }
+
+ try {
+ results = client.serve("http://localhost:8080/xtstest/xtsservicetest1", commands);
+ } catch (Exception e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : server failure " + exception);
+ return;
+ }
+
+ for (String s : results.getResultList()) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : enlistDurable " + s);
+ }
+
+ // now commit the transaction
+
+ try {
+ tx.commit();
+ } catch (TransactionRolledBackException e) {
+ exception = e;
+ } catch (UnknownTransactionException e) {
+ exception = e;
+ } catch (SystemException e) {
+ exception = e;
+ } catch (WrongStateException e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : commit failure " + exception);
+ }
+
+ System.out.println("ATMultiParticipantPrepareAndCommitTest : completed");
+ }
+
+ public boolean isSuccessful() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Exception getException() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiServicePrepareAndCommitTest.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiServicePrepareAndCommitTest.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATMultiServicePrepareAndCommitTest.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.test;
+
+import org.jboss.jbossts.xts.servicetests.service.XTSServiceTestServiceManager;
+import org.jboss.jbossts.xts.servicetests.client.XTSServiceTestClient;
+import org.jboss.jbossts.xts.servicetests.generated.CommandsType;
+import org.jboss.jbossts.xts.servicetests.generated.ResultsType;
+import com.arjuna.mw.wst11.UserTransactionFactory;
+import com.arjuna.mw.wst11.UserTransaction;
+import com.arjuna.wst.WrongStateException;
+import com.arjuna.wst.SystemException;
+import com.arjuna.wst.TransactionRolledBackException;
+import com.arjuna.wst.UnknownTransactionException;
+
+/**
+ * Starts a transaction and enlist a single participants for each of several web services with instructions to
+ * prepare and commit without error
+ */
+public class ATMultiServicePrepareAndCommitTest implements XTSServiceTest
+{
+ private boolean isSuccessful = false;
+ private Exception exception;
+
+ public void run() {
+
+ // wait a while so the service has time to start
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
+ UserTransaction tx = UserTransactionFactory.userTransaction();
+
+
+ // invoke the service via the client
+
+ XTSServiceTestClient client = new XTSServiceTestClient();
+ CommandsType commands = new CommandsType();
+ ResultsType results = null;
+
+ // start the transaction
+
+ try {
+ tx.begin();
+ } catch (WrongStateException e) {
+ exception = e;
+ } catch (SystemException e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : txbegin failure " + exception);
+ return;
+ }
+
+ // invoke the service and tell it to prepare and commit
+ commands = new CommandsType();
+ commands.getCommandList().add("enlistDurable");
+ commands.getCommandList().add("prepare");
+ commands.getCommandList().add("commit");
+
+ // call the same web service multiple times -- it's ok to use the samew commands list
+
+ try {
+ results = client.serve("http://localhost:8080/xtstest/xtsservicetest1", commands);
+ } catch (Exception e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : server failure " + exception);
+ return;
+ }
+
+ for (String s : results.getResultList()) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : enlistDurable " + s);
+ }
+
+ try {
+ results = client.serve("http://localhost:8080/xtstest/xtsservicetest2", commands);
+ } catch (Exception e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : server failure " + exception);
+ return;
+ }
+
+ for (String s : results.getResultList()) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : enlistDurable " + s);
+ }
+
+ try {
+ results = client.serve("http://localhost:8080/xtstest/xtsservicetest3", commands);
+ } catch (Exception e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : server failure " + exception);
+ return;
+ }
+
+ for (String s : results.getResultList()) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : enlistDurable " + s);
+ }
+
+ // now commit the transaction
+
+ try {
+ tx.commit();
+ } catch (TransactionRolledBackException e) {
+ exception = e;
+ } catch (UnknownTransactionException e) {
+ exception = e;
+ } catch (SystemException e) {
+ exception = e;
+ } catch (WrongStateException e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATMultiServicePrepareAndCommitTest : commit failure " + exception);
+ }
+
+ System.out.println("ATMultiServicePrepareAndCommitTest : completed");
+ }
+
+ public boolean isSuccessful() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Exception getException() {
+ return exception; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATSingleParticipantPrepareAndCommitTest.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATSingleParticipantPrepareAndCommitTest.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/ATSingleParticipantPrepareAndCommitTest.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.test;
+
+import org.jboss.jbossts.xts.servicetests.service.XTSServiceTestServiceManager;
+import org.jboss.jbossts.xts.servicetests.client.XTSServiceTestClient;
+import org.jboss.jbossts.xts.servicetests.generated.CommandsType;
+import org.jboss.jbossts.xts.servicetests.generated.ResultsType;
+import com.arjuna.mw.wst11.UserTransactionFactory;
+import com.arjuna.mw.wst11.UserTransaction;
+import com.arjuna.wst.WrongStateException;
+import com.arjuna.wst.SystemException;
+import com.arjuna.wst.TransactionRolledBackException;
+import com.arjuna.wst.UnknownTransactionException;
+
+/**
+ * Starts a transaction and enlists a single participant with instructions to prepare and commit
+ * without error
+ */
+public class ATSingleParticipantPrepareAndCommitTest implements XTSServiceTest
+{
+ private boolean isSuccessful = false;
+ private Exception exception;
+
+ public void run() {
+
+ // wait a while so the service has time to start
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
+ UserTransaction tx = UserTransactionFactory.userTransaction();
+
+
+ // invoke the service via the client
+
+ XTSServiceTestClient client = new XTSServiceTestClient();
+ CommandsType commands = new CommandsType();
+ ResultsType results = null;
+
+ // start the transaction
+
+ try {
+ tx.begin();
+ } catch (WrongStateException e) {
+ exception = e;
+ } catch (SystemException e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATSingleParticipantPrepareAndCommitTest : txbegin failure " + exception);
+ return;
+ }
+
+ // invoke the service and tell it to prepare and commit
+ commands = new CommandsType();
+ commands.getCommandList().add("enlistDurable");
+ commands.getCommandList().add("prepare");
+ commands.getCommandList().add("commit");
+
+ try {
+ results = client.serve("http://localhost:8080/xtstest/xtsservicetest1", commands);
+ } catch (Exception e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATSingleParticipantPrepareAndCommitTest : server failure " + exception);
+ return;
+ }
+
+ for (String s : results.getResultList()) {
+ System.out.println("ATSingleParticipantPrepareAndCommitTest : enlistDurable " + s);
+ }
+
+ // now commit the transaction
+
+ try {
+ tx.commit();
+ } catch (TransactionRolledBackException e) {
+ exception = e;
+ } catch (UnknownTransactionException e) {
+ exception = e;
+ } catch (SystemException e) {
+ exception = e;
+ } catch (WrongStateException e) {
+ exception = e;
+ }
+
+ if (exception != null) {
+ System.out.println("ATSingleParticipantPrepareAndCommitTest : commit failure " + exception);
+ }
+
+ System.out.println("ATSingleParticipantPrepareAndCommitTest : completed");
+ }
+
+ public boolean isSuccessful() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Exception getException() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/XTSServiceTest.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/XTSServiceTest.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/tests/src/org/jboss/jbossts/xts/servicetests/test/XTSServiceTest.java 2009-01-19 11:20:43 UTC (rev 24781)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 Lesser General Public License, v. 2.1.
+ * 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.jbossts.xts.servicetests.test;
+
+/**
+ * API implemented by classes which are used to execute a specific XTS service test
+ */
+public interface XTSServiceTest
+{
+ public void run();
+ public boolean isSuccessful();
+ public Exception getException();
+}
More information about the jboss-svn-commits
mailing list