[jboss-cvs] JBossAS SVN: r93624 - in trunk/testsuite: imports/config and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 16 15:28:40 EDT 2009
Author: istudens at redhat.com
Date: 2009-09-16 15:28:39 -0400 (Wed, 16 Sep 2009)
New Revision: 93624
Added:
trunk/testsuite/imports/config/tests-crash-recovery.xml
trunk/testsuite/imports/sections/crashrecovery.xml
trunk/testsuite/src/main/org/jboss/test/crashrecovery/
trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/
trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/
trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java
trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java
trunk/testsuite/src/resources/crashrecovery/
trunk/testsuite/src/resources/crashrecovery/META-INF/
trunk/testsuite/src/resources/crashrecovery/META-INF/persistence.xml
trunk/testsuite/src/resources/crashrecovery/resources/
trunk/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/java.policy
trunk/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/oracle10-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml
trunk/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml
trunk/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml
trunk/testsuite/src/resources/crashrecovery/scripts/
trunk/testsuite/src/resources/crashrecovery/scripts/README.txt
trunk/testsuite/src/resources/crashrecovery/scripts/as-tests.xml
trunk/testsuite/src/resources/crashrecovery/scripts/imports/
trunk/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml
Modified:
trunk/testsuite/imports/config/configs.xml
trunk/testsuite/imports/test-jars.xml
Log:
porting of JBossTS crash recovery tests from the JBPAPP_5_0 branch, JBAS-7219
Modified: trunk/testsuite/imports/config/configs.xml
===================================================================
--- trunk/testsuite/imports/config/configs.xml 2009-09-16 17:52:49 UTC (rev 93623)
+++ trunk/testsuite/imports/config/configs.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -10,6 +10,7 @@
<!-- Import all the xml files that define targets that require a separate
JBoss Server Configuration -->
<import file="tests-clustering.xml"/>
+<import file="tests-crash-recovery.xml"/>
<import file="tests-bootstrap-dependencies.xml"/>
<import file="tests-password-mask.xml"/>
Added: trunk/testsuite/imports/config/tests-crash-recovery.xml
===================================================================
--- trunk/testsuite/imports/config/tests-crash-recovery.xml (rev 0)
+++ trunk/testsuite/imports/config/tests-crash-recovery.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+
+<!--
+ | Targets that run JBossTS crash recovery tests
+-->
+
+<!-- $Id$ -->
+<project name="main.server.config.crashrecovery" xmlns:server="http://jboss.org/ns/test/ant/server">
+
+
+ <property name="jbossts.crash.recovery.test.dir" value="crashrecovery" />
+ <property name="jbossts.crash.recovery.test.script.dir" value="${jbossts.crash.recovery.test.dir}/scripts" />
+ <property name="jbossts.crash.recovery.test.resource.dir" value="${jbossts.crash.recovery.test.dir}/resources" />
+
+ <!--
+ | Targets
+ -->
+
+ <!--
+ | JBQA-2176 - JBossTS crash recovery tests.
+ |
+ | Usage for all tests:
+ | ./build.sh tests-ts-crash-recovery
+ |
+ | or for particular database:
+ | ./build.sh tests-ts-crash-recovery -Dcrash.db=psql_8.3 -Dcrash.target=crash-tests-single-db
+ |
+ | or for particular test scenario:
+ | ./build.sh tests-ts-crash-recovery -Dcrash.db=psql_8.3 -Dcrash.tstype=jts -Dcrash.tsdemarc=bmt -Dcrash.testcase=none.rev -Dcrash.target=crash-tests-single
+ |
+ | Note: If you want to force the wiping out any txs in doubt from DB before the test you can use the property -DwipeOutTxsInDoubtBeforeTest=true.
+ -->
+ <target name="tests-ts-crash-recovery" depends="init-dependencies"
+ description="Runs JBossTS crash recovery tests">
+
+ <available file="${jboss.dist}/server/crashrecovery-jta" property="have.profiles" value="true"/>
+ <antcall target="prepare-crashrec-profiles" />
+
+ <property name="crash.target" value="crash-tests" />
+ <property name="crash.max.time" value="300000" />
+
+ <run-as-test target="${crash.target}" />
+
+ </target>
+
+
+ <!--
+ | Macros and others
+ -->
+
+ <macrodef name="run-as-test">
+ <attribute name="target"/>
+ <sequential>
+ <echo message="starting of ${build.resources}/${jbossts.crash.recovery.test.script.dir}/as-tests.xml"/>
+ <java classname="org.apache.tools.ant.launch.Launcher" fork="true" failonerror="true">
+ <classpath>
+ <pathelement location="${build.lib}/crashrecovery-astest.jar"/>
+ <pathelement location="${jbosstest.dist}/common/lib/jbossts-common.jar"/>
+ <pathelement location="${ant.library.dir}/ant-launcher.jar"/>
+ <fileset refid="org.apache.ant:ant:jar"/>
+ <fileset refid="org.apache.ant:ant-junit:jar"/>
+ <fileset refid="junit:junit:jar"/>
+ <fileset refid="org.jboss.jbossas:jboss-server-manager:jar"/>
+ <fileset dir="${jbosstest.dist}/client"/>
+ </classpath>
+ <sysproperty key="ant.home" value="${ant.home}"/>
+ <sysproperty key="ant.library.dir" value="${ant.library.dir}"/>
+ <sysproperty key="java.security.policy" value="${build.resources}/${jbossts.crash.recovery.test.resource.dir}/java.policy"/>
+ <sysproperty key="product.dir" value="${build.resources}/${jbossts.crash.recovery.test.dir}" />
+ <sysproperty key="jboss.home" value="${jbosstest.dist}" />
+ <sysproperty key="astest.jar.dir" value="${build.lib}" />
+ <sysproperty key="astest.jar.name" value="crashrecovery-astest.jar" />
+ <sysproperty key="astest.jar.deploy.dir" value="../../lib" />
+ <sysproperty key="jboss.server.manager.jar" value="${org.jboss.jbossas:jboss-server-manager:jar}" />
+ <sysproperty key="build.reports" value="${build.reports}" />
+ <sysproperty key="jbossas.startup.timeout" value="480" />
+ <sysproperty key="jbossas.shutdown.timeout" value="240" />
+ <sysproperty key="wipeOutTxsInDoubtBeforeTest" value="${wipeOutTxsInDoubtBeforeTest}" />
+ <sysproperty key="crash.db" value="${crash.db}" />
+ <sysproperty key="crash.tstype" value="${crash.tstype}" />
+ <sysproperty key="crash.tsdemarc" value="${crash.tsdemarc}" />
+ <sysproperty key="crash.testcase" value="${crash.testcase}" />
+ <sysproperty key="testTime" value="${crash.max.time}" />
+ <env key="JBOSS_HOME" value="${jbosstest.dist}" />
+ <arg value="-f"/>
+ <arg value="${build.resources}/${jbossts.crash.recovery.test.script.dir}/as-tests.xml"/>
+ <arg value="@{target}"/>
+ <!--jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/-->
+ </java>
+ </sequential>
+ </macrodef>
+
+
+ <target name="prepare-crashrec-profiles" unless="have.profiles">
+ <delete dir="${jboss.dist}/server/crashrecovery-jta" />
+ <create-config baseconf="standard" newconf="crashrecovery-jta">
+ <patternset>
+ <include name="conf/**"/>
+ <include name="deploy/**"/>
+ <include name="deployers/**"/>
+ <include name="lib/**"/>
+ </patternset>
+ </create-config>
+
+ <delete dir="${jboss.dist}/server/crashrecovery-jts" />
+ <create-config baseconf="all" newconf="crashrecovery-jts">
+ <patternset>
+ <include name="conf/**"/>
+ <include name="deploy/**"/>
+ <include name="deployers/**"/>
+ <include name="lib/**"/>
+ </patternset>
+ </create-config>
+
+ <!-- install JTS transactions into crashrecovery-jts profile -->
+ <ant dir="${jboss.dist}/docs/examples/transactions" target="jts">
+ <property name="target.server.dir" location="${jboss.dist}/server/crashrecovery-jts"/>
+ </ant>
+
+ <setup-crash-recovery conf="crashrecovery-jta"/>
+ <setup-crash-recovery conf="crashrecovery-jts"/>
+ </target>
+
+
+ <macrodef name="setup-crash-recovery">
+ <attribute name="conf"/>
+ <sequential>
+ <!-- enable crash recovery and point it to our datasource -->
+ <replace file="${jboss.dist}/server/@{conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[</transaction-service>]]></replacetoken>
+ <replacevalue><![CDATA[
+ <properties depends="arjuna" name="jta">
+ <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery1" value= "com.arjuna.ats.internal.jbossatx.jta.AppServerJDBCXARecovery;jndiname=CrashRecoveryDS"/>
+ <!-- xaRecoveryNode should match value in nodeIdentifier or be * -->
+ <property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>
+ </properties>
+</transaction-service>]]></replacevalue>
+ </replace>
+ <!-- more verbose logging -->
+ <replace file="${jboss.dist}/server/@{conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[type="System" value="0x00000000"]]></replacetoken>
+ <replacevalue><![CDATA[type="System" value="0xffffffff"]]></replacevalue>
+ </replace>
+ </sequential>
+ </macrodef>
+
+</project>
Added: trunk/testsuite/imports/sections/crashrecovery.xml
===================================================================
--- trunk/testsuite/imports/sections/crashrecovery.xml (rev 0)
+++ trunk/testsuite/imports/sections/crashrecovery.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,18 @@
+<project name="tests-crashrecovery-jars">
+ <!-- JBossTS crash recovery tests -->
+ <target name="_jars-crashrecovery" depends="jbqa2176"/>
+
+ <target name="jbqa2176" depends="compile">
+ <jar destfile="${build.lib}/crashrecovery-astest.jar">
+ <fileset dir="${build.resources}/crashrecovery">
+ <include name="META-INF/*.xml"/>
+ </fileset>
+ <fileset dir="${build.resources}/crashrecovery/resources">
+ <include name="java.policy"/>
+ </fileset>
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/crashrecovery/**/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+</project>
Modified: trunk/testsuite/imports/test-jars.xml
===================================================================
--- trunk/testsuite/imports/test-jars.xml 2009-09-16 17:52:49 UTC (rev 93623)
+++ trunk/testsuite/imports/test-jars.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -18,6 +18,7 @@
<import file="sections/cluster.xml"/>
<import file="sections/cmp.xml"/>
<import file="sections/cookie.xml"/>
+ <import file="sections/crashrecovery.xml"/>
<import file="sections/cts.xml"/>
<import file="sections/dbtest.xml"/>
<import file="sections/deadlock.xml"/>
@@ -103,6 +104,7 @@
_jars-cluster,
_jars-cmp2,
_jars-cookie,
+ _jars-crashrecovery,
_jars-cts,
_jars-dbtest,
_jars-deadlock,
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,499 @@
+/*
+ * 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.test.crashrecovery.ASCrashRecovery01;
+
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.test.crashrecovery.taskdefs.JUnitClientTest;
+import org.jboss.test.crashrecovery.taskdefs.TransactionLog;
+import org.jboss.test.crashrecovery.crash.CrashHelper;
+import org.jboss.test.crashrecovery.crash.CrashHelperRem;
+import org.jboss.test.crashrecovery.crash.CrashRem;
+import org.jboss.test.crashrecovery.crash.RecoveredXid;
+import org.jboss.test.crashrecovery.crash.TestEntity;
+import org.jboss.test.crashrecovery.crash.TestEntityHelper;
+import org.jboss.test.crashrecovery.crash.TestEntityHelperRem;
+import org.jboss.remoting.CannotConnectException;
+import org.apache.tools.ant.BuildException;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.EJBTransactionRolledbackException;
+import javax.naming.NamingException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+/**
+ * Crash recovery tests with one crash XA resource and one JPA entity resource.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestWithJPA extends JUnitClientTest
+{
+ // the longest time to wait in millis before declaring a test a failed (overridable)
+ private static final int MAX_TEST_TIME = 300000; // 5 minutes - allows two intervals of recovery which is 2 minutes by default
+
+ private boolean isCMT = false;
+ private boolean clientTx = false;
+ private boolean isDebug = false;
+ private boolean expectFailure = false;
+ private boolean reverseOrder = false;
+ private boolean rollbackExpected = false;
+ private boolean wipeOutTxsInDoubt = false;
+ private boolean wipeOutTxsInDoubtBeforeTest = false;
+ private boolean wipeOutTxsInDoubtAfterTest = false;
+ private int maxTestTime = MAX_TEST_TIME;
+
+ private String storeDir = null;
+ private String storeImple = "HashedActionStore";
+ private String storeType = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
+ private TransactionLog store;
+ private int existingUids;
+ private Set<RecoveredXid> existingXidsInDoubt;
+
+ private String serverName = "default";
+
+ private TestEntity initEntity;
+
+
+ public void testCrashRecovery()
+ {
+ if (config == null || params == null)
+ throw new UnsupportedOperationException("The test has not been initiated yet. Call the init() method first.");
+
+ StringBuilder sb = new StringBuilder();
+ ASFailureSpec[] fspecs = null;
+
+ for (Map.Entry<String, String> me : params.entrySet())
+ {
+ String key = me.getKey().trim();
+ String val = me.getValue().trim();
+
+ if ("name".equals(key))
+ setName(val);
+ else if ("cmt".equals(key))
+ isCMT = val.equalsIgnoreCase("true");
+ else if ("debug".equals(key))
+ isDebug = val.equalsIgnoreCase("true");
+ else if ("serverName".equals(key))
+ serverName = val;
+ else if ("storeType".equals(key))
+ storeType = val;
+ else if ("storeDir".equals(key))
+ storeDir = val;
+ else if ("clientTx".equals(key))
+ clientTx = val.equalsIgnoreCase("true");
+ else if ("storeImple".equals(key))
+ storeImple = val;
+ else if ("testTime".equals(key))
+ maxTestTime = parseInt(val, "parameter testTime should represent a number of miliseconds: ");
+ else if ("specs".equals(key))
+ fspecs = parseSpecs(val, sb);
+ else if ("wait".equals(key))
+ suspendFor(Integer.parseInt(val));
+ else if ("reverseOrder".equals(key))
+ reverseOrder = val.equalsIgnoreCase("true");
+ else if ("rollbackExpected".equals(key))
+ rollbackExpected = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubt".equals(key))
+ wipeOutTxsInDoubt = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubtBeforeTest".equals(key))
+ wipeOutTxsInDoubtBeforeTest = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubtAfterTest".equals(key))
+ wipeOutTxsInDoubtAfterTest = val.equalsIgnoreCase("true");
+ }
+
+ sb.insert(0, ":\n").insert(0, getName()).insert(0, "Executing test ");
+
+ System.out.println(sb);
+
+ try
+ {
+ // get a handle to the transaction logs
+ if (storeDir == null)
+ storeDir = serverPath + "data/tx-object-store";
+ else
+ storeDir = serverPath + storeDir;
+
+ store = new TransactionLog(storeDir, storeImple);
+
+ if (expectFailure)
+ {
+ // this test may halt the VM so make sure the transaction log is empty
+ // before starting the test - then the pass/fail check is simply to
+ // test whether or not the log is empty (see recoverUids() below).
+ try
+ {
+ store.clearXids(storeType);
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ existingUids = getPendingUids();
+ }
+
+ if (wipeOutTxsInDoubtBeforeTest)
+ wipeOutTxsInDoubt();
+
+ existingXidsInDoubt = lookupCrashHelper().checkXidsInDoubt();
+ if (isDebug)
+ print(existingXidsInDoubt.size() + " txs in doubt in database before test run");
+
+ // name of this test will be the primary key for test record in DB
+ String testEntityPK = getName();
+
+ // initialize database
+ initDatabase(testEntityPK);
+
+ // run the crash test
+ boolean result = crashTest(fspecs, testEntityPK, reverseOrder);
+ print("crashTest result: " + result);
+
+ // checking the state of DB after recovering
+ boolean dbChanged = true;
+ if (result)
+ {
+ dbChanged = checkDatabase(testEntityPK);
+ print("checkDatabase result: " + dbChanged);
+ }
+
+ Set<RecoveredXid> xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
+ if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
+ wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
+
+ assertTrue("Crash recovery failed.", result);
+ assertTrue("Incorrect data in database after crash recovery.", dbChanged);
+ assertEquals("There are still unrecovered txs in database after crash recovery.", existingXidsInDoubt.size(), xidsInDoubtAfterTest.size());
+ }
+ catch (Exception e)
+ {
+ if (isDebug)
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ }
+
+ private void initDatabase(String entityPK) throws Exception
+ {
+ TestEntityHelperRem hlp = (TestEntityHelperRem) config.getNamingContext(serverName).lookup(TestEntityHelper.REMOTE_JNDI_NAME);
+
+ initEntity = hlp.initTestEntity(entityPK);
+
+ print("TestWithJPA#initDatabase(): initEntity = " + initEntity);
+ }
+
+ private boolean checkDatabase(String entityPK)
+ {
+ try
+ {
+ TestEntityHelperRem hlp = (TestEntityHelperRem) config.getNamingContext(serverName).lookup(TestEntityHelper.REMOTE_JNDI_NAME);
+ TestEntity recoveredEntity = hlp.getTestEntity(entityPK);
+
+ print("TestWithJPA#checkDatabase(): initEntity = " + initEntity);
+ print("TestWithJPA#checkDatabase(): recoveredEntity = " + recoveredEntity);
+
+ return (rollbackExpected) ? recoveredEntity.getA() == initEntity.getA()
+ : recoveredEntity.getA() != initEntity.getA();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Wipes out all the txs in doubt from database.
+ *
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt()
+ {
+ // wipes out all txs in doubt from DB
+ return wipeOutTxsInDoubt(null);
+ }
+
+ /**
+ * Wipes out only new txs in doubt from database after test run.
+ *
+ * @param xidsInDoubtBeforeTest txs in doubt in database before test run
+ * @param xidsInDoubtBeforeTest txs in doubt in database after test run
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsInDoubtBeforeTest, Set<RecoveredXid> xidsInDoubtAfterTest)
+ {
+ Set<RecoveredXid> xidsToRecover = new HashSet<RecoveredXid>(xidsInDoubtAfterTest);
+ xidsToRecover.removeAll(xidsInDoubtBeforeTest);
+
+ if (xidsToRecover.isEmpty())
+ return true;
+
+ return wipeOutTxsInDoubt(xidsToRecover);
+ }
+
+ /**
+ * Wipes out txs in doubt from database according to a xidsToRecover list.
+ *
+ * @param xidsToRecover list of xids to recover
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
+ {
+ print("wiping out txs in doubt");
+ try
+ {
+ lookupCrashHelper().wipeOutTxsInDoubt(xidsToRecover);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+
+ private ASFailureSpec[] parseSpecs(String specArg, StringBuilder sb)
+ {
+ ASFailureSpec[] fspecs = config.parseSpecs(specArg);
+
+ for (ASFailureSpec spec : fspecs)
+ {
+ String name = (spec == null ? "INVALID" : spec.getName());
+
+ if (spec != null && spec.willTerminateVM())
+ expectFailure = true;
+
+ sb.append("\t").append(name).append('\n');
+ }
+
+ return fspecs;
+ }
+
+ private int parseInt(String intValue, String errorMessage) throws IllegalArgumentException
+ {
+ try
+ {
+ return Integer.parseInt(intValue);
+ }
+ catch (NumberFormatException e)
+ {
+ System.out.println(errorMessage + e.getMessage());
+
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ // count how many pending transaction branches there are in the transaction log
+ private int getPendingUids()
+ {
+ try
+ {
+ return store.getIds(storeType).size();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+
+ return -1;
+ }
+ }
+
+ private CrashRem lookupCrashBean(String name) throws Exception
+ {
+ return (CrashRem) config.getNamingContext(serverName).lookup(name);
+ }
+
+ private CrashHelperRem lookupCrashHelper() throws Exception
+ {
+ return (CrashHelperRem) config.getNamingContext(serverName).lookup(CrashHelper.REMOTE_JNDI_NAME);
+ }
+
+ private UserTransaction startTx() throws NamingException, SystemException, NotSupportedException
+ {
+ UserTransaction tx = (UserTransaction) config.getNamingContext(serverName).lookup("UserTransaction");
+
+ tx.begin();
+
+ return tx;
+ }
+
+ private boolean crashTest(ASFailureSpec[] sa, String testEntityPK, boolean reverseOrder) throws Exception
+ {
+ UserTransaction tx = null;
+
+ try
+ {
+ CrashRem cr = lookupCrashBean(isCMT ? CrashRem.CMT_JNDI_NAME : CrashRem.BMT_JNDI_NAME);
+
+ if (clientTx)
+ tx = startTx();
+
+ String res = cr.testXA(testEntityPK, reverseOrder, sa);
+
+ return "Passed".equalsIgnoreCase(res);
+ }
+ catch (CannotConnectException e)
+ {
+ if (expectFailure)
+ {
+ print("Failure was expected: " + e.getMessage());
+
+ return recoverUids();
+ }
+ else
+ {
+ System.err.println("XACrashTest:crashTest: Caught[1] " + e);
+
+ e.printStackTrace();
+ }
+ }
+ catch (EJBTransactionRolledbackException re)
+ {
+ // try to recover, this failure was expected maybe?!
+ print("Failure was expected (maybe): " + re.getMessage());
+
+ return recoverUids();
+ }
+ catch (RuntimeException re)
+ {
+ if (re.getCause() instanceof HeuristicMixedException)
+ {
+ // try to recover, this failure was expected maybe?!
+ print("Failure was expected (maybe): " + re.getMessage());
+
+ return recoverUids();
+ }
+ else
+ {
+ System.err.println("XACrashTest:crashTest: Caught[2] " + re);
+ re.printStackTrace();
+ }
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ System.err.println("XACrashTest:crashTest: Caught[3] " + t);
+ }
+ finally {
+ if (clientTx)
+ try
+ {
+ tx.commit();
+ }
+ catch (Throwable e)
+ {
+ System.out.println("User tx commit failure: " + e.getMessage());
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Wait for any pending transactions to recover by restarting the AS.
+ * @return true if all pending branches have been recovered
+ * @throws IOException if the server cannot be started
+ */
+ private boolean recoverUids() throws IOException
+ {
+ int retryPeriod = 60000; // 1 minute
+ int maxWait = maxTestTime;
+
+ Set<RecoveredXid> xidsInDoubtAfterTest;
+ int pendingUids;
+ int pendingXidsInDoubt;
+ int totalExistingXidsInDoubt = existingXidsInDoubt.size();
+
+ // wait for the server to start up the first time through, we will need it for later database checking
+ suspendFor(2000); // a little waiting is needed sometimes in order to be able to start server again, 2 secs
+ config.startServer(serverName);
+
+ do
+ {
+ pendingUids = getPendingUids();
+ try
+ {
+ xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ pendingXidsInDoubt = xidsInDoubtAfterTest.size();
+
+ if (pendingUids == -1)
+ return false; // object store error
+
+ if (pendingUids <= existingUids && pendingXidsInDoubt <= totalExistingXidsInDoubt)
+ return true; // all uids in AS and txs in doubt in DB recovered
+
+ pendingUids -= existingUids;
+ pendingXidsInDoubt -= totalExistingXidsInDoubt;
+
+ print("waiting for " + pendingUids + " branches");
+ print("waiting for " + pendingXidsInDoubt + " txs in doubt");
+
+ suspendFor(retryPeriod);
+ maxWait -= retryPeriod;
+
+ } while (maxWait > 0);
+
+ // the test failed to recover some uids - clear them out ready for the next test
+ try
+ {
+ store.clearXids(storeType);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (pendingXidsInDoubt > 0)
+ {
+ print(pendingXidsInDoubt + " new txs in doubt in database after the test");
+
+ if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
+ wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
+ }
+
+ return false;
+ }
+
+ private void suspendFor(int millis)
+ {
+ try
+ {
+ Thread.sleep(millis);
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("Test " + getName() + " interupted");
+ }
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,89 @@
+/*
+ * 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.test.crashrecovery.ASCrashRecovery01;
+
+import org.jboss.test.crashrecovery.taskdefs.JUnitClientTest;
+import org.jboss.test.crashrecovery.crash.CrashHelper;
+import org.jboss.test.crashrecovery.crash.CrashHelperRem;
+import org.apache.tools.ant.BuildException;
+
+import java.util.Map;
+
+/**
+ * Helper test just for wiping out of txs in doubt from DB.
+ * It can be called via the as-tests.xml script.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public class WipeOutTxsInDoubt extends JUnitClientTest
+{
+ private boolean isDebug = false;
+
+ private String serverName = "default";
+
+ public void testCrashRecovery()
+ {
+ for (Map.Entry<String, String> me : params.entrySet())
+ {
+ String key = me.getKey().trim();
+ String val = me.getValue().trim();
+
+ if ("name".equals(key))
+ setName(val);
+ else if ("serverName".equals(key))
+ serverName = val;
+ else if ("debug".equals(key))
+ isDebug = val.equalsIgnoreCase("true");
+ }
+
+ print("Executing test " + getName() + ":\n");
+
+ try
+ {
+ print("wiping out txs in doubt from database");
+ wipeOutTxsInDoubt();
+ }
+ catch (Exception e)
+ {
+ if (isDebug)
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ }
+
+
+ public boolean wipeOutTxsInDoubt()
+ {
+ try
+ {
+ CrashHelperRem helper = (CrashHelperRem) config.getNamingContext(serverName).lookup(CrashHelper.REMOTE_JNDI_NAME);
+ helper.wipeOutTxsInDoubt(null);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,106 @@
+/*
+ * 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.test.crashrecovery.crash;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.test.crashrecovery.recovery.TestASRecovery;
+import org.jboss.test.crashrecovery.recovery.TestASRecoveryWithJPA;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBContext;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+ at Stateless
+ at TransactionManagement(TransactionManagementType.BEAN)
+public class CrashBMTBean implements CrashLocal, CrashRem {
+ private static Logger log = Logger.getLogger(CrashBMTBean.class);
+
+// @Resource
+// private UserTransaction utx;
+ @Resource
+ private EJBContext context;
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String ... args)
+ {
+ return "Passed";
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(ASFailureSpec... specs)
+ {
+ TestASRecovery xatest = new TestASRecovery();
+ String txStatus = getStatus(context.getUserTransaction());
+
+ if (txStatus != null)
+ log.info("BMT method called with tx status: " + txStatus);
+
+ log.info("BMT testXA called with " + specs.length + " specs");
+
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ return xatest.startTest() ? "Passed" : "Failed";
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs)
+ {
+ TestASRecoveryWithJPA xatest = new TestASRecoveryWithJPA();
+ String txStatus = getStatus(context.getUserTransaction());
+
+ if (txStatus != null)
+ log.info("BMT method called with tx status: " + txStatus);
+
+ log.info("BMT testXA called with " + specs.length + " specs and testEntityPK=" + testEntityPK + " reverseOrder=" + reverseOrder);
+
+ xatest.setTestEntityPK(testEntityPK);
+ xatest.setReverseOrder(reverseOrder);
+
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ return xatest.startTest() ? "Passed" : "Failed";
+ }
+
+ public String getStatus(UserTransaction tx)
+ {
+ if (tx == null)
+ return null;
+
+ try
+ {
+ return org.jboss.tm.TxUtils.getStatusAsString(tx.getStatus());
+ }
+ catch (SystemException e)
+ {
+ return "tx status error: " + e.getMessage();
+ }
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,116 @@
+/*
+ * 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.test.crashrecovery.crash;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.test.crashrecovery.recovery.TestASRecovery;
+import org.jboss.test.crashrecovery.recovery.TestASRecoveryWithJPA;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.transaction.Transaction;
+
+ at Stateless
+public class CrashCMTBean implements CrashLocal, CrashRem {
+ private static Logger log = Logger.getLogger(CrashCMTBean.class);
+
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String ... args)
+ {
+ return "Passed";
+ }
+
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(ASFailureSpec... specs)
+ {
+ log.info("CMT testXA called with " + specs.length + " specs");
+
+ TestASRecovery xatest = new TestASRecovery();
+ Transaction tx;
+
+ try
+ {
+ tx = com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction();
+ }
+ catch (javax.transaction.SystemException e)
+ {
+ tx = null;
+ }
+
+ if (tx == null)
+ {
+ log.error("CMT testXA called without a transaction");
+
+ return "Failed";
+ }
+ else
+ {
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ xatest.startTest(tx);
+
+ return "Passed";
+ }
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs)
+ {
+ log.info("CMT testXA called with " + specs.length + " specs and testEntityPK=" + testEntityPK + " reverseOrder=" + reverseOrder);
+
+ TestASRecoveryWithJPA xatest = new TestASRecoveryWithJPA();
+ Transaction tx;
+
+ try
+ {
+ tx = com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction();
+ }
+ catch (javax.transaction.SystemException e)
+ {
+ tx = null;
+ }
+
+ if (tx == null)
+ {
+ log.error("CMT testXA called without a transaction");
+
+ return "Failed";
+ }
+ else
+ {
+ xatest.setTestEntityPK(testEntityPK);
+ xatest.setReverseOrder(reverseOrder);
+
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ xatest.startTest(tx);
+
+ return "Passed";
+ }
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.crash;
+
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+
+import com.arjuna.ats.internal.jbossatx.jta.AppServerJDBCXARecovery;
+
+
+/**
+ * Helper class for playing with txs in doubt.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class CrashHelper implements CrashHelperRem
+{
+ public static final String REMOTE_JNDI_NAME = CrashHelper.class.getSimpleName() + "/remote";
+ private static Logger log = Logger.getLogger(CrashHelper.class);
+
+ /**
+ * JNDI name of crash recovery datasource.
+ */
+ public static final String DS_JNDI_NAME = "CrashRecoveryDS";
+
+
+ /**
+ * Wipes out xids in doubt from database ({@link #DS_JNDI_NAME}) according to
+ * <code>xidToRecover</code> list. If xidToRecover is null, it wipes out all xids in doubt.
+ *
+ * @param xidToRecover list of Xids to recover
+ */
+ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+ public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
+ {
+ log.info("wipe out txs in doubt");
+ try
+ {
+ AppServerJDBCXARecovery appServerRecovery = new AppServerJDBCXARecovery();
+
+ if (appServerRecovery.initialise("jndiname=" + DS_JNDI_NAME))
+ {
+ if (appServerRecovery.hasMoreResources())
+ {
+ XAResource xares = appServerRecovery.getXAResource();
+
+ Xid[] txInDoubt = null;
+ try
+ {
+ txInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot start recovering on xares", e);
+
+ try
+ {
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (Exception e1)
+ {
+ }
+
+ return false;
+ }
+
+ if (txInDoubt == null || txInDoubt.length == 0)
+ return true;
+
+ log.info("There are " + txInDoubt.length + " xids in doubt");
+
+ for (int k=0; k < txInDoubt.length; k++)
+ {
+ RecoveredXid xid = convertToRecoveredXid(txInDoubt[k]);
+ if (xidsToRecover == null || xidsToRecover.contains(xid))
+ {
+ try
+ {
+ log.info("rollbacking of Xid " + xid);
+ xares.rollback(txInDoubt[k]);
+ }
+ catch (Exception e)
+ {
+ log.error("Error in rollback of Xid " + txInDoubt[k], e);
+ }
+ }
+ }
+
+ try
+ {
+ if (xares != null)
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot finish recovering on xares", e);
+ }
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ log.error("Cannot get any XAResource by AppServerJDBCXARecovery", e);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks xids in doubt in datasource with {@link #DS_JNDI_NAME}.
+ *
+ * @return number of xids in doubt
+ */
+ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+ public Set<RecoveredXid> checkXidsInDoubt()
+ {
+ Set<RecoveredXid> xids = new HashSet<RecoveredXid>();
+ try
+ {
+ AppServerJDBCXARecovery appServerRecovery = new AppServerJDBCXARecovery();
+
+ if (appServerRecovery.initialise("jndiname=" + DS_JNDI_NAME))
+ {
+ if (appServerRecovery.hasMoreResources())
+ {
+ XAResource xares = appServerRecovery.getXAResource();
+
+ try
+ {
+ Xid[] xidsInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
+
+ if (xidsInDoubt != null)
+ {
+ log.info("There are " + xidsInDoubt.length + " xids in doubt");
+
+ for (int k=0; k < xidsInDoubt.length; k++)
+ xids.add(convertToRecoveredXid(xidsInDoubt[k]));
+ }
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot start recover scan on xares", e);
+ }
+ finally
+ {
+ try
+ {
+ if (xares != null)
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot finish recover scan on xares", e);
+ }
+ }
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ log.error("Cannot get any XAResource by AppServerJDBCXARecovery", e);
+ }
+
+ return xids;
+ }
+
+ private RecoveredXid convertToRecoveredXid(Xid xid)
+ {
+ RecoveredXid recoveredXid = new RecoveredXid();
+
+ recoveredXid.setBranchQualifier(xid.getBranchQualifier());
+ recoveredXid.setFormatId(xid.getFormatId());
+ recoveredXid.setGlobalTransactionId(xid.getGlobalTransactionId());
+
+ return recoveredXid;
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.crash;
+
+import java.util.Set;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface CrashHelperRem
+{
+ public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover);
+ public Set<RecoveredXid> checkXidsInDoubt();
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,32 @@
+/*
+ * 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.test.crashrecovery.crash;
+
+import javax.ejb.Local;
+
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+
+ at Local
+public interface CrashLocal {
+ String testXA(String ... args);
+ String testXA(ASFailureSpec... specs);
+ String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs);
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,28 @@
+/*
+ * 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.test.crashrecovery.crash;
+
+import javax.ejb.EJBLocalHome;
+import javax.ejb.CreateException;
+
+public interface CrashLocalHome extends EJBLocalHome {
+ CrashLocal create() throws CreateException;
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,36 @@
+/*
+ * 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.test.crashrecovery.crash;
+
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface CrashRem {
+ // JNDI names of the fault injection beans
+ String BMT_JNDI_NAME = "CrashBMTBean/remote";
+ String CMT_JNDI_NAME = "CrashCMTBean/remote";
+
+ String testXA(String ... args);
+ String testXA(ASFailureSpec... specs);
+ String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs);
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,29 @@
+/*
+ * 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.test.crashrecovery.crash;
+
+import javax.ejb.EJBHome;
+import javax.ejb.CreateException;
+import java.rmi.RemoteException;
+
+public interface CrashRemHome extends EJBHome {
+ CrashRem create() throws CreateException, RemoteException;
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.crash;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class RecoveredXid implements Serializable
+{
+ private byte[] branchQualifier;
+ private int formatId;
+ private byte[] globalTransactionId;
+
+ public RecoveredXid()
+ {
+ }
+
+ public byte[] getBranchQualifier()
+ {
+ return branchQualifier;
+ }
+
+ public void setBranchQualifier(byte[] branchQualifier)
+ {
+ this.branchQualifier = branchQualifier;
+ }
+
+ public int getFormatId()
+ {
+ return formatId;
+ }
+
+ public void setFormatId(int formatId)
+ {
+ this.formatId = formatId;
+ }
+
+ public byte[] getGlobalTransactionId()
+ {
+ return globalTransactionId;
+ }
+
+ public void setGlobalTransactionId(byte[] globalTransactionId)
+ {
+ this.globalTransactionId = globalTransactionId;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(branchQualifier);
+ result = prime * result + formatId;
+ result = prime * result + Arrays.hashCode(globalTransactionId);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RecoveredXid other = (RecoveredXid) obj;
+ if (!Arrays.equals(branchQualifier, other.branchQualifier))
+ return false;
+ if (formatId != other.formatId)
+ return false;
+ if (!Arrays.equals(globalTransactionId, other.globalTransactionId))
+ return false;
+ return true;
+ }
+
+ @Override
+ /**
+ * Only for debugging purposes.
+ */
+ public String toString()
+ {
+ return "RecoveredXid [branchQualifier=" + Arrays.toString(branchQualifier) + ", formatId=" + formatId
+ + ", globalTransactionId=" + Arrays.toString(globalTransactionId) + "]";
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.crash;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * TestEntity for crash recovery tests.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Entity
+ at Table(name="testentity")
+public class TestEntity implements Serializable
+{
+ private String id;
+ private int a;
+
+ public TestEntity()
+ {
+ // default constructor
+ }
+
+ public TestEntity(String id, int a)
+ {
+ this.id = id;
+ this.a = a;
+ }
+
+ @Id
+ public String getId()
+ {
+ return id;
+ }
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+ public int getA()
+ {
+ return a;
+ }
+ public void setA(int a)
+ {
+ this.a = a;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TestEntity other = (TestEntity) obj;
+ if (id == null)
+ {
+ if (other.id != null)
+ return false;
+ }
+ else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TestEntity [a=" + a + ", id=" + id + "]";
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.crash;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.logging.Logger;
+
+
+/**
+ * Helper SLSB for playing (initiate, update, ...) with test entity.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class TestEntityHelper implements TestEntityHelperRem, TestEntityHelperLocal
+{
+ public static final String REMOTE_JNDI_NAME = TestEntityHelper.class.getSimpleName() + "/remote";
+ public static final String LOCAL_JNDI_NAME = TestEntityHelper.class.getSimpleName() + "/local";
+
+ public static final int TEST_ENTITY_INIT_VALUE = 1;
+
+ private static Logger log = Logger.getLogger(TestEntityHelper.class);
+
+
+ @PersistenceContext
+ EntityManager em;
+
+ /**
+ * Initiates test entity with <code>entityPK</code> key to the {@link #TEST_ENTITY_INIT_VALUE}.
+ * @param entityPK primary key of test entity
+ * @return initiated test entity
+ */
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public TestEntity initTestEntity(String entityPK)
+ {
+ TestEntity entity = em.find(TestEntity.class, entityPK);
+
+ if (entity == null)
+ {
+ entity = new TestEntity(entityPK, TEST_ENTITY_INIT_VALUE);
+ em.persist(entity);
+ }
+ else
+ {
+ entity.setA(TEST_ENTITY_INIT_VALUE);
+ }
+
+ return entity;
+ }
+
+ /**
+ * Finds test entity with <code>entityPK</code> key.
+ * @param entityPK primary key of test entity
+ * @return test entity
+ */
+ public TestEntity getTestEntity(String entityPK)
+ {
+ log.info("entityPK = " + entityPK);
+ TestEntity entity = em.find(TestEntity.class, entityPK);
+ log.debug("TestEntityHelper#getTestEntity(" + entityPK + ") = " + entity);
+
+ return entity;
+ }
+
+ /**
+ * Updates test entity, i.e. increments its value.
+ * @param entityPK primary key of test entity
+ * @return true in success, false otherwise
+ */
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public boolean updateTestEntity(String entityPK)
+ {
+ try
+ {
+ TestEntity entity = em.find(TestEntity.class, entityPK);
+ entity.setA(entity.getA() + 1);
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot update a test entity", e);
+ }
+ return false;
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.crash;
+
+import javax.ejb.Local;
+
+ at Local
+public interface TestEntityHelperLocal
+{
+ public boolean updateTestEntity(String entityPK);
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.crash;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface TestEntityHelperRem
+{
+ public TestEntity initTestEntity(String entityPK);
+ public TestEntity getTestEntity(String entityPK);
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,54 @@
+/*
+ * 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.test.crashrecovery.recovery;
+
+import java.io.Serializable;
+
+/**
+ * Specification of what to do when a failure is injected
+ */
+public enum ASFailureMode implements Serializable
+{
+ NONE(false)
+
+ ,HALT(true) // halt the JVM
+ ,EXIT(true) // exit the JVM
+ ,SUSPEND(false) // suspend the calling thread
+ ,XAEXCEPTION(false) // fail via one of the xa exception codes
+ ;
+
+ private boolean willTerminateVM;
+
+ ASFailureMode(boolean willTerminateVM)
+ {
+ this.willTerminateVM = willTerminateVM;
+ }
+
+ public boolean willTerminateVM()
+ {
+ return willTerminateVM;
+ }
+
+ public static ASFailureMode toEnum(String mode)
+ {
+ return ASFailureMode.valueOf(mode.toUpperCase());
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,140 @@
+/*
+ * 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.test.crashrecovery.recovery;
+
+import java.io.Serializable;
+
+/**
+ * An ASFailureSpec is for defining different ways of generating
+ * failures and essentially consists of a mode and type.
+ *
+ * If you need to generate new kinds of failure you should
+ * modify the ASFailureMode and ASFailureType classes. Your
+ * test will be given a reference to these specifications and is
+ * responsible for interpreting their meaning.
+ *
+ * @see org.jboss.test.crashrecovery.ASCrashRecovery01.Test03 for an example
+ * @see org.jboss.test.crashrecovery.recovery.ASFailureMode
+ * @see org.jboss.test.crashrecovery.recovery.ASFailureType
+ *
+ * A failure specification is defined in ASTestConfig
+ * @see org.jboss.test.crashrecovery.taskdefs.ASTestConfig
+ */
+public class ASFailureSpec implements Serializable
+{
+ String name;
+ ASFailureMode mode;
+ ASFailureType type;
+ String modeArg;
+ int recoveryArg;
+
+ public ASFailureSpec()
+ {
+ mode = ASFailureMode.NONE;
+ type = ASFailureType.NONE;
+ }
+
+ public ASFailureSpec(String name, ASFailureMode mode, ASFailureType type, String modeArg, int recoveryArg)
+ {
+ this.name = name;
+ this.mode = mode;
+ this.type = type;
+ this.modeArg = modeArg;
+ this.recoveryArg = recoveryArg;
+ }
+
+ public boolean willTerminateVM()
+ {
+ return mode.willTerminateVM();
+ }
+
+ public ASFailureMode getMode()
+ {
+ return mode;
+ }
+
+ public ASFailureType getType()
+ {
+ return type;
+ }
+
+ public String getModeArg()
+ {
+ return modeArg;
+ }
+
+ public int getRecoveryArg()
+ {
+ return recoveryArg;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public void setMode(String mode)
+ {
+ this.mode = ASFailureMode.valueOf(mode);
+ }
+
+ public void setType(String type)
+ {
+ this.type = ASFailureType.valueOf(type);
+ }
+
+ public void setModeArg(String modeArg)
+ {
+ this.modeArg = modeArg;
+ }
+
+ public void setRecoveryArg(int recoveryArg)
+ {
+ this.recoveryArg = recoveryArg;
+ }
+
+ public String toString()
+ {
+ return new StringBuilder().append(mode).append(',').append(type).append(',').append(modeArg).toString();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof ASFailureSpec)) return false;
+
+ ASFailureSpec that = (ASFailureSpec) o;
+
+ if (name != null ? !name.equals(that.name) : that.name != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (name != null ? name.hashCode() : 0);
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,65 @@
+/*
+ * 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.test.crashrecovery.recovery;
+
+import java.io.Serializable;
+
+/**
+ * Specification of when to inject a failure
+ */
+public enum ASFailureType implements Serializable
+{
+ NONE
+
+ ,PRE_PREPARE // do something before prepare is called
+
+ ,XARES_START // failures specific to the XA protocol
+ ,XARES_END
+ ,XARES_PREPARE
+ ,XARES_ROLLBACK
+ ,XARES_COMMIT
+ ,XARES_RECOVER
+ ,XARES_FORGET
+
+ ,SYNCH_BEFORE // do something before completion
+ ,SYNCH_AFTER
+ ;
+
+ public static ASFailureType toEnum(String type)
+ {
+ return ASFailureType.valueOf(type.toUpperCase());
+ }
+
+ public boolean isXA()
+ {
+ return name().startsWith("XARES");
+ }
+
+ public boolean isSynchronization()
+ {
+ return name().startsWith("SYNCH");
+ }
+
+ public boolean isPreCommit()
+ {
+ return equals(PRE_PREPARE);
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,327 @@
+/*
+ * 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.test.crashrecovery.recovery;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+import javax.transaction.Synchronization;
+import java.io.Serializable;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Simulate a variety of faults during the various phases of the XA protocol
+ */
+public class ASTestResource implements Synchronization, XAResource, Serializable
+{
+ private static final Map<String, XAException> xaCodeMap = new HashMap<String, XAException>();
+
+ private ASFailureType _xaFailureType = ASFailureType.NONE;
+ private ASFailureMode _xaFailureMode = ASFailureMode.NONE;
+ private String[] _args;
+ private int _suspend;
+ private int _recoveryAttempts = 1;
+ private XAException _xaException;
+ private int txTimeout = 10;
+ private Set<Xid> _xids = new HashSet<Xid>();
+ private transient boolean _isPrepared = false; // transient so it doesn't get persisted in the tx store
+
+ static
+ {
+ init();
+ }
+
+ public ASTestResource()
+ {
+ }
+
+ public ASTestResource(ASFailureSpec spec)
+ {
+ this();
+
+ if (spec == null)
+ throw new IllegalArgumentException("Invalid XA resource failure injection specification");
+
+ setFailureMode(spec.getMode(), spec.getModeArg());
+ setFailureType(spec.getType());
+ setRecoveryAttempts(spec.getRecoveryArg());
+ }
+
+ public void applySpec(String message) throws XAException
+ {
+ applySpec(message, _isPrepared);
+ }
+
+ public void applySpec(String message, boolean prepared) throws XAException
+ {
+ if (_xaFailureType.equals(ASFailureType.NONE) || _xaFailureMode.equals(ASFailureMode.NONE) || !prepared)
+ {
+ System.out.println(message + (_isPrepared ? " ... " : " recovery"));
+ return; // NB if !_isPrepared then we must have been called from the recovery subsystem
+ }
+
+ System.out.println("Applying fault injection with " + _xids.size() + " active branches");
+ if (_xaException != null)
+ {
+ System.out.println(message + " ... xa error: " + _xaException.getMessage());
+ throw _xaException;
+ }
+ else if (_xaFailureMode.equals(ASFailureMode.HALT))
+ {
+ System.out.println(message + " ... halting");
+ Runtime.getRuntime().halt(1);
+ }
+ else if (_xaFailureMode.equals(ASFailureMode.EXIT))
+ {
+ System.out.println(message + " ... exiting");
+ System.exit(1);
+ }
+ else if (_xaFailureMode.equals(ASFailureMode.SUSPEND))
+ {
+ System.out.println(message + " ... suspending for " + _suspend);
+ suspend(_suspend);
+ System.out.println(message + " ... resuming");
+ }
+ }
+
+ public String toString()
+ {
+ return _xaFailureType + ", " + _xaFailureMode + ", " + (_args != null && _args.length != 0 ? _args[0] : "");
+ }
+
+ private void suspend(int msecs)
+ {
+ try
+ {
+ Thread.sleep(msecs);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void setFailureMode(ASFailureMode mode, String ... args) throws IllegalArgumentException
+ {
+ _xaFailureMode = mode;
+ _args = args;
+
+ if (args != null && args.length != 0)
+ {
+ if (_xaFailureMode.equals(ASFailureMode.SUSPEND))
+ {
+ _suspend = Integer.parseInt(args[0]);
+ }
+ else if (_xaFailureMode.equals(ASFailureMode.XAEXCEPTION))
+ {
+ _xaException = xaCodeMap.get(args[0]);
+
+ if (_xaException == null)
+ _xaException = new XAException(XAException.XAER_RMFAIL);
+ }
+ }
+ }
+
+ public void setFailureType(ASFailureType type)
+ {
+ _xaFailureType = type;
+ }
+
+ public ASFailureType getFailureType()
+ {
+ return _xaFailureType;
+ }
+
+ public void setRecoveryAttempts(int _recoveryAttempts)
+ {
+ this._recoveryAttempts = _recoveryAttempts;
+ }
+
+ // Synchronizatons
+
+ public void beforeCompletion()
+ {
+ if (_xaFailureType.equals(ASFailureType.SYNCH_BEFORE))
+ try
+ {
+ applySpec("Before completion");
+ }
+ catch (XAException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void afterCompletion(int i)
+ {
+ if (_xaFailureType.equals(ASFailureType.SYNCH_AFTER))
+ try
+ {
+ applySpec("After completion");
+ }
+ catch (XAException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // XA Interface implementation
+
+ public void commit(Xid xid, boolean b) throws XAException
+ {
+ if (_xaFailureType.equals(ASFailureType.XARES_COMMIT))
+ applySpec("xa commit");
+
+ _isPrepared = false;
+ _xids.remove(xid);
+ }
+
+ public void rollback(Xid xid) throws XAException
+ {
+ if (_xaFailureType.equals(ASFailureType.XARES_ROLLBACK))
+ applySpec("xa rollback");
+
+ _isPrepared = false;
+ _xids.remove(xid);
+ }
+
+ public void end(Xid xid, int i) throws XAException
+ {
+ if (_xaFailureType.equals(ASFailureType.XARES_END))
+ applySpec("xa end");
+ }
+
+ public void forget(Xid xid) throws XAException
+ {
+ if (_xaFailureType.equals(ASFailureType.XARES_FORGET))
+ applySpec("xa forget");
+
+ _isPrepared = false;
+ _xids.remove(xid);
+ }
+
+ public int getTransactionTimeout() throws XAException
+ {
+ return txTimeout;
+ }
+
+ public boolean isSameRM(XAResource xaResource) throws XAException
+ {
+ return false;
+ }
+
+ public int prepare(Xid xid) throws XAException
+ {
+ _isPrepared = true;
+
+ if (_xaFailureType.equals(ASFailureType.XARES_PREPARE))
+ applySpec("xa prepare");
+
+ _xids.add(xid);
+
+ return XA_OK;
+ }
+
+ public Xid[] recover(int i) throws XAException
+ {
+ if (_recoveryAttempts <= 0)
+ return _xids.toArray(new Xid[_xids.size()]);
+
+ _recoveryAttempts -= 1;
+
+ if (_xaFailureType.equals(ASFailureType.XARES_RECOVER))
+ applySpec("xa recover");
+
+ return new Xid[0];
+ }
+
+ public boolean setTransactionTimeout(int txTimeout) throws XAException
+ {
+ this.txTimeout = txTimeout;
+
+ return true; // set was successfull
+ }
+
+ public void start(Xid xid, int i) throws XAException
+ {
+ _xids.add(xid);
+
+ if (_xaFailureType.equals(ASFailureType.XARES_START))
+ applySpec("xa start");
+ }
+
+ public String getEISProductName() { return "Test XAResouce";}
+
+ public String getEISProductVersion() { return "v666.0";}
+
+ @SuppressWarnings({"ThrowableInstanceNeverThrown"})
+ private static void init()
+ {
+ xaCodeMap.put("XA_HEURCOM", new XAException(XAException.XA_HEURCOM));
+ xaCodeMap.put("XA_HEURHAZ", new XAException(XAException.XA_HEURHAZ));
+ xaCodeMap.put("XA_HEURMIX", new XAException(XAException.XA_HEURMIX));
+ xaCodeMap.put("XA_HEURRB", new XAException(XAException.XA_HEURRB));
+ xaCodeMap.put("XA_NOMIGRATE", new XAException(XAException.XA_NOMIGRATE));
+ xaCodeMap.put("XA_RBBASE", new XAException(XAException.XA_RBBASE));
+ xaCodeMap.put("XA_RBCOMMFAIL", new XAException(XAException.XA_RBCOMMFAIL));
+ xaCodeMap.put("XA_RBDEADLOCK", new XAException(XAException.XA_RBDEADLOCK));
+ xaCodeMap.put("XA_RBEND", new XAException(XAException.XA_RBEND));
+ xaCodeMap.put("XA_RBINTEGRITY", new XAException(XAException.XA_RBINTEGRITY));
+ xaCodeMap.put("XA_RBOTHER", new XAException(XAException.XA_RBOTHER));
+ xaCodeMap.put("XA_RBPROTO", new XAException(XAException.XA_RBPROTO));
+ xaCodeMap.put("XA_RBROLLBACK", new XAException(XAException.XA_RBROLLBACK));
+ xaCodeMap.put("XA_RBTIMEOUT", new XAException(XAException.XA_RBTIMEOUT));
+ xaCodeMap.put("XA_RBTRANSIENT", new XAException(XAException.XA_RBTRANSIENT));
+ xaCodeMap.put("XA_RDONLY", new XAException(XAException.XA_RDONLY));
+ xaCodeMap.put("XA_RETRY", new XAException(XAException.XA_RETRY));
+ xaCodeMap.put("XAER_ASYNC", new XAException(XAException.XAER_ASYNC));
+ xaCodeMap.put("XAER_DUPID", new XAException(XAException.XAER_DUPID));
+ xaCodeMap.put("XAER_INVAL", new XAException(XAException.XAER_INVAL));
+ xaCodeMap.put("XAER_NOTA", new XAException(XAException.XAER_NOTA));
+ xaCodeMap.put("XAER_OUTSIDE", new XAException(XAException.XAER_OUTSIDE));
+ xaCodeMap.put("XAER_PROTO", new XAException(XAException.XAER_PROTO));
+ xaCodeMap.put("XAER_RMERR", new XAException(XAException.XAER_RMERR));
+ xaCodeMap.put("XAER_RMFAIL ", new XAException(XAException.XAER_RMFAIL));
+ }
+
+ public boolean isXAResource()
+ {
+ return _xaFailureType.isXA() || _xaFailureType.equals(ASFailureType.NONE);
+ }
+
+ public boolean isSynchronization()
+ {
+ return _xaFailureType.isSynchronization();
+ }
+
+ public boolean isPreCommit()
+ {
+ return _xaFailureType.isPreCommit();
+ }
+
+ public boolean expectException()
+ {
+ return _xaFailureMode.equals(ASFailureMode.XAEXCEPTION);
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,121 @@
+/*
+ * 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.test.crashrecovery.recovery;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Helper class for manually starting a transaction and enlisting various resources
+ * and synchronizations.
+ */
+public class TestASRecovery
+{
+ List<ASTestResource> resources = new ArrayList<ASTestResource> ();
+ private boolean expectException;
+
+ public void addResource(ASFailureSpec spec)
+ {
+ resources.add(new ASTestResource(spec));
+ }
+
+ /**
+ * See if there are any faults that should be injected before starting the
+ * commit protocol
+ */
+ private void preCommit()
+ {
+ for (ASTestResource spec : resources)
+ {
+ if (spec.isPreCommit())
+ try
+ {
+ spec.applySpec("Pre commit", true);
+ }
+ catch (XAException ignore)
+ {
+ }
+ }
+ }
+
+ public boolean startTest(Transaction tx)
+ {
+ try
+ {
+ for (ASTestResource res : resources)
+ {
+ System.out.println("Enlisting " + res);
+
+ if (res.isXAResource())
+ tx.enlistResource(res);
+ else if (res.isSynchronization())
+ tx.registerSynchronization(res);
+
+ if (res.expectException())
+ expectException = true;
+ }
+
+ preCommit();
+
+ return true;
+ }
+ catch (RollbackException e)
+ {
+ e.printStackTrace();
+ }
+ catch (SystemException e)
+ {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+ public boolean startTest()
+ {
+ UserTransaction ut = com.arjuna.ats.jta.UserTransaction.userTransaction();
+
+ try
+ {
+ ut.begin();
+
+ if (!startTest(com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction()))
+ ut.rollback();
+ else
+ {
+ ut.commit();
+
+ return !expectException;
+ }
+ }
+ catch (Exception e)
+ {
+ if (expectException)
+ return true; // TODO should check each specific exception type
+
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.recovery;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.Transaction;
+
+import org.jboss.test.crashrecovery.crash.TestEntityHelper;
+import org.jboss.test.crashrecovery.crash.TestEntityHelperLocal;
+
+/**
+ * Extends TestASRecovery class by adding JPA entity update.
+ */
+public class TestASRecoveryWithJPA extends TestASRecovery
+{
+ private String testEntityPK = null;
+ private boolean reverseOrder = false;
+
+ /**
+ * Primary key of test entity.
+ * Typically depends on the name of a particular test.
+ *
+ * @param testEntityPK
+ */
+ public void setTestEntityPK(String testEntityPK)
+ {
+ this.testEntityPK = testEntityPK;
+ }
+
+ /**
+ * Sets order of enlisting of XA resources.
+ * <ul><li>non-rev (b=false): 1. JPA XA resource, 2. crash XA resource
+ * <li>rev (b=true): 1. crash XA resource, 2. JPA XA resource</ul>
+ *
+ * @param b
+ */
+ public void setReverseOrder(boolean b)
+ {
+ this.reverseOrder = b;
+ }
+
+ public boolean startTest(Transaction tx)
+ {
+ boolean result = true;
+
+ if (reverseOrder)
+ {
+ result = result && super.startTest(tx); // this sequence denies usage of PRECOMMIT, but we don't need it for crash recovery tests
+ result = result && doJPAEntityUpdate();
+ }
+ else
+ {
+ result = result && doJPAEntityUpdate();
+ result = result && super.startTest(tx);
+ }
+
+
+ return result;
+ }
+
+ public boolean startTest()
+ {
+ return super.startTest();
+ }
+
+
+ /**
+ * Calls update of a test entity.
+ */
+ protected boolean doJPAEntityUpdate()
+ {
+ TestEntityHelperLocal testEntityHelper;
+ try
+ {
+ testEntityHelper = (TestEntityHelperLocal) new InitialContext().lookup(TestEntityHelper.LOCAL_JNDI_NAME);
+
+ return testEntityHelper.updateTestEntity(testEntityPK);
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,216 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.jboss.test.crashrecovery.taskdefs.ClientAction;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Ant task for executing a chunk of java code. The interface name of the code to be executed is specified
+ * the impl field:
+ * @see ClientAction
+ *
+ * It the task completes successfully "Passed" is printed on system output, otherwise "Failed" is printed
+ */
+public class ASClientTask extends Task
+{
+ /**
+ * The text to print on standard output if the client action returned the expected result.
+ * Note that these values can be overridden on per task basis
+ * When running under the DTF the text should correspond values defined in the file
+ * nodeconfig.xml. The DTF TaskRunner controlling the test will search the output stream
+ * for this text to determine success or failure.
+ */
+ public static final String PASS = "Passed";
+ public static final String FAIL = "Failed";
+
+ private String impl;
+ private String waitFor;
+ private String name;
+ private String passText = PASS;
+ private String failText = FAIL;
+ private List<TaskProperty> params = new ArrayList<TaskProperty>();
+ private boolean abortOnFail = true;
+
+ public void execute() throws BuildException
+ {
+ ASTestConfig config = (ASTestConfig) getProject().getReference(ASTestConfig.CONFIG_REF);
+ Map<String, String> args = new HashMap<String, String> ();
+
+ for (TaskProperty param : params)
+ args.put(param.getKey(), param.getValue());
+
+ ClientAction action = null;
+
+ try
+ {
+ suspendFor(waitFor);
+
+ action = (ClientAction) Class.forName(impl).newInstance();
+ }
+ catch (ClassCastException e)
+ {
+ System.err.println("Class " + impl + " does not implement " + ClientAction.class.getName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ System.err.println("Cannot locate class " + impl);
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InstantiationException e)
+ {
+ System.err.println("Class " + impl + " cannot be instantiated: " + e.getMessage());
+ }
+
+ try
+ {
+ printResult(action.execute(config, args));
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error executing test: " + e.getMessage());
+ printResult(false);
+ }
+
+ }
+
+ private void printResult(boolean passed)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if (name != null)
+ {
+ sb.append(name).append(' ');
+ }
+
+ System.out.println(sb.append(passed ? passText : failText));
+
+ if (!passed && abortOnFail)
+ throw new BuildException("Test failed");
+ }
+
+ /**
+ * Suspend the calling thread
+ * @param millis the number of milli seconds to suspend for
+ * @return false if interupted
+ * @throws IllegalArgumentException if millis is not a number or negative
+ */
+ static boolean suspendFor(String millis) throws IllegalArgumentException
+ {
+ try
+ {
+ try
+ {
+ if (millis != null)
+ Thread.sleep(Integer.parseInt(millis));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+
+ return true;
+ }
+ catch (InterruptedException e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Task property to set the test name. This name will be printed when the test completes
+ * followed by a string to indicate pass or failure.
+ * see org.jboss.test.crashrecovery.taskdefs.ASClientTask.PASS
+ * @param name the name of the test.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ /**
+ * Task property to force the task to suspend before executing the client action
+ *
+ * @param waitFor the number of milli seconds to suspend - a null value means don't suspend
+ * @throws IllegalArgumentException if waitFor is not a number or is negative
+ */
+ public void setWaitFor(String waitFor) throws IllegalArgumentException
+ {
+ this.waitFor = waitFor;
+ }
+
+ public void setAbortOnFail(String abortOnFail)
+ {
+ this.abortOnFail = "true".equals(abortOnFail);
+ }
+
+ /**
+ * Task property containing the fully qualified class name of the action to execute.
+ * This class must contain an empty constructor and implement:
+ * @see ClientAction
+ *
+ * @param impl the class name of the action that this task will instantiate and run
+ */
+ public void setImpl(String impl)
+ {
+ this.impl = impl;
+ }
+
+ /**
+ * Task parameters that are passed into the execute method of the client action
+ *
+ * @param param a task parameter
+ */
+ public void addParam(TaskProperty param)
+ {
+ params.add(param);
+ }
+
+ /**
+ * Task property defaults to
+ * see org.jboss.test.crashrecovery.taskdefs.ASTestConfig.PASS
+ *
+ * @param passText the text to print if the test succeeds
+ */
+ public void setPassText(String passText)
+ {
+ this.passText = passText;
+ }
+
+ /**
+ * Task property to
+ * see org.jboss.test.crashrecovery.taskdefs.ASTestConfig.FAIL
+ *
+ * @param failText the text to print if the test succeeds
+ */
+ public void setFailText(String failText)
+ {
+ this.failText = failText;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,344 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.jbossas.servermanager.Server;
+import org.jboss.jbossas.servermanager.ServerManager;
+import org.xml.sax.SAXException;
+
+import javax.naming.NamingException;
+import javax.naming.Context;
+import javax.xml.transform.TransformerException;
+import javax.xml.parsers.ParserConfigurationException;
+import java.util.*;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Ant task for capturing common configuration for a group of tests
+ * defined in an ant build script.
+ */
+public class ASTestConfig extends Task
+{
+ // arbitary handle for refering to the unique instance of the task configuration
+ public static final String CONFIG_REF = "asTestConfig";
+ // the name of the system property holding the path the product directory
+ public final static String PRODUCT_DIR_PROP = "product.dir";
+ // the location of a JBoss distribution relative to the product directory
+ private final static String AS_ROOT_DIR = "/as/";
+
+ private List<ASFailureSpec> specs = new ArrayList<ASFailureSpec>();
+ private Map<String, ASFailureSpec> specMap = new HashMap<String, ASFailureSpec>();
+ private String productDir;
+ private boolean isDebug = false;
+ private ServerManager manager = new ServerManager();
+
+ public void execute() throws BuildException
+ {
+ System.setSecurityManager(new java.rmi.RMISecurityManager());
+
+ // The Task Runner should have set the product directory
+ productDir = System.getProperty(PRODUCT_DIR_PROP);
+
+ if (productDir == null)
+ throw new BuildException("Please specify the location of the product directory via the \""+ PRODUCT_DIR_PROP + "\" system property");
+
+ productDir = Utils.toFile(productDir).getAbsolutePath();
+
+ if (!productDir.endsWith("/"))
+ productDir += '/';
+
+ if (isDebug)
+ System.out.println("ASCrashConfig: productDir=" + productDir + " and jbossHome=" + manager.getJBossHome());
+
+ if (manager.getJBossHome() == null)
+ {
+ File jbh = Utils.toFile(productDir + AS_ROOT_DIR);
+
+ if (isDebug)
+ System.out.println("ASCrashConfig: jbh=" + jbh.getAbsolutePath() + " exists=" + jbh.exists());
+
+ if (jbh.exists())
+ setJbossHome(jbh.getAbsolutePath());
+ else
+ setJbossHome(System.getenv("JBOSS_HOME"));
+ }
+
+ // add this to the ant project so that other tasks are able to locate this
+ if (getProject().getReference(CONFIG_REF) == null)
+ getProject().addReference(CONFIG_REF, this);
+
+ ASFailureSpec[] sa = getSpecs();
+
+ // read in any failure specifications so that an ant target may look them up
+ for (ASFailureSpec fs : sa)
+ specMap.put(fs.getName(), fs);
+
+ if (isDebug)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("configuring ").append(specs.size()).append(" crash specifications:\n");
+
+ for (ASFailureSpec spec : specs)
+ {
+ sb.append("\t").append(spec).append('\n');
+ }
+
+ System.out.print(sb);
+ }
+ }
+
+ /**
+ * Task parameter to add a fault injection specification.
+ *
+ * @param spec definition of the fault
+ */
+ public void addSpec(ASFailureSpec spec)
+ {
+ specs.add(spec);
+ }
+
+ public ASFailureSpec getSpec(String spec)
+ {
+ return specMap.get(spec);
+ }
+
+ public ASFailureSpec[] getSpecs()
+ {
+ ASFailureSpec[] sa = new ASFailureSpec[specs.size()];
+
+ return specs.toArray(sa);
+ }
+
+ public ASFailureSpec[] parseSpecs(String specArg)
+ {
+ String[] specs = specArg.split(",");
+ ASFailureSpec[] fspecs = new ASFailureSpec[specs.length];
+
+ for (int i = 0; i < specs.length; i++)
+ fspecs[i] = getSpec(specs[i].trim());
+
+ return fspecs;
+ }
+
+ /**
+ * Task parameter to add a server.
+ *
+ * @param server the server
+ */
+ public void addServer(Server server)
+ {
+ manager.addServer(server);
+ }
+
+ /**
+ * JAVA_HOME to start jboss with.
+ *
+ * @param javaHome Path to the the java installation
+ */
+ public void setJavaHome(String javaHome)
+ {
+ manager.setJavaHome(javaHome);
+ }
+
+ public String getJBossHome()
+ {
+ return manager.getJBossHome();
+ }
+
+ /**
+ * JBoss dist to start. The default is to use the AS installed with the product.
+ * If no AS can be found then the environment variable JBOSS_HOME is used
+ *
+ * @param jbossHome Path to the the jboss installation
+ */
+ public void setJbossHome(String jbossHome)
+ {
+ manager.setJbossHome(jbossHome);
+ }
+
+ /**
+ * JVM command to use default is "java"
+ * @param jvm JVM command
+ */
+ public void setJvm(String jvm)
+ {
+ manager.setJvm(jvm);
+ }
+
+ /**
+ * The UDP group to pass to org.jboss.Main using
+ * the -u option.
+ *
+ * @param udpGroup the udp group
+ */
+ public void setUdpGroup(String udpGroup)
+ {
+ manager.setUdpGroup(udpGroup);
+ }
+
+ public void setDebug(boolean debug)
+ {
+ isDebug = debug;
+ }
+
+ /**
+ *
+ * @return the location where the product being tested is installed
+ */
+ public String getProductDir()
+ {
+ return productDir;
+ }
+
+ /**
+ * Return the nameing context that a given server is providing
+ *
+ * @param serverName the server providing the context
+ * @return a naming context
+ */
+ public Context getNamingContext(String serverName)
+ {
+ try
+ {
+ Server server = manager.getServer(serverName);
+
+ return (server != null ? server.getNamingContext() : null);
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ *
+ * @param serverName the name of the server whose path is being sought
+ * @return the path to the JBoss instance corresponding to the provided name
+ */
+ public String getServerPath(String serverName)
+ {
+ return getJBossHome() + "/server/" + serverName + '/';
+ }
+
+ /**
+ * Start a JBoss instance in a new VM
+ *
+ * @param serverName name of the target instance
+ * @throws IOException If another process is already using a port required by this instance
+ * @see org.jboss.jbossas.servermanager.ServerController#startServer(org.jboss.jbossas.servermanager.Server, org.jboss.jbossas.servermanager.ServerManager)
+ */
+ public void startServer(String serverName) throws IOException
+ {
+ Server server = manager.getServer(serverName);
+
+ // Warning !server.isRunning() is not equivalent to server.isStopped()
+ // !server.isRunning() and !server.isStopped() implies that some other entity terminated the server
+ if (!server.isRunning())
+ manager.startServer(serverName);
+ }
+
+ /**
+ * @see org.jboss.jbossas.servermanager.ServerController#stopServer(org.jboss.jbossas.servermanager.Server, org.jboss.jbossas.servermanager.ServerManager)
+ */
+ public void stopServer(String serverName) throws IOException
+ {
+ Server server = manager.getServer(serverName);
+
+ if (server.isRunning())
+ manager.stopServer(serverName);
+ }
+
+ /**
+ * Stop a group of servers. Any error stopping a server will logged and then the next one in the list will be tried.
+ *
+ * @param servers the names of the servers to be stopped
+ * @see ASTestConfig#stopServer(String)
+ */
+ public void stopServers(String ... servers)
+ {
+ for (String server : servers)
+ {
+ try
+ {
+ stopServer(server);
+ }
+ catch (IOException e)
+ {
+ System.err.println("Unable to stop server " + server);
+ }
+ }
+ }
+
+ public ServerManager getServerManager()
+ {
+ return manager;
+ }
+
+ /**
+ * Configure a target AS to start with a non-default set of bindings
+ *
+ * @param serverName the server whose bindings are being configured
+ * @throws TransformerException error parsing the server bindings xml file
+ * @throws IOException error whilst locating the bindings file in the file system
+ * @throws SAXException error parsing the server bindings xml file
+ * @throws ParserConfigurationException error parsing the server bindings xml file
+ */
+ public void configureServerBinding(String serverName) throws TransformerException, IOException, SAXException, ParserConfigurationException
+ {
+ Server server = manager.getServer(serverName);
+ String configHome = getProductDir();
+ String mbeanServiceFile = getServerPath(serverName) + "conf/jboss-service.xml";
+ String bindingName = server.getSysProperty("server.binding.name");
+ String bindingFile = server.getSysProperty("server.binding.location");
+
+ if (bindingFile == null)
+ return;
+
+ bindingFile = configHome + bindingFile;
+
+ // if bindingName is set then it is safe to check that the AS is up via the Naming service port
+ // BTW the AS5 team has changed the behavior of the naming service port - it is opened before
+ // all the services have been configured so any target deployments may not have been initialised
+ // when the server is declared as running. Instead we force the server to use a web server port to
+ // determine if the AS is running.
+ if (bindingName == null)
+ return;
+// bindingName = ServerBindingConfig.DEFAULT_BINDING;
+// else
+// server.setHasWebServer(true);
+
+ ServerBindingConfig.setBinding(mbeanServiceFile, bindingName, bindingFile);
+
+ server.setRmiPort(ServerBindingConfig.lookupRmiPort(bindingFile, bindingName, server.getRmiPort()));
+ server.setHttpPort(ServerBindingConfig.lookupHttpPort(bindingFile, bindingName, server.getHttpPort()));
+
+ System.out.println("Using: " + Context.PROVIDER_URL
+ + " = jnp://"+ server.getHost() + ':' + server.getRmiPort()
+ + " and http port " + server.getHttpPort());
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,49 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import java.util.Map;
+
+/**
+ * General mechanism for running code during the execution of an ant target
+ */
+public interface ClientAction
+{
+ /**
+ * Execute code in the context of an ant target
+ *
+ * @param config Configuration for this execution loaded from the ant script
+ * that triggered this action
+ * @param params Arbitary collection of name/value pairs passed in from the ant script
+ * that triggered this action
+ * @return true to indicate that the action completed successfully
+ * @see org.jboss.test.crashrecovery.taskdefs.ASClientTask
+ */
+ boolean execute(ASTestConfig config, Map<String, String> params);
+
+ /**
+ * Cancel any executing operation
+ *
+ * @return true if the opeartion was cancelled
+ * @throws UnsupportedOperationException Not implemented
+ */
+ boolean cancel() throws UnsupportedOperationException;
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,216 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.jboss.test.crashrecovery.taskdefs.ClientAction;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Ant task for executing a chunk of java code. The interface name of the code to be executed is specified
+ * the impl field:
+ * @see ClientAction
+ *
+ * It the task completes successfully "Passed" is printed on system output, otherwise "Failed" is printed
+ */
+public class ClientTask extends Task
+{
+ /**
+ * The text to print on standard output if the client action returned the expected result.
+ * Note that these values can be overridden on per task basis
+ * When running under the DTF the text should correspond values defined in the file
+ * nodeconfig.xml. The DTF TaskRunner controlling the test will search the output stream
+ * for this text to determine success or failure.
+ */
+ public static final String PASS = "Passed";
+ public static final String FAIL = "Failed";
+
+ private String impl;
+ private String waitFor;
+ private String name;
+ private String passText = PASS;
+ private String failText = FAIL;
+ private List<TaskProperty> params = new ArrayList<TaskProperty>();
+ private boolean abortOnFail = true;
+
+ public void execute() throws BuildException
+ {
+ ASTestConfig config = (ASTestConfig) getProject().getReference(ASTestConfig.CONFIG_REF);
+ Map<String, String> args = new HashMap<String, String> ();
+
+ for (TaskProperty param : params)
+ args.put(param.getKey(), param.getValue());
+
+ ClientAction action = null;
+
+ try
+ {
+ suspendFor(waitFor);
+
+ action = (ClientAction) Class.forName(impl).newInstance();
+ }
+ catch (ClassCastException e)
+ {
+ System.err.println("Class " + impl + " does not implement " + ClientAction.class.getName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ System.err.println("Cannot locate class " + impl);
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InstantiationException e)
+ {
+ System.err.println("Class " + impl + " cannot be instantiated: " + e.getMessage());
+ }
+
+ try
+ {
+ printResult(action.execute(config, args));
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error executing test: " + e.getMessage());
+ printResult(false);
+ }
+
+ }
+
+ private void printResult(boolean passed)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if (name != null)
+ {
+ sb.append(name).append(' ');
+ }
+
+ System.out.println(sb.append(passed ? passText : failText));
+
+ if (!passed && abortOnFail)
+ throw new BuildException("Test failed");
+ }
+
+ /**
+ * Suspend the calling thread
+ * @param millis the number of milli seconds to suspend for
+ * @return false if interupted
+ * @throws IllegalArgumentException if millis is not a number or negative
+ */
+ static boolean suspendFor(String millis) throws IllegalArgumentException
+ {
+ try
+ {
+ try
+ {
+ if (millis != null)
+ Thread.sleep(Integer.parseInt(millis));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+
+ return true;
+ }
+ catch (InterruptedException e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Task property to set the test name. This name will be printed when the test completes
+ * followed by a string to indicate pass or failure.
+ * see org.jboss.test.crashrecovery.taskdefs.ASClientTask.PASS
+ * @param name the name of the test.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ /**
+ * Task property to force the task to suspend before executing the client action
+ *
+ * @param waitFor the number of milli seconds to suspend - a null value means don't suspend
+ * @throws IllegalArgumentException if waitFor is not a number or is negative
+ */
+ public void setWaitFor(String waitFor) throws IllegalArgumentException
+ {
+ this.waitFor = waitFor;
+ }
+
+ public void setAbortOnFail(String abortOnFail)
+ {
+ this.abortOnFail = "true".equals(abortOnFail);
+ }
+
+ /**
+ * Task property containing the fully qualified class name of the action to execute.
+ * This class must contain an empty constructor and implement:
+ * @see ClientAction
+ *
+ * @param impl the class name of the action that this task will instantiate and run
+ */
+ public void setImpl(String impl)
+ {
+ this.impl = impl;
+ }
+
+ /**
+ * Task parameters that are passed into the execute method of the client action
+ *
+ * @param param a task parameter
+ */
+ public void addParam(TaskProperty param)
+ {
+ params.add(param);
+ }
+
+ /**
+ * Task property defaults to
+ * see org.jboss.test.crashrecovery.taskdefs.ASTestConfig.PASS
+ *
+ * @param passText the text to print if the test succeeds
+ */
+ public void setPassText(String passText)
+ {
+ this.passText = passText;
+ }
+
+ /**
+ * Task property to
+ * see org.jboss.test.crashrecovery.taskdefs.ASTestConfig.FAIL
+ *
+ * @param failText the text to print if the test succeeds
+ */
+ public void setFailText(String failText)
+ {
+ this.failText = failText;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,151 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Map;
+
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+/**
+ * General client action that can call JUnit based client tests
+ * and write their result to an xml report.
+ * @see JUnitClientTest
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public class JUnitClientAction implements ClientAction
+{
+ private boolean isDebug = false;
+
+
+ public boolean execute(ASTestConfig config, Map<String, String> params)
+ {
+ String testClass = null;
+ String name = "Test";
+ String serverName = "default";
+ String reportFile = null;
+
+ for (Map.Entry<String, String> me : params.entrySet())
+ {
+ String key = me.getKey().trim();
+ String val = me.getValue().trim();
+
+ if ("name".equals(key))
+ name = val;
+ else if ("serverName".equals(key))
+ serverName = val;
+ else if ("debug".equals(key))
+ isDebug = val.equalsIgnoreCase("true");
+ else if ("reportFile".equals(key))
+ reportFile = val;
+ else if ("testClass".equals(key))
+ testClass = val;
+ }
+
+ try
+ {
+ String serverPath = config.getServerPath(serverName);
+
+ TestResult result = new TestResult();
+
+ XMLJUnitResultFormatter resultFormatter = new XMLJUnitResultFormatter();
+
+ JUnitTest dummyJUnit = new JUnitTest(name);
+ resultFormatter.startTestSuite(dummyJUnit);
+
+ OutputStream writer = new FileOutputStream(new File(reportFile));
+ resultFormatter.setOutput(writer);
+
+ result.addListener(resultFormatter);
+
+ TestSuite suite = new TestSuite();
+
+
+ JUnitClientTest test = null;
+ try
+ {
+ test = (JUnitClientTest) Class.forName(testClass).newInstance();
+ }
+ catch (ClassCastException e)
+ {
+ System.err.println("Class " + testClass + " does not implement " + JUnitClientTest.class.getName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ System.err.println("Cannot locate class " + testClass);
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InstantiationException e)
+ {
+ System.err.println("Class " + testClass + " cannot be instantiated: " + e.getMessage());
+ }
+
+ test.setName("testCrashRecovery");
+ test.init(config, params, serverPath);
+
+ suite.addTest(test);
+
+ long startTime = new Date().getTime();
+ suite.run(result);
+ long endTime = new Date().getTime();
+
+ dummyJUnit.setCounts(result.runCount(), result.failureCount(), result.errorCount());
+ dummyJUnit.setRunTime(endTime - startTime);
+
+ resultFormatter.endTestSuite(dummyJUnit);
+
+ writer.close();
+
+ return result.wasSuccessful();
+ }
+ catch (Exception e)
+ {
+ if (isDebug)
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ }
+
+ public boolean cancel() throws UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ static void print(String msg)
+ {
+ System.out.println(msg);
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt 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.test.crashrecovery.taskdefs;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Abstract junit-based client test.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class JUnitClientTest extends TestCase
+{
+ protected ASTestConfig config = null;
+ protected Map<String, String> params = null;
+ protected String serverPath = null;
+
+ public JUnitClientTest()
+ {
+ super();
+ }
+
+ public JUnitClientTest(String name)
+ {
+ super(name);
+ }
+
+ public void init(ASTestConfig config, Map<String, String> params, String serverPath)
+ {
+ this.config = config;
+ this.params = params;
+ this.serverPath = serverPath;
+ }
+
+ /**
+ * The test method.
+ * Should be overridden.
+ */
+ public abstract void testCrashRecovery();
+
+
+ protected void print(String msg)
+ {
+ System.out.println(msg);
+ }
+
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,278 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.FileWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+
+/**
+ * Helper class to read a JBoss AS bindings file
+ */
+public class ServerBindingConfig
+{
+ private static final String BINDING_MANAGER_NAME = "jboss.system:service=ServiceBindingManager";
+ private static final String BINDING_MANAGER_CLASS = "org.jboss.services.binding.ServiceBindingManager";
+ private static final String STORE_FACTORY_CLASS = "org.jboss.services.binding.XMLServicesStoreFactory";
+ public static final String DEFAULT_BINDING = "ports-01";
+
+ /**
+ * Configure an AS to start up with a non-default set of bindings.
+ *
+ * An mbean entry will be inserted into xmlFile with a name specified by bindingName.
+ * The file bindingXml will contain an entry with the name bindingName.
+ *
+ * @param xmlFile The file that is to recieve the binding service specification
+ * @param bindingName The name of the binding definition to use
+ * @param bindingXml file name of the file that contains a group of binding definitions
+ * @throws IOException
+ * @throws ParserConfigurationException
+ * @throws org.xml.sax.SAXException
+ * @throws TransformerException
+ */
+ public static void setBinding(String xmlFile, String bindingName, String bindingXml) throws IOException, ParserConfigurationException,
+ org.xml.sax.SAXException, TransformerException
+ {
+ String xmlFileName = Utils.toFile(xmlFile).getAbsolutePath();
+
+ System.out.println("update bindings:");
+ System.out.println("\tConf File: " + xmlFileName);
+ System.out.println("\tBinding File: " + bindingXml);
+ System.out.println("\tBinding Name: " + bindingName);
+
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ documentBuilderFactory.setValidating(false);
+
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document doc1 = documentBuilder.parse(xmlFileName);
+ Document doc2 = documentBuilder.newDocument();
+
+ doc2.appendChild(doc2.createElement("server"));
+
+ NodeList children = doc1.getDocumentElement().getChildNodes();
+ Node server2 = doc2.getDocumentElement();
+
+ // add an mbean entry for the server binding
+ server2.appendChild(createBinding(doc2, bindingName, bindingXml));
+
+ for (int i=0; i< children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if ("mbean".equals(child.getNodeName()))
+ {
+ String name = ((Element) child).getAttribute("name");
+
+ // ignore the original binding since we are creating a new one
+ if (BINDING_MANAGER_NAME.equals(name))
+ continue;
+ }
+
+ // take a detached copy of the node and add it to the new document
+ Node copy = doc2.importNode(child, true).cloneNode(true);
+
+ server2.appendChild(copy);
+ }
+
+ printDocument(doc2, xmlFileName);
+ }
+
+ private static Element createBinding(Document document, String binding, String bindingXml)
+ {
+ Element mbean = document.createElement("mbean");
+
+ mbean.setAttribute("code", BINDING_MANAGER_CLASS);
+ mbean.setAttribute("name", BINDING_MANAGER_NAME);
+
+ mbean.appendChild(createMbeanAttribute(document, "ServerName", binding));
+ mbean.appendChild(createMbeanAttribute(document, "StoreURL", bindingXml));
+ mbean.appendChild(createMbeanAttribute(document, "StoreFactoryClassName", STORE_FACTORY_CLASS));
+
+ return mbean;
+ }
+
+ private static Element createMbeanAttribute(Document document, String name, String cdata)
+ {
+ Element element = document.createElement("attribute");
+
+ element.setAttribute("name", name);
+ element.setTextContent(cdata);
+
+ return element;
+ }
+
+ public static void printDocument(Document document, String fname){
+ try{
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ DOMSource source = new DOMSource(document);
+ StreamResult result;
+
+ if (fname == null)
+ result = new StreamResult(System.out);
+ else
+ result = new StreamResult(new FileWriter(fname));
+
+ transformer.transform(source, result);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private static Document getDocument(String xmlFile)
+ {
+ Document doc = null;
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+
+ documentBuilderFactory.setNamespaceAware(true);
+ documentBuilderFactory.setValidating(false);
+
+ try
+ {
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ doc = documentBuilder.parse(xmlFile);
+ }
+ catch (ParserConfigurationException e)
+ {
+ System.out.println("Unable to locate an XML doc builder: " + e.getMessage());
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error parsing " + xmlFile + ' ' + e.getMessage());
+ }
+
+ return doc;
+ }
+
+ public static Node findServiceConfig(String bindingsFile, String server, String service)
+ {
+ Document doc = getDocument(bindingsFile);
+
+ if (doc == null)
+ return null;
+
+ Node node = findNode(doc.getDocumentElement(), "server", "name", server);
+
+ return (node != null ? findNode(node, "service-config", "name", service) : null);
+ }
+
+ public static String findBindingPort(Node node)
+ {
+ node = findNode(node, "binding", "port", null);
+
+ return (node != null ? ((Element) node).getAttribute("port") : null);
+ }
+
+ private static int parseInt(String intValue, int defValue, String errMsg)
+ {
+ try
+ {
+ return (intValue != null ? Integer.parseInt(intValue) : defValue);
+ }
+ catch (NumberFormatException e)
+ {
+ if (errMsg != null)
+ System.out.println(errMsg);
+
+ return defValue;
+ }
+ }
+
+ public static int lookupHttpPort(String bindingsFile, String server, int defValue)
+ {
+ Node node = findServiceConfig(bindingsFile, server, "jboss:service=invoker,type=http");
+ String port = findBindingPort(node);
+
+ return parseInt(port, defValue, "Invalid port found in service-config for binding " + server);
+ }
+
+ public static int lookupRmiPort(String bindingsFile, String server, int defValue)
+ {
+ Node node = findServiceConfig(bindingsFile, server, "jboss:service=Naming");
+ String port = findBindingPort(node);
+
+ return parseInt(port, defValue, "Invalid port found in service-config for binding " + server);
+ }
+
+ /**
+ * Find a node with a given name and having a specified attribute
+ * @param node the node to start the search from
+ * @param nodeName the name of the xml node to look for the attribute
+ * @param attrName the name of the attribute to match against
+ * @param attrValue the value of the attribute to match against. If null
+ * the first matching node with an attribute called attrName is returned
+ * @return the matching node
+ */
+ private static Node findNode(Node node, String nodeName, String attrName, String attrValue)
+ {
+ if (node != null)
+ {
+ NodeList children = node.getChildNodes();
+
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if (nodeName.equals(child.getNodeName()))
+ {
+ // found a node of the correct type - now see if it has the given attribute
+ String value = ((Element) child).getAttribute(attrName);
+
+ if (attrName == null || attrValue == null || value.equals(attrValue))
+ return child;
+ }
+ }
+
+ System.out.println("Node of type " + nodeName + " with " + attrName + '=' + attrValue + " not found");
+ }
+
+ return null;
+ }
+
+ public static void main(String[] args) throws IOException, ParserConfigurationException,
+ org.xml.sax.SAXException, TransformerException
+ {
+ if (args.length >= 3) {
+ setBinding(args[0], args[1], args[2]);
+ } else if (args.length == 2) {
+ System.out.println("Rmi port: " + lookupRmiPort(args[0], args[1], -1));
+ System.out.println("Http port: " + lookupHttpPort(args[0], args[1], -1));
+ } else {
+ System.out.println("syntax: ServerBindingConfig <conf file path> <server binding name> <path of bindings file>");
+ }
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,228 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.jboss.jbossas.servermanager.Server;
+import org.jboss.jbossas.servermanager.ServerManager;
+import org.xml.sax.SAXException;
+
+import javax.xml.transform.TransformerException;
+import javax.xml.parsers.ParserConfigurationException;
+import java.util.ArrayList;
+import java.io.*;
+
+public class ServerTask extends Task
+{
+ /** the method name for starting a server */
+ public static final String START = "start";
+ public static final String STOP = "stop";
+ public static final String DEPLOY = "deploy";
+ public static final String UNDEPLOY = "undeploy";
+
+ private ArrayList<TaskProperty> deployArtifacts = new ArrayList<TaskProperty>();
+ private ArrayList<TaskProperty> undeployArtifacts = new ArrayList<TaskProperty>();
+ private String method;
+ private String serverName;
+ private String waitFor;
+
+ public void execute() throws BuildException
+ {
+ String[] servers = serverName.split(",");
+
+ try
+ {
+ if (START.equals(method))
+ startServers(servers);
+ else if (STOP.equals(method))
+ stopServers(servers);
+ else if (DEPLOY.equals(method))
+ deploy(servers);
+ else if (UNDEPLOY.equals(method))
+ undeploy(servers);
+
+ if (waitFor != null)
+ ASClientTask.suspendFor(waitFor);
+ }
+ catch (ServerTaskException e)
+ {
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ * Specify which server operation is being requested
+ * @param method currently supported methods are "start" and "stop"
+ */
+ public void setMethod(String method)
+ {
+ this.method = method;
+ }
+
+ /** the name of the server to operate on */
+ public void setServerName(String serverName)
+ {
+ this.serverName = serverName;
+ }
+
+ /** suspend after performing the task - useful for deploy operations */
+ public void setWaitFor(String waitFor)
+ {
+ this.waitFor = waitFor;
+ }
+
+ /** list of artifacts that should be deployed to this server **/
+ public void addDeploy(TaskProperty arg)
+ {
+ deployArtifacts.add(arg);
+ }
+
+ /** list of artifacts that should be undeployed from this server **/
+ public void addUndeploy(TaskProperty arg)
+ {
+ undeployArtifacts.add(arg);
+ }
+
+ private void stopServers(String ... servers) throws ServerTaskException
+ {
+ ASTestConfig config = (ASTestConfig) getProject().getReference(ASTestConfig.CONFIG_REF);
+
+ for (String name : servers)
+ {
+ try
+ {
+ config.getServerManager().stopServer(name);
+ }
+ catch (IOException e)
+ {
+ throw new ServerTaskException("Error stoping server " + name);
+ }
+ }
+
+ undeploy(servers);
+ }
+
+ private void startServers(String ... servers) throws ServerTaskException
+ {
+ ASTestConfig config = (ASTestConfig) getProject().getReference(ASTestConfig.CONFIG_REF);
+
+ deploy(servers);
+
+ for (String name : servers)
+ {
+ try
+ {
+ config.getServerManager().startServer(name);
+ }
+ catch (IOException e)
+ {
+ throw new ServerTaskException("Error starting server " + name);
+ }
+ }
+ }
+
+ private void deploy(String ... servers) throws ServerTaskException
+ {
+ ASTestConfig config = (ASTestConfig) getProject().getReference(ASTestConfig.CONFIG_REF);
+ String configHome = config.getProductDir();
+
+ // configure the AS to start with a non-default set of bindings
+ for (String name : servers)
+ {
+ // make sure the server config exists
+ config.getServerManager().getServer(name);
+ // update its bindings if required
+ try
+ {
+ config.configureServerBinding(name);
+ }
+ catch (Exception e)
+ {
+ throw new ServerTaskException("Error configuring binding for server " + name, e);
+ }
+
+ // deploy any artifacts required by this test
+ try
+ {
+ deploy(deployArtifacts, configHome, config.getServerPath(name));
+ deploy(undeployArtifacts, config.getServerPath(name), configHome);
+ }
+ catch (IOException e)
+ {
+ throw new ServerTaskException("Error deploying artifacts to server " + name, e);
+ }
+ }
+ }
+
+ private void undeploy(String ... servers) throws ServerTaskException
+ {
+ deploy(servers);
+ }
+
+ // deploy any artifacts required by this test
+ private void deploy(ArrayList<TaskProperty> artifacts, String srcDir, String dstDir) throws IOException
+ {
+ for (TaskProperty artifact : artifacts)
+ {
+ File from = Utils.toFile(srcDir + artifact.getFrom());
+
+ if (artifact.getTo() == null)
+ {
+ // delete the artifact
+ System.out.println("Deleting artifact " + from.getAbsolutePath());
+ from.delete();
+ }
+ else if (!from.exists())
+ {
+ System.out.println("Deployment source " + from.getAbsolutePath() + " does not exist");
+ }
+ else
+ {
+ File to = Utils.toFile(dstDir + artifact.getTo());
+
+ if (to.isDirectory())
+ to = new File(to.getAbsolutePath() + '/' + from.getName());
+
+ if (!to.getParentFile().exists())
+ {
+ // to.mkdirs() is too presumtuous
+ System.out.println("Deployment target directory " + to.getParent() + " does not exist");
+ }
+ else
+ {
+ System.out.println("copying from " + from.getAbsolutePath() + " to " + to.getAbsolutePath());
+
+ InputStream in = new FileInputStream(from);
+ OutputStream out = new FileOutputStream(to);
+ byte[] buf = new byte[1024];
+ int len;
+
+ while ((len = in.read(buf)) > 0)
+ out.write(buf, 0, len);
+
+ in.close();
+ out.close();
+ }
+ }
+ }
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,76 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import java.util.Collection;
+import java.util.ArrayList;
+
+public class ServerTaskException extends Exception
+{
+ Collection<String> errors = new ArrayList<String> ();
+ Exception cause;
+
+ public ServerTaskException()
+ {
+ }
+
+ public ServerTaskException(String message)
+ {
+ super(message);
+ }
+
+ public ServerTaskException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ServerTaskException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public void addError(String error)
+ {
+ errors.add(error);
+ }
+
+ public void setCause(Exception cause)
+ {
+ this.cause = cause;
+ }
+
+ public ServerTaskException getServerTaskException()
+ {
+ if (cause == null && errors.size() == 0)
+ return this;
+
+ StringBuilder msg = new StringBuilder();
+ String nl = System.getProperty("line.separator");
+
+ for (String error : errors)
+ {
+ msg.append(error).append(nl);
+ }
+
+ //noinspection ThrowableInstanceNeverThrown
+ return new ServerTaskException(msg.toString(), cause);
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,72 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+/**
+ * Key/value holder for passing in parameters to custom ant tasks
+ */
+public class TaskProperty
+{
+ private String key;
+ private String value;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ // add some syntactic sugar to make specific use of properties more intuitive
+
+ public String getFrom()
+ {
+ return key;
+ }
+
+ public void setFrom(String from)
+ {
+ this.key = from;
+ }
+
+ public String getTo()
+ {
+ return value;
+ }
+
+ public void setTo(String to)
+ {
+ this.value = to;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,39 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+/**
+ * Value holder for passing in parameters to custom ant tasks
+ */
+public class TaskValue
+{
+ String value;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,164 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.gandiva.ClassName;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.AtomicAction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Utility class for interaction with a transaction log
+ */
+public class TransactionLog
+{
+ /**
+ * Default object type for store operations
+ */
+ public static final String DEFAULT_OBJECT_TYPE = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
+
+ private ObjectStore store;
+
+ public TransactionLog(String storeDir, String impleType)
+ {
+ init(storeDir, impleType);
+ }
+
+ private void init(String storeDir, String impleType)
+ {
+ System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", storeDir);
+
+ if (impleType != null)
+ store = new ObjectStore(new ClassName(impleType), (String) null);
+ else
+ store = new ObjectStore();
+ }
+
+ /**
+ * Remove any committed objects from the storer
+ * @param objectType the type of objects that should be removed
+ * @return the number of objects that were purged
+ * @throws ObjectStoreException the store implementation was unable to remove a committed object
+ */
+ public int clearXids(String objectType) throws ObjectStoreException
+ {
+ Collection<Uid> uids = getIds(objectType);
+
+ for (Uid uid : uids)
+ store.remove_committed(uid, objectType);
+
+ return uids.size();
+ }
+
+ public Collection<Uid> getIds(String objectType) throws ObjectStoreException
+ {
+ return getIds(null, objectType);
+ }
+
+ /**
+ * Get a list object ids for a given object type
+ *
+ * @param ids holder for the returned uids
+ * @param objectType The type of object to search in the store for
+ * @return all objects of the given type
+ * @throws ObjectStoreException the store implementation was unable retrieve all types of objects
+ */
+ public Collection<Uid> getIds(Collection<Uid> ids, String objectType) throws ObjectStoreException
+ {
+ if (ids == null)
+ ids = new ArrayList<Uid> ();
+
+
+ InputObjectState types = new InputObjectState();
+
+ if (store.allTypes(types))
+ {
+ String theName;
+
+ try
+ {
+ boolean endOfList = false;
+
+ while (!endOfList)
+ {
+ theName = types.unpackString();
+
+ if (theName.compareTo("") == 0)
+ endOfList = true;
+ else
+ {
+ if (objectType != null && !theName.equals(objectType))
+ continue;
+
+ InputObjectState uids = new InputObjectState();
+
+ if (store.allObjUids(theName, uids))
+ {
+ try
+ {
+ boolean endOfUids = false;
+
+ while (!endOfUids)
+ {
+ Uid theUid = new Uid(Uid.nullUid());
+ theUid.unpack(uids);
+
+ if (theUid.equals(Uid.nullUid()))
+ endOfUids = true;
+ else
+ ids.add(theUid);
+ }
+ }
+ catch (Exception e)
+ {
+ // end of uids!
+ }
+ }
+
+ System.out.println();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ System.err.println(e);
+
+ // end of list!
+ }
+ }
+
+ return ids;
+ }
+
+ public int getStatus(Uid uid)
+ {
+ AtomicAction action = new AtomicAction(uid);
+
+ action.activate();
+
+ return action.status();
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,40 @@
+/*
+ * 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.test.crashrecovery.taskdefs;
+
+import java.io.File;
+import java.io.IOException;
+
+public class Utils
+{
+ public static File toFile(String fileName)
+ {
+ try
+ {
+ return new File(fileName).getCanonicalFile();
+ }
+ catch (IOException e)
+ {
+ return new File(fileName).getAbsoluteFile();
+ }
+ }
+
+}
Added: trunk/testsuite/src/resources/crashrecovery/META-INF/persistence.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/META-INF/persistence.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/META-INF/persistence.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence">
+ <persistence-unit name="ejb3">
+ <jta-data-source>java:/CrashRecoveryDS</jta-data-source>
+ <properties>
+ <property name="jboss.entity.manager.jndi.name" value="java:/CrashRecoveryManager" />
+ <property name="jboss.entity.manager.factory.jndi.name"
+ value="java:/CrashRecoveryManagerFactory" />
+ <property name="hibernate.hbm2ddl.auto" value="update"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: trunk/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- Thanks to Horia Muntean <horia at bvb.ro> -->
+<!-- ===================================================================== -->
+
+<!-- $Id: db2-xa-ds.xml 77479 2008-08-26 10:33:09Z alex.loubyansky at jboss.com $ -->
+
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
+
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+
+ <!-- Note, as opposed to the Type2 driver, DB2 Type 4 requires the PortNumber. By default this is 50000-->
+ <xa-datasource-property name="PortNumber">50000</xa-datasource-property>
+ <xa-datasource-property name="ServerName">vmg06.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="DriverType">4</xa-datasource-property>
+
+ <!-- If driverType 4 is used, the following two tags are needed -->
+ <track-connection-by-tx></track-connection-by-tx>
+ <!-- Must be set if using multiple DB2 XA resources in same transaction -->
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <no-tx-separate-pools></no-tx-separate-pools>
+
+ <!-- uncomment to enable interleaving <interleaving/> -->
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
+ <metadata>
+ <type-mapping>DB2</type-mapping>
+ </metadata>
+ </xa-datasource>
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/java.policy
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/java.policy (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/java.policy 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,3 @@
+grant {
+ permission java.security.AllPermission;
+};
Added: trunk/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: mssql-xa-ds.xml 77479 2008-08-26 10:33:09Z alex.loubyansky at jboss.com $ -->
+ <!-- ==================================================================== -->
+ <!-- ConnectionManager setup for xa Microsoft SQL Server 2005, using -->
+ <!-- Microsoft's JDBC driver. -->
+ <!-- Thanks to Benjamin Geer <benjamin.geer at misys.com> -->
+ <!-- Be sure to set the JndiName property to the name you want to look up -->
+ <!-- the datasource under and set the location of your database in -->
+ <!-- the xa-datasource-property section. -->
+ <!-- Further information about the Microsoft JDBC Driver version 1.1 -->
+ <!-- can be found here: -->
+ <!-- http://msdn2.microsoft.com/en-us/library/aa496082.aspx -->
+ <!-- ==================================================================== -->
+
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">dev30.qa.atl.jboss.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">3918</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>MS SQLSERVER2000</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: mssql-xa-ds.xml 77479 2008-08-26 10:33:09Z alex.loubyansky at jboss.com $ -->
+ <!-- ==================================================================== -->
+ <!-- ConnectionManager setup for xa Microsoft SQL Server 2005, using -->
+ <!-- Microsoft's JDBC driver. -->
+ <!-- Thanks to Benjamin Geer <benjamin.geer at misys.com> -->
+ <!-- Be sure to set the JndiName property to the name you want to look up -->
+ <!-- the datasource under and set the location of your database in -->
+ <!-- the xa-datasource-property section. -->
+ <!-- Further information about the Microsoft JDBC Driver version 1.1 -->
+ <!-- can be found here: -->
+ <!-- http://msdn2.microsoft.com/en-us/library/aa496082.aspx -->
+ <!-- ==================================================================== -->
+
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg04.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">1433</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>MS SQLSERVER2000</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
+<!-- Datasource config for MySQL using 3.0.9 available from:
+http://www.mysql.com/downloads/api-jdbc-stable.html
+-->
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg08.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">3306</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
+ <!-- sql to call when connection is created
+ <new-connection-sql>some arbitrary sql</new-connection-sql>
+ -->
+ <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>mySQL</type-mapping>
+ </metadata>
+ </xa-datasource>
+</datasources>
+
Added: trunk/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
+<!-- Datasource config for MySQL using 3.0.9 available from:
+http://www.mysql.com/downloads/api-jdbc-stable.html
+-->
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg02.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">3306</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
+ <!-- sql to call when connection is created
+ <new-connection-sql>some arbitrary sql</new-connection-sql>
+ -->
+ <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>mySQL</type-mapping>
+ </metadata>
+ </xa-datasource>
+</datasources>
+
Added: trunk/testsuite/src/resources/crashrecovery/resources/oracle10-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/oracle10-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/oracle10-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: oracle-xa-ds.xml 71535 2008-04-01 07:05:03Z adrian at jboss.org $ -->
+
+<!-- ===================================================================== -->
+<!-- ATTENTION: DO NOT FORGET TO SET Pad=true IN transaction-service.xml -->
+<!-- ===================================================================== -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ <xa-datasource-property name="URL">jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
+ <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <!-- Checks the Oracle error codes and messages for fatal errors -->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+ <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
+ <no-tx-separate-pools/>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>Oracle9i</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: oracle-xa-ds.xml 71535 2008-04-01 07:05:03Z adrian at jboss.org $ -->
+
+<!-- ===================================================================== -->
+<!-- ATTENTION: DO NOT FORGET TO SET Pad=true IN transaction-service.xml -->
+<!-- ===================================================================== -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ <xa-datasource-property name="URL">jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:qaora11</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
+ <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <!-- Checks the Oracle error codes and messages for fatal errors -->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+ <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
+ <no-tx-separate-pools/>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>Oracle9i</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg01.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <!--xa-datasource-property name="ServerName">dev01.qa.atl.jboss.com</xa-datasource-property-->
+ <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ </xa-datasource>
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg03.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ </xa-datasource>
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,1370 @@
+<!--
+ $Id: sample-bindings.xml 71362 2008-03-27 22:38:50Z clebert.suconic at jboss.com $
+
+ A sample configuration for the binding service which defines different
+ port configurations (ports-default, ports-01, ports-02) for running multiple
+ JBoss instances in parallel on the same machine.
+
+ The actual port configuration can be selected within the jboss-service.xml
+ file via ServiceBindingManager attribute ServerName.
+
+ The following sample e.g. selects the jboss-default port configuration
+
+ <mbean code="org.jboss.services.binding.ServiceBindingManager"
+ name="jboss.system:service=ServiceBindingManager">
+ <attribute name="ServerName">ports-default</attribute>
+ <attribute name="StoreURL">file:../server/port-bindings.xml</attribute>
+ <attribute name="StoreFactoryClassName">
+ org.jboss.services.binding.XMLServicesStoreFactory
+ </attribute>
+ </mbean>
+
+ For running a second server instance you have to change the port
+ bindings of that instance by specifing an alternative port binding
+ configuration in the jboss-service.xml of the second server, e.g.
+
+ <attribute name="ServerName">ports-01</attribute>
+
+ Additional documentation for running multiple JBoss instances on the
+ same machine can be found at http://www.jboss.com/products/jbossas/docs
+ in the offical JBoss Application Server Guide in chapter
+ "MBean Service Miscellany - Services Binding Management"
+-->
+<service-bindings>
+
+ <!-- ********************************************************** -->
+ <!-- * ports-default * -->
+ <!-- ********************************************************** -->
+ <server name="ports-default">
+
+ <!-- ********************* jboss-service.xml ****************** -->
+
+ <service-config name="jboss:service=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" hostName="BindAddress">
+ <attribute name="RmiPort">1098</attribute>
+ </delegate-config>
+ <binding port="1099" host="${jboss.bind.address}"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=WebService"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="8083"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=jrmp"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4444"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=pooled"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <!-- don't care for now -->
+ <binding port="0"/>
+ </service-config>
+
+
+ <!-- ********************* cluster-service.xml **************** -->
+
+ <service-config name="jboss:service=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="Port">
+ <attribute name="RmiPort">1101</attribute>
+ </delegate-config>
+ <binding port="1100"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=jrmpha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4445"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=pooledha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="4448"/>
+ </service-config>
+
+ <!-- ********************* iiop-service.xml ****************** -->
+
+ <service-config name="jboss:service=CorbaORB"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="3528"/>
+ </service-config>
+
+
+ <!-- ********************* jmx-rmi-adaptor.sar **************** -->
+
+ <service-config name="jboss.jmx:type=Connector,name=RMI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="19001"/>
+ </service-config>
+
+
+ <!-- ********************* snmp-adaptor.sar ****************** -->
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1162"/>
+ </service-config>
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1161"/>
+ </service-config>
+
+ <!-- ********************* jbossmq-service.xml **************** -->
+
+ <!-- JMS related services -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8093"/>
+ </service-config>
+
+ <service-config name="jboss.mq:service=InvocationLayer,type=OIL"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8090"/>
+ </service-config>
+
+
+ <!-- ********************* jbossmq-httpil.sar **************** -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="URLPort"/>
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
+ <!-- EJBInvoker -->
+ <service-config name="jboss:service=invoker,type=http"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- readonly JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- **************** httpha-invoker.sar*************** -->
+ <!-- EJBInvokerHA -->
+ <service-config name="jboss:service=invoker,type=httpHA"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- JMXInvokerHA -->
+ <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8080"/>
+ </service-config>
+
+
+ <!-- ********************* jbossws.sar **************** -->
+
+ <!-- Web Service related services -->
+ <service-config name="jboss.ws:service=ServiceEndpointManager"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="WebServicePort" hostName="WebServiceHost">
+ <attribute name="WebServiceSecurePort">8443</attribute>
+ </delegate-config>
+ <binding port="8080" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <!-- ********************* remoting **************** -->
+
+ <service-config name="jboss.remoting:service=JMXConnectorServer,protocol=rmi"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RegistryPort" hostName="BindAddress"/>
+ <binding port="1090" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="InvokerLocator">socket://0.0.0.0:3873</attribute>
+ </delegate-config>
+ </service-config>
+
+ <!-- *** remoting connector *** -->
+ <service-config name="jboss.remoting:service=Connector,transport=socket"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
+ <delegate-config>
+ <xslt-config configName="Configuration"><![CDATA[
+ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="attribute[@name='serverBindPort']">
+ <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="4446" />
+ </service-config>
+
+
+ <!-- ********************* hsqldb-ds.xml ********************** -->
+
+ <!-- Hypersonic related services when using the tcp/ip access
+ <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="host"/>
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="config-property[@name='ConnectionURL']">
+ <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
+]]>
+ </xslt-config>
+ </delegate-config>
+ <binding host="localhost" port="1701" />
+ </service-config>
+
+ <service-config name="jboss:service=Hypersonic"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" />
+ <binding port="1701" />
+ </service-config>
+ -->
+
+ <!-- jbossweb-tomcat50.sar -->
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTFileDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ConfigFile"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8080"/>
+ </service-config>
+
+ <!-- ********************* jbossweb-tomcat.sar *****************
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="Config"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8080"/>
+ </service-config>
+-->
+
+ <!-- ********************* jboss messaging ********************** -->
+
+ <service-config name="jboss.messaging:service=Connector,transport=bisocket"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="Configuration"><![CDATA[
+ <config>
+ <invoker transport="bisocket">
+ <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="dataType" isParam="true">jms</attribute>
+ <attribute name="socket.check_connection" isParam="true">false</attribute>
+ <attribute name="timeout" isParam="true">0</attribute>
+ <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
+ <attribute name="serverBindPort">4457</attribute>
+ <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
+ <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
+ <attribute name="numberOfCallRetries" isParam="true">1</attribute>
+ <attribute name="pingFrequency" isParam="true">214748364</attribute>
+ <attribute name="pingWindowFactor" isParam="true">10</attribute>
+ <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
+ <attribute name="stopLeaseOnFailure" isParam="true">true</attribute>
+ <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
+ <attribute name="numberOfRetries" isParam="true">10</attribute>
+ <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
+ <attribute name="callbackTimeout">10000</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
+ </handlers>
+ </config>
+ ]]></attribute>
+ </delegate-config>
+ <binding port="4457"/>
+ </service-config>
+
+ </server>
+
+
+ <!-- ********************************************************** -->
+ <!-- * ports-01 * -->
+ <!-- ********************************************************** -->
+ <server name="ports-01">
+
+ <!-- ********************* jboss-service.xml ****************** -->
+
+ <service-config name="jboss:service=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" hostName="BindAddress">
+ <attribute name="RmiPort">1198</attribute>
+ </delegate-config>
+ <binding port="1199" host="${jboss.bind.address}"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=WebService"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="8183"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=jrmp"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4544"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=pooled"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <!-- don't care for now -->
+ <binding port="0"/>
+ </service-config>
+
+ <!-- ********************* cluster-service.xml **************** -->
+
+ <service-config name="jboss:service=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="Port">
+ <attribute name="RmiPort">1201</attribute>
+ </delegate-config>
+ <binding port="1200"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=jrmpha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4545"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=pooledha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="4548"/>
+ </service-config>
+
+ <!-- ********************* iiop-service.xml ****************** -->
+
+ <service-config name="jboss:service=CorbaORB"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="3628"/>
+ </service-config>
+
+
+ <!-- ********************* jmx-rmi-adaptor.sar **************** -->
+
+ <service-config name="jboss.jmx:type=Connector,name=RMI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="19101"/>
+ </service-config>
+
+
+ <!-- ********************* snmp-adaptor.sar ****************** -->
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1262"/>
+ </service-config>
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1261"/>
+ </service-config>
+
+ <!-- ********************* jbossmq-service.xml **************** -->
+
+ <!-- JMS related services -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8193"/>
+ </service-config>
+
+ <service-config name="jboss.mq:service=InvocationLayer,type=OIL"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8190"/>
+ </service-config>
+
+
+ <!-- ********************* jbossmq-httpil.sar **************** -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="URLPort"/>
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
+ <!-- EJBInvoker -->
+ <service-config name="jboss:service=invoker,type=http"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- readonly JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- **************** httpha-invoker.sar*************** -->
+ <!-- EJBInvokerHA -->
+ <service-config name="jboss:service=invoker,type=httpHA"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- JMXInvokerHA -->
+ <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8180"/>
+ </service-config>
+
+
+
+ <!-- ********************* jbossws.sar **************** -->
+
+ <!-- Web Service related services -->
+ <service-config name="jboss.ws:service=ServiceEndpointManager"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="WebServicePort" hostName="WebServiceHost">
+ <attribute name="WebServiceSecurePort">8543</attribute>
+ </delegate-config>
+ <binding port="8180" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <!-- ********************* remoting **************** -->
+
+ <service-config name="jboss.remoting:service=JMXConnectorServer,protocol=rmi"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RegistryPort" hostName="BindAddress"/>
+ <binding port="1190" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="InvokerLocator">socket://0.0.0.0:3973</attribute>
+ </delegate-config>
+ </service-config>
+
+ <!-- *** remoting connector *** -->
+ <service-config name="jboss.remoting:service=Connector,transport=socket"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
+ <delegate-config>
+ <xslt-config configName="Configuration"><![CDATA[
+ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="attribute[@name='serverBindPort']">
+ <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="5446" />
+ </service-config>
+
+ <!-- ********************* hsqldb-ds.xml ********************** -->
+
+ <!-- Hypersonic related services
+
+ Only if using TCP setup (local file setup by default)
+
+ <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="host"/>
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="config-property[@name='ConnectionURL']">
+ <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
+]]>
+ </xslt-config>
+ </delegate-config>
+ <binding host="localhost" port="1801" />
+ </service-config>
+
+ <service-config name="jboss:service=Hypersonic"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" />
+ <binding port="1801" />
+ </service-config>
+
+ -->
+
+ <!-- jbossweb-tomcat50.sar -->
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTFileDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ConfigFile"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8180"/>
+ </service-config>
+
+ <!-- ********************* jbossweb-tomcat41.sar *****************
+
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="Config"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8180" />
+ </service-config>
+ -->
+
+ <!-- ********************* jboss messaging ********************** -->
+
+ <service-config name="jboss.messaging:service=Connector,transport=bisocket"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="Configuration"><![CDATA[
+ <config>
+ <invoker transport="bisocket">
+ <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="dataType" isParam="true">jms</attribute>
+ <attribute name="socket.check_connection" isParam="true">false</attribute>
+ <attribute name="timeout" isParam="true">0</attribute>
+ <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
+ <attribute name="serverBindPort">4557</attribute>
+ <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
+ <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
+ <attribute name="numberOfCallRetries" isParam="true">1</attribute>
+ <attribute name="pingFrequency" isParam="true">214748364</attribute>
+ <attribute name="pingWindowFactor" isParam="true">10</attribute>
+ <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
+ <attribute name="stopLeaseOnFailure" isParam="true">true</attribute>
+ <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
+ <attribute name="numberOfRetries" isParam="true">10</attribute>
+ <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
+ <attribute name="callbackTimeout">10000</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
+ </handlers>
+ </config>
+ ]]></attribute>
+ </delegate-config>
+ <binding port="4557"/>
+ </service-config>
+
+ </server>
+
+
+ <!-- ********************************************************** -->
+ <!-- * ports-02 * -->
+ <!-- ********************************************************** -->
+ <server name="ports-02">
+
+ <!-- ********************* jboss-service.xml ****************** -->
+
+ <service-config name="jboss:service=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" hostName="BindAddress">
+ <attribute name="RmiPort">1298</attribute>
+ </delegate-config>
+ <binding port="1299" host="${jboss.bind.address}"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=WebService"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="8283"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=jrmp"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4644"/>
+ </service-config>
+
+
+ <service-config name="jboss:service=invoker,type=pooled"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <!-- don't care for now -->
+ <binding port="0"/>
+ </service-config>
+
+ <!-- ********************* cluster-service.xml **************** -->
+
+ <service-config name="jboss:service=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="Port">
+ <attribute name="RmiPort">1301</attribute>
+ </delegate-config>
+ <binding port="1300"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=jrmpha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="4645"/>
+ </service-config>
+
+ <service-config name="jboss:service=invoker,type=pooledha"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="4648"/>
+ </service-config>
+
+ <!-- ********************* iiop-service.xml ****************** -->
+
+ <service-config name="jboss:service=CorbaORB"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="3728"/>
+ </service-config>
+
+
+ <!-- ********************* jmx-rmi-adaptor.sar **************** -->
+
+ <service-config name="jboss.jmx:type=Connector,name=RMI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="RMIObjectPort"/>
+ <binding port="19201"/>
+ </service-config>
+
+
+ <!-- ********************* snmp-adaptor.sar ****************** -->
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1362"/>
+ </service-config>
+
+ <service-config name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port"/>
+ <binding port="1361"/>
+ </service-config>
+
+ <!-- ********************* jbossmq-service.xml **************** -->
+
+ <!-- JMS related services -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=UIL2"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8293"/>
+ </service-config>
+
+ <service-config name="jboss.mq:service=InvocationLayer,type=OIL"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="ServerBindPort"/>
+ <binding port="8290"/>
+ </service-config>
+
+
+ <!-- ********************* jbossmq-httpil.sar **************** -->
+ <service-config name="jboss.mq:service=InvocationLayer,type=HTTP"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="URLPort"/>
+ <binding port="8280"/>
+ </service-config>
+
+ <!-- **************** http-invoker.sar & httpha-invoker.sar*************** -->
+ <!-- EJBInvoker -->
+ <service-config name="jboss:service=invoker,type=http"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8280"/>
+ </service-config>
+
+ <!-- JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8280"/>
+ </service-config>
+
+ <!-- readonly JMXInvoker -->
+ <service-config name="jboss:service=invoker,type=http,target=Naming,readonly=true"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/readonly/JMXInvokerServlet</attribute>
+ </delegate-config>
+ <!--
+ MUST BE THE SAME AS
+ TOMCAT HTTP CONNECTOR BELOW !!!
+ -->
+ <binding port="8280"/>
+ </service-config>
+
+ <!-- **************** httpha-invoker.sar*************** -->
+ <!-- EJBInvokerHA -->
+ <service-config name="jboss:service=invoker,type=httpHA"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/EJBInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8280"/>
+ </service-config>
+
+ <!-- JMXInvokerHA -->
+ <service-config name="jboss:service=invoker,type=http,target=HAJNDI"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config>
+ <attribute name="InvokerURLSuffix">:${port}/invoker/JMXInvokerHAServlet</attribute>
+ </delegate-config>
+ <binding port="8280"/>
+ </service-config>
+
+
+ <!-- ********************* jbossws.sar **************** -->
+
+ <!-- Web Service related services -->
+ <service-config name="jboss.ws:service=ServiceEndpointManager"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="WebServicePort" hostName="WebServiceHost">
+ <attribute name="WebServiceSecurePort">8643</attribute>
+ </delegate-config>
+ <binding port="8280" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <!-- ********************* remoting **************** -->
+
+ <service-config name="jboss.remoting:service=JMXConnectorServer,protocol=rmi"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config portName="RegistryPort" hostName="BindAddress"/>
+ <binding port="1290" host="${jboss.bind.address}"/>
+ </service-config>
+
+ <service-config name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="InvokerLocator">socket://0.0.0.0:4073</attribute>
+ </delegate-config>
+ </service-config>
+
+ <!-- *** remoting connector *** -->
+ <service-config name="jboss.remoting:service=Connector,transport=socket"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate">
+ <delegate-config>
+ <xslt-config configName="Configuration"><![CDATA[
+ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="attribute[@name='serverBindPort']">
+ <attribute type="java.lang.String" name="serverBindPort"><xsl:value-of select='$port'/></attribute>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="6446" />
+ </service-config>
+
+
+ <!-- ********************* hsqldb-ds.xml ********************** -->
+
+ <!-- Hypersonic related services
+
+ Only if using TCP setup (local file setup by default)
+
+ <service-config name="jboss.jca:service=ManagedConnectionFactory,name=DefaultDS"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ManagedConnectionFactoryProperties"><![CDATA[
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="host"/>
+ <xsl:param name="port"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="config-property[@name='ConnectionURL']">
+ <config-property type="java.lang.String" name="ConnectionURL">jdbc:hsqldb:hsql://<xsl:value-of select='$host'/>:<xsl:value-of select='$port'/></config-property>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>
+]]>
+ </xslt-config>
+ </delegate-config>
+ <binding host="localhost" port="1901" />
+ </service-config>
+
+ <service-config name="jboss:service=Hypersonic"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
+ >
+ <delegate-config portName="Port" />
+ <binding port="1901" />
+ </service-config>
+
+ -->
+
+ <!-- jbossweb-tomcat50.sar -->
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTFileDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="ConfigFile"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8280"/>
+ </service-config>
+
+ <!-- ********************* jbossweb-tomcat.sar *****************
+
+ <service-config name="jboss.web:service=WebServer"
+ delegateClass="org.jboss.services.binding.XSLTConfigDelegate"
+ >
+ <delegate-config>
+ <xslt-config configName="Config"><![CDATA[
+ <xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+ <xsl:output method="xml" />
+ <xsl:param name="port"/>
+
+ <xsl:variable name="portAJP" select="$port - 71"/>
+ <xsl:variable name="portHttps" select="$port + 363"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match = "Connector">
+ <Connector>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="(name() = 'port' and . = '8080')">
+ <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8009')">
+ <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'redirectPort')">
+ <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="(name() = 'port' and . = '8443')">
+ <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:apply-templates/>
+ </Connector>
+ </xsl:template>
+
+ <xsl:template match="*|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ </xsl:stylesheet>
+ ]]>
+ </xslt-config>
+ </delegate-config>
+ <binding port="8280" />
+ </service-config>
+ -->
+
+ <!-- ********************* jboss messaging ********************** -->
+
+ <service-config name="jboss.messaging:service=Connector,transport=bisocket"
+ delegateClass="org.jboss.services.binding.AttributeMappingDelegate">
+ <delegate-config>
+ <attribute name="Configuration"><![CDATA[
+ <config>
+ <invoker transport="bisocket">
+ <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+ <attribute name="dataType" isParam="true">jms</attribute>
+ <attribute name="socket.check_connection" isParam="true">false</attribute>
+ <attribute name="timeout" isParam="true">0</attribute>
+ <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
+ <attribute name="serverBindPort">4657</attribute>
+ <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
+ <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
+ <attribute name="numberOfCallRetries" isParam="true">1</attribute>
+ <attribute name="pingFrequency" isParam="true">214748364</attribute>
+ <attribute name="pingWindowFactor" isParam="true">10</attribute>
+ <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
+ <attribute name="stopLeaseOnFailure" isParam="true">true</attribute>
+ <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
+ <attribute name="numberOfRetries" isParam="true">10</attribute>
+ <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
+ <attribute name="callbackTimeout">10000</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
+ </handlers>
+ </config>
+ ]]></attribute>
+ </delegate-config>
+ <binding port="4657"/>
+ </service-config>
+
+ </server>
+
+</service-bindings>
Added: trunk/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- Thanks to kosulin in the forumns -->
+<!-- ===================================================================== -->
+
+<!-- $Id: sybase-xa-ds.xml 85945 2009-03-16 19:45:12Z dimitris at jboss.org $ -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <xa-datasource-class>com.sybase.jdbc3.jdbc.SybXADataSource</xa-datasource-class>
+ <xa-datasource-property name="NetworkProtocol">Tds</xa-datasource-property>
+ <xa-datasource-property name="ServerName">dev01.qa.atl.jboss.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">4100</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <min-pool-size>1</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <idle-timeout-minutes>15</idle-timeout-minutes>
+ <!--check-valid-connection-sql>select 1 from mytable</check-valid-connection-sql-->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.SybaseExceptionSorter</exception-sorter-class-name>
+ <type-mapping>Sybase</type-mapping>
+
+ </xa-datasource>
+
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- Thanks to kosulin in the forumns -->
+<!-- ===================================================================== -->
+
+<!-- $Id: sybase-xa-ds.xml 85945 2009-03-16 19:45:12Z dimitris at jboss.org $ -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <xa-datasource-class>com.sybase.jdbc3.jdbc.SybXADataSource</xa-datasource-class>
+ <xa-datasource-property name="NetworkProtocol">Tds</xa-datasource-property>
+ <xa-datasource-property name="ServerName">dev77.qa.atl2.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">4100</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <min-pool-size>1</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <idle-timeout-minutes>15</idle-timeout-minutes>
+ <!--check-valid-connection-sql>select 1 from mytable</check-valid-connection-sql-->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.SybaseExceptionSorter</exception-sorter-class-name>
+ <type-mapping>Sybase</type-mapping>
+
+ </xa-datasource>
+
+</datasources>
Added: trunk/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+ <!-- RECOVERY destinations -->
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=recovery">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
+ <attribute name="SecurityConf">
+ <security>
+ <role name="guest" read="true" write="true" create="true"/>
+ </security>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Topic"
+ name="jboss.mq.destination:service=Topic,name=recoveryTopic">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
+ <attribute name="SecurityConf">
+ <security>
+ <role name="guest" read="true" write="true" create="true"/>
+ </security>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Topic"
+ name="jboss.mq.destination:service=Topic,name=recoveryDurableTopic">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
+ <attribute name="SecurityConf">
+ <security>
+ <role name="guest" read="true" write="true" create="true"/>
+ </security>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=recoveryQueue">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
+ <attribute name="SecurityConf">
+ <security>
+ <role name="guest" read="true" write="true" create="true"/>
+ </security>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=rcvQ">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
+ <attribute name="SecurityConf">
+ <security>
+ <role name="guest" read="true" write="true" create="true"/>
+ </security>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=sndQ">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+<!--
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ <attribute name="SecurityConf">
+ <security>
+ <role name="guest" read="true" write="true" create="true"/>
+ </security>
+ </attribute>
+-->
+ </mbean>
+
+
+</server>
+
Added: trunk/testsuite/src/resources/crashrecovery/scripts/README.txt
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/scripts/README.txt (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/scripts/README.txt 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,18 @@
+This directory contains ant build scripts for running TS tests with an AS under
+the DTF framework.
+
+To add new tests you may either add new targets to an existing script or write
+a new script. For an example of how to run a target under DTF please refer to
+the test selection jbossts-qa-as-crashrecovery01-testdefs.xml located in
+the testdefs directory.
+
+These tests normally run as part of the DTF test suite. To run them in
+standalone mode you will need define a security policy and override the ant
+property product.dir (which controls where the tests will search for product
+resources) as follows:
+ export ANT_OPTS="-Djava.security.policy=../src/org/jboss/jbossts/qa/astests/resources/java.policy
+-Dproduct.dir=../../build/"
+
+If the target product directory does not contain a directory called 'as'
+containing a JBOSS installation then the environment variable JBOSS_HOME will
+be used.
Added: trunk/testsuite/src/resources/crashrecovery/scripts/as-tests.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/scripts/as-tests.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/scripts/as-tests.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,565 @@
+<?xml version="1.0"?>
+
+<project name="crashrecovery-tests" default="crash-tests" basedir="."
+ xmlns:astest="http://jboss.org/ns/test/ant/astest">
+
+ <property environment="env"/>
+ <property name="jboss.home" value="${env.JBOSS_HOME}"/>
+ <property name="product.dir" value="${env.DTF_HOME}/JBossTS-JTA-QA/"/>
+
+ <property name="astest.jar.dir" value="${product.dir}/qa/resources"/>
+ <property name="astest.jar.name" value="astest.jar"/>
+ <property name="astest.jar.deploy.dir" value="qa/lib"/>
+
+ <property name="node0" value="localhost" />
+ <property name="node1" value="192.168.1.106" />
+
+ <property name="driver.home" value="${product.dir}/dbdrivers"/>
+
+ <!--
+ import configuration settings for the tests
+ -->
+ <import file="imports/test-config.xml"/>
+
+
+ <!--
+ Main targets intended for JBossAS Testsuite optional task
+ -->
+ <target name="crash-tests" depends="want-all-dbs, want-all-tstypes, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
+
+ <target name="crash-tests-single-db" depends="set-db, want-all-tstypes, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
+
+ <target name="crash-tests-single-db-tstype" depends="set-db, set-tstype, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
+
+ <target name="crash-tests-single" depends="init, prepare-drivers, set-db, set-tstype, set-tsdemarc, set-testcase, crash-tests-tstype-jta, crash-tests-tstype-jts" />
+
+
+ <!--
+ Other targets...
+ -->
+ <target name="init">
+ <echo message="jboss.home=${jboss.home}"/>
+ <property name="wipeOutTxsInDoubt" value="true" />
+ </target>
+
+ <target name="set-db">
+ <condition property="want.psql_8.2">
+ <equals arg1="${crash.db}" arg2="psql_8.2"/>
+ </condition>
+ <condition property="want.psql_8.3">
+ <equals arg1="${crash.db}" arg2="psql_8.3"/>
+ </condition>
+ <condition property="want.sybase_15">
+ <equals arg1="${crash.db}" arg2="sybase_15"/>
+ </condition>
+ <condition property="want.oracle_10">
+ <equals arg1="${crash.db}" arg2="oracle_10"/>
+ </condition>
+ <condition property="want.oracle_11">
+ <equals arg1="${crash.db}" arg2="oracle_11"/>
+ </condition>
+ <condition property="want.db2_9.7">
+ <equals arg1="${crash.db}" arg2="db2_9.7"/>
+ </condition>
+ <condition property="want.mysql_5.0">
+ <equals arg1="${crash.db}" arg2="mysql_5.0"/>
+ </condition>
+ <condition property="want.mysql_5.1">
+ <equals arg1="${crash.db}" arg2="mysql_5.1"/>
+ </condition>
+ <condition property="want.mssql_2005">
+ <equals arg1="${crash.db}" arg2="mssql_2005"/>
+ </condition>
+ <condition property="want.mssql_2008">
+ <equals arg1="${crash.db}" arg2="mssql_2008"/>
+ </condition>
+ </target>
+
+ <target name="want-all-dbs">
+ <property name="want.psql_8.2" value="true" />
+ <property name="want.psql_8.3" value="true" />
+ <property name="want.sybase_15" value="true" />
+ <property name="want.oracle_10" value="true" />
+ <property name="want.oracle_11" value="true" />
+ <property name="want.db2_9.7" value="true" />
+ <property name="want.mysql_5.0" value="true" />
+ <property name="want.mysql_5.1" value="true" />
+ <property name="want.mssql_2005" value="true" />
+ <property name="want.mssql_2008" value="true" />
+ <!-- DEPRECATED property name="want.sybase_12" value="true" /-->
+ <!-- DEPRECATED property name="want.db2_8.2" value="true" /-->
+ </target>
+
+ <target name="set-tstype">
+ <condition property="want.tstype.jta">
+ <equals arg1="${crash.tstype}" arg2="jta"/>
+ </condition>
+ <condition property="want.tstype.jts">
+ <equals arg1="${crash.tstype}" arg2="jts"/>
+ </condition>
+ </target>
+
+ <target name="want-all-tstypes">
+ <property name="want.tstype.jta" value="true" />
+ <property name="want.tstype.jts" value="true" />
+ </target>
+
+ <target name="set-tsdemarc">
+ <condition property="want.cmt">
+ <equals arg1="${crash.tsdemarc}" arg2="cmt"/>
+ </condition>
+ <condition property="want.bmt">
+ <equals arg1="${crash.tsdemarc}" arg2="bmt"/>
+ </condition>
+ </target>
+
+ <target name="want-all-tsdemarc">
+ <property name="want.cmt" value="true" />
+ <property name="want.bmt" value="true" />
+ </target>
+
+ <target name="set-testcase">
+ <condition property="want.none">
+ <equals arg1="${crash.testcase}" arg2="none"/>
+ </condition>
+ <condition property="want.none.rev">
+ <equals arg1="${crash.testcase}" arg2="none.rev"/>
+ </condition>
+ <condition property="want.prepare_ex">
+ <equals arg1="${crash.testcase}" arg2="prepare_ex"/>
+ </condition>
+ <condition property="want.prepare_ex.rev">
+ <equals arg1="${crash.testcase}" arg2="prepare_ex.rev"/>
+ </condition>
+ <condition property="want.prepare_halt">
+ <equals arg1="${crash.testcase}" arg2="prepare_halt"/>
+ </condition>
+ <condition property="want.prepare_halt.rev">
+ <equals arg1="${crash.testcase}" arg2="prepare_halt.rev"/>
+ </condition>
+ <condition property="want.commit_halt">
+ <equals arg1="${crash.testcase}" arg2="commit_halt"/>
+ </condition>
+ <condition property="want.commit_halt.rev">
+ <equals arg1="${crash.testcase}" arg2="commit_halt.rev"/>
+ </condition>
+ </target>
+
+ <target name="want-all-testcases">
+ <property name="want.prepare_ex" value="true" />
+ <property name="want.prepare_ex.rev" value="true" />
+ <property name="want.prepare_halt" value="true" />
+ <property name="want.prepare_halt.rev" value="true" />
+ <property name="want.commit_halt.rev" value="true" />
+ </target>
+
+
+ <target name="crash-tests-tstype-jta" if="want.tstype.jta">
+ <antcall target="call-tests-for-all-dbs"><param name="tstype" value="jta"/><param name="call.target" value="crash-tests-for-database"/></antcall>
+ </target>
+
+ <target name="crash-tests-tstype-jts" if="want.tstype.jts">
+ <antcall target="call-tests-for-all-dbs"><param name="tstype" value="jts"/><param name="call.target" value="crash-tests-for-database"/></antcall>
+ </target>
+
+ <target name="call-tests-for-all-dbs">
+ <antcall target="call-tests-for-psql_8.2"/>
+ <antcall target="call-tests-for-psql_8.3"/>
+ <antcall target="call-tests-for-oracle_10"/>
+ <antcall target="call-tests-for-oracle_11"/>
+ <antcall target="call-tests-for-mssql_2005"/>
+ <antcall target="call-tests-for-mssql_2008"/>
+ <antcall target="call-tests-for-mysql_5.0"/>
+ <antcall target="call-tests-for-mysql_5.1"/>
+ <antcall target="call-tests-for-db2_9.7"/>
+ <antcall target="call-tests-for-sybase_15"/>
+ </target>
+
+ <target name="call-tests-for-psql_8.2" if="want.psql_8.2">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="postgresql-8.2.jar"/>
+ <param name="datasource" value="postgres82-xa-ds.xml" />
+ <param name="dbname" value="psql82" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-psql_8.3" if="want.psql_8.3">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="postgresql-8.3.jar"/>
+ <param name="datasource" value="postgres83-xa-ds.xml" />
+ <param name="dbname" value="psql83" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-oracle_10" if="want.oracle_10">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="ojdbc14.jar"/>
+ <param name="datasource" value="oracle10-xa-ds.xml" />
+ <param name="dbname" value="oracle10" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-oracle_11" if="want.oracle_11">
+ <!-- Oracle has qot different .jar for jdk 1.5 vs. 1.6 runtime -->
+ <condition property="oracle.driver" value="ojdbc6.jar">
+ <equals arg1="${java.specification.version}" arg2="1.6"/>
+ </condition>
+ <property name="oracle.driver" value="ojdbc5.jar"/>
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="${oracle.driver}"/>
+ <param name="datasource" value="oracle11-xa-ds.xml" />
+ <param name="dbname" value="oracle11" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mssql_2005" if="want.mssql_2005">
+ <!-- MSSQL needs different .jar for jdk 1.5 vs. 1.6 runtime -->
+ <condition property="mssql.driver" value="sqljdbc4.jar">
+ <equals arg1="${java.specification.version}" arg2="1.6"/>
+ </condition>
+ <property name="mssql.driver" value="sqljdbc.jar"/>
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="${mssql.driver}"/>
+ <param name="datasource" value="mssql2005-xa-ds.xml" />
+ <param name="dbname" value="mssql2005" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mssql_2008" if="want.mssql_2008">
+ <!-- MSSQL needs different .jar for jdk 1.5 vs. 1.6 runtime -->
+ <condition property="mssql.driver" value="sqljdbc4.jar">
+ <equals arg1="${java.specification.version}" arg2="1.6"/>
+ </condition>
+ <property name="mssql.driver" value="sqljdbc.jar"/>
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="${mssql.driver}"/>
+ <param name="datasource" value="mssql2008-xa-ds.xml" />
+ <param name="dbname" value="mssql2008" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mysql_5.0" if="want.mysql_5.0">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="mysql-connector-java-5.0.8.jar"/>
+ <param name="datasource" value="mysql50-xa-ds.xml" />
+ <param name="dbname" value="mysql50" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mysql_5.1" if="want.mysql_5.1">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="mysql-connector-java-5.1.7.jar"/>
+ <param name="datasource" value="mysql51-xa-ds.xml" />
+ <param name="dbname" value="mysql51" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-db2_8.2" if="want.db2_8.2">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="DB2_v8.2_fp14/db2jcc*.jar"/>
+ <param name="datasource" value="db2_82-xa-ds.xml" />
+ <param name="dbname" value="db2_82" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-db2_9.7" if="want.db2_9.7">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="db2jcc.jar" />
+ <param name="datasource" value="db2_97-xa-ds.xml" />
+ <param name="dbname" value="db2_9" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-sybase_12" if="want.sybase_12">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="jconn3.jar"/>
+ <param name="datasource" value="sybase12-xa-ds.xml" />
+ <param name="dbname" value="sybase12" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-sybase_15" if="want.sybase_15">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="jconn3.jar"/>
+ <param name="datasource" value="sybase15-xa-ds.xml" />
+ <param name="dbname" value="sybase15" />
+ </antcall>
+ </target>
+
+ <target name="crash-tests-for-database" depends="crash-tests-for-database-cmt, crash-tests-for-database-bmt" />
+
+ <target name="crash-tests-for-database-cmt" if="want.cmt">
+ <antcall target="crash-tests-all-testcases"><param name="cmt" value="true" /></antcall>
+ </target>
+
+ <target name="crash-tests-for-database-bmt" if="want.bmt">
+ <antcall target="crash-tests-all-testcases"><param name="cmt" value="false" /></antcall>
+ </target>
+
+
+ <target name="crash-tests-all-testcases"
+ depends="testcase-none,
+ testcase-none-rev,
+ testcase-prepare_ex,
+ testcase-prepare_ex-rev,
+ testcase-prepare_halt,
+ testcase-prepare_halt-rev,
+ testcase-commit_halt-rev" />
+
+ <target name="testcase-none" if="want.none">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="none"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-none-rev" if="want.none.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="none"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_ex" if="want.prepare_ex">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_ex"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_ex-rev" if="want.prepare_ex.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_ex"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_halt" if="want.prepare_halt">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_halt"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_halt-rev" if="want.prepare_halt.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_halt"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-commit_halt-rev" if="want.commit_halt.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="commit_halt"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-commit_halt" if="want.commit_halt">
+ <!-- DISABLED test-case: this test scenario is invalid for the current version of JBossTS -->
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="commit_halt"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="execute-crash-recovery-test" depends="hack-before-astest-run, crash-recovery-test, hack-after-astest-run" />
+
+ <!--
+ Note: If you want to wipe out txs in doubt before and after test you have to set property 'wipeOutTxsInDoubt' to true.
+ -->
+ <target name="crash-recovery-test">
+<!-- <attribute name="specs"/>
+ <attribute name="datasource"/>
+ <attribute name="dbdriver"/>
+ <attribute name="dbname"/>
+ <attribute name="cmt"/>
+ <attribute name="tstype"/>
+ <attribute name="reverseOrder"/>
+ <attribute name="rollbackExpected"/> -->
+ <sequential>
+
+ <condition property="test.name.cmt" value="cmt" else="bmt">
+ <istrue value="${cmt}"/>
+ </condition>
+ <condition property="test.name.reverseOrder" value="-reverse" else="">
+ <istrue value="${reverseOrder}"/>
+ </condition>
+ <property name="testname" value="${tstype}-${specs}-${test.name.cmt}${test.name.reverseOrder}"/>
+
+ <condition property="astest.app.jar.name" value="${astest.alternative.jar.name}">
+ <isset property="astest.alternative.jar.name"/>
+ </condition>
+ <property name="astest.app.jar.name" value="${astest.jar.name}" />
+
+ <condition property="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/ArjunaTransactionImple">
+ <equals arg1="${tstype}" arg2="jts" />
+ </condition>
+ <property name="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction" />
+
+ <astest:server method="start" serverName="crashrecovery-${tstype}" >
+ <deploy from="dbdrivers/${dbdriver}" to="lib/${dbdriver}" />
+ <deploy from="resources/${datasource}" to="deploy/${datasource}" />
+ <deploy from="${astest.jar.deploy.dir}/${astest.app.jar.name}" to="deploy/${astest.app.jar.name}" />
+ </astest:server>
+ <astest:action abortOnFail="false" waitFor="10000" impl="org.jboss.test.crashrecovery.taskdefs.JUnitClientAction">
+ <param key="testClass" value="org.jboss.test.crashrecovery.ASCrashRecovery01.TestWithJPA" />
+ <param key="name" value="${dbname}-${testname}" />
+ <param key="serverName" value="crashrecovery-${tstype}" />
+ <param key="specs" value="${specs}" />
+ <param key="cmt" value="${cmt}" />
+ <param key="storeType" value="${storeType}" />
+ <param key="reverseOrder" value="${reverseOrder}" />
+ <param key="rollbackExpected" value="${rollbackExpected}" />
+ <param key="wipeOutTxsInDoubtBeforeTest" value="${wipeOutTxsInDoubtBeforeTest}" />
+ <param key="wipeOutTxsInDoubt" value="${wipeOutTxsInDoubt}" />
+ <param key="debug" value="true" />
+ <param key="reportFile" value="${build.reports}/TEST-org.jboss.test.crashrecovery.ASCrashRecovery01.TestWithJPA-${dbname}-${testname}.xml" />
+ <param key="testTime" value="${testTime}" />
+ </astest:action>
+ <astest:server method="stop" serverName="crashrecovery-${tstype}" >
+ <undeploy from="deploy/${astest.app.jar.name}" />
+ <undeploy from="deploy/${datasource}" />
+ <undeploy from="lib/${dbdriver}" />
+ </astest:server>
+
+ <!-- archive the server log -->
+ <zip destfile="${jboss.home}/server/crashrecovery-${tstype}/log/server-${dbname}-${testname}.log.zip">
+ <fileset file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
+ </zip>
+ <delete file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
+ <copy todir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store-${dbname}-${testname}">
+ <fileset dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store" />
+ </copy>
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store"/>
+ <!-- delete work and tmp dirs otherwise tests failed due to permgen space - FIXME is this the right way how to ensure that? -->
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/work"/>
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/tmp"/>
+
+ </sequential>
+ </target>
+
+ <target name="hack-before-astest-run" depends="hack-before-astest-run-for-db2_9.7" />
+
+ <target name="hack-after-astest-run" depends="hack-after-astest-run-for-db2_9.7" />
+
+ <target name="hack-before-astest-run-for-db2_9.7" if="want.db2_9.7">
+ <!-- deploy license .jar file -->
+ <copy file="${product.dir}/dbdrivers/db2jcc_license_cu.jar" todir="${jboss.home}/server/crashrecovery-${tstype}/lib" />
+
+ <!-- prepare hacked astest jar -->
+ <property name="astest.alternative.jar.name" value="db2-${astest.jar.name}" />
+
+ <available file="${astest.jar.dir}/${astest.alternative.jar.name}"
+ property="have.db2.astest.alternative.jar" />
+ <antcall target="prepare-db2-alternative-jar" />
+
+ </target>
+
+ <target name="prepare-db2-alternative-jar" unless="have.db2.astest.alternative.jar">
+ <mkdir dir="${astest.jar.dir}/${astest.alternative.jar.name}_content"/>
+ <unjar src="${astest.jar.dir}/${astest.jar.name}" dest="${astest.jar.dir}/${astest.alternative.jar.name}_content" />
+ <available file="${astest.jar.dir}/${astest.alternative.jar.name}_content/META-INF/persistence.xml"
+ property="have.persistence.xml" />
+ <antcall target="change-hbm2ddl-update-to-none" />
+ <jar destfile="${astest.jar.dir}/${astest.alternative.jar.name}">
+ <fileset dir="${astest.jar.dir}/${astest.alternative.jar.name}_content"/>
+ </jar>
+ <delete dir="${astest.jar.dir}/${astest.alternative.jar.name}_content" />
+ </target>
+
+ <target name="change-hbm2ddl-update-to-none" if="have.persistence.xml">
+ <replace file="${astest.jar.dir}/${astest.alternative.jar.name}_content/META-INF/persistence.xml" summary="true">
+ <replacetoken><![CDATA[name="hibernate.hbm2ddl.auto" value="update"]]></replacetoken>
+ <replacevalue><![CDATA[name="hibernate.hbm2ddl.auto" value="none" ]]></replacevalue>
+ </replace>
+ </target>
+
+ <target name="hack-after-astest-run-for-db2_9.7" if="want.db2_9.7">
+ <!-- undeploy license .jar file -->
+ <delete file="${jboss.home}/server/crashrecovery-${tstype}/lib/db2jcc_license_cu.jar" />
+ </target>
+
+
+
+ <!--
+ Do use this target if you want to wipe out txs in doubt in all databases.
+ -->
+ <target name="wipeout-txs-indoubt-all-dbs" depends="want-all-dbs, wipeout-txs-indoubt-single-db" />
+
+ <!--
+ Do use this target if you want to wipe out txs in doubt.
+ You can select the databases by setting crash.db property, see target set-db.
+ -->
+ <target name="wipeout-txs-indoubt-single-db" depends="set-db, prepare-drivers">
+ <property name="tstype" value="jta" />
+ <antcall target="call-tests-for-all-dbs"><param name="call.target" value="execute-wipeout-txs-indoubt"/></antcall>
+ </target>
+
+ <target name="execute-wipeout-txs-indoubt" depends="hack-before-astest-run, wipeout-txs-indoubt, hack-after-astest-run"/>
+
+ <target name="wipeout-txs-indoubt">
+ <condition property="astest.app.jar.name" value="${astest.alternative.jar.name}">
+ <isset property="astest.alternative.jar.name"/>
+ </condition>
+ <property name="astest.app.jar.name" value="${astest.jar.name}" />
+
+ <astest:server method="start" serverName="crashrecovery-jta" >
+ <deploy from="dbdrivers/${dbdriver}" to="lib/${dbdriver}" />
+ <deploy from="resources/${datasource}" to="deploy/${datasource}" />
+ <deploy from="${astest.jar.deploy.dir}/${astest.app.jar.name}" to="deploy/${astest.app.jar.name}" />
+ </astest:server>
+ <astest:action abortOnFail="false" waitFor="10000" impl="org.jboss.test.crashrecovery.taskdefs.JUnitClientAction">
+ <param key="testClass" value="org.jboss.test.crashrecovery.ASCrashRecovery01.WipeOutTxsInDoubt" />
+ <param key="name" value="test-wipeout-txs-indoubt-${dbname}" />
+ <param key="serverName" value="crashrecovery-${tstype}" />
+ <param key="debug" value="true" />
+ <param key="reportFile" value="${build.reports}/TEST-org.jboss.test.crashrecovery.ASCrashRecovery01.WipeOutTxsInDoubt-${dbname}.xml" />
+ </astest:action>
+ <astest:server method="stop" serverName="crashrecovery-jta" >
+ <undeploy from="deploy/${datasource}" />
+ <undeploy from="lib/${dbdriver}" />
+ <undeploy from="deploy/${astest.app.jar.name}" />
+ </astest:server>
+ </target>
+
+
+ <!-- ===== get db drivers - borrowed from https://svn.jboss.org/repos/labs/labs/jbosstm/trunk/qa/build.xml ==== -->
+ <!-- set these to the location(s) of the database drivers -->
+
+ <property name="driver.url" value="http://reports.qa.atl.jboss.com/jdbc-drivers/"/>
+
+ <target name="prepare-drivers">
+ <available file="${driver.home}" property="have.dbdrivers" value="true"/>
+ <antcall target="get.drivers" />
+ </target>
+
+ <target name="get.drivers" unless="have.dbdrivers">
+
+ <mkdir dir="${driver.home}" />
+
+ <get src="${driver.url}/maven2/com/oracle/ojdbc14/10.2.0.4/ojdbc14-10.2.0.4.jar"
+ dest="${driver.home}/ojdbc14.jar"/>
+ <get src="${driver.url}/maven2/com/oracle/ojdbc5/11.1.0.7.0/ojdbc5-11.1.0.7.0.jar"
+ dest="${driver.home}/ojdbc5.jar"/>
+ <get src="${driver.url}/maven2/com/oracle/ojdbc6/11.1.0.7.0/ojdbc6-11.1.0.7.0.jar"
+ dest="${driver.home}/ojdbc6.jar"/>
+
+ <get src="${driver.url}/maven2/com/microsoft/sqlserver/msjdbc/2.0.1008.2/msjdbc-2.0.1008.2.jar"
+ dest="${driver.home}/sqljdbc.jar"/>
+ <get src="${driver.url}/maven2/com/microsoft/sqlserver/msjdbc/2.0.1008.2/msjdbc-2.0.1008.2-4.jar"
+ dest="${driver.home}/sqljdbc4.jar"/>
+
+ <get src="${driver.url}/maven2/postgresql/postgresql/8.3-604/postgresql-8.3-604-jdbc4.jar"
+ dest="${driver.home}/postgresql-8.3.jar"/>
+ <get src="${driver.url}/maven2/postgresql/postgresql/8.2-504/postgresql-8.2-504-jdbc3.jar"
+ dest="${driver.home}/postgresql-8.2.jar"/>
+
+ <get src="${driver.url}/maven2/mysql/mysql-connector-java/5.1.7/mysql-connector-java-5.1.7.jar"
+ dest="${driver.home}/mysql-connector-java-5.1.7.jar"/>
+ <get src="${driver.url}/maven2/mysql/mysql-connector-java/5.0.8/mysql-connector-java-5.0.8.jar"
+ dest="${driver.home}/mysql-connector-java-5.0.8.jar"/>
+
+ <get src="${driver.url}/maven2/com/ibm/db2jcc/3.1.57/db2jcc-3.1.57.jar"
+ dest="${driver.home}/db2jcc.jar"/>
+ <get src="${driver.url}/maven2/com/ibm/db2jcc_license_cu/3.1.57/db2jcc_license_cu-3.1.57.jar"
+ dest="${driver.home}/db2jcc_license_cu.jar"/>
+
+ <get src="${driver.url}/maven2/com/sybase/jconnect/6.0.5/jconnect-6.0.5.jar"
+ dest="${driver.home}/jconn3.jar"/>
+
+ </target>
+
+</project>
Added: trunk/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml
===================================================================
--- trunk/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml (rev 0)
+++ trunk/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml 2009-09-16 19:28:39 UTC (rev 93624)
@@ -0,0 +1,80 @@
+<project name="crashrecovery-tests-server-config"
+ xmlns:astest="http://jboss.org/ns/test/ant/astest">
+
+ <taskdef name="config" classname="org.jboss.test.crashrecovery.taskdefs.ASTestConfig"
+ uri="http://jboss.org/ns/test/ant/astest" loaderref="astest.loader">
+ </taskdef>
+
+ <!--
+ - Task to start/stop servers with attribute for deploying and undeploying artifacts
+ -->
+ <taskdef name="server" classname="org.jboss.test.crashrecovery.taskdefs.ServerTask"
+ uri="http://jboss.org/ns/test/ant/astest" loaderref="astest.loader">
+ </taskdef>
+
+ <!--
+ - Task to perform an arbitary action. The action will have access to the test configuration
+ - specified in the configuration.
+ -->
+ <taskdef name="action" classname="org.jboss.test.crashrecovery.taskdefs.ASClientTask"
+ uri="http://jboss.org/ns/test/ant/astest" loaderref="astest.loader">
+ </taskdef>
+
+ <!--
+ - a spec is specification of how to inject faults into the XA protocol operations
+ -->
+ <typedef name="spec" classname="org.jboss.test.crashrecovery.recovery.ASFailureSpec"
+ uri="http://jboss.org/ns/test/ant/astest" loaderref="astest.loader">
+ </typedef>
+
+
+ <!--
+ - If the product directory where this test is running from contains an AS installation then use it,
+ - otherwise use the value of the JBOSS_HOME environment variable
+ -->
+ <!--
+ - The framework detects whether a server is running via the httpPort if the server has a web server,
+ - otherwise it uses the servers rmi port.
+ - To specify the http port use the httpPort attribute in the server definition.
+ - To specify the rmi port in the server definition use the rmiPort attribute together with hasWebServer="false"
+ -
+ - The port numbers must match the ports used by the actual server. Note that the default port bindings for a
+ - server can be changed via the server.binding.name and server.binding.location properties.
+ -->
+ <astest:config javaHome="${env.JAVA_HOME}" debug="false">
+ <spec name= "prepare_ex" mode="XAEXCEPTION" type="XARES_PREPARE" modeArg="XAER_RMFAIL" />
+ <spec name= "prepare_halt" mode="HALT" type="XARES_PREPARE" />
+ <spec name= "commit_halt" mode="HALT" type="XARES_COMMIT" />
+ <spec name= "none" mode="NONE" type="NONE" />
+
+ <!--
+ Profiles for JBossAS Testsuite integration
+ -->
+ <server name="crashrecovery-jta" host="${node0}">
+ <jvmarg value="-Xms128m" />
+ <jvmarg value="-Xmx512m" />
+ <jvmarg value="-XX:MaxPermSize=512m" />
+ <jvmarg value="-server" />
+ <sysproperty key="java.net.preferIPv4Stack" value="true" />
+ <sysproperty key="org.jboss.resolver.warning" value="true" />
+ <sysproperty key="sun.rmi.dgc.client.gcInterval" value="3600000" />
+ <sysproperty key="sun.rmi.dgc.server.gcInterval" value="3600000" />
+ <sysproperty key="xb.builder.useUnorderedSequence" value="true" />
+ <!--jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/-->
+ </server>
+
+ <server name="crashrecovery-jts" host="${node0}">
+ <jvmarg value="-Xms128m" />
+ <jvmarg value="-Xmx512m" />
+ <jvmarg value="-XX:MaxPermSize=512m" />
+ <jvmarg value="-server" />
+ <sysproperty key="java.net.preferIPv4Stack" value="true" />
+ <sysproperty key="org.jboss.resolver.warning" value="true" />
+ <sysproperty key="sun.rmi.dgc.client.gcInterval" value="3600000" />
+ <sysproperty key="sun.rmi.dgc.server.gcInterval" value="3600000" />
+ <sysproperty key="xb.builder.useUnorderedSequence" value="true" />
+ </server>
+
+ </astest:config>
+</project>
More information about the jboss-cvs-commits
mailing list