[jboss-svn-commits] JBL Code SVN: r32979 - in labs/jbosstm/trunk/txbridge: docs and 12 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 20 06:21:35 EDT 2010


Author: jhalliday
Date: 2010-05-20 06:21:34 -0400 (Thu, 20 May 2010)
New Revision: 32979

Added:
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/junit/
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/junit/BasicTests.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/junit/
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/junit/BasicTests.java
Modified:
   labs/jbosstm/trunk/txbridge/README.txt
   labs/jbosstm/trunk/txbridge/build.xml
   labs/jbosstm/trunk/txbridge/docs/TransactionBridgingGuide.odt
   labs/jbosstm/trunk/txbridge/docs/TransactionBridgingGuide.pdf
   labs/jbosstm/trunk/txbridge/tests/build.xml
   labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java
   labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java
Log:
Improved testing of the txbridge, using the new byteman/dtest framework. JBTM-44


Modified: labs/jbosstm/trunk/txbridge/README.txt
===================================================================
--- labs/jbosstm/trunk/txbridge/README.txt	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/README.txt	2010-05-20 10:21:34 UTC (rev 32979)
@@ -38,4 +38,9 @@
 ant deploy-service
 ant deploy-client
 
-See docs/TransactionBridgingGuide for further details on the demo app.
\ No newline at end of file
+See docs/TransactionBridgingGuide for further details on the demo app.
+
+Testing:
+--------
+
+See tests/README.txt
\ No newline at end of file

Modified: labs/jbosstm/trunk/txbridge/build.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/build.xml	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/build.xml	2010-05-20 10:21:34 UTC (rev 32979)
@@ -28,16 +28,30 @@
 
     <property name="jbossts.home" location=".."/>
 
-	<property name="src" location="src"/>
-	<property name="build" location="build"/>
+    <property name="global.ext.lib.dir" value="${jbossts.home}/build/extlib"/>
 
+    <!-- remember to turn emma off for prdn builds or it will be a runtime dep! -->
+    <property name="emma.enabled" value="false"/>
+
+    <!-- directory that contains emma.jar and emma_ant.jar: -->
+    <property name="emma.dir" value="${global.ext.lib.dir}" />
+
+    <path id="emma.lib" >
+        <pathelement location="${emma.dir}/emma.jar" />
+        <pathelement location="${emma.dir}/emma_ant.jar" />
+    </path>
+    <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+
+	<property name="src.dir" location="src"/>
+	<property name="build.dir" location="build"/>
+
 	<path id="build-prereqs">
         <fileset dir="${jbossts.home}/install/lib">
             <include name="jbossjta.jar"/>
             <include name="jbossjts.jar"/>
         </fileset>
 
-        <fileset dir="../build/extlib">
+        <fileset dir="${global.ext.lib.dir}">
             <include name="log4j.jar"/>
             <include name="jboss-transaction-api_1.1_spec.jar"/>
             <include name="jboss-connector-api_1.5_spec.jar"/>
@@ -49,26 +63,39 @@
 	</path>
 
 	<target name="clean" description="clean up">
-		<delete dir="${build}"/>
+		<delete dir="${build.dir}"/>
 	</target>
 
 	<target name="init">
 		<tstamp/>
-		<mkdir dir="${build}"/>
+		<mkdir dir="${build.dir}"/>
 	</target>
 
 	<target name="compile" depends="init"
 			description="compile the source ">
-		<mkdir dir="${build}/classes"/>
-		<javac srcdir="${src}" destdir="${build}/classes" debug="true" includeantruntime="false">
+
+		<mkdir dir="${build.dir}/classes"/>
+		<javac srcdir="${src.dir}" destdir="${build.dir}/classes" debug="true" includeantruntime="false">
 			<classpath refid="build-prereqs"/>
 		</javac>
+
+        <emma enabled="${emma.enabled}">
+            <instr mode="overwrite"
+                   metadatafile="${build.dir}/metadata.emma"
+                   merge="true"
+                   filter="">
+                <instrpath>
+                    <pathelement location="${build.dir}/classes"/>
+                </instrpath>
+            </instr>
+        </emma>
+
 	</target>
 
 	<target name="dist" depends="compile"
 			description="generate the distribution">
-		<jar jarfile="${build}/txbridge.jar">
-			<fileset dir="${build}/classes">
+		<jar jarfile="${build.dir}/txbridge.jar">
+			<fileset dir="${build.dir}/classes">
 				<include name="org/jboss/**"/>
 			</fileset>
             <fileset dir=".">
@@ -86,7 +113,7 @@
     <property name="jbossas.server" value="default"/>
 
     <target name="deploy" depends="dist" description="deploy to JBossAS">
-        <copy file="${build}/txbridge.jar" todir="${jbossas.home}/server/${jbossas.server}/deploy/"/>
+        <copy file="${build.dir}/txbridge.jar" todir="${jbossas.home}/server/${jbossas.server}/deploy/"/>
     </target>
 
     <target name="install-jts">
@@ -108,5 +135,27 @@
                dest="${jbossas.home}/server/${jbossas.server}/deploy/jbossxts.sar"/>
     </target>
 
+    <target name="install-emma">
+        <copy file="${global.ext.lib.dir}/emma.jar" todir="${jbossas.home}/common/lib"/>
+    </target>
+
+    <!-- file:///home/jhalli/IdeaProjects/jboss/jbossts_trunk/txbridge/build/emma/coverage.html -->
+    <target name="emma-report">
+        <emma enabled="true">
+            <report>
+                <fileset dir="${build.dir}" includes="metadata.emma"/>
+                <fileset dir="${jbossas.home}" includes="coverage.ec"/>
+                <sourcepath>
+                    <dirset dir="${src.dir}"/>
+                </sourcepath>
+                <txt outfile="${build.dir}/emma/coverage.txt" />
+                <html outfile="${build.dir}/emma/coverage.html" />
+                <sourcepath>
+                    <dirset dir="${src.dir}"/>
+                </sourcepath>
+            </report>
+        </emma>
+    </target>
+
 </project>
 

