[jboss-cvs] JBossAS SVN: r89424 - in branches/Branch_5_x/testsuite: imports and 14 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 26 04:29:31 EDT 2009


Author: istudens at redhat.com
Date: 2009-05-26 04:29:31 -0400 (Tue, 26 May 2009)
New Revision: 89424

Added:
   branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml
   branches/Branch_5_x/testsuite/imports/sections/crashrecovery.xml
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test01.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test02.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test03.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/ejb-jar.xml
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss-beans.xml
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss.xml
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/java.policy
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle-xa-ds.xml
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/README.txt
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/imports/
   branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml
Modified:
   branches/Branch_5_x/testsuite/build.xml
   branches/Branch_5_x/testsuite/imports/config/configs.xml
   branches/Branch_5_x/testsuite/imports/test-jars.xml
Log:
added JBossTS crash recovery tests as optional test target, JBQA-2176

Modified: branches/Branch_5_x/testsuite/build.xml
===================================================================
--- branches/Branch_5_x/testsuite/build.xml	2009-05-26 08:10:22 UTC (rev 89423)
+++ branches/Branch_5_x/testsuite/build.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -191,6 +191,9 @@
       <!-- hibernate tests need slfj4 -->
       <path refid="org.jboss.slf4j.classpath"/>
       <path refid="org.slf4j.classpath"/>
+      <!-- jbossts crash recovery tests need server manager -->
+      <path refid="jboss.server.manager.classpath"/>
+      <path refid="jboss.jbossts.classpath"/>
 
    </path>
 

Modified: branches/Branch_5_x/testsuite/imports/config/configs.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/config/configs.xml	2009-05-26 08:10:22 UTC (rev 89423)
+++ branches/Branch_5_x/testsuite/imports/config/configs.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -13,5 +13,6 @@
 <import file="tests-bootstrap-dependencies.xml"/>
 <import file="tests-jts.xml"/>
 <import file="tests-password-mask.xml"/>
+<import file="tests-crash-recovery.xml"/>
 
 </project>

Added: branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,90 @@
+<?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 -->
+   <target name="tests-ts-crash-recovery" depends="prepare-crashrec-profiles"
+   	description="Runs JBossTS crash recovery tests">
+
+      <run-as-test target="as-tests" />
+
+   </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"
+            classpath="${ant.library.dir}/ant-launcher.jar"
+            fork="true" failonerror="true">
+            <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="jbossts.common.jar.dir" value="${jbosstest.dist}/common/lib" />
+	    <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.dir" value="${jboss.server.manager.lib}" />
+	    <sysproperty key="jboss.server.manager.jar.name" value="jboss-server-manager.jar" />
+	    <sysproperty key="sm.legacy.shutdown" value="true" />
+            <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}"/>
+         </java>
+      </sequential>
+   </macrodef>
+
+
+   <target name="prepare-crashrec-profiles">
+      <delete dir="${jboss.dist}/server/crashrecovery-jta" />
+      <create-config baseconf="all" newconf="crashrecovery-jta">
+         <patternset>
+            <include name="conf/**"/>
+            <include name="deploy/**"/>
+            <include name="deploy-hasingleton/**"/>
+            <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="deploy-hasingleton/**"/>
+            <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>
+   </target>
+	
+</project>

