[jboss-svn-commits] JBL Code SVN: r37884 - in labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests: src and 24 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Feb 13 16:40:42 EST 2012
Author: istudens at redhat.com
Date: 2012-02-13 16:40:39 -0500 (Mon, 13 Feb 2012)
New Revision: 37884
Added:
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/README
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/pom.xml
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractBasicTests.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractCrashRecoveryTests.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSAS7ServerKillProcessor.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSServerExtension.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundBasicTests.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundCrashRecoveryTests.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/service/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundBasicTests.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundCrashRecoveryTests.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestRecoveryModule.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/META-INF/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/META-INF/services/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/arquillian.xml
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/inbound/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/logging.properties
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/scripts/
Removed:
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/dd/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/inbound/web.xml
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/service-web.xml
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/web.xml
Modified:
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/build.xml
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/inbound/jboss-beans.xml
labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/jboss-beans.xml
Log:
changing the txbridge tests to as7+arquillian, JBTM-1053, JBQA-3924
Added: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/README
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/README (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/README 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,41 @@
+# JBoss, Home of Professional Open Source.
+# Copyright (c) 2011, Red Hat, Inc., and individual contributors
+# as indicated by the @author tags. See the copyright.txt file 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.
+
+
+--------- JBossTS TxBridge Tests
+Author: Jonathan Halliday <jonathan.halliday at redhat.com>
+Author: Ivo Studensky <istudens at redhat.com>
+
+These tests have been derived from txbridge tests of JBOSSTS_4_16 which were ant based.
+
+The new tests are powered by Maven + Arquillian. The tests have been changed to work
+on AS7 and JUnit test classes have been renamed to have distinct names in order to
+allow being run by Surefire separately. Also the directory structure has been slightly
+changed to comply with Maven standards.
+
+
+--- Requirements:
+1. apache maven tool
+2. installed AS7
+
+--- Steps to run:
+
+1. export JBOSS_HOME=<path to AS7>
+2. ant test
Modified: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/build.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/build.xml 2012-02-09 14:10:01 UTC (rev 37883)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/build.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -1,252 +1,87 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- * 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.
--->
+<project name="txbridge-tests" default="test" basedir=".">
-<project name="TxBridgeTests" default="dist" basedir=".">
- <description>
- JBossTS Transaction Bridge Test Suite
- </description>
+ <import file="../../sharedbuild.xml"/>
- <property name="jboss.home" location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/target/jboss-6.0.0-SNAPSHOT"/>
+ <property name="jbossts.version" value="4.16.localbuild-SNAPSHOT"/>
+ <property name="groupid" value="org.jboss.jbossts"/>
- <property name="jbossts.home" location="../.."/>
- <property name="byteman.home" location="${jbossts.home}/build/extlib"/>
-
- <property name="java.home" location="/usr/local/jdk1.6.0_22/"/>
-
- <!-- ######################################################################### -->
-
- <property name="src" location="src"/>
- <property name="dd" location="dd"/>
- <property name="build.dir" location="build"/>
-
- <path id="build-prereqs">
- <fileset dir="../../build/extlib">
- <include name="jboss-servlet-api_3.0_spec.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="jboss-server-manager.jar"/>
- <include name="jboss-logging.jar"/>
- <include name="jnp-client.jar"/>
- <include name="byteman.jar"/>
- <include name="byteman-submit.jar"/>
- <include name="byteman-dtest.jar"/>
- </fileset>
-
- <fileset dir="${jbossts.home}/install/lib">
- <include name="jbossjta.jar"/>
- <include name="jbossjts.jar"/>
- </fileset>
-
- <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="${jboss.home}/client/jboss-system-client.jar"/>
-
- <!--<pathelement location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/target/jboss-6.0.0-SNAPSHOT/client/jboss-system-client.jar"/>-->
-
- </path>
-
- <target name="clean" description="clean up">
- <delete dir="${build.dir}"/>
+ <target name="clean">
+ <mvn.macro>
+ <mvn.args>
+ <arg value="clean"/>
+ </mvn.args>
+ </mvn.macro>
</target>
- <target name="init">
- <tstamp/>
- <mkdir dir="${build.dir}"/>
- </target>
-
- <target name="compile" depends="init"
- description="compile the source ">
- <mkdir dir="${build.dir}/classes"/>
- <javac srcdir="${src}" destdir="${build.dir}/classes" debug="true" includeantruntime="false">
- <classpath refid="build-prereqs"/>
- </javac>
- </target>
-
- <target name="dist" depends="compile"
- description="generate the distribution">
-
- <copy file="dd/inbound/jaxws-handlers-server.xml"
- 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>
- <metainf dir="dd/inbound">
- <include name="jboss-beans.xml"/>
- </metainf>
- </jar>
-
- <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.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>
- <webinf dir="dd/outbound">
- <include name="jboss-beans.xml"/>
- </webinf>
- </war>
-
- <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/jbossts_trunk/build/extlib/byteman.jar=port:9091,listener:true,sys:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/build/extlib/byteman-dtest.jar -Dorg.jboss.byteman.debug=true -Dorg.jboss.byteman.verbose=true -Dorg.jboss.byteman.contrib.dtest.rmiregistry.port=1199"
- -->
-
-
- <target name="run-inbound-tests" depends="compile">
- <run.tests.macro>
- <tests>
- <fileset dir="src" includes="**/inbound/**/BasicTests.java">
- </fileset>
- </tests>
- </run.tests.macro>
+ <target name="dist" depends="clean, install-deps">
+ <mvn.macro>
+ <mvn.args>
+ <arg value="compile"/>
+ </mvn.args>
+ </mvn.macro>
</target>
- <target name="run-inbound-crashrec-tests" depends="compile">
- <run.tests.macro>
- <tests>
- <fileset dir="src" includes="**/inbound/**/CrashRecoveryTests.java">
- </fileset>
- </tests>
- </run.tests.macro>
+ <target name="test" depends="dist">
+ <mvn.macro>
+ <mvn.args>
+ <arg value="test"/>
+ </mvn.args>
+ </mvn.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 name="install-deps">
+ <mvn-install-artifact.macro artifact="jbosstxbridge" file="${basedir}/../build/txbridge.jar" version="${jbossts.version}" />
+ <mvn-install-artifact.macro artifact="jbossjts" file="${basedir}/../../install/lib/jbossjts.jar" version="${jbossts.version}" />
+ <mvn-install-artifact.macro artifact="jbossxts-api" file="${basedir}/../../XTS/xts-install/lib/jbossxts-api.jar" version="${jbossts.version}" />
</target>
- <target name="run-outbound-crashrec-tests" depends="compile">
- <run.tests.macro>
- <tests>
- <fileset dir="src" includes="**/outbound/**/CrashRecoveryTests.java">
- </fileset>
- </tests>
- </run.tests.macro>
- </target>
+ <!-- ================== macros =================== -->
+ <macrodef name="mvn-install-artifact.macro">
+ <attribute name="artifact"/>
+ <attribute name="file"/>
+ <attribute name="packaging" default="jar"/>
+ <attribute name="version"/>
- <macrodef name="run.tests.macro">
-
- <attribute name="showoutput" default="true"/>
- <element name="tests"/>
- <element name="additional.classpath" optional="true"/>
- <element name="additional.jvmargs" optional="true"/>
-
<sequential>
+ <mvn.macro>
+ <mvn.args>
+ <arg value="install:install-file"/>
+ <arg value="-Dfile=@{file}"/>
+ <arg value="-DgroupId=${groupid}"/>
+ <arg value="-DartifactId=@{artifact}"/>
+ <arg value="-Dversion=@{version}"/>
+ <arg value="-Dpackaging=@{packaging}"/>
+ <arg value="-DgeneratePom=true"/>
+ </mvn.args>
+ </mvn.macro>
+ </sequential>
+ </macrodef>
- <mkdir dir="${build.dir}/testresults"/>
- <junit printsummary="yes" fork="yes" dir="${build.dir}" showoutput="@{showoutput}" includeantruntime="true">
- <formatter type="xml"/>
- <classpath>
- <path refid="build-prereqs"/>
- <pathelement location="${build.dir}/classes"/>
- <additional.classpath/>
- </classpath>
+ <macrodef name="mvn.macro">
+ <element name="mvn.args"/>
- <batchtest haltonerror="yes" haltonfailure="yes" fork="yes" todir="${build.dir}/testresults">
- <tests/>
- </batchtest>
-
- <jvmarg value="-DJAVA_HOME=${java.home}"/>
- <jvmarg value="-DJBOSS_HOME=${jboss.home}"/>
- <jvmarg value="-DBYTEMAN_HOME=${byteman.home}"/>
- <jvmarg value="-DSERVER_NAME=${jbossas.server}"/>
-
- <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>
+ <if>
+ <os family="unix" />
+ <then>
+ <exec executable="mvn" dir="${basedir}" failonerror="true">
+ <mvn.args />
+ </exec>
+ </then>
+ </if>
+ <if>
+ <os family="windows" />
+ <then>
+ <exec executable="mvn" dir="${basedir}" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <mvn.args />
+ </exec>
+ </then>
+ </if>
</sequential>
+ </macrodef>
- </macrodef>
-
- <!-- ######################################################################### -->
-
- <property name="jbossas.server" value="default"/>
-
- <target name="deploy-inbound-service" depends="dist" description="deploy EJB to JBossAS">
- <copy file="${build.dir}/txbridge-inbound-tests-service.jar"
- todir="${jboss.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.dir}/txbridge-inbound-tests-client.war"
- todir="${jboss.home}/server/${jbossas.server}/deploy"
- overwrite="true"/>
- </target>
-
- <target name="deploy-outbound-service" depends="dist" description="deploy WS to JBossAS">
- <copy file="${build.dir}/txbridge-outbound-tests-service.war"
- todir="${jboss.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.dir}/txbridge-outbound-tests-client.war"
- todir="${jboss.home}/server/${jbossas.server}/deploy"
- overwrite="true"/>
- </target>
-
</project>
-
Added: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/pom.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/pom.xml (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/pom.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.jbossts</groupId>
+ <artifactId>txbridge-tests</artifactId>
+ <version>4.16-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <properties>
+ <version.jbossas>7.1.0.Final-SNAPSHOT</version.jbossas>
+ <version.jbossts>4.16.localbuild-SNAPSHOT</version.jbossts>
+ <version.arquillian.junit>1.0.0.CR7</version.arquillian.junit>
+ <version.junit>4.8.2</version.junit>
+ <version.byteman>2.0.0</version.byteman>
+ <version.apache.httpcomponents>4.1.2</version.apache.httpcomponents>
+
+ <byteman.home>${project.build.directory}/byteman</byteman.home>
+ <byteman.server.jvm.args>
+ -Dorg.jboss.byteman.debug=true -Dorg.jboss.byteman.verbose=true -Dorg.jboss.byteman.contrib.dtest.rmiregistry.port=1199
+ -Djboss.modules.system.pkgs=org.jboss.byteman
+ -javaagent:${byteman.home}/byteman.jar=port:9091,listener:true,sys:${byteman.home}/byteman-dtest.jar
+ </byteman.server.jvm.args>
+ <jpda.server.jvm.args></jpda.server.jvm.args>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.jbossts</groupId>
+ <artifactId>jbossxts-api</artifactId>
+ <version>${version.jbossts}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossts</groupId>
+ <artifactId>jbossjts</artifactId>
+ <version>${version.jbossts}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossts</groupId>
+ <artifactId>jbosstxbridge</artifactId>
+ <version>${version.jbossts}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>1.0.0.Final</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>${version.arquillian.junit}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <version>${version.byteman}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-dtest</artifactId>
+ <version>${version.byteman}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${version.apache.httpcomponents}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>${version.apache.httpcomponents}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- this solves bad deps of Arq, 7.1.0.Final-SNAPSHOT needs these -->
+ <dependency>
+ <groupId>org.jboss.remoting3</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>3.2.0.CR9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <version>3.1.0.CR2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Repository Group</name>
+ <url>http://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Repository Group</name>
+ <url>http://repository.jboss.org/nexus/content/groups/public/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>byteman.copy</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <version>${version.byteman}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-dtest</artifactId>
+ <version>${version.byteman}</version>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${byteman.home}</outputDirectory>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Prevent test and server output appearing in console. -->
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <enableAssertions>true</enableAssertions>
+
+ <!-- Tests to execute. -->
+ <includes>
+ <include>**/*Tests.java</include>
+ </includes>
+
+ <!-- System properties passed to test cases -->
+ <systemPropertyVariables>
+ <!-- Used in arquillian.xml - arguments for all JBoss AS instances. -->
+ <server.jvm.args>${byteman.server.jvm.args}</server.jvm.args>
+ <java.rmi.server.codebase>file://target/test-classes/</java.rmi.server.codebase>
+ </systemPropertyVariables>
+
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>arq-jbossas-managed-7</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <version>${version.jbossas}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <profile>
+ <id>jpda.profile</id>
+ <activation>
+ <property><name>jpda</name></property>
+ </activation>
+ <properties>
+ <jpda.server.jvm.args>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</jpda.server.jvm.args>
+ </properties>
+ </profile>
+ </profiles>
+</project>
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractBasicTests.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/common/AbstractBasicTests.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractBasicTests.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractBasicTests.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,122 @@
+/*
+ * 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.common;
+
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.BasicResponseHandler;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.jboss.byteman.agent.submit.Submit;
+import org.jboss.byteman.contrib.dtest.Instrumentor;
+import org.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResource;
+import org.jboss.jbossts.txbridge.tests.outbound.utility.TestDurableParticipant;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+import java.io.IOException;
+
+/**
+ * Common methods for tx bridge test cases.
+ *
+ * @author Ivo Studensky (istudens at redhat.com)
+ */
+public abstract class AbstractBasicTests {
+
+ protected static Instrumentor instrumentor = null;
+
+ public static final String INBOUND_SERVICE_DEPLOYMENT_NAME = "txbridge-inbound-tests-service";
+ public static final String INBOUND_CLIENT_DEPLOYMENT_NAME = "txbridge-inbound-tests-client";
+
+ public static final String OUTBOUND_SERVICE_DEPLOYMENT_NAME = "txbridge-outbound-tests-service";
+ public static final String OUTBOUND_CLIENT_DEPLOYMENT_NAME = "txbridge-outbound-tests-client";
+
+ protected static final String CONTAINER = "jboss";
+
+ protected static Archive<?> getInboundServiceArchive() {
+ Archive<?> archive = ShrinkWrap.create(WebArchive.class, INBOUND_SERVICE_DEPLOYMENT_NAME + ".war")
+ .addPackage("org.jboss.jbossts.txbridge.tests.inbound.service")
+ .addPackage("org.jboss.jbossts.txbridge.tests.inbound.utility")
+ .addAsResource("inbound/jaxws-handlers-server.xml", "jaxws-handlers-server.xml")
+ .addAsManifestResource("inbound/jboss-beans.xml", "jboss-beans.xml")
+ .addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
+// archive.as(ZipExporter.class).exportTo(new File("/tmp/deployment.zip"), true);
+ return archive;
+ }
+
+ protected static Archive<?> getInboundClientArchive() {
+ Archive<?> archive = ShrinkWrap.create(WebArchive.class, INBOUND_CLIENT_DEPLOYMENT_NAME + ".war")
+ .addPackage("org.jboss.jbossts.txbridge.tests.inbound.client")
+ .addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
+ return archive;
+ }
+
+ protected static Archive<?> getOutboundServiceArchive() {
+ Archive<?> archive = ShrinkWrap.create(WebArchive.class, OUTBOUND_SERVICE_DEPLOYMENT_NAME + ".war")
+ .addPackage("org.jboss.jbossts.txbridge.tests.outbound.service")
+ .addPackage("org.jboss.jbossts.txbridge.tests.outbound.utility")
+ .addAsResource("outbound/jaxws-handlers-server.xml", "jaxws-handlers-server.xml")
+ .addAsManifestResource("outbound/jboss-beans.xml", "jboss-beans.xml")
+ .addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
+ return archive;
+ }
+
+ protected static Archive<?> getOutboundClientArchive() {
+ Archive<?> archive = ShrinkWrap.create(WebArchive.class, OUTBOUND_CLIENT_DEPLOYMENT_NAME + ".war")
+ .addPackage("org.jboss.jbossts.txbridge.tests.outbound.client")
+ .addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
+ return archive;
+ }
+
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ if (instrumentor == null) {
+ instrumentor = new Instrumentor(new Submit(), 1199);
+ }
+ }
+
+
+ protected void execute(String url) throws Exception {
+ execute(url, true);
+ }
+
+ protected void execute(String url, boolean expectResponse) throws Exception {
+ try {
+ DefaultHttpClient httpclient = new DefaultHttpClient();
+ HttpGet httpget = new HttpGet(url);
+ ResponseHandler<String> responseHandler = new BasicResponseHandler();
+ String response = httpclient.execute(httpget, responseHandler);
+
+ if (expectResponse) {
+ Assert.assertEquals("Invalid response!", "finished", response.trim());
+ }
+ } catch (IOException e) {
+ if (expectResponse) {
+ throw e;
+ }
+ }
+ }
+
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractCrashRecoveryTests.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/common/AbstractCrashRecoveryTests.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractCrashRecoveryTests.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractCrashRecoveryTests.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,155 @@
+/*
+ * 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.common;
+
+import com.arjuna.ats.arjuna.common.recoveryPropertyManager;
+import org.jboss.arquillian.container.test.api.Config;
+import org.jboss.arquillian.container.test.api.ContainerController;
+import org.jboss.logging.Logger;
+import org.junit.Before;
+
+import java.io.*;
+import java.net.Socket;
+
+/**
+ * Common methods for crash recovery test cases.
+ *
+ * @author Ivo Studensky (istudens at redhat.com)
+ */
+public abstract class AbstractCrashRecoveryTests extends AbstractBasicTests {
+ private static Logger log = Logger.getLogger(AbstractCrashRecoveryTests.class);
+
+
+ /**
+ * Instrumentation to be done on server reboot.
+ * For details see @link #rebootServer.
+ * Note: Before each server restart it is necessary to store the instrumentation into a file and then start up the server
+ * with that file as a parameter for byteman to ensure the appropriate classes are instrumented once the server is up.
+ *
+ * @throws Exception
+ */
+ protected abstract void instrumentationOnServerReboot() throws Exception;
+
+
+ @Before
+ public void setUp() throws Exception {
+ String jbossHome = System.getenv("JBOSS_HOME");
+ removeContents(new File(jbossHome, "standalone/data/tx-object-store/"));
+ }
+
+
+ protected void rebootServer(ContainerController controller) throws Exception {
+
+ instrumentor.removeLocalState();
+ File rulesFile = File.createTempFile("jbosstxbridgetests", "btm");
+ rulesFile.deleteOnExit();
+ instrumentor.setRedirectedSubmissionsFile(rulesFile);
+
+ instrumentationOnServerReboot();
+
+ // just let Arquillian know that server has been killed
+ // note: in fact the server has been killed by byteman before
+ controller.kill(CONTAINER);
+
+ // start up the server
+ String javaVmArguments = System.getProperty("server.jvm.args").trim();
+ javaVmArguments = javaVmArguments.replaceFirst("byteman-dtest.jar", "byteman-dtest.jar,script:" + rulesFile.getCanonicalPath());
+ log.info("javaVmArguments = " + javaVmArguments);
+ controller.start(CONTAINER, new Config().add("javaVmArguments", javaVmArguments).map());
+ }
+
+
+ /////////////////
+
+ // stolen from CrashRecoveryDelays - should probably just add that to the classpath?
+ // prod the recovery manager via its socket. This avoid any sleep delay.
+ protected static void doRecovery() throws InterruptedException {
+ int port = recoveryPropertyManager.getRecoveryEnvironmentBean().getRecoveryPort();
+ String host = recoveryPropertyManager.getRecoveryEnvironmentBean().getRecoveryAddress();
+
+ System.err.println("doRecovery#host = " + host);
+ System.err.println("doRecovery#port = " + port);
+
+ BufferedReader in = null;
+ PrintStream out = null;
+ Socket sckt = null;
+
+ try {
+ sckt = new Socket(host, port);
+
+ in = new BufferedReader(new InputStreamReader(sckt.getInputStream()));
+ out = new PrintStream(sckt.getOutputStream());
+
+ // Output ping message
+ out.println("SCAN");
+ out.flush();
+
+ // Receive pong message
+ String inMessage = in.readLine();
+
+ System.err.println("inMessage = " + inMessage);
+ if (!inMessage.equals("DONE")) {
+ System.err.println("Recovery failed with message: " + inMessage);
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+
+ if (out != null) {
+ out.close();
+ }
+
+ sckt.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ // stolen from EmptyObjectStore.java
+ protected static void removeContents(File directory) {
+ if ((directory != null) &&
+ directory.isDirectory() &&
+ (!directory.getName().equals("")) &&
+ (!directory.getName().equals("/")) &&
+ (!directory.getName().equals("\\")) &&
+ (!directory.getName().equals(".")) &&
+ (!directory.getName().equals(".."))) {
+ File[] contents = directory.listFiles();
+
+ for (int index = 0; index < contents.length; index++) {
+ if (contents[index].isDirectory()) {
+ removeContents(contents[index]);
+
+ //System.err.println("Deleted: " + contents[index]);
+ contents[index].delete();
+ } else {
+ System.err.println("Deleted: " + contents[index]);
+ contents[index].delete();
+ }
+ }
+ }
+ }
+
+}
Added: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSAS7ServerKillProcessor.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSAS7ServerKillProcessor.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSAS7ServerKillProcessor.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.jbossts.txbridge.tests.extension;
+
+import org.jboss.arquillian.container.spi.Container;
+import org.jboss.arquillian.container.spi.ServerKillProcessor;
+
+/**
+ * Server extension for JBossTSAS7ServerKillProcessor.
+ *
+ * @author <a href="mailto:istudens at redhat.com">Ivo Studensky</a>
+ */
+public class JBossTSAS7ServerKillProcessor implements ServerKillProcessor {
+
+ public void kill(Container container) throws Exception {
+ // do nothing, just let Arquillian know that the container is down
+ }
+}
+
Added: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSServerExtension.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSServerExtension.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/extension/JBossTSServerExtension.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.jbossts.txbridge.tests.extension;
+
+import org.jboss.arquillian.container.spi.ServerKillProcessor;
+import org.jboss.arquillian.core.spi.LoadableExtension;
+
+/**
+ * Server extension for JBossTSAS7ServerKillProcessor.
+ *
+ * @author <a href="mailto:istudens at redhat.com">Ivo Studensky</a>
+ */
+public class JBossTSServerExtension implements LoadableExtension {
+
+ public void register(ExtensionBuilder builder) {
+ builder.service(ServerKillProcessor.class, JBossTSAS7ServerKillProcessor.class);
+ }
+}
+
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,125 @@
+/*
+ * 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.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;
+import org.jboss.logging.Logger;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+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.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+ at WebServlet(name = "Inbound Test Client Servlet", urlPatterns = TestClient.URL_PATTERN)
+public class TestClient extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ private static Logger log = Logger.getLogger(TestClient.class);
+
+ public static final String URL_PATTERN = "/testclient";
+
+ private ServletContext context;
+ private TestService testService;
+
+ /**
+ * Initialise the servlet.
+ *
+ * @param config The servlet configuration.
+ */
+ public void init(final ServletConfig config)
+ throws ServletException {
+ try {
+ URL wsdlLocation = new URL("http://localhost:8080/txbridge-inbound-tests-service/TestServiceImpl?wsdl");
+ QName serviceName = new QName("http://client.inbound.tests.txbridge.jbossts.jboss.org/", "TestServiceImplService");
+
+ Service service = Service.create(wsdlLocation, serviceName);
+ testService = service.getPort(TestService.class);
+
+ BindingProvider bindingProvider = (BindingProvider) testService;
+ List<Handler> handlers = new ArrayList<Handler>(1);
+ handlers.add(new JaxWSHeaderContextProcessor());
+ bindingProvider.getBinding().setHandlerChain(handlers);
+
+ context = config.getServletContext();
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ try {
+ UserTransaction ut = UserTransactionFactory.userTransaction();
+
+ log.info("starting the transaction...");
+
+ ut.begin();
+
+ log.info("transaction ID= " + ut.toString());
+
+ log.info("calling business Web Services...");
+
+ testService.doNothing();
+
+ log.info("terminating the transaction...");
+
+ terminateTransaction(ut, false);
+ } catch (final TransactionRolledBackException tre) {
+ log.info("Transaction rolled back");
+ } catch (Exception e) {
+ log.info("problem: ", e);
+ }
+
+ response.setContentType("text/plain");
+ PrintWriter out = response.getWriter();
+ 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();
+ }
+ }
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,36 @@
+/*
+ * 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.client;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.WebServiceClient;
+
+/**
+ * Interface for a web service used by txbridge test cases. Client side version.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+ at WebService(name = "TestServiceImpl", targetNamespace = "http://client.inbound.tests.txbridge.jbossts.jboss.org/")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface TestService {
+ public void doNothing();
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundBasicTests.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/junit/BasicTests.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundBasicTests.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundBasicTests.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,185 @@
+/*
+ * 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.jboss.arquillian.container.test.api.*;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.jbossts.txbridge.tests.common.AbstractBasicTests;
+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.jboss.shrinkwrap.api.Archive;
+import org.junit.*;
+
+import org.jboss.byteman.contrib.dtest.*;
+import org.junit.runner.RunWith;
+
+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
+ * @author Ivo Studensky (istudens at redhat.com)
+ */
+ at RunWith(Arquillian.class)
+ at RunAsClient
+public class InboundBasicTests extends AbstractBasicTests {
+
+ @Deployment(name = INBOUND_SERVICE_DEPLOYMENT_NAME, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createServiceArchive() {
+ return getInboundServiceArchive();
+ }
+
+ @Deployment(name = INBOUND_CLIENT_DEPLOYMENT_NAME, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createClientArchive() {
+ return getInboundClientArchive();
+ }
+
+
+ @ArquillianResource
+ private ContainerController controller;
+
+ private InstrumentedClass instrumentedTestSynchronization;
+ private InstrumentedClass instrumentedTestXAResource;
+
+
+ @Before
+ public void setUp() throws Exception {
+ // start up the appserver
+ controller.start(CONTAINER);
+
+ instrumentor.setRedirectedSubmissionsFile(null);
+
+ instrumentedTestSynchronization = instrumentor.instrumentClass(TestSynchronization.class);
+ instrumentedTestXAResource = instrumentor.instrumentClass(TestXAResource.class);
+
+ instrumentor.injectOnCall(TestServiceImpl.class, "doNothing", "$0.enlistSynchronization(1), $0.enlistXAResource(1)");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ instrumentor.removeAllInstrumentation();
+
+ // shut down the appserver
+ controller.stop(CONTAINER);
+ }
+
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testRollback(@ArquillianResource URL baseURL) throws Exception {
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ instrumentedTestSynchronization.assertKnownInstances(1);
+ instrumentedTestSynchronization.assertMethodNotCalled("beforeCompletion");
+ instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+ instrumentedTestXAResource.assertMethodCalled("rollback");
+ }
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCommit(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ instrumentedTestSynchronization.assertKnownInstances(1);
+ instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+ instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodNotCalled("rollback");
+ instrumentedTestXAResource.assertMethodCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testBeforeCompletionFailure(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectFault(TestSynchronization.class, "beforeCompletion", RuntimeException.class, new Object[]{"injected BeforeCompletion fault"});
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ instrumentedTestSynchronization.assertKnownInstances(1);
+ instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+ instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testPrepareReadonly(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestXAResource.class, "prepare", "return " + XAResource.XA_RDONLY);
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ instrumentedTestSynchronization.assertKnownInstances(1);
+ instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+ instrumentedTestSynchronization.assertMethodCalled("afterCompletion");
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodNotCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testPrepareFailure(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectFault(TestXAResource.class, "prepare", XAException.class, new Object[]{XAException.XA_RBROLLBACK});
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$2 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ 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
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundCrashRecoveryTests.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/junit/CrashRecoveryTests.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundCrashRecoveryTests.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/junit/InboundCrashRecoveryTests.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,216 @@
+/*
+ * 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.jboss.arquillian.container.test.api.*;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.jbossts.txbridge.inbound.BridgeDurableParticipant;
+import org.jboss.jbossts.txbridge.tests.common.AbstractCrashRecoveryTests;
+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.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResourceRecovered;
+import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.*;
+
+import org.jboss.byteman.contrib.dtest.*;
+import org.junit.runner.RunWith;
+
+import java.net.URL;
+
+
+/**
+ * Crash Recovery test cases for the inbound side of the transaction bridge.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-05
+ * @author Ivo Studensky (istudens at redhat.com)
+ */
+ at RunWith(Arquillian.class)
+ at RunAsClient
+public class InboundCrashRecoveryTests extends AbstractCrashRecoveryTests {
+ private static Logger log = Logger.getLogger(InboundCrashRecoveryTests.class);
+
+ @Deployment(name = INBOUND_SERVICE_DEPLOYMENT_NAME, managed = false, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createServiceArchive() {
+ return getInboundServiceArchive();
+ }
+
+ @Deployment(name = INBOUND_CLIENT_DEPLOYMENT_NAME, managed = false, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createClientArchive() {
+ return getInboundClientArchive();
+ }
+
+
+ @ArquillianResource
+ private ContainerController controller;
+
+ @ArquillianResource
+ private Deployer deployer;
+
+ private InstrumentedClass instrumentedTestSynchronization;
+ private InstrumentedClass instrumentedTestXAResource;
+
+
+ @Before
+ public void setUp() throws Exception {
+ // start up the appserver
+ String javaVmArguments = System.getProperty("server.jvm.args").trim();
+ log.info("javaVmArguments = " + javaVmArguments);
+ controller.start(CONTAINER, new Config().add("javaVmArguments", javaVmArguments).map());
+ // deploy the tests
+ deployer.deploy(INBOUND_SERVICE_DEPLOYMENT_NAME);
+ deployer.deploy(INBOUND_CLIENT_DEPLOYMENT_NAME);
+
+ instrumentor.setRedirectedSubmissionsFile(null);
+ instrumentedTestSynchronization = instrumentor.instrumentClass(TestSynchronization.class);
+ instrumentedTestXAResource = instrumentor.instrumentClass(TestXAResource.class);
+
+ instrumentor.injectOnCall(TestServiceImpl.class, "doNothing", "$0.enlistSynchronization(1), $0.enlistXAResource(1)");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ try {
+ instrumentor.removeAllInstrumentation();
+ } finally {
+ // un-deploy the tests
+ deployer.undeploy(INBOUND_CLIENT_DEPLOYMENT_NAME);
+ deployer.undeploy(INBOUND_SERVICE_DEPLOYMENT_NAME);
+ // shut down the appserver
+ controller.stop(CONTAINER);
+ }
+ }
+
+ @Override
+ protected void instrumentationOnServerReboot() throws Exception {
+ instrumentedTestSynchronization = instrumentor.instrumentClass(TestSynchronization.class);
+ instrumentedTestXAResource = instrumentor.instrumentClass(TestXAResourceRecovered.class);
+ }
+
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCrashOneLog(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$2 = true"); // shouldCommit=true
+ instrumentor.crashAtMethodExit(TestXAResource.class, "prepare");
+
+ execute(baseURL + TestClient.URL_PATTERN, false);
+
+ instrumentedTestSynchronization.assertKnownInstances(1);
+ instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+ instrumentedTestSynchronization.assertMethodNotCalled("afterCompletion");
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodCalled("prepare");
+ instrumentedTestXAResource.assertMethodNotCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+
+ rebootServer(controller);
+
+ doRecovery();
+ doRecovery();
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodCalled("recover");
+ instrumentedTestXAResource.assertMethodCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCrashTwoLogs(@ArquillianResource URL baseURL) throws Exception {
+
+ InstrumentedClass durableParticipant = instrumentor.instrumentClass(BridgeDurableParticipant.class);
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$2 = true"); // shouldCommit=true
+ instrumentor.crashAtMethodExit(BridgeDurableParticipant.class, "prepare");
+
+ execute(baseURL + TestClient.URL_PATTERN, false);
+
+ durableParticipant.assertMethodCalled("prepare");
+ durableParticipant.assertMethodNotCalled("rollback");
+ durableParticipant.assertMethodNotCalled("commit");
+
+ instrumentedTestSynchronization.assertKnownInstances(1);
+ instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+ instrumentedTestSynchronization.assertMethodNotCalled("afterCompletion");
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodCalled("prepare");
+ instrumentedTestXAResource.assertMethodNotCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+
+ rebootServer(controller);
+
+ doRecovery();
+ doRecovery();
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodCalled("recover");
+ instrumentedTestXAResource.assertMethodCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(INBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCrashThreeLogs(@ArquillianResource URL baseURL) throws Exception {
+
+ InstrumentedClass durableParticipant = instrumentor.instrumentClass(BridgeDurableParticipant.class);
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$2 = true"); // shouldCommit=true
+ instrumentor.crashAtMethodExit("^XTSATRecoveryManager", "writeParticipantRecoveryRecord");
+
+ execute(baseURL + TestClient.URL_PATTERN, false);
+
+ durableParticipant.assertMethodCalled("prepare");
+ durableParticipant.assertMethodNotCalled("rollback");
+ durableParticipant.assertMethodNotCalled("commit");
+
+ instrumentedTestSynchronization.assertKnownInstances(1);
+ instrumentedTestSynchronization.assertMethodCalled("beforeCompletion");
+ instrumentedTestSynchronization.assertMethodNotCalled("afterCompletion");
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodCalled("prepare");
+ instrumentedTestXAResource.assertMethodNotCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+
+ rebootServer(controller);
+
+ doRecovery();
+ doRecovery();
+
+ instrumentedTestXAResource.assertKnownInstances(1);
+ instrumentedTestXAResource.assertMethodCalled("recover");
+ instrumentedTestXAResource.assertMethodCalled("rollback");
+ instrumentedTestXAResource.assertMethodNotCalled("commit");
+ }
+
+ // TODO: add test for 4log case i.e. commit
+
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,82 @@
+/*
+ * 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.service;
+
+import org.jboss.logging.Logger;
+import org.jboss.jbossts.txbridge.tests.inbound.utility.TestSynchronization;
+import org.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResource;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.jws.HandlerChain;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+
+
+/**
+ * Implementation of a web service used by txbridge test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+ at Stateless
+ at WebService(targetNamespace = "http://client.inbound.tests.txbridge.jbossts.jboss.org/")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+ at HandlerChain(file = "/jaxws-handlers-server.xml") // relative path from the class file
+ at TransactionAttribute(TransactionAttributeType.MANDATORY) // default is REQUIRED
+public class TestServiceImpl {
+ private static Logger log = Logger.getLogger(TestServiceImpl.class);
+
+ @WebMethod
+ public void doNothing() {
+ log.trace("doNothing()");
+ }
+
+ @WebMethod(exclude = true)
+ public void enlistSynchronization(int count) {
+ TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+ try {
+ for (int i = 0; i < count; i++) {
+ TestSynchronization testSynchronization = new TestSynchronization();
+ tm.getTransaction().registerSynchronization(testSynchronization);
+ }
+ } catch (Exception e) {
+ log.error("could not enlist", e);
+ }
+ }
+
+ @WebMethod(exclude = true)
+ 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);
+ }
+ } catch (Exception e) {
+ log.error("could not enlist", e);
+ }
+ }
+}
\ No newline at end of file
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.txbridge.tests.inbound.utility;
+
+import org.jboss.logging.Logger;
+
+import javax.transaction.Synchronization;
+
+/**
+ * Implementation of Synchronization for use in tx test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestSynchronization implements Synchronization {
+ private static Logger log = Logger.getLogger(TestSynchronization.class);
+
+ public void beforeCompletion() {
+ log.trace("TestSynchronization.beforeCompletion()");
+ }
+
+ public void afterCompletion(int i) {
+ log.trace("TestSynchronization.afterCompletion(" + i + ")");
+ }
+}
\ No newline at end of file
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.txbridge.tests.inbound.utility;
+
+import org.jboss.logging.Logger;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+
+/**
+ * Implementation of XAResource for use in tx test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestXAResource implements XAResource {
+ private static Logger log = Logger.getLogger(TestXAResource.class);
+
+ private int txTimeout;
+
+ private Xid currentXid;
+
+ private int prepareReturnValue = XAResource.XA_OK;
+
+ public void commit(Xid xid, boolean b) throws XAException {
+ log.trace("TestXAResource.commit(Xid=" + xid + ", b=" + b + ")");
+ if (!xid.equals(currentXid)) {
+ log.trace("TestXAResource.commit - wrong Xid!");
+ }
+
+ currentXid = null;
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ public void end(Xid xid, int i) throws XAException {
+ log.trace("TestXAResource.end(Xid=" + xid + ", b=" + i + ")");
+ }
+
+ public void forget(Xid xid) throws XAException {
+ log.trace("TestXAResource.forget(Xid=" + xid + ")");
+ if (!xid.equals(currentXid)) {
+ log.trace("TestXAResource.forget - wrong Xid!");
+ }
+ currentXid = null;
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ log.trace("TestXAResource.getTransactionTimeout() [returning " + txTimeout + "]");
+ return txTimeout;
+ }
+
+ public boolean isSameRM(XAResource xaResource) throws XAException {
+ log.trace("TestXAResource.isSameRM(xaResource=" + xaResource + ")");
+ return false;
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ log.trace("TestXAResource.prepare(Xid=" + xid + ") returning " + prepareReturnValue);
+
+ if (prepareReturnValue == XA_OK) {
+ TestXAResourceRecoveryHelper.getInstance().logPrepared(xid);
+ }
+ return prepareReturnValue;
+ }
+
+ public Xid[] recover(int i) throws XAException {
+ log.trace("TestXAResource.recover(i=" + i + ")");
+ return new Xid[0];
+ }
+
+ public void rollback(Xid xid) throws XAException {
+ log.trace("TestXAResource.rollback(Xid=" + xid + ")");
+ if (!xid.equals(currentXid)) {
+ log.trace("TestXAResource.rollback - wrong Xid!");
+ }
+ currentXid = null;
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ 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 {
+ log.trace("TestXAResource.start(Xid=" + xid + ", i=" + i + ")");
+ if (currentXid != null) {
+ log.trace("TestXAResource.start - wrong Xid!");
+ }
+ currentXid = xid;
+ }
+
+ public String toString() {
+ return new String("TestXAResourcee(" + txTimeout + ", " + currentXid + ")");
+ }
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecovered.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,65 @@
+/*
+ * 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.utility;
+
+import org.jboss.logging.Logger;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * Implementation of XAResource for use in txbridge recovery tests.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestXAResourceRecovered extends TestXAResource implements XAResource {
+ private static Logger log = Logger.getLogger(TestXAResourceRecovered.class);
+
+ @Override
+ public void rollback(Xid xid) throws XAException {
+ log.trace("TestXAResourceRecovered.rollback(Xid=" + xid + ")");
+
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ @Override
+ public void commit(Xid xid, boolean b) throws XAException {
+ log.trace("TestXAResourceRecovered.commit(Xid=" + xid + ", b=" + b + ")");
+
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ @Override
+ 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 {
+ log.trace("TestXAResource.forget(Xid=" + xid + ")");
+
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,185 @@
+/*
+ * 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.utility;
+
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.recovery.RecoveryModule;
+import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
+import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
+import org.jboss.logging.Logger;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import java.io.*;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+/**
+ * Implementation of XAResourceRecoveryHelper for use in txbridge recovery tests.
+ * Provides persistence for TestXAResource via a file in the ObjectStore.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestXAResourceRecoveryHelper implements XAResourceRecoveryHelper {
+ private static Logger log = Logger.getLogger(TestXAResourceRecoveryHelper.class);
+
+ private static final TestXAResourceRecoveryHelper instance = new TestXAResourceRecoveryHelper();
+ private static final TestXAResourceRecovered xaResourceInstance = new TestXAResourceRecovered();
+
+ private final Set<Xid> preparedXids = new HashSet<Xid>();
+
+ public static TestXAResourceRecoveryHelper getInstance() {
+ return instance;
+ }
+
+ protected TestXAResourceRecoveryHelper() {
+ }
+
+ /**
+ * MC lifecycle callback, used to register the recovery module with the transaction manager.
+ */
+ public void start() {
+ log.info("TestXAResourceRecoveryHelper starting");
+
+ getRecoveryModule().addXAResourceRecoveryHelper(getInstance());
+
+ recoverFromDisk();
+ }
+
+ /**
+ * MC lifecycle callback, used to unregister the recovery module from the transaction manager.
+ */
+ public void stop() {
+ log.info("TestXAResourceRecoveryHelper stopping");
+
+ getRecoveryModule().removeXAResourceRecoveryHelper(getInstance());
+ }
+
+ private XARecoveryModule getRecoveryModule() {
+ for (RecoveryModule recoveryModule : ((Vector<RecoveryModule>) RecoveryManager.manager().getModules())) {
+ if (recoveryModule instanceof XARecoveryModule) {
+ return (XARecoveryModule) recoveryModule;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean initialise(String param) throws Exception {
+ log.trace("initialise(param=" + param + ")");
+
+ return true;
+ }
+
+ @Override
+ public XAResource[] getXAResources() throws Exception {
+ log.trace("getXAResources()");
+
+ XAResource values[] = new XAResource[1];
+ values[0] = xaResourceInstance;
+
+ return values;
+ }
+
+ ///////////////////////////
+
+ public void logPrepared(Xid xid) throws XAException {
+ log.trace("logPrepared(xid=" + xid + ")");
+
+ synchronized (preparedXids) {
+ if (preparedXids.add(xid)) {
+ writeToDisk();
+ } else {
+ throw new XAException(XAException.XAER_PROTO);
+ }
+ }
+ }
+
+ public void removeLog(Xid xid) throws XAException {
+ log.trace("removeLog(xid=" + xid);
+
+ synchronized (preparedXids) {
+ if (preparedXids.remove(xid)) {
+ writeToDisk();
+ } else {
+ log.trace("no log present for " + xid);
+ }
+ }
+ }
+
+ public Xid[] recover() {
+ log.trace("recover()");
+
+ return preparedXids.toArray(new Xid[preparedXids.size()]);
+ }
+
+
+ private void writeToDisk() {
+ File logFile = getLogFile();
+ log.trace("logging " + preparedXids.size() + " records to " + logFile.getAbsolutePath());
+
+ try {
+ FileOutputStream fos = new FileOutputStream(logFile);
+ ObjectOutputStream oos = new ObjectOutputStream(fos);
+ oos.writeObject(preparedXids);
+ oos.close();
+ fos.close();
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+
+ private void recoverFromDisk() {
+ File logFile = getLogFile();
+ log.trace("recovering from " + logFile.getAbsolutePath());
+
+ if (!logFile.exists()) {
+ return;
+ }
+
+ try {
+ FileInputStream fis = new FileInputStream(logFile);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ Set<Xid> xids = (Set<Xid>) ois.readObject();
+ preparedXids.addAll(xids);
+ log.trace("Recovered " + xids + " Xids");
+ ois.close();
+ fis.close();
+ } catch (Exception e) {
+ log.error(e);
+ }
+
+ }
+
+ private File getLogFile() {
+ String parentDir = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir();
+ String childDir = arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot();
+ File logDir = new File(parentDir, childDir);
+ logDir.mkdirs();
+ File logFile = new File(logDir, "TestXAResource.ser");
+ return logFile;
+ }
+
+
+}
\ No newline at end of file
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestClient.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,130 @@
+/*
+ * 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.client;
+
+import com.arjuna.ats.jta.exceptions.RollbackException;
+import com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor;
+import org.jboss.logging.Logger;
+import org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+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.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+ at WebServlet(name="Outbound Test Client Servlet", urlPatterns=TestClient.URL_PATTERN)
+public class TestClient extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ private static Logger log = Logger.getLogger(TestClient.class);
+
+ public static final String URL_PATTERN = "/testclient";
+
+ private UserTransaction userTransaction;
+ private ServletContext context;
+ private TestService testService;
+
+ /**
+ * Initialise the servlet.
+ *
+ * @param config The servlet configuration.
+ */
+ public void init(final ServletConfig config)
+ throws ServletException {
+ try {
+ Context ic = new InitialContext();
+ userTransaction = (UserTransaction) ic.lookup("java:comp/UserTransaction");
+
+ URL wsdlLocation = new URL("http://localhost:8080/txbridge-outbound-tests-service/TestServiceImpl?wsdl");
+ QName serviceName = new QName("http://service.outbound.tests.txbridge.jbossts.jboss.org/", "TestServiceImplService");
+
+ 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) {
+ throw new ServletException(e);
+ }
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ try {
+ log.info("starting the transaction...");
+
+ userTransaction.begin();
+
+ log.info("transaction ID= " + userTransaction.toString());
+
+ log.info("calling business Web Services...");
+
+ testService.doNothing();
+
+ log.info("terminating the transaction...");
+
+ terminateTransaction(false);
+ } catch (final RollbackException re) {
+ log.info("Transaction rolled back");
+ } catch (Exception e) {
+ log.info("problem: ", e);
+ }
+
+ response.setContentType("text/plain");
+ PrintWriter out = response.getWriter();
+ 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
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestService.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,36 @@
+/*
+ * 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.client;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+/**
+ * Interface for a web service used by txbridge test cases. Client side version.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-03
+ */
+ at WebService(targetNamespace = "http://service.outbound.tests.txbridge.jbossts.jboss.org/",
+ portName = "TestServiceImplPort")
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface TestService {
+ public void doNothing();
+}
\ No newline at end of file
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundBasicTests.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/junit/BasicTests.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundBasicTests.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundBasicTests.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,186 @@
+/*
+ * 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.jboss.arquillian.container.test.api.*;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.jbossts.txbridge.tests.common.AbstractBasicTests;
+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.jboss.shrinkwrap.api.Archive;
+import org.junit.*;
+
+import org.jboss.byteman.contrib.dtest.*;
+import org.junit.runner.RunWith;
+
+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
+ * @author Ivo Studensky (istudens at redhat.com)
+ */
+ at RunWith(Arquillian.class)
+ at RunAsClient
+public class OutboundBasicTests extends AbstractBasicTests {
+
+ @Deployment(name = OUTBOUND_SERVICE_DEPLOYMENT_NAME, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createServiceArchive() {
+ return getOutboundServiceArchive();
+ }
+
+ @Deployment(name = OUTBOUND_CLIENT_DEPLOYMENT_NAME, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createClientArchive() {
+ return getOutboundClientArchive();
+ }
+
+
+ @ArquillianResource
+ private ContainerController controller;
+
+ private InstrumentedClass instrumentedTestVolatileParticipant;
+ private InstrumentedClass instrumentedTestDurableParticipant;
+
+ @Before
+ public void setUp() throws Exception {
+ // start up the appserver
+ controller.start(CONTAINER);
+
+ instrumentor.setRedirectedSubmissionsFile(null);
+
+ 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();
+
+ // shut down the appserver
+ controller.stop(CONTAINER);
+ }
+
+
+ @Test
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testRollback(@ArquillianResource URL baseURL) throws Exception {
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ 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
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCommit(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ 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
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testBeforeCompletionFailure(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestVolatileParticipant.class, "prepare", "return new com.arjuna.wst.Aborted()");
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ instrumentedTestVolatileParticipant.assertKnownInstances(1);
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("commit");
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodNotCalled("prepare");
+ instrumentedTestDurableParticipant.assertMethodCalled("rollback");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testPrepareReadonly(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestDurableParticipant.class, "prepare", "return new com.arjuna.wst.ReadOnly()");
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ instrumentedTestVolatileParticipant.assertKnownInstances(1);
+ instrumentedTestVolatileParticipant.assertMethodCalled("prepare");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+ instrumentedTestVolatileParticipant.assertMethodCalled("commit");
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testPrepareFailure(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestDurableParticipant.class, "prepare", "return new com.arjuna.wst.Aborted()");
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+ execute(baseURL.toString() + TestClient.URL_PATTERN);
+
+ 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
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundCrashRecoveryTests.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/junit/CrashRecoveryTests.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundCrashRecoveryTests.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/OutboundCrashRecoveryTests.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,206 @@
+/*
+ * 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.jboss.arquillian.container.test.api.*;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.jbossts.txbridge.outbound.BridgeXAResource;
+import org.jboss.jbossts.txbridge.tests.common.AbstractCrashRecoveryTests;
+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.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.*;
+
+import org.jboss.byteman.contrib.dtest.*;
+import org.junit.runner.RunWith;
+
+import java.net.URL;
+
+
+/**
+ * Crash Recovery test cases for the outbound side of the transaction bridge.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-05
+ * @author Ivo Studensky (istudens at redhat.com)
+ */
+ at RunWith(Arquillian.class)
+ at RunAsClient
+public class OutboundCrashRecoveryTests extends AbstractCrashRecoveryTests {
+ private static Logger log = Logger.getLogger(OutboundCrashRecoveryTests.class);
+
+ @Deployment(name = OUTBOUND_SERVICE_DEPLOYMENT_NAME, managed = false, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createServiceArchive() {
+ return getOutboundServiceArchive();
+ }
+
+ @Deployment(name = OUTBOUND_CLIENT_DEPLOYMENT_NAME, managed = false, testable = false)
+ @TargetsContainer(CONTAINER)
+ public static Archive<?> createClientArchive() {
+ return getOutboundClientArchive();
+ }
+
+
+ @ArquillianResource
+ private ContainerController controller;
+
+ @ArquillianResource
+ private Deployer deployer;
+
+ private InstrumentedClass instrumentedTestVolatileParticipant;
+ private InstrumentedClass instrumentedTestDurableParticipant;
+
+
+ @Before
+ public void setUp() throws Exception {
+ // start up the appserver
+ String javaVmArguments = System.getProperty("server.jvm.args").trim();
+ log.info("javaVmArguments = " + javaVmArguments);
+ controller.start(CONTAINER, new Config().add("javaVmArguments", javaVmArguments).map());
+ // deploy the tests
+ deployer.deploy(OUTBOUND_SERVICE_DEPLOYMENT_NAME);
+ deployer.deploy(OUTBOUND_CLIENT_DEPLOYMENT_NAME);
+
+ instrumentor.setRedirectedSubmissionsFile(null);
+ instrumentationOnServerReboot();
+
+ instrumentor.injectOnCall(TestServiceImpl.class, "doNothing", "$0.enlistVolatileParticipant(1), $0.enlistDurableParticipant(1)");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ try {
+ instrumentor.removeAllInstrumentation();
+ } finally {
+ // un-deploy the tests
+ deployer.undeploy(OUTBOUND_CLIENT_DEPLOYMENT_NAME);
+ deployer.undeploy(OUTBOUND_SERVICE_DEPLOYMENT_NAME);
+ // shut down the appserver
+ controller.stop(CONTAINER);
+ }
+ }
+
+ @Override
+ protected void instrumentationOnServerReboot() throws Exception {
+ instrumentedTestVolatileParticipant = instrumentor.instrumentClass(TestVolatileParticipant.class);
+ instrumentedTestDurableParticipant = instrumentor.instrumentClass(TestDurableParticipant.class);
+ }
+
+ @Test
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCrashOneLog(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+ instrumentor.crashAtMethodExit("^XTSATRecoveryManager", "writeParticipantRecoveryRecord");
+
+ execute(baseURL + TestClient.URL_PATTERN, false);
+
+ instrumentedTestVolatileParticipant.assertKnownInstances(1);
+ instrumentedTestVolatileParticipant.assertMethodCalled("prepare");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("commit");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodCalled("prepare");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+
+ rebootServer(controller);
+
+ doRecovery();
+ doRecovery();
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodNotCalled("prepare");
+ instrumentedTestDurableParticipant.assertMethodCalled("rollback");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+ }
+
+ @Test
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCrashTwoLogs(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+ instrumentor.crashAtMethodExit(BridgeXAResource.class, "prepare");
+
+ execute(baseURL + TestClient.URL_PATTERN, false);
+
+ instrumentedTestVolatileParticipant.assertKnownInstances(1);
+ instrumentedTestVolatileParticipant.assertMethodCalled("prepare");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("commit");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodCalled("prepare");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+
+ rebootServer(controller);
+
+ doRecovery();
+ doRecovery();
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodNotCalled("prepare");
+ instrumentedTestDurableParticipant.assertMethodCalled("rollback");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+ }
+
+ // this one requires <property name="commitOnePhase">false</property> on CoordinatorEnvironmentBean
+ @Test
+ @Ignore
+ @OperateOnDeployment(OUTBOUND_CLIENT_DEPLOYMENT_NAME)
+ public void testCrashThreeLogs(@ArquillianResource URL baseURL) throws Exception {
+
+ instrumentor.injectOnCall(TestClient.class, "terminateTransaction", "$1 = true"); // shouldCommit=true
+
+ instrumentor.crashAtMethodEntry(BridgeXAResource.class, "commit");
+
+ execute(baseURL + TestClient.URL_PATTERN, false);
+
+ instrumentedTestVolatileParticipant.assertKnownInstances(1);
+ instrumentedTestVolatileParticipant.assertMethodCalled("prepare");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("commit");
+ instrumentedTestVolatileParticipant.assertMethodNotCalled("rollback");
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodCalled("prepare");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("commit");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+
+ rebootServer(controller);
+
+ doRecovery();
+ doRecovery();
+
+ instrumentedTestDurableParticipant.assertKnownInstances(1);
+ instrumentedTestDurableParticipant.assertMethodNotCalled("prepare");
+ instrumentedTestDurableParticipant.assertMethodNotCalled("rollback");
+ instrumentedTestDurableParticipant.assertMethodCalled("commit");
+ }
+
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestServiceImpl.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,80 @@
+/*
+ * 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.service;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.mw.wst11.TransactionManager;
+import com.arjuna.mw.wst11.TransactionManagerFactory;
+
+import org.jboss.logging.Logger;
+
+import org.jboss.jbossts.txbridge.tests.outbound.utility.TestDurableParticipant;
+import org.jboss.jbossts.txbridge.tests.outbound.utility.TestVolatileParticipant;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.servlet.annotation.WebServlet;
+
+/**
+ * Implementation of a web service used by txbridge test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-03
+ */
+ at WebService()
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+ at HandlerChain(file = "/jaxws-handlers-server.xml") // relative path from the class file
+ at WebServlet(name="OutboundTestServiceServlet", urlPatterns=TestServiceImpl.URL_PATTERN)
+public class TestServiceImpl {
+ private static Logger log = Logger.getLogger(TestServiceImpl.class);
+
+ public static final String URL_PATTERN = "/TestServiceImpl/*";
+
+ @WebMethod
+ public void doNothing() {
+ log.trace("doNothing()");
+ }
+
+ 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 {
+ for (int i = 0; i < count; i++) {
+ TestDurableParticipant durableParticipant = new TestDurableParticipant();
+ tm.enlistForDurableTwoPhase(durableParticipant, TestDurableParticipant.TYPE_IDENTIFIER + new Uid().toString());
+ }
+ } catch (Exception e) {
+ log.error("could not enlist", e);
+ }
+ }
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestDurableParticipant.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,105 @@
+/*
+ * 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.utility;
+
+import com.arjuna.wst.*;
+import org.jboss.logging.Logger;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of Durable2PCParticipant for use in tx test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-03
+ */
+public class TestDurableParticipant implements Durable2PCParticipant, Serializable {
+ private static Logger log = Logger.getLogger(TestDurableParticipant.class);
+
+ /*
+ * Uniq String used to prefix ids at participant registration,
+ * so that the recovery module can identify relevant instances.
+ */
+ public static final String TYPE_IDENTIFIER = "TestDurableParticipant_";
+
+ 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
+ * transaction. The implementation is free to do whatever it needs to in
+ * order to fulfill the implicit contract between it and the coordinator.
+ *
+ * @return an indication of whether it can prepare or not.
+ * @see com.arjuna.wst.Vote
+ */
+ @Override
+ public Vote prepare() throws WrongStateException, SystemException {
+ log.trace("prepare()");
+
+ 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();
+ }
+ }
+
+ /**
+ * The participant should make permanent the work that it controls.
+ */
+ @Override
+ public void commit() throws WrongStateException, SystemException {
+ log.trace("commit()");
+ }
+
+ /**
+ * The participant should undo the work that it controls. The participant
+ * will then return an indication of whether or not it succeeded.
+ */
+ @Override
+ public void rollback() throws WrongStateException, SystemException {
+ log.trace("rollback()");
+ }
+
+ /**
+ * During recovery the participant can enquire as to the status of the
+ * transaction it was registered with. If that transaction is no longer
+ * available (has rolled back) then this operation will be invoked by the
+ * coordination service.
+ */
+ @Override
+ public void unknown() throws SystemException {
+ log.trace("unknown()");
+ }
+
+ /**
+ * During recovery the participant can enquire as to the status of the
+ * transaction it was registered with. If an error occurs (e.g., the
+ * transaction service is unavailable) then this operation will be invoked.
+ */
+ @Override
+ public void error() throws SystemException {
+ log.trace("error()");
+ }
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestRecoveryModule.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestRecoveryModule.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestRecoveryModule.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestRecoveryModule.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,111 @@
+/*
+ * 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.utility;
+
+import com.arjuna.wst.Durable2PCParticipant;
+import org.jboss.logging.Logger;
+import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryManager;
+import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryModule;
+
+import java.io.ObjectInputStream;
+
+/**
+ * Implementation of XTSATRecoveryModule for deserializing TestDurableParticipant instances in tx test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-05
+ */
+public class TestRecoveryModule implements XTSATRecoveryModule {
+ private static final Logger log = Logger.getLogger(TestRecoveryModule.class);
+
+ /**
+ * MC lifecycle callback, used to register components with the recovery manager.
+ */
+ public void start() {
+ log.info("TestRecoveryModule starting");
+
+ //FIXME this is ugly hack!! it seems that dependency names from jboss-beans.xml no longer work in AS7!?
+ XTSATRecoveryManager xtsATRecoveryManager = null;
+ do {
+ xtsATRecoveryManager = XTSATRecoveryManager.getRecoveryManager();
+ log.info("trying to get XTSATRecoverManager = " + xtsATRecoveryManager);
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ } while (xtsATRecoveryManager == null);
+
+ xtsATRecoveryManager.registerRecoveryModule(this);
+ }
+
+ /**
+ * MC lifecycle callback, used to unregister components from the recovery manager.
+ */
+ public void stop() {
+ log.info("TestRecoveryModule stopping");
+
+ XTSATRecoveryManager.getRecoveryManager().unregisterRecoveryModule(this);
+ }
+
+ /**
+ * 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 objectInputStream 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
+ */
+ @Override
+ public Durable2PCParticipant deserialize(String id, ObjectInputStream objectInputStream) throws Exception {
+ log.trace("deserialize(id=" + id + ")");
+
+ if (id.startsWith(TestDurableParticipant.TYPE_IDENTIFIER)) {
+ Object participant = objectInputStream.readObject();
+ TestDurableParticipant testDurableParticipant = (TestDurableParticipant) participant;
+ return testDurableParticipant;
+ } else {
+ return null; // it belongs to some other XTS app, ignore it.
+ }
+ }
+
+ /**
+ * Unused recovery callback. We use serialization instead, so this method will always throw an exception if called.
+ */
+ @Override
+ public Durable2PCParticipant recreate(String id, byte[] recoveryState) throws Exception {
+ throw new Exception("recreation not supported - should use deserialization instead.");
+ }
+
+ /**
+ * participant recovery modules may need to perform special processing when the a recovery scan has
+ * completed. in particular it is only after the first recovery scan has completed they can identify
+ * whether locally prepared changes are accompanied by a recreated participant and roll back changes
+ * for those with no such participant.
+ */
+ @Override
+ public void endScan() {
+ // unused
+ }
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java (from rev 37883, labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/utility/TestVolatileParticipant.java 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,87 @@
+/*
+ * 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.utility;
+
+import com.arjuna.wst.*;
+import org.jboss.logging.Logger;
+
+/**
+ * Implementation of Volatile2PCParticipant for use in tx test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-03
+ */
+public class TestVolatileParticipant implements Volatile2PCParticipant {
+ private static Logger log = Logger.getLogger(TestVolatileParticipant.class);
+
+ /**
+ * Perform any work necessary to allow it to either commit or rollback
+ * the work performed by the Web service under the scope of the
+ * transaction. The implementation is free to do whatever it needs to in
+ * order to fulfill the implicit contract between it and the coordinator.
+ *
+ * @return an indication of whether it can prepare or not.
+ * @see com.arjuna.wst.Vote
+ */
+ @Override
+ public Vote prepare() throws WrongStateException, SystemException {
+ log.trace("prepare()");
+
+ return new Prepared(); // or Aborted()
+ }
+
+ /**
+ * The participant should make permanent the work that it controls.
+ */
+ @Override
+ public void commit() throws WrongStateException, SystemException {
+ log.trace("commit()");
+ }
+
+ /**
+ * The participant should undo the work that it controls. The participant
+ * will then return an indication of whether or not it succeeded.
+ */
+ @Override
+ public void rollback() throws WrongStateException, SystemException {
+ log.trace("rollback()");
+ }
+
+ /**
+ * During recovery the participant can enquire as to the status of the
+ * transaction it was registered with. If that transaction is no longer
+ * available (has rolled back) then this operation will be invoked by the
+ * coordination service.
+ */
+ @Override
+ public void unknown() throws SystemException {
+ log.trace("unknown()");
+ }
+
+ /**
+ * During recovery the participant can enquire as to the status of the
+ * transaction it was registered with. If an error occurs (e.g., the
+ * transaction service is unavailable) then this operation will be invoked.
+ */
+ @Override
+ public void error() throws SystemException {
+ log.trace("error()");
+ }
+}
Added: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1 @@
+org.jboss.jbossts.txbridge.tests.extension.JBossTSServerExtension
\ No newline at end of file
Added: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/arquillian.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/arquillian.xml (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/arquillian.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,10 @@
+<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+ <container qualifier="jboss" default="true" mode="manual">
+ <configuration>
+ <property name="javaVmArguments">${server.jvm.args}</property>
+ <property name="serverConfig">../../docs/examples/configs/standalone-xts.xml</property>
+ </configuration>
+ </container>
+</arquillian>
\ No newline at end of file
Modified: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/inbound/jboss-beans.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/dd/inbound/jboss-beans.xml 2012-02-09 14:10:01 UTC (rev 37883)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/inbound/jboss-beans.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -21,11 +21,13 @@
* @author JBoss, by Red Hat.
-->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
+<deployment xmlns="urn:jboss:pojo:7.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:pojo:7.0 jboss-mc_7_0.xsd">
<bean name="TxBridgeInboundTests" class="org.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResourceRecoveryHelper">
- <constructor factoryClass="org.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResourceRecoveryHelper" factoryMethod="getInstance"/>
+ <constructor factory-class="org.jboss.jbossts.txbridge.tests.inbound.utility.TestXAResourceRecoveryHelper" factory-method="getInstance"/>
<depends>jboss.xts:service=XTSService</depends>
Deleted: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/inbound/web.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/dd/inbound/web.xml 2012-02-09 14:10:01 UTC (rev 37883)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/inbound/web.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -1,38 +0,0 @@
-<!--
- * 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.
--->
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4">
- <display-name>XML Transaction Bridge Inbound Test Client</display-name>
-
- <description>XML Transaction Bridge Inbound Test Client</description>
-
- <servlet>
- <servlet-name>Inbound Test Client Servlet</servlet-name>
- <servlet-class>org.jboss.jbossts.txbridge.tests.inbound.client.TestClient</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>Inbound Test Client Servlet</servlet-name>
- <url-pattern>/testclient</url-pattern>
- </servlet-mapping>
-</web-app>
Added: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/logging.properties
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/logging.properties (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/logging.properties 2012-02-13 21:40:39 UTC (rev 37884)
@@ -0,0 +1,55 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2010, Red Hat, Inc., and individual contributors
+# as indicated by the @author tags. See the copyright.txt file 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.
+#
+
+# Additional logger names to configure (root logger is always configured)
+loggers=sun.rmi,org.jboss.shrinkwrap
+logger.org.jboss.shrinkwrap.level=INFO
+logger.sun.rmi.level=WARNING
+
+# Root logger level
+logger.level=DEBUG
+
+# Root logger handlers
+logger.handlers=FILE, CONSOLE
+
+# Console handler configuration
+handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
+handler.CONSOLE.properties=autoFlush
+handler.CONSOLE.level=INFO
+handler.CONSOLE.autoFlush=true
+handler.CONSOLE.formatter=PATTERN
+
+# File handler configuration
+handler.FILE=org.jboss.logmanager.handlers.FileHandler
+handler.FILE.level=DEBUG
+handler.FILE.properties=autoFlush,fileName
+handler.FILE.autoFlush=true
+handler.FILE.fileName=./target/test.log
+handler.FILE.formatter=PATTERN
+
+# Formatter pattern configuration
+formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
+formatter.PATTERN.properties=pattern
+formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
+
+
+logger.sun.rmi
Modified: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/jboss-beans.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/dd/outbound/jboss-beans.xml 2012-02-09 14:10:01 UTC (rev 37883)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/jboss-beans.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -21,7 +21,9 @@
* @author JBoss, by Red Hat.
-->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
+<deployment xmlns="urn:jboss:pojo:7.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:pojo:7.0 jboss-mc_7_0.xsd">
<bean name="TxBridgeOutboundTests" class="org.jboss.jbossts.txbridge.tests.outbound.utility.TestRecoveryModule">
Deleted: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/service-web.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/dd/outbound/service-web.xml 2012-02-09 14:10:01 UTC (rev 37883)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/service-web.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -1,39 +0,0 @@
-<!--
- * 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.
--->
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4">
- <display-name>XML Transaction Bridge Outbound Test Service</display-name>
-
- <description>XML Transaction Bridge Outbound Test Service</description>
-
- <!-- don't put spaces in the servet name: https://jira.jboss.org/browse/JBWS-3059 -->
- <servlet>
- <servlet-name>OutboundTestServiceServlet</servlet-name>
- <servlet-class>org.jboss.jbossts.txbridge.tests.outbound.service.TestServiceImpl</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>OutboundTestServiceServlet</servlet-name>
- <url-pattern>/TestServiceImpl/*</url-pattern>
- </servlet-mapping>
-</web-app>
Deleted: labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/web.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/dd/outbound/web.xml 2012-02-09 14:10:01 UTC (rev 37883)
+++ labs/jbosstm/branches/JBOSSTS_4_16/txbridge/tests/src/test/resources/outbound/web.xml 2012-02-13 21:40:39 UTC (rev 37884)
@@ -1,38 +0,0 @@
-<!--
- * 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.
--->
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4">
- <display-name>XML Transaction Bridge Outbound Test Client</display-name>
-
- <description>XML Transaction Bridge Outbound Test Client</description>
-
- <servlet>
- <servlet-name>Outbound Test Client Servlet</servlet-name>
- <servlet-class>org.jboss.jbossts.txbridge.tests.outbound.client.TestClient</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>Outbound Test Client Servlet</servlet-name>
- <url-pattern>/testclient</url-pattern>
- </servlet-mapping>
-</web-app>
More information about the jboss-svn-commits
mailing list