Modified: labs/jbosstm/trunk/txbridge/docs/TransactionBridgingGuide.odt
===================================================================
(Binary files differ)

Modified: labs/jbosstm/trunk/txbridge/docs/TransactionBridgingGuide.pdf
===================================================================
(Binary files differ)

Modified: labs/jbosstm/trunk/txbridge/tests/build.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/build.xml	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/build.xml	2010-05-20 10:21:34 UTC (rev 32979)
@@ -30,22 +30,20 @@
 
 	<property name="src" location="src"/>
     <property name="dd" location="dd"/>
-	<property name="build" location="build"/>
+	<property name="build.dir" location="build"/>
 
 	<path id="build-prereqs">
         <fileset dir="../../build/extlib">
-
-            <!-- TODO remove old names -->
-            <include name="servlet-api.jar"/>
-            <include name="jta.jar"/>
-            <include name="jboss-ejb-api.jar"/>            
-
             <include name="jboss-servlet-api_3.0_spec.jar"/>
             <include name="log4j.jar"/>
             <include name="jboss-transaction-api_1.1_spec.jar"/>
             <include name="hibernate-jpa-2.0-api.jar"/>
             <include name="jboss-ejb-api_3.1_spec.jar"/>
             <include name="junit.jar"/>
+            <include name="commons-httpclient.jar"/>
+            <include name="commons-logging.jar"/>
+            <include name="commons-codec.jar"/>
+            <!--<include name="byteman.jar"/>-->
         </fileset>
 
         <fileset dir="${jbossts.home}/install/lib">
@@ -53,49 +51,42 @@
             <include name="jbossjts.jar"/>
         </fileset>
 
-        <fileset dir="${jbossts.home}/XTS/xts-install/lib">
-            <include  name="jbossxts-api.jar"/>
+        <fileset dir="${jbossts.home}/XTS/xts-install">
+            <include name="lib/jbossxts-api.jar"/>
+            <include name="tests/localjunit.jar"/>
         </fileset>
 
+        <pathelement location="../build/txbridge.jar"/>
+
+        <pathelement location="/home/jhalli/IdeaProjects/jboss/byteman_trunk/install/lib/byteman.jar"/>        
+        <pathelement location="/home/jhalli/IdeaProjects/jboss/byteman_trunk/contrib/dtest/build/lib/byteman-dtest.jar"/>
+
 	</path>
 
 	<target name="clean" description="clean up">
-		<delete dir="${build}"/>
+		<delete dir="${build.dir}"/>
 	</target>
 
 	<target name="init">
 		<tstamp/>
-		<mkdir dir="${build}"/>
+		<mkdir dir="${build.dir}"/>
 	</target>
 
 	<target name="compile" depends="init"
 			description="compile the source ">
-		<mkdir dir="${build}/classes"/>
-		<javac srcdir="${src}" destdir="${build}/classes" debug="true" includeantruntime="false">
+		<mkdir dir="${build.dir}/classes"/>
+		<javac srcdir="${src}" destdir="${build.dir}/classes" debug="true" includeantruntime="false">
 			<classpath refid="build-prereqs"/>
 		</javac>
 	</target>
 
-    <target name="run" depends="compile">
-        <java classname="org.jboss.jbossts.txbridge.tests.Scratch" fork="true">
-            <classpath>
-                <pathelement location="${build}/classes"/>
-                <path refid="build-prereqs"/>
-            </classpath>
-
-            <jvmarg value="-Xdebug" />
-            <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>
-
-        </java>
-    </target>
-
     <target name="dist" depends="compile"
 			description="generate the distribution">
 
         <copy file="dd/inbound/jaxws-handlers-server.xml"
-              todir="${build}/classes/org/jboss/jbossts/txbridge/tests/inbound/service"/>
-        <jar destfile="${build}/txbridge-inbound-tests-service.jar">
-			<fileset dir="${build}/classes">
+              todir="${build.dir}/classes/org/jboss/jbossts/txbridge/tests/inbound/service"/>
+        <jar destfile="${build.dir}/txbridge-inbound-tests-service.jar">
+			<fileset dir="${build.dir}/classes">
 				<include name="org/jboss/jbossts/txbridge/tests/inbound/service/*"/>
                 <include name="org/jboss/jbossts/txbridge/tests/inbound/utility/*"/>
 			</fileset>
@@ -104,58 +95,120 @@
             </metainf>
 		</jar>
 
-        <war warfile="${build}/txbridge-inbound-tests-client.war" webxml="dd/inbound/web.xml">
-			<classes dir="${build}/classes">
+        <war warfile="${build.dir}/txbridge-inbound-tests-client.war" webxml="dd/inbound/web.xml">
+			<classes dir="${build.dir}/classes">
                 <include name="org/jboss/jbossts/txbridge/tests/inbound/client/*"/>
 			</classes>
 		</war>
 
         <copy file="dd/outbound/jaxws-handlers-server.xml"
-              todir="${build}/classes/org/jboss/jbossts/txbridge/tests/outbound/service"/>
-        <war warfile="${build}/txbridge-outbound-tests-service.war" webxml="dd/outbound/service-web.xml">
-			<classes dir="${build}/classes">
+              todir="${build.dir}/classes/org/jboss/jbossts/txbridge/tests/outbound/service"/>
+        <war warfile="${build.dir}/txbridge-outbound-tests-service.war" webxml="dd/outbound/service-web.xml">
+			<classes dir="${build.dir}/classes">
 				<include name="org/jboss/jbossts/txbridge/tests/outbound/service/*"/>
                 <include name="org/jboss/jbossts/txbridge/tests/outbound/utility/*"/>
 			</classes>
 		</war>
 
-        <copy file="dd/outbound/jaxws-handlers-client.xml"
-              todir="${build}/classes/org/jboss/jbossts/txbridge/tests/outbound/client"/>
-        <war warfile="${build}/txbridge-outbound-tests-client.war" webxml="${dd}/outbound/web.xml">
-			<classes dir="${build}/classes">
+        <war warfile="${build.dir}/txbridge-outbound-tests-client.war" webxml="${dd}/outbound/web.xml">
+			<classes dir="${build.dir}/classes">
                 <include name="org/jboss/jbossts/txbridge/tests/outbound/client/*"/>
 			</classes>
 		</war>
 