Added: branches/Branch_5_x/testsuite/imports/sections/crashrecovery.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/crashrecovery.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/imports/sections/crashrecovery.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/imports/test-jars.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/test-jars.xml	2009-05-26 08:10:22 UTC (rev 89423)
+++ branches/Branch_5_x/testsuite/imports/test-jars.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test01.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test01.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test01.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,45 @@
+/*
+ * 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.ClientAction;
+import org.jboss.test.crashrecovery.taskdefs.ASTestConfig;
+
+import java.util.Map;
+
+public class Test01 implements ClientAction
+{
+    public static void main(String args[])
+	{
+        System.out.println("Passed");
+    }
+
+    public boolean execute(ASTestConfig config, Map<String, String> params)
+    {
+        return true;
+    }
+
+    public boolean cancel() throws UnsupportedOperationException
+    {
+        throw new UnsupportedOperationException("TODO");
+    }
+}
+

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test02.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test02.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test02.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,41 @@
+/*
+ * 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.ClientAction;
+import org.jboss.test.crashrecovery.taskdefs.ASTestConfig;
+
+
+import java.util.Map;
+
+public class Test02 implements ClientAction
+{
+
+    public boolean execute(ASTestConfig config, Map<String, String> params)
+    {
+        return true;
+    }
+
+    public boolean cancel() throws UnsupportedOperationException
+    {
+        return true;
+    }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test03.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test03.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test03.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,331 @@
+/*
+ * 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.ClientAction;
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.test.crashrecovery.taskdefs.ASTestConfig;
+import org.jboss.test.crashrecovery.taskdefs.TransactionLog;
+import org.jboss.test.crashrecovery.crash.CrashRem;
+import org.jboss.test.crashrecovery.crash.CrashRemHome;
+import org.jboss.remoting.CannotConnectException;
+import org.apache.tools.ant.BuildException;
+
+import java.util.Map;
+import java.io.*;
+
+import javax.rmi.PortableRemoteObject;
+import javax.transaction.*;
+import javax.naming.NamingException;
+
+public class Test03 implements ClientAction
+{
+    // the longest time to wait in millis before declaring a test a failed (overridable)
+    private static final int MAX_TEST_TIME = 180000;
+
+    private ASTestConfig config;
+    private boolean isCMT = false;
+    private boolean clientTx = false;
+    private boolean isDebug = false;
+    private boolean expectFailure = false;
+    private int maxTestTime = MAX_TEST_TIME;
+
+    private String storeDir = null;
+    private String storeImple = "HashedActionStore";
+    private String storeType = null; //"StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
+    private TransactionLog store;
+    private int existingUids;
+
+    private String name = "Test";
+    private String serverName = "default";
+
+    public boolean execute(ASTestConfig config, Map<String, String> params)
+    {
+        StringBuilder sb = new StringBuilder();
+        ASFailureSpec[] fspecs = null;
+
+        this.config = config;
+
+        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 ("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 seconds: ");
+            else if ("specs".equals(key))
+                fspecs = parseSpecs(val, sb);
+            else if ("wait".equals(key))
+                suspendFor(Integer.parseInt(val));
+        }
+
+        sb.insert(0, ":\n").insert(0, name).insert(0, "Executing test ");
+
+        System.out.println(sb);
+
+        ClassLoader loader1 = Thread.currentThread().getContextClassLoader();
+        ClassLoader loader2 = this.getClass().getClassLoader();
+
+        try
+        {
+            String serverPath = config.getServerPath(serverName);
+
+            // switch class loaders since a custom ant task runs with a different loader from the loader
+            // that loader that loaded the class
+            Thread.currentThread().setContextClassLoader(loader2);
+
+            // 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();
+            }
+
+            // run the crash test
+            return crashTest(fspecs);
+        }
+        catch (Exception e)
+        {
+            if (isDebug)
+                e.printStackTrace();
+
+            throw new BuildException(e);
+        }
+        finally
+        {
+            Thread.currentThread().setContextClassLoader(loader1);
+        }
+    }
+
+    public boolean cancel() throws UnsupportedOperationException
+    {
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    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 lookup(String name) throws Exception
+    {
+        Object o = config.getNamingContext(serverName).lookup(name);
+        CrashRemHome home = (CrashRemHome) PortableRemoteObject.narrow(o, CrashRemHome.class);
+
+        return home.create();
+    }
+
+    private UserTransaction startTx() throws NamingException, SystemException, NotSupportedException
+    {
+        UserTransaction tx = (UserTransaction) config.getNamingContext(serverName).lookup("UserTransaction");
+
+        tx.begin();
+
+        return tx;
+    }
+
+    private boolean crashTest(ASFailureSpec[] sa) throws Exception
+    {
+        UserTransaction tx = null;
+
+        try
+        {
+            CrashRem cr = lookup(isCMT ? CrashRem.CMT_JNDI_NAME : CrashRem.BMT_JNDI_NAME);
+
+            if (clientTx)
+                tx = startTx();
+
+            String res = cr.testXA(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 " + e);
+
+                e.printStackTrace();
+            }
+        }
+        catch (Throwable t)
+        {
+            t.printStackTrace();
+            System.err.println("XACrashTest:crashTest: Caught " + 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 restaring 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 = 30000;
+        int maxWait = maxTestTime;
+        int pendingUids;
+
+        do
+        {
+            pendingUids = getPendingUids();
+
+            if (pendingUids == -1)
+                return false;   // object store error
+
+            if (pendingUids <= existingUids)
+                return true;    // all uids recovered
+
+            pendingUids -= existingUids;
+
+            print("waiting for " + pendingUids + " branches");
+
+            // wait for the server to start up the first time through
+            if (maxWait == maxTestTime)
+                config.startServer(serverName);
+
+            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();
+        }
+
+        return false;
+    }
+
+    private void suspendFor(int millis)
+    {
+        try
+        {
+            Thread.sleep(millis);
+        }
+        catch (InterruptedException e)
+        {
+            System.out.println("Test " + name + " interupted");
+        }
+    }
+
+    static void print(String msg)
+    {
+        System.out.println(msg);
+    }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.test.crashrecovery.recovery.TestASRecovery;
+
+import javax.ejb.SessionContext;
+import javax.ejb.SessionBean;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+public class CrashBMTBean implements SessionBean {
+    private SessionContext context;
+
+    public void setSessionContext(SessionContext context) { this.context = context; }
+    public void ejbCreate() { }
+    public void ejbActivate() { }
+    public void ejbPassivate() { }
+    public void ejbRemove() { }
+
+    public CrashBMTBean()
+    {
+    }
+
+    public String testXA(String ... args)
+    {
+         return "Passed";
+    }
+
+    public String testXA(ASFailureSpec... specs)
+    {
+        TestASRecovery xatest = new TestASRecovery();
+        String txStatus = getStatus(context.getUserTransaction());
+
+        if (txStatus != null)
+            System.out.println("BMT method called with tx status: " + txStatus);
+        
+        System.out.println("BMT testXA called with " + specs.length + " specs");
+
+        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());
+/*
+            switch (tx.getStatus())
+            {
+                case Status.STATUS_ACTIVE:
+                    return "A transaction is associated with the target object and it is in the active state.";
+                case Status.STATUS_COMMITTED:
+                    return "A transaction is associated with the target object and it has been committed.";
+                case Status.STATUS_COMMITTING:
+                    return "A transaction is associated with the target object and it is in the process of committing.";
+                case Status.STATUS_MARKED_ROLLBACK:
+                    return "A transaction is associated with the target object and it has been marked for rollback, perhaps as a result of a setRollbackOnly operation.";
+                case Status.STATUS_NO_TRANSACTION:
+                    return "No transaction is currently associated with the target object.";
+                case Status.STATUS_PREPARED:
+                    return "A transaction is associated with the target object and it has been prepared.";
+                case Status.STATUS_PREPARING:
+                    return "A transaction is associated with the target object and it is in the process of preparing.";
+                case Status.STATUS_ROLLEDBACK:
+                    return "A transaction is associated with the target object and the outcome has been determined to be rollback.";
+                case Status.STATUS_ROLLING_BACK:
+                    return "A transaction is associated with the target object and it is in the process of rolling back.";
+                case Status.STATUS_UNKNOWN:
+                    return "A transaction is associated with the target object but its current status cannot be determined.";
+                default:
+                    return "Unknown tx status code: " + tx.getStatus();
+            }
+*/
+        }
+        catch (SystemException e)
+        {
+            return "tx status error: " + e.getMessage();
+        }
+    }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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.crash;
+
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.test.crashrecovery.recovery.TestASRecovery;
+
+import javax.ejb.SessionContext;
+import javax.ejb.SessionBean;
+import javax.transaction.Transaction;
+
+public class CrashCMTBean implements SessionBean {
+    private SessionContext context;
+
+    public void setSessionContext(SessionContext context) { this.context = context; }
+    public void ejbCreate() { }
+    public void ejbActivate() { }
+    public void ejbPassivate() { }
+    public void ejbRemove() { }
+
+    public String testXA(String ... args)
+    {
+        return "Passed";
+    }
+
+    public String testXA(ASFailureSpec... specs)
+    {
+        System.out.println("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)
+        {
+            System.out.println("CMT testXA called without a transaction");
+
+            return "Failed";
+        }
+        else
+        {
+            for (ASFailureSpec spec : specs)
+                xatest.addResource(spec);
+
+            xatest.startTest(tx);
+
+            return "Passed";
+        }
+    }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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 org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+
+public interface CrashLocal extends javax.ejb.EJBLocalObject {
+    String testXA(String ... args);
+    String testXA(ASFailureSpec... specs);
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocalHome.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,35 @@
+/*
+ * 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.EJBObject;
+import java.rmi.RemoteException;
+
+public interface CrashRem extends EJBObject {
+    // JNDI names of the fault injection beans
+    String BMT_JNDI_NAME = "org.jboss.test.crashrecovery.crash.CrashBMTRem";
+    String CMT_JNDI_NAME = "org.jboss.test.crashrecovery.crash.CrashCMTRem";
+
+    String testXA(String ... args) throws RemoteException;
+    String testXA(ASFailureSpec... specs) throws RemoteException;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRemHome.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureMode.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureSpec.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASFailureType.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/ASTestResource.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecovery.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASClientTask.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ASTestConfig.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientAction.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerBindingConfig.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTask.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ServerTaskException.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskProperty.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TaskValue.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,168 @@
+/*
+ * 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 com.arjuna.ats.arjuna.coordinator.ActionStatus;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+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))
+                        {
+                            Uid theUid = new Uid(Uid.nullUid());
+
+                            try
+                            {
+                                boolean endOfUids = false;
+
+                                while (!endOfUids)
+                                {
+                                    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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/Utils.java	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/ejb-jar.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/ejb-jar.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
+<ejb-jar>
+  <enterprise-beans>
+      <session>
+          <description>Crash Testing BMT (Remote)</description>
+          <ejb-name>CrashBMTRemEJB</ejb-name>
+          <home>org.jboss.test.crashrecovery.crash.CrashRemHome</home>
+          <remote>org.jboss.test.crashrecovery.crash.CrashRem</remote>
+          <local-home>org.jboss.test.crashrecovery.crash.CrashLocalHome</local-home>
+          <local>org.jboss.test.crashrecovery.crash.CrashLocal</local>
+          <ejb-class>org.jboss.test.crashrecovery.crash.CrashBMTBean</ejb-class>
+          <session-type>Stateless</session-type>
+          <transaction-type>Bean</transaction-type>
+      </session>
+      
+      <session>
+          <description>Crash Testing CMT (Remote)</description>
+          <ejb-name>CrashCMTRemEJB</ejb-name>
+          <home>org.jboss.test.crashrecovery.crash.CrashRemHome</home>
+          <remote>org.jboss.test.crashrecovery.crash.CrashRem</remote>
+          <local-home>org.jboss.test.crashrecovery.crash.CrashLocalHome</local-home>
+          <local>org.jboss.test.crashrecovery.crash.CrashLocal</local>
+          <ejb-class>org.jboss.test.crashrecovery.crash.CrashCMTBean</ejb-class>
+          <session-type>Stateless</session-type>
+          <transaction-type>Container</transaction-type>
+      </session>
+<!--
+      <message-driven>
+          <ejb-name>TextMdb</ejb-name>
+          <ejb-class>org.jboss.test.crashrecovery.crash.TextMdb</ejb-class>
+          <transaction-type>Bean</transaction-type>
+          <message-driven-destination>
+              <destination-type>javax.jms.Queue</destination-type>
+          </message-driven-destination>
+
+        <security-identity>
+            <run-as>
+                <role-name>guest</role-name>
+            </run-as>
+        </security-identity>
+      </message-driven>
+-->
+  </enterprise-beans>
+
+  <assembly-descriptor>
+      <container-transaction>
+          <method>
+              <ejb-name>CrashCMTRemEJB</ejb-name>
+              <method-name>testXA</method-name>
+          </method>
+          <trans-attribute>RequiresNew</trans-attribute>
+      </container-transaction>
+    </assembly-descriptor>
+</ejb-jar>

Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss-beans.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss-beans.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss-beans.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+<!--
+  <bean name="ASTestEJB" class="org.jboss.test.crashrecovery.crash.CrashBMTBean" >
+    <depends>jboss.mq:service=DestinationManager</depends>
+    <depends>jboss.mq:service=SecurityManager</depends>
+  </bean>
+-->
+
+</deployment>

Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<jboss>
+   <enterprise-beans>
+      <session>
+         <ejb-name>CrashBMTRemEJB</ejb-name>
+         <jndi-name>org.jboss.test.crashrecovery.crash.CrashBMTRem</jndi-name>
+      </session>
+       
+      <session>
+         <ejb-name>CrashCMTRemEJB</ejb-name>
+         <jndi-name>org.jboss.test.crashrecovery.crash.CrashCMTRem</jndi-name>
+      </session>
+
+<!--
+      <message-driven>
+         <ejb-name>TextMdb</ejb-name>
+         <destination-jndi-name>queue/sndQ</destination-jndi-name>
+      </message-driven>
+-->
+
+   </enterprise-beans>
+</jboss>

Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/java.policy
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/java.policy	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/java.policy	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,3 @@
+grant {
+    permission java.security.AllPermission;
+};

Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle-xa-ds.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle-xa-ds.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,62 @@
+<?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>XAOracleDS</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:oci8:@dtfdb5:1521:TSH1</xa-datasource-property>
+    <xa-datasource-property name="User">system</xa-datasource-property>
+    <xa-datasource-property name="Password">jboss83</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>
+
+  <xa-datasource>
+    <jndi-name>XAOracleDS2</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:oci8:@dtfdb7:1521:TSH1</xa-datasource-property>
+    <xa-datasource-property name="User">system</xa-datasource-property>
+    <xa-datasource-property name="Password">jboss83</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>
+  <mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter" 
+         name="jboss.jca:service=OracleXAExceptionFormatter">
+    <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
+  </mbean>
+
+</datasources>

Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sample-bindings.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/xa-mq-destinations-service.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/README.txt
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/README.txt	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/README.txt	2009-05-26 08:29:31 UTC (rev 89424)
@@ -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: branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,231 @@
+<?xml version="1.0"?>
+
+<project name="crashrecovery-tests" default="help" basedir="."
+         xmlns:astest="http://jboss.org/ns/test/ant/astest">
+
+  <property environment="env"/>
+  <property name="jboss.home" value="${env.JBOSS_HOME}"/>
+  <property name="jboss.server.config" value="default"/>
+  <property name="product.dir" value="${env.DTF_HOME}/JBossTS-JTA-QA/"/>
+
+  <property name="jbossts.common.jar.dir" value="${product.dir}/lib/ext"/>
+  <property name="astest.jar.dir" value="${product.dir}/qa/lib"/>
+  <property name="astest.jar.name" value="astest.jar"/>
+  <property name="astest.jar.deploy.dir" value="qa/lib"/>
+  <property name="jboss.server.manager.jar.dir" value="${product.dir}/qa/lib"/>
+  <property name="jboss.server.manager.jar.name" value="jboss-server-manager-0.1.1.GA.jar"/>
+
+  <path id="astest.taskdef.classpath">
+    <pathelement location="${jboss.home}/client/jbossall-client.jar"/>
+    <pathelement location="${jboss.home}/client/log4j.jar" />
+    <pathelement location="${jboss.home}/client/jboss-logging-spi.jar" />
+    <pathelement location="${jboss.home}/lib/trove.jar"/>
+
+    <pathelement location="${jbossts.common.jar.dir}/jbossts-common.jar"/>
+    <pathelement location="${astest.jar.dir}/${astest.jar.name}"/>
+    <pathelement location="${jboss.server.manager.jar.dir}/${jboss.server.manager.jar.name}"/>
+
+    <!-- FIXME Does DTF need this fileset? If not it is needless. -->
+    <fileset dir="${product.dir}">
+       <include name="lib/*.jar"/>
+       <include name="lib/ext/*.jar"/>
+       <include name="qa/lib/*.jar"/>
+    </fileset>
+  </path>
+
+  <property name="node0" value="localhost" />
+  <property name="node1" value="192.168.1.106" />
+
+  <target name="help">
+    <echo message="
+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:${line.separator}
+   export ANT_OPTS=&quot;-Djava.security.policy=../src/org/jboss/jbossts/qa/astests/resources/java.policy -Dproduct.dir=../../build/&quot;
+${line.separator}
+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.
+"/>
+    <echo message="test4 - 2 xa resources, throw exceptions in commit"/>
+    <echo message="test5 - 2 xa resources, suspend one in prepare"/>
+    <echo message="test6 - 2 xa resources, halt the VM on commit"/>
+    <echo message="testjta - run lots of tests in parallel against a running server (using jta) "/>
+    <echo message="testjts - run lots of tests in parallel against a running server (using jts) "/>
+  </target>
+
+  <!--
+      import configuration settings for the tests
+    -->
+  <import file="imports/test-config.xml"/>
+
+  <target name="test4">
+    <!--
+        start a server identified by the name default (specified in the imported config file)
+        and deploy one artifact
+      -->
+    <astest:server method="start" serverName="default" >
+      <deploy from="${astest.jar.deploy.dir}/${astest.jar.name}" to="deploy/${astest.jar.name}" />
+    </astest:server>
+    <!--
+        wait 10000 ms and then execute an action (TODO implement a method of detecting when the
+        desired artifacts have deployed)
+      -->
+    <astest:action waitFor="10000" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+      <param key="name" value="test04" />
+      <param key="specs" value="commit_ex,commit_ex" />
+      <param key="serverName" value="default" />
+    </astest:action>
+    <!--
+        stop a server and undeploy an artifact
+      -->
+    <astest:server method="stop" serverName="default" >
+      <undeploy from="deploy/${astest.jar.name}" />
+    </astest:server>
+  </target>
+
+  <target name="test5">
+    <astest:server method="start" serverName="default" >
+      <deploy from="${astest.jar.deploy.dir}/${astest.jar.name}" to="deploy/${astest.jar.name}" />
+    </astest:server>
+    <astest:action waitFor="10000" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+      <param key="name" value="test05" />
+      <param key="specs" value="prepare_suspend,none" />
+      <param key="cmt" value="false" />
+      <param key="debug" value="false" />
+      <param key="serverName" value="default" />
+    </astest:action>
+    <astest:server method="stop" serverName="default" >
+      <undeploy from="deploy/${astest.jar.name}" />
+    </astest:server>
+  </target>
+
+  <target name="test6">
+    <astest:server method="start" serverName="default" >
+      <deploy from="${astest.jar.deploy.dir}/${astest.jar.name}" to="deploy/${astest.jar.name}" />
+    </astest:server>
+    <astest:action waitFor="10000" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+      <param key="name" value="test06" />
+      <param key="specs" value="none,commit_halt" />
+      <param key="cmt" value="true" />
+      <param key="debug" value="false" />
+      <param key="serverName" value="default" />
+      <param key="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction" />
+    </astest:action>
+    <astest:server method="stop" serverName="default" >
+      <undeploy from="deploy/${astest.jar.name}" />
+    </astest:server>
+  </target>
+
+  <target name="nulltest">
+    <astest:action impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test01" />
+  </target>
+
+  <!--
+      A test that does not start a server - ie the server must already be running.
+      A waitFor property is used on the deploy action to give enough time
+      for the server to deploy the artifacts.
+    -->
+  <target name="testjta">
+    <astest:server method="deploy" serverName="jta" waitFor="10000">
+      <deploy from="${astest.jar.deploy.dir}/${astest.jar.name}" to="deploy/${astest.jar.name}" />
+    </astest:server>
+    <parallel>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="name" value="testjta" />
+        <param key="specs" value="none,none,none,commit_ex,commit_ex" />
+        <param key="serverName" value="jta" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+    </parallel>
+    <astest:server method="undeploy" serverName="jta" >
+      <undeploy from="deploy/${astest.jar.name}" />
+    </astest:server>
+  </target>
+
+  <target name="testjts">
+    <astest:server method="deploy" serverName="jts" waitFor="10000">
+      <deploy from="${astest.jar.deploy.dir}/${astest.jar.name}" to="deploy/${astest.jar.name}" />
+    </astest:server>
+    <parallel>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="name" value="testjts" />
+        <param key="specs" value="none,none,none,commit_ex,commit_ex" />
+        <param key="serverName" value="jts" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+        <param key="serverName" value="jts" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+    </parallel>
+    <astest:server method="undeploy" serverName="jts" >
+      <undeploy from="deploy/${astest.jar.name}" />
+    </astest:server>
+  </target>
+
+
+  <!--
+      Tests intended for JBossAS Testsuite optional task
+    -->
+  <target name="as-tests" depends="as-tests-jta, as-tests-jts" />
+
+  <target name="as-tests-jta">
+    <astest:server method="start" serverName="crashrecovery-jta" >
+      <deploy from="${astest.jar.deploy.dir}/${astest.jar.name}" to="deploy/${astest.jar.name}" />
+    </astest:server>
+    <parallel>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="name" value="testjta" />
+        <param key="specs" value="none,none,none,commit_ex,commit_ex" />
+        <param key="serverName" value="crashrecovery-jta" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+    </parallel>
+    <astest:server method="stop" serverName="crashrecovery-jta" >
+      <undeploy from="deploy/${astest.jar.name}" />
+    </astest:server>
+   </target>
+
+  <target name="as-tests-jts">
+    <astest:server method="start" serverName="crashrecovery-jts" >
+      <deploy from="${astest.jar.deploy.dir}/${astest.jar.name}" to="deploy/${astest.jar.name}" />
+    </astest:server>
+    <parallel>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="name" value="testjts" />
+        <param key="specs" value="none,none,none,commit_ex,commit_ex" />
+        <param key="serverName" value="crashrecovery-jts" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+        <param key="serverName" value="crashrecovery-jts" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+      <astest:action abortOnFail="false" impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test03">
+        <param key="specs" value="sync_before,sync_after,none,pre_prepare_suspend" />
+      </astest:action>
+    </parallel>
+    <astest:server method="stop" serverName="crashrecovery-jts" >
+      <undeploy from="deploy/${astest.jar.name}" />
+    </astest:server>
+  </target>
+
+</project>

Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml	2009-05-26 08:29:31 UTC (rev 89424)
@@ -0,0 +1,118 @@
+<project name="crashrecovery-tests-server-config" default="help"
+         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">
+    <classpath refid="astest.taskdef.classpath"/>
+  </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>
+
+  <!--
+    - a server is specification of how configure a instance of an AS
+  <typedef name="server" classname="org.jboss.jbossas.servermanager.Server"
+           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= "commit_ex" mode="XAEXCEPTION" type="XARES_COMMIT" modeArg="XA_RDONLY" />
+     <spec name= "prepare_suspend" mode="SUSPEND" type="XARES_PREPARE" modeArg="40000" />
+     <spec name= "pre_prepare_suspend" mode="SUSPEND" type="PRE_PREPARE" modeArg="40000" />
+     <spec name= "sync_before" mode="NONE" type="SYNCH_BEFORE" modeArg="0" />
+     <spec name= "sync_after" mode="NONE" type="SYNCH_AFTER" modeArg="0" />
+     <spec name= "prepare_ex" mode="XAEXCEPTION" type="XARES_PREPARE" modeArg="XA_RDONLY" />
+     <spec name= "prepare_halt" mode="HALT" type="XARES_PREPARE" />
+     <spec name= "commit_suspend" mode="SUSPEND" type="XARES_COMMIT" modeArg="40000" />
+     <spec name= "commit_halt" mode="HALT" type="XARES_COMMIT" />
+     <spec name= "none" mode="NONE" type="NONE" />
+
+     <server name="jta" host="${node0}" >
+       <jvmarg value="-Xmx512M" />
+       <jvmarg value="-Xdebug" />
+       <jvmarg value="-Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"/>
+     </server>
+
+     <server name="jts" host="${node0}" />
+
+     <server name="default" host="${node0}">
+       <jvmarg value="-Xms128m" />
+       <jvmarg value="-Xmx512m" />
+       <jvmarg value="-XX:MaxPermSize=512m" />
+       <jvmarg value="-server" />
+<!--
+       <jvmarg value="-Xdebug" />
+       <jvmarg value="-Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"/>
+-->
+       <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" />
+       <sysproperty key="server.binding.name" value="ports-02" />
+       <sysproperty key="server.binding.location" value="qa/resources/sample-bindings.xml" />
+     </server>
+
+
+     <!--
+         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" />
+     </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