+        <jar destfile="${build.dir}/byteman-test-server.jar">
+            <fileset dir="${build.dir}/classes">
+                <include name="org/jboss/jbossts/txbridge/tests/inbound/junit/*.class"/>
+            </fileset>
+        </jar>
+
 	</target>
 
+    <!-- Note: running tests requires JBossAS to be started and the relevant artifacts
+        (XTS, txbridge, test -client and -service) to be deployted in it. Additionally,
+        the AS needs to be running with byteman installed e.g.
+
+        export JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006 -Xmx1024m -javaagent:/home/jhalli/IdeaProjects/jboss/byteman_trunk/install/lib/byteman.jar=port:9091,listener:true -Dorg.jboss.byteman.debug=true -Dorg.jboss.byteman.verbose=true"
+    -->
+
+
+    <target name="run-inbound-tests" depends="compile">
+        <run.tests.macro>
+            <tests>
+                <fileset dir="src" includes="**/inbound/**/BasicTests.java">
+                </fileset>
+            </tests>
+        </run.tests.macro>
+    </target>
+
+    <target name="run-outbound-tests" depends="compile">
+        <run.tests.macro>
+            <tests>
+                <fileset dir="src" includes="**/outbound/**/BasicTests.java">
+                </fileset>
+            </tests>
+        </run.tests.macro>
+    </target>
+
+
+    <macrodef name="run.tests.macro">
+
+        <attribute name="showoutput" default="false"/>
+        <element name="tests"/>
+        <element name="additional.classpath" optional="true"/>
+        <element name="additional.jvmargs" optional="true"/>
+
+        <sequential>
+
+        <mkdir dir="${build.dir}/testresults"/>
+        <junit printsummary="yes" fork="yes" dir="${build.dir}" showoutput="@{showoutput}" includeantruntime="true">
+            <formatter type="plain"/>
+            <classpath>
+                <path refid="build-prereqs"/>
+                <pathelement location="${build.dir}/classes"/>
+                <additional.classpath/>
+            </classpath>
+
+            <batchtest haltonerror="yes" haltonfailure="yes" fork="yes" todir="${build.dir}/testresults">
+                <tests/>
+            </batchtest>
+
+            <jvmarg value="-Djava.rmi.server.codebase=file://build/classes/"/>
+            <!--<jvmarg value="-Xdebug"/>-->
+            <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>-->
+	        <additional.jvmargs/>
+        </junit>
+        </sequential>
+
+    </macrodef>
+
     <!-- ##################################################################################### -->
 
     <property name="jbossas.home" location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/target/jboss-6.0.0-SNAPSHOT"/>
     <property name="jbossas.server" value="default"/>
 
     <target name="deploy-inbound-service" depends="dist" description="deploy EJB to JBossAS">
-        <copy file="${build}/txbridge-inbound-tests-service.jar"
+        <copy file="${build.dir}/txbridge-inbound-tests-service.jar"
               todir="${jbossas.home}/server/${jbossas.server}/deploy"
               overwrite="true"/>
     </target>
 
     <!-- http://localhost:8080/txbridge-inbound-tests-client/testclient -->
     <target name="deploy-inbound-client" depends="dist" description="deploy Servlet to JBossAS">
-        <copy file="${build}/txbridge-inbound-tests-client.war"
+        <copy file="${build.dir}/txbridge-inbound-tests-client.war"
               todir="${jbossas.home}/server/${jbossas.server}/deploy"
               overwrite="true"/>
     </target>
 
     <target name="deploy-outbound-service" depends="dist" description="deploy WS to JBossAS">
-        <copy file="${build}/txbridge-outbound-tests-service.war"
+        <copy file="${build.dir}/txbridge-outbound-tests-service.war"
               todir="${jbossas.home}/server/${jbossas.server}/deploy"
               overwrite="true"/>
     </target>
 
     <!-- http://localhost:8080/txbridge-outbound-tests-client/testclient -->
     <target name="deploy-outbound-client" depends="dist" description="deploy Servlet to JBossAS">
-        <copy file="${build}/txbridge-outbound-tests-client.war"
+        <copy file="${build.dir}/txbridge-outbound-tests-client.war"
               todir="${jbossas.home}/server/${jbossas.server}/deploy"
               overwrite="true"/>
     </target>

Modified: labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt	2010-05-20 10:21:34 UTC (rev 32979)
@@ -1,15 +1,91 @@
-#RULE testrule
-#CLASS ^XTSATRecoveryManager
-#METHOD writeParticipantRecoveryRecord
-#AT EXIT
-#IF true
-#DO killJVM()
-#ENDRULE
+#
+# byteman test rules for txbridge crash recovery.
+# @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-04
+#
+################
 
-RULE testrule
-CLASS ^TestXAResource
+#
+# force crash during prepare of an inbound bridged tx,
+# at the point where only the XAResource in the subordinate is logged.
+#
+RULE inbound_crash_rec_fail_onelog
+CLASS org.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResource
 METHOD prepare
 AT EXIT
-IF true
-DO killJVM()
+IF false
+DO debug("killing JVM"), killJVM()
 ENDRULE
+
+#
+# force crash during prepare of an inbound bridged tx,
+# at the point where the XAResource in the subordinate and
+# and the SubordinateAtomicAction are logged.
+#
+RULE inbound_crash_rec_fail_twologs
+CLASS org.jboss.jbossts.txbridge.inbound.BridgeDurableParticipant
+METHOD prepare
+AT EXIT
+IF false
+DO debug("killing JVM"), killJVM()
+ENDRULE
+
+#
+# force crash during prepare of an inbound bridged tx,
+# at the point where the XAResource in the subordinate,
+# the subordinate and the BridgeDurableParticipant are logged.
+#
+RULE inbound_crash_rec_fail_threelogs
+CLASS ^XTSATRecoveryManager
+METHOD writeParticipantRecoveryRecord
+AT EXIT
+IF false
+DO debug("killing JVM"), killJVM()
+ENDRULE
+
+################
+
+#
+# force crash during prepare of an outbound bridged tx,
+# at the point where only the DurableParticipant in the subordinate
+# XTS transaction is logged.
+#
+RULE outbound_crash_rec_fail_onelog
+CLASS ^XTSATRecoveryManager
+METHOD writeParticipantRecoveryRecord
+AT EXIT
+IF false
+DO debug("killing JVM"), killJVM()
+ENDRULE
+
+#
+# force crash during prepare of an outbound bridged tx,
+# at the point where the DurableParticipant and subordinate
+# XTS transaction (BridgeWrapper) are logged.
+# requires onePhaseCommit=false cfg to force logging.
+#
+RULE outbound_crash_rec_fail_twologs
+CLASS org.jboss.jbossts.txbridge.outbound.BridgeXAResource
+METHOD prepare
+AT EXIT
+IF false
+DO debug("killing JVM"), killJVM()
+ENDRULE
+
+#
+# force crash during prepare of an outbound bridged tx,
+# at the point where the DurableParticipant, subordinate
+# XTS transaction (BridgeWrapper) and BridgeXAResource (inlined
+# to the top level JTA transaction) are logged.
+# requires onePhaseCommit=false cfg to force logging.
+# Uses the commit entry rather than prepare exit to avoid triggering
+# on non-bridged transactions in the app server.
+#
+RULE outbound_crash_rec_fail_threelogs
+CLASS org.jboss.jbossts.txbridge.outbound.BridgeXAResource
+METHOD commit
+AT ENTRY
+IF false
+DO debug("killing JVM"), killJVM()
+ENDRULE
+
+################
\ No newline at end of file

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -20,6 +20,7 @@
  */
 package org.jboss.jbossts.txbridge.tests.inbound.client;
 
+import com.arjuna.mw.wst11.UserTransaction;
 import com.arjuna.mw.wst11.UserTransactionFactory;
 import com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor;
 import com.arjuna.wst.TransactionRolledBackException;
@@ -68,7 +69,6 @@
             Service service = Service.create(wsdlLocation, serviceName);
             testService = service.getPort(TestService.class);
 
-            // we could have used @HandlerChain but it's nice to show a bit of variety...
             BindingProvider bindingProvider = (BindingProvider)testService;
             List<Handler> handlers = new ArrayList<Handler>(1);
             handlers.add(new JaxWSHeaderContextProcessor());
@@ -84,14 +84,9 @@
 
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
     {
-        String outcome = request.getParameter("outcome");
-        String failInBeforeCompletion = request.getParameter("failInBeforeCompletion");
-        String prepareXAErrorCode = request.getParameter("prepareXAErrorCode");
-        
-
         try
         {
-            com.arjuna.mw.wst11.UserTransaction ut = UserTransactionFactory.userTransaction();
+            UserTransaction ut = UserTransactionFactory.userTransaction();
 
             log.info("starting the transaction...");
 
@@ -101,28 +96,11 @@
 
             log.info("calling business Web Services...");
 
-            //////////////////////
+            testService.doNothing();
 
-            if("true".equals(failInBeforeCompletion)) {
-                testService.arrangeBeforeCompletionFailure();
-            }
+            log.info("terminating the transaction...");
 
-            if(prepareXAErrorCode != null) {
-                testService.arrangeXAResourcePrepareXAException(Integer.parseInt(prepareXAErrorCode));
-            }
-
-            testService.doTestResourceEnlistment();
-            testService.doNothing();            
-
-            //////////////////////
-
-            log.info("calling "+outcome+" on the transaction...");
-
-            if("commit".equals(outcome)) {
-                ut.commit();
-            } else {
-                ut.rollback();
-            }
+            terminateTransaction(ut, false);
         }
         catch (final TransactionRolledBackException tre)
         {
@@ -133,8 +111,20 @@
             log.info("problem: ", e);
         }
 
+        response.setContentType("text/plain");
         PrintWriter out = response.getWriter();
-        out.println("done");
+        out.println("finished");
         out.close();
     }
+
+    private void terminateTransaction(UserTransaction userTransaction, boolean shouldCommit) throws Exception
+    {
+        log.info("shouldCommit="+shouldCommit);
+
+        if(shouldCommit) {
+            userTransaction.commit();
+        } else {
+            userTransaction.rollback();
+        }
+    }
 }

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -32,11 +32,5 @@
 @SOAPBinding(style = SOAPBinding.Style.RPC)
 public interface TestService
 {
-    public void doTestResourceEnlistment();
-
     public void doNothing();
-
-    public void arrangeBeforeCompletionFailure();
-
-    public void arrangeXAResourcePrepareXAException(int xaErrorCode);
 }

Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/junit/BasicTests.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/junit/BasicTests.java	                        (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/junit/BasicTests.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * 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) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.inbound.junit;
+
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.jboss.jbossts.txbridge.tests.inbound.client.TestClient;
+import org.jboss.jbossts.txbridge.tests.inbound.service.TestServiceImpl;
+import org.jboss.jbossts.txbridge.tests.inbound.utility.TestSynchronization;
+import org.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResource;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+
+import org.jboss.byteman.agent.submit.Submit;
+import org.jboss.byteman.contrib.dtest.*;
+
+import com.arjuna.qa.junit.HttpUtils;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import java.net.URL;
+
+/**
+ * Basic (i.e. non-crashrec) test cases for the inbound side of the transaction bridge.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-05
+ */
+public class BasicTests
+{
+    private static final String baseURL = "http://localhost:8080/txbridge-inbound-tests-client/testclient";
+
+    private static Instrumentor instrumentor;
+    private InstrumentedClass instrumentedTestSynchronization;
+    private InstrumentedClass instrumentedTestXAResource;
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        instrumentor = new Instrumentor(new Submit(), 1199);
+        instrumentor.installHelperJar("/home/jhalli/IdeaProjects/jboss/byteman_trunk/contrib/dtest/build/lib/byteman-dtest.jar");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        instrumentedTestSynchronization = instrumentor.instrumentClass(TestSynchronization.class);
+        instrumentedTestXAResource = instrumentor.instrumentClass(TestXAResource.class);
+
+        //instrumentor.captureLogging(TestSynchronization.class, null, org.apache.log4j.Logger.class, "error");
+        instrumentor.injectOnCall(TestServiceImpl.class, "doNothing", "$0.enlistSynchronization(1), $0.enlistXAResource(1)");
+
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        instrumentor.removeAllInstrumentation();
+    }
+
+    private void execute() throws Exception {
+        HttpMethodBase request = HttpUtils.accessURL(new URL(baseURL));
+        String response = request.getResponseBodyAsString().trim();
+        assertEquals("finished", response);
+    }
+
+    @Test
+    public void testRollback() throws Exception {
+
+        execute();
+
+        instrumentedTestSynchronization.assertKnownInstances(1);
+        instrumentedTestSynchronization.assertMethodNotCalled("beforeCompletion");
+        instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+        instrumentedTestXAResource.assertKnownInstances(1);
+        instrumentedTestXAResource.assertMethodNotCalled("commit");
+        instrumentedTestXAResource.assertMethodCalled("rollback");
+    }
+
+    @Test
+    public void testCommit() throws Exception {
+
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+        execute();
+
+        instrumentedTestSynchronization.assertKnownInstances(1);
+        instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+        instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+        instrumentedTestXAResource.assertKnownInstances(1);
+        instrumentedTestXAResource.assertMethodNotCalled("rollback");
+        instrumentedTestXAResource.assertMethodCalled("commit");
+    }
+
+    @Test
+    public void testBeforeCompletionFailure() throws Exception {
+
+        instrumentor.injectFault(TestSynchronization.class, "beforeCompletion", RuntimeException.class, new Object[] { "injected BeforeCompletion fault"});
+
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+        execute();
+
+        instrumentedTestSynchronization.assertKnownInstances(1);
+        instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+        instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+        instrumentedTestXAResource.assertKnownInstances(1);
+        instrumentedTestXAResource.assertMethodCalled("rollback");
+        instrumentedTestXAResource.assertMethodNotCalled("commit");
+    }
+
+    @Test
+    public void testPrepareReadonly() throws Exception {
+
+        instrumentor.injectOnCall(TestXAResource.class,  "prepare", "return "+ XAResource.XA_RDONLY);
+
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+        execute();
+
+        instrumentedTestSynchronization.assertKnownInstances(1);
+        instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+        instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+        instrumentedTestXAResource.assertKnownInstances(1);
+        instrumentedTestXAResource.assertMethodNotCalled("rollback");
+        instrumentedTestXAResource.assertMethodNotCalled("commit");
+    }
+
+    @Test
+    public void testPrepareFailure() throws Exception {
+
+        instrumentor.injectFault(TestXAResource.class, "prepare", XAException.class, new Object[] { XAException.XA_RBROLLBACK });
+        
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+        execute();
+
+        instrumentedTestSynchronization.assertKnownInstances(1);
+        instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+        instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+        instrumentedTestXAResource.assertKnownInstances(1);
+
+        //instrumentedTestXAResource.assertMethodNotCalled("rollback");
+        // TODO hmm, XA_RBROLLBACK winds up on pending list, so is called at abortPhase2. bug?
+
+        instrumentedTestXAResource.assertMethodNotCalled("commit");
+    }
+}
\ No newline at end of file

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -27,11 +27,5 @@
  */
 public interface TestService
 {
-    public void doTestResourceEnlistment();
-
     public void doNothing();
-
-    public void arrangeBeforeCompletionFailure();
-
-    public void arrangeXAResourcePrepareXAException(int xaErrorCode);
 }

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -51,54 +51,33 @@
 {
     private static Logger log = Logger.getLogger(TestServiceImpl.class);
 
-    private boolean arrangeBeforeCompletionFailure = false;
-    private int xaErrorCode = 0;
-
     @Override
     @WebMethod
-    public void doTestResourceEnlistment()
-    {
-        log.trace("doTestResourceEnlistment()");
+    public void doNothing() {
+        log.trace("doNothing()");
+    }
 
+    public void enlistSynchronization(int count) {
         TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
-
-        try
-        {
-            TestSynchronization testSynchronization = new TestSynchronization();
-            if(arrangeBeforeCompletionFailure) {
-                testSynchronization.setFailInBeforeCompletion(true);
+        try {
+            for(int i = 0; i < count; i++) {
+                TestSynchronization testSynchronization = new TestSynchronization();
+                tm.getTransaction().registerSynchronization(testSynchronization);
             }
-            tm.getTransaction().registerSynchronization(testSynchronization);
+        } catch(Exception e) {
+            log.error("could not enlist", e);
+        }
+    }
 
-            TestXAResource testXAResource = new TestXAResource();
-            if(xaErrorCode != 0) {
-                testXAResource.setPrepareException(new XAException(xaErrorCode));
+    public void enlistXAResource(int count) {
+        TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+        try {
+            for(int i = 0; i < count; i++) {
+                TestXAResource testXAResource = new TestXAResource();
+                tm.getTransaction().enlistResource(testXAResource);
             }
-            tm.getTransaction().enlistResource(testXAResource);
-
         } catch(Exception e) {
             log.error("could not enlist", e);
         }
     }
-
-    @Override
-    @WebMethod
-    public void doNothing() {
-        log.trace("doNothing()");
-    }
-
-    @Override
-    @WebMethod
-    public void arrangeBeforeCompletionFailure() {
-        log.trace("arrangeBeforeCompletionFailure()");
-        arrangeBeforeCompletionFailure = true;
-    }
-
-    @Override
-    @WebMethod
-    public void arrangeXAResourcePrepareXAException(int xaErrorCode) {
-        log.trace("arrangeXAResourcePrepareXAException("+xaErrorCode+")");
-        this.xaErrorCode = xaErrorCode;
-    }
-
 }
\ No newline at end of file

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -33,53 +33,13 @@
 {
     private static Logger log = Logger.getLogger(TestSynchronization.class);
 
-    private boolean beforeCompletionDone = false;
-    private boolean afterCompletionDone = false;
-
-    private boolean failInBeforeCompletion = false;
-
-    public boolean isBeforeCompletionDone()
+    public void beforeCompletion()
     {
-        return beforeCompletionDone;
-    }
-
-    public boolean isAfterCompletionDone()
-    {
-        return afterCompletionDone;
-    }
-
-    public boolean isFailInBeforeCompletion()
-    {
-        return failInBeforeCompletion;
-    }
-
-    public void setFailInBeforeCompletion(boolean failInBeforeCompletion)
-    {
-        this.failInBeforeCompletion = failInBeforeCompletion;
-    }
-
-    public void beforeCompletion() {
-        if(beforeCompletionDone) {
-            log.trace("beforeCompletion called more than once");
-            throw new RuntimeException("beforeCompletion called more than once");
-        }
-
-        beforeCompletionDone = true;
         log.trace("TestSynchronization.beforeCompletion()");
-
-        if(failInBeforeCompletion) {
-            log.trace("failing in beforeCompletion");
-            throw new RuntimeException("failed in beforeCompletion");
-        }
     }
 
-    public void afterCompletion(int i) {
-        if(afterCompletionDone) {
-            log.trace("afterCompletion called more than once");
-            throw new RuntimeException("afterCompletion called more than once");
-        }
-
-        afterCompletionDone = true;
+    public void afterCompletion(int i)
+    {
         log.trace("TestSynchronization.afterCompletion("+i+")");
     }
 }
\ No newline at end of file

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -40,39 +40,7 @@
     private Xid currentXid;
 
     private int prepareReturnValue = XAResource.XA_OK;
-    private XAException prepareException = null;
-    private XAException commitException = null;
 
-    public int getPrepareReturnValue()
-    {
-        return prepareReturnValue;
-    }
-
-    public void setPrepareReturnValue(int prepareReturnValue)
-    {
-        this.prepareReturnValue = prepareReturnValue;
-    }
-
-    public XAException getPrepareException()
-    {
-        return prepareException;
-    }
-
-    public void setPrepareException(XAException prepareException)
-    {
-        this.prepareException = prepareException;
-    }
-
-    public XAException getCommitException()
-    {
-        return commitException;
-    }
-
-    public void setCommitException(XAException commitException)
-    {
-        this.commitException = commitException;
-    }
-
     public void commit(Xid xid, boolean b) throws XAException
     {
         log.trace("TestXAResource.commit(Xid="+xid+", b="+b+")");
@@ -80,19 +48,17 @@
             log.trace("TestXAResource.commit - wrong Xid!");
         }
 
-        if(commitException != null) {
-            throw commitException;
-        }
-
         currentXid = null;
         TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
     }
 
-    public void end(Xid xid, int i) throws XAException {
+    public void end(Xid xid, int i) throws XAException
+    {
         log.trace("TestXAResource.end(Xid="+xid+", b="+i+")");
     }
 
-    public void forget(Xid xid) throws XAException {
+    public void forget(Xid xid) throws XAException
+    {
         log.trace("TestXAResource.forget(Xid="+xid+")");
         if(!xid.equals(currentXid)) {
             log.trace("TestXAResource.forget - wrong Xid!");
@@ -100,7 +66,8 @@
         currentXid = null;
     }
 
-    public int getTransactionTimeout() throws XAException {
+    public int getTransactionTimeout() throws XAException
+    {
         log.trace("TestXAResource.getTransactionTimeout() [returning "+txTimeout+"]");
         return txTimeout;
     }
@@ -110,26 +77,24 @@
         return false;
     }
 
-    public int prepare(Xid xid) throws XAException {
+    public int prepare(Xid xid) throws XAException
+    {
         log.trace("TestXAResource.prepare(Xid="+xid+") returning "+prepareReturnValue);
 
-        if(prepareException != null) {
-            log.trace("prepare throwing XAException "+prepareException.errorCode);
-            throw prepareException;
-        }
-
         if(prepareReturnValue == XA_OK) {
             TestXAResourceRecoveryHelper.getInstance().logPrepared(xid);
         }
         return prepareReturnValue;
     }
 
-    public Xid[] recover(int i) throws XAException {
+    public Xid[] recover(int i) throws XAException
+    {
         log.trace("TestXAResource.recover(i="+i+")");
         return new Xid[0];
     }
 
-    public void rollback(Xid xid) throws XAException {
+    public void rollback(Xid xid) throws XAException
+    {
         log.trace("TestXAResource.rollback(Xid="+xid+")");
         if(!xid.equals(currentXid)) {
             log.trace("TestXAResource.rollback - wrong Xid!");
@@ -138,13 +103,15 @@
         TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
     }
 
-    public boolean setTransactionTimeout(int i) throws XAException {
+    public boolean setTransactionTimeout(int i) throws XAException
+    {
         log.trace("TestXAResource.setTransactionTimeout(i="+i+")");
         txTimeout= i;
         return true;
     }
 
-    public void start(Xid xid, int i) throws XAException {
+    public void start(Xid xid, int i) throws XAException
+    {
         log.trace("TestXAResource.start(Xid="+xid+", i="+i+")");
         if(currentXid != null) {
             log.trace("TestXAResource.start - wrong Xid!");
@@ -152,7 +119,8 @@
         currentXid = xid;
     }
 
-    public String toString() {
+    public String toString()
+    {
         return new String("TestXAResourcee("+txTimeout+", "+currentXid+")");
     }
 }

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -52,14 +52,16 @@
     }
 
     @Override
-    public Xid[] recover(int i) throws XAException {
+    public Xid[] recover(int i) throws XAException
+    {
         log.trace("TestXAResourceRecovered.recover(i="+i+")");
         
         return TestXAResourceRecoveryHelper.getInstance().recover();
     }
 
     @Override
-    public void forget(Xid xid) throws XAException {
+    public void forget(Xid xid) throws XAException
+    {
         log.trace("TestXAResource.forget(Xid="+xid+")");
 
         TestXAResourceRecoveryHelper.getInstance().removeLog(xid);

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -21,7 +21,9 @@
 package org.jboss.jbossts.txbridge.tests.outbound.client;
 
 import com.arjuna.ats.jta.exceptions.RollbackException;
+import com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor;
 import org.apache.log4j.Logger;
+import org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -33,10 +35,14 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.transaction.UserTransaction;
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Service;
+import javax.xml.ws.handler.Handler;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Servlet which includes test methods for exercising the txbridge.
@@ -69,6 +75,12 @@
             Service service = Service.create(wsdlLocation, serviceName);
             testService = service.getPort(TestService.class);
 
+            BindingProvider bindingProvider = (BindingProvider)testService;
+            List<Handler> handlers = new ArrayList<Handler>(2);
+            handlers.add(new JaxWSTxOutboundBridgeHandler());
+            handlers.add(new JaxWSHeaderContextProcessor());
+            bindingProvider.getBinding().setHandlerChain(handlers);
+
             context = config.getServletContext();
         }
         catch(Exception e)
@@ -79,10 +91,6 @@
 
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
     {
-        String param = request.getParameter("param");
-
-        log.info("param: "+param);
-
         try
         {
             log.info("starting the transaction...");
@@ -93,15 +101,11 @@
 
             log.info("calling business Web Services...");
 
-            //////////////////////
+            testService.doNothing();
 
-            testService.doStuff();
+            log.info("terminating the transaction...");
 
-            //////////////////////
-
-            log.info("calling commit on the transaction...");
-
-            userTransaction.commit();
+            terminateTransaction(false);
         }
         catch (final RollbackException re)
         {
@@ -112,8 +116,20 @@
             log.info("problem: ", e);
         }
 
+        response.setContentType("text/plain");
         PrintWriter out = response.getWriter();
-        out.println("done");
+        out.println("finished");
         out.close();
     }
+
+    private void terminateTransaction(boolean shouldCommit) throws Exception
+    {
+        log.info("shouldCommit="+shouldCommit);
+
+        if(shouldCommit) {
+            userTransaction.commit();
+        } else {
+            userTransaction.rollback();
+        }
+    }
 }
\ No newline at end of file

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -32,8 +32,15 @@
  */
 @WebService
 @SOAPBinding(style = SOAPBinding.Style.RPC)
- at HandlerChain(file = "jaxws-handlers-client.xml") // relative path from the class file
 public interface TestService
 {
-    public void doStuff();
+    public void doTestResourceEnlistment();
+
+    public void doNothing();
+
+    public void arrangeBeforeCompletionFailure();
+
+    public void resetState();
+
+    public void arrangeDurableParticipantPrepareOutcome(String outcome);
 }
\ No newline at end of file

Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/junit/BasicTests.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/junit/BasicTests.java	                        (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/junit/BasicTests.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * 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) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.outbound.junit;
+
+import org.apache.commons.httpclient.HttpMethodBase;
+
+import org.jboss.jbossts.txbridge.tests.outbound.client.TestClient;
+import org.jboss.jbossts.txbridge.tests.outbound.service.TestServiceImpl;
+import org.jboss.jbossts.txbridge.tests.outbound.utility.TestDurableParticipant;
+import org.jboss.jbossts.txbridge.tests.outbound.utility.TestVolatileParticipant;
+import org.junit.*;
+import static org.junit.Assert.*;
+
+import org.jboss.byteman.agent.submit.Submit;
+import org.jboss.byteman.contrib.dtest.*;
+
+import com.arjuna.qa.junit.HttpUtils;
+
+import java.net.URL;
+
+/**
+ * Basic (i.e. non-crashrec) test cases for the outbound side of the transaction bridge.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-05
+ */
+public class BasicTests
+{
+    private static final String baseURL = "http://localhost:8080/txbridge-outbound-tests-client/testclient";
+
+    private static Instrumentor instrumentor;
+    private InstrumentedClass instrumentedTestVolatileParticipant;
+    private InstrumentedClass instrumentedTestDurableParticipant;
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        instrumentor = new Instrumentor(new Submit(), 1199);
+        instrumentor.installHelperJar("/home/jhalli/IdeaProjects/jboss/byteman_trunk/contrib/dtest/build/lib/byteman-dtest.jar");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        instrumentedTestVolatileParticipant = instrumentor.instrumentClass(TestVolatileParticipant.class);
+        instrumentedTestDurableParticipant = instrumentor.instrumentClass(TestDurableParticipant.class);
+
+        instrumentor.injectOnCall(TestServiceImpl.class, "doNothing", "$0.enlistVolatileParticipant(1), $0.enlistDurableParticipant(1)");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        instrumentor.removeAllInstrumentation();
+    }
+
+    private void execute() throws Exception {
+        HttpMethodBase request = HttpUtils.accessURL(new URL(baseURL));
+        String response = request.getResponseBodyAsString().trim();
+        assertEquals("finished", response);
+    }
+
+    @Test
+    public void testRollback() throws Exception {
+
+        execute();
+
+        instrumentedTestVolatileParticipant.assertKnownInstances(1);
+        instrumentedTestVolatileParticipant.assertMethodNotCalled("prepare");
+        instrumentedTestVolatileParticipant.assertMethodNotCalled("commit");
+        instrumentedTestVolatileParticipant.assertMethodCalled("rollback");
+
+        instrumentedTestDurableParticipant.assertKnownInstances(1);
+        instrumentedTestDurableParticipant.assertMethodNotCalled("prepare");
+        instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+        instrumentedTestDurableParticipant.assertMethodCalled("rollback");
+    }
+
+    @Test
+    public void testCommit() throws Exception {
+
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+        execute();
+
+        instrumentedTestVolatileParticipant.assertKnownInstances(1);
+        instrumentedTestVolatileParticipant.assertMethodCalled("prepare");
+        instrumentedTestVolatileParticipant.assertMethodCalled("commit");
+        instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+
+        instrumentedTestDurableParticipant.assertKnownInstances(1);
+        instrumentedTestDurableParticipant.assertMethodCalled("prepare");
+        instrumentedTestDurableParticipant.assertMethodCalled("commit");
+        instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+    }
+
+    @Test
+    public void testBeforeCompletionFailure() throws Exception {
+
+        instrumentor.injectOnCall(TestVolatileParticipant.class, "prepare", "return new com.arjuna.wst.Aborted()");
+
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+        execute();
+
+        instrumentedTestVolatileParticipant.assertKnownInstances(1);
+        instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+        instrumentedTestVolatileParticipant.assertMethodNotCalled("commit");
+
+        instrumentedTestDurableParticipant.assertKnownInstances(1);
+        instrumentedTestDurableParticipant.assertMethodNotCalled("prepare");
+        instrumentedTestDurableParticipant.assertMethodCalled("rollback");
+        instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+    }
+
+    @Test
+    public void testPrepareReadonly() throws Exception {
+
+        instrumentor.injectOnCall(TestDurableParticipant.class, "prepare", "return new com.arjuna.wst.ReadOnly()");
+
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+        execute();
+
+        instrumentedTestVolatileParticipant.assertKnownInstances(1);
+        instrumentedTestVolatileParticipant.assertMethodCalled("prepare");
+        instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+        instrumentedTestVolatileParticipant.assertMethodCalled("commit");
+
+        instrumentedTestDurableParticipant.assertKnownInstances(1);
+        instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+        instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+    }
+
+    @Test
+    public void testPrepareFailure() throws Exception {
+
+        instrumentor.injectOnCall(TestDurableParticipant.class, "prepare", "return new com.arjuna.wst.Aborted()");
+
+        instrumentor.injectOnCall(TestClient.class,  "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+        HttpMethodBase request = HttpUtils.accessURL(new URL(baseURL));
+        String response = request.getResponseBodyAsString().trim();
+
+        instrumentedTestVolatileParticipant.assertKnownInstances(1);
+        instrumentedTestVolatileParticipant.assertMethodCalled("prepare");
+        instrumentedTestVolatileParticipant.assertMethodCalled("rollback");
+        instrumentedTestVolatileParticipant.assertMethodNotCalled("commit");
+
+        instrumentedTestDurableParticipant.assertKnownInstances(1);
+        instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+        instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+    }
+}
\ No newline at end of file

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -24,8 +24,6 @@
 import com.arjuna.mw.wst11.TransactionManager;
 import com.arjuna.mw.wst11.TransactionManagerFactory;
 import com.arjuna.mw.wst11.UserTransactionFactory;
-import com.arjuna.wst.Durable2PCParticipant;
-import com.arjuna.wst.Volatile2PCParticipant;
 
 import org.apache.log4j.Logger;
 
@@ -50,24 +48,32 @@
     private static Logger log = Logger.getLogger(TestServiceImpl.class);
 
     @WebMethod
-    public void doStuff()
+    public void doNothing()
     {
-        log.trace("doStuff()");
+        log.trace("doNothing()");
+    }
 
-        String transactionId = UserTransactionFactory.userTransaction().toString();
+    public void enlistVolatileParticipant(int count) {
+        TransactionManager tm = TransactionManagerFactory.transactionManager();
+        try {
+            for(int i = 0; i < count; i++) {
+                TestVolatileParticipant volatileParticipant = new TestVolatileParticipant();
+                tm.enlistForVolatileTwoPhase(volatileParticipant, "org.jboss.jbossts.txbridge.tests.outbound.Volatile:" + new Uid().toString());
+            }
+        } catch(Exception e) {
+            log.error("could not enlist", e);
+        }
+    }
 
+    public void enlistDurableParticipant(int count) {
+        TransactionManager tm = TransactionManagerFactory.transactionManager();
         try {
-            TransactionManager tm = TransactionManagerFactory.transactionManager();
-
-            Volatile2PCParticipant volatileParticipant = new TestVolatileParticipant();
-            tm.enlistForVolatileTwoPhase(volatileParticipant, "org.jboss.jbossts.txbridge.tests.outbound.Volatile:" + new Uid().toString());
-
-            Durable2PCParticipant durableParticipant = new TestDurableParticipant();
-            tm.enlistForDurableTwoPhase(durableParticipant, "org.jboss.jbossts.txbridge.tests.outbound.Durable:" + new Uid().toString());
-
+            for(int i = 0; i < count; i++) {
+                TestDurableParticipant durableParticipant = new TestDurableParticipant();
+                tm.enlistForDurableTwoPhase(durableParticipant, "org.jboss.jbossts.txbridge.tests.outbound.Durable:" + new Uid().toString());
+            }
         } catch(Exception e) {
-            log.error("could not enlist participant", e);
+            log.error("could not enlist", e);
         }
-
     }
 }

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -34,6 +34,8 @@
 {
     private static Logger log = Logger.getLogger(TestDurableParticipant.class);
 
+    private String prepareOutcome = "prepared";
+
     /**
      * Perform any work necessary to allow it to either commit or rollback
      * the work performed by the Web service under the scope of the
@@ -47,7 +49,16 @@
     public Vote prepare() throws WrongStateException, SystemException
     {
         log.trace("prepare()");
-        return new Prepared();
+
+        if("aborted".equals(prepareOutcome)) {
+            log.trace("prepare returning Aborted");
+            return new Aborted();
+        } else if("readonly".equals(prepareOutcome)) {
+            log.trace("prepare returning ReadOnly");
+            return new ReadOnly();
+        } else {
+            return new Prepared();
+        }
     }
 
     /**

Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java	2010-05-20 04:27:17 UTC (rev 32978)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java	2010-05-20 10:21:34 UTC (rev 32979)
@@ -45,7 +45,8 @@
     public Vote prepare() throws WrongStateException, SystemException
     {
         log.trace("prepare()");
-        return new Prepared();
+
+        return new Prepared(); // or Aborted()
     }
 
     /**



More information about the jboss-svn-commits mailing list