[jboss-cvs] JBossAS SVN: r92939 - in branches/Branch_5_x/testsuite: src/main/org/jboss/test/crashrecovery/ASCrashRecovery01 and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 28 06:06:04 EDT 2009
Author: istudens at redhat.com
Date: 2009-08-28 06:06:04 -0400 (Fri, 28 Aug 2009)
New Revision: 92939
Added:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java
branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/persistence.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle10-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml
Removed:
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/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/oracle-xa-ds.xml
Modified:
branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml
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/CrashRem.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java
branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml
branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml
Log:
JBossTS crash recovery tests ported from the JBPAPP_5_0 branch, JBAS-7214
Modified: branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/imports/config/tests-crash-recovery.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -11,21 +11,39 @@
<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">
+ <!--
+ | JBQA-2176 - JBossTS crash recovery tests.
+ |
+ | Usage for all tests:
+ | ./build.sh tests-ts-crash-recovery
+ |
+ | or for a selective database:
+ | ./build.sh tests-ts-crash-recovery -Dcrash.db=psql_8.3 -Dcrash.target=crash-tests-single-db
+ |
+ | or for a selective test scenario:
+ | ./build.sh tests-ts-crash-recovery -Dcrash.db=psql_8.3 -Dcrash.tstype=jts -Dcrash.tsdemarc=bmt -Dcrash.testcase=none.rev -Dcrash.target=crash-tests-single
+ |
+ | Note: If you want to force the wiping out any txs in doubt from DB before the test you can use the property -DwipeOutTxsInDoubtBeforeTest=true.
+ -->
+ <target name="tests-ts-crash-recovery"
+ description="Runs JBossTS crash recovery tests">
+
+ <available file="${jboss.dist}/server/crashrecovery-jta" property="have.profiles" value="true"/>
+ <antcall target="prepare-crashrec-profiles" />
+
+ <property name="crash.target" value="crash-tests" />
+ <property name="crash.max.time" value="300000" />
+
+ <run-as-test target="${crash.target}" />
- <run-as-test target="as-tests" />
-
</target>
-
<!--
| Macros and others
-->
@@ -34,37 +52,51 @@
<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">
+ <java classname="org.apache.tools.ant.launch.Launcher" fork="true" failonerror="true">
+ <classpath>
+ <pathelement location="${ant.library.dir}/ant-launcher.jar"/>
+ <path refid="org.apache.ant.classpath"/>
+ <path refid="junit.junit.classpath"/>
+ </classpath>
<sysproperty key="ant.home" value="${ant.home}"/>
<sysproperty key="ant.library.dir" value="${ant.library.dir}"/>
- <sysproperty key="java.security.policy" value="${build.resources}/${jbossts.crash.recovery.test.resource.dir}/java.policy"/>
+ <sysproperty key="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" />
+ <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="junit.junit.lib" value="${junit.junit.lib}" />
+ <sysproperty key="org.apache.ant.lib" value="${org.apache.ant.lib}" />
+ <sysproperty key="build.reports" value="${build.reports}" />
+ <sysproperty key="sm.legacy.shutdown" value="true" />
+ <sysproperty key="jbossas.startup.timeout" value="480" />
+ <sysproperty key="jbossas.shutdown.timeout" value="240" />
+ <sysproperty key="wipeOutTxsInDoubtBeforeTest" value="${wipeOutTxsInDoubtBeforeTest}" />
+ <sysproperty key="crash.db" value="${crash.db}" />
+ <sysproperty key="crash.tstype" value="${crash.tstype}" />
+ <sysproperty key="crash.tsdemarc" value="${crash.tsdemarc}" />
+ <sysproperty key="crash.testcase" value="${crash.testcase}" />
+ <sysproperty key="testTime" value="${crash.max.time}" />
<env key="JBOSS_HOME" value="${jbosstest.dist}" />
- <arg value="-f"/>
+ <!--arg value="-verbose"/-->
+ <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">
+
+
+ <target name="prepare-crashrec-profiles" unless="have.profiles">
<delete dir="${jboss.dist}/server/crashrecovery-jta" />
- <create-config baseconf="all" newconf="crashrecovery-jta">
+ <create-config baseconf="standard" newconf="crashrecovery-jta">
<patternset>
<include name="conf/**"/>
<include name="deploy/**"/>
- <include name="deploy-hasingleton/**"/>
<include name="deployers/**"/>
<include name="lib/**"/>
</patternset>
@@ -75,7 +107,6 @@
<patternset>
<include name="conf/**"/>
<include name="deploy/**"/>
- <include name="deploy-hasingleton/**"/>
<include name="deployers/**"/>
<include name="lib/**"/>
</patternset>
@@ -85,6 +116,32 @@
<ant dir="${jboss.dist}/docs/examples/transactions" target="jts">
<property name="target.server.dir" location="${jboss.dist}/server/crashrecovery-jts"/>
</ant>
+
+ <setup-crash-recovery conf="crashrecovery-jta"/>
+ <setup-crash-recovery conf="crashrecovery-jts"/>
</target>
+
+ <macrodef name="setup-crash-recovery">
+ <attribute name="conf"/>
+ <sequential>
+ <!-- enable crash recovery and point it to our datasource -->
+ <replace file="${jboss.dist}/server/@{conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[</transaction-service>]]></replacetoken>
+ <replacevalue><![CDATA[
+ <properties depends="arjuna" name="jta">
+ <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery1" value= "com.arjuna.ats.internal.jbossatx.jta.AppServerJDBCXARecovery;jndiname=CrashRecoveryDS"/>
+ <!-- xaRecoveryNode should match value in nodeIdentifier or be * -->
+ <property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>
+ </properties>
+</transaction-service>]]></replacevalue>
+ </replace>
+ <!-- more verbose logging -->
+ <replace file="${jboss.dist}/server/@{conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[type="System" value="0x00000000"]]></replacetoken>
+ <replacevalue><![CDATA[type="System" value="0xffffffff"]]></replacevalue>
+ </replace>
+ </sequential>
+ </macrodef>
+
</project>
Deleted: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test01.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,45 +0,0 @@
-/*
- * 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");
- }
-}
-
Deleted: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test02.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,41 +0,0 @@
-/*
- * 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;
- }
-}
Deleted: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/Test03.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,331 +0,0 @@
-/*
- * 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/ASCrashRecovery01/TestWithJPA.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,499 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.crashrecovery.ASCrashRecovery01;
+
+import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
+import org.jboss.test.crashrecovery.taskdefs.JUnitClientTest;
+import org.jboss.test.crashrecovery.taskdefs.TransactionLog;
+import org.jboss.test.crashrecovery.crash.CrashHelper;
+import org.jboss.test.crashrecovery.crash.CrashHelperRem;
+import org.jboss.test.crashrecovery.crash.CrashRem;
+import org.jboss.test.crashrecovery.crash.RecoveredXid;
+import org.jboss.test.crashrecovery.crash.TestEntity;
+import org.jboss.test.crashrecovery.crash.TestEntityHelper;
+import org.jboss.test.crashrecovery.crash.TestEntityHelperRem;
+import org.jboss.remoting.CannotConnectException;
+import org.apache.tools.ant.BuildException;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.EJBTransactionRolledbackException;
+import javax.naming.NamingException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+/**
+ * Crash recovery tests with one crash XA resource and one JPA entity resource.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestWithJPA extends JUnitClientTest
+{
+ // the longest time to wait in millis before declaring a test a failed (overridable)
+ private static final int MAX_TEST_TIME = 300000; // 5 minutes - allows two intervals of recovery which is 2 minutes by default
+
+ private boolean isCMT = false;
+ private boolean clientTx = false;
+ private boolean isDebug = false;
+ private boolean expectFailure = false;
+ private boolean reverseOrder = false;
+ private boolean rollbackExpected = false;
+ private boolean wipeOutTxsInDoubt = false;
+ private boolean wipeOutTxsInDoubtBeforeTest = false;
+ private boolean wipeOutTxsInDoubtAfterTest = false;
+ private int maxTestTime = MAX_TEST_TIME;
+
+ private String storeDir = null;
+ private String storeImple = "HashedActionStore";
+ private String storeType = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
+ private TransactionLog store;
+ private int existingUids;
+ private Set<RecoveredXid> existingXidsInDoubt;
+
+ private String serverName = "default";
+
+ private TestEntity initEntity;
+
+
+ public void testCrashRecovery()
+ {
+ if (config == null || params == null)
+ throw new UnsupportedOperationException("The test has not been initiated yet. Call the init() method first.");
+
+ StringBuilder sb = new StringBuilder();
+ ASFailureSpec[] fspecs = null;
+
+ for (Map.Entry<String, String> me : params.entrySet())
+ {
+ String key = me.getKey().trim();
+ String val = me.getValue().trim();
+
+ if ("name".equals(key))
+ setName(val);
+ else if ("cmt".equals(key))
+ isCMT = val.equalsIgnoreCase("true");
+ else if ("debug".equals(key))
+ isDebug = val.equalsIgnoreCase("true");
+ else if ("serverName".equals(key))
+ serverName = val;
+ else if ("storeType".equals(key))
+ storeType = val;
+ else if ("storeDir".equals(key))
+ storeDir = val;
+ else if ("clientTx".equals(key))
+ clientTx = val.equalsIgnoreCase("true");
+ else if ("storeImple".equals(key))
+ storeImple = val;
+ else if ("testTime".equals(key))
+ maxTestTime = parseInt(val, "parameter testTime should represent a number of miliseconds: ");
+ else if ("specs".equals(key))
+ fspecs = parseSpecs(val, sb);
+ else if ("wait".equals(key))
+ suspendFor(Integer.parseInt(val));
+ else if ("reverseOrder".equals(key))
+ reverseOrder = val.equalsIgnoreCase("true");
+ else if ("rollbackExpected".equals(key))
+ rollbackExpected = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubt".equals(key))
+ wipeOutTxsInDoubt = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubtBeforeTest".equals(key))
+ wipeOutTxsInDoubtBeforeTest = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubtAfterTest".equals(key))
+ wipeOutTxsInDoubtAfterTest = val.equalsIgnoreCase("true");
+ }
+
+ sb.insert(0, ":\n").insert(0, getName()).insert(0, "Executing test ");
+
+ System.out.println(sb);
+
+ try
+ {
+ // get a handle to the transaction logs
+ if (storeDir == null)
+ storeDir = serverPath + "data/tx-object-store";
+ else
+ storeDir = serverPath + storeDir;
+
+ store = new TransactionLog(storeDir, storeImple);
+
+ if (expectFailure)
+ {
+ // this test may halt the VM so make sure the transaction log is empty
+ // before starting the test - then the pass/fail check is simply to
+ // test whether or not the log is empty (see recoverUids() below).
+ try
+ {
+ store.clearXids(storeType);
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ existingUids = getPendingUids();
+ }
+
+ if (wipeOutTxsInDoubtBeforeTest)
+ wipeOutTxsInDoubt();
+
+ existingXidsInDoubt = lookupCrashHelper().checkXidsInDoubt();
+ if (isDebug)
+ print(existingXidsInDoubt.size() + " txs in doubt in database before test run");
+
+ // name of this test will be the primary key for test record in DB
+ String testEntityPK = getName();
+
+ // initialize database
+ initDatabase(testEntityPK);
+
+ // run the crash test
+ boolean result = crashTest(fspecs, testEntityPK, reverseOrder);
+ print("crashTest result: " + result);
+
+ // checking the state of DB after recovering
+ boolean dbChanged = true;
+ if (result)
+ {
+ dbChanged = checkDatabase(testEntityPK);
+ print("checkDatabase result: " + dbChanged);
+ }
+
+ Set<RecoveredXid> xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
+ if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
+ wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
+
+ assertTrue("Crash recovery failed.", result);
+ assertTrue("Incorrect data in database after crash recovery.", dbChanged);
+ assertEquals("There are still unrecovered txs in database after crash recovery.", existingXidsInDoubt.size(), xidsInDoubtAfterTest.size());
+ }
+ catch (Exception e)
+ {
+ if (isDebug)
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ }
+
+ private void initDatabase(String entityPK) throws Exception
+ {
+ TestEntityHelperRem hlp = (TestEntityHelperRem) config.getNamingContext(serverName).lookup(TestEntityHelper.REMOTE_JNDI_NAME);
+
+ initEntity = hlp.initTestEntity(entityPK);
+
+ print("TestWithJPA#initDatabase(): initEntity = " + initEntity);
+ }
+
+ private boolean checkDatabase(String entityPK)
+ {
+ try
+ {
+ TestEntityHelperRem hlp = (TestEntityHelperRem) config.getNamingContext(serverName).lookup(TestEntityHelper.REMOTE_JNDI_NAME);
+ TestEntity recoveredEntity = hlp.getTestEntity(entityPK);
+
+ print("TestWithJPA#checkDatabase(): initEntity = " + initEntity);
+ print("TestWithJPA#checkDatabase(): recoveredEntity = " + recoveredEntity);
+
+ return (rollbackExpected) ? recoveredEntity.getA() == initEntity.getA()
+ : recoveredEntity.getA() != initEntity.getA();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Wipes out all the txs in doubt from database.
+ *
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt()
+ {
+ // wipes out all txs in doubt from DB
+ return wipeOutTxsInDoubt(null);
+ }
+
+ /**
+ * Wipes out only new txs in doubt from database after test run.
+ *
+ * @param xidsInDoubtBeforeTest txs in doubt in database before test run
+ * @param xidsInDoubtBeforeTest txs in doubt in database after test run
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsInDoubtBeforeTest, Set<RecoveredXid> xidsInDoubtAfterTest)
+ {
+ Set<RecoveredXid> xidsToRecover = new HashSet<RecoveredXid>(xidsInDoubtAfterTest);
+ xidsToRecover.removeAll(xidsInDoubtBeforeTest);
+
+ if (xidsToRecover.isEmpty())
+ return true;
+
+ return wipeOutTxsInDoubt(xidsToRecover);
+ }
+
+ /**
+ * Wipes out txs in doubt from database according to a xidsToRecover list.
+ *
+ * @param xidsToRecover list of xids to recover
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
+ {
+ print("wiping out txs in doubt");
+ try
+ {
+ lookupCrashHelper().wipeOutTxsInDoubt(xidsToRecover);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+
+ private ASFailureSpec[] parseSpecs(String specArg, StringBuilder sb)
+ {
+ ASFailureSpec[] fspecs = config.parseSpecs(specArg);
+
+ for (ASFailureSpec spec : fspecs)
+ {
+ String name = (spec == null ? "INVALID" : spec.getName());
+
+ if (spec != null && spec.willTerminateVM())
+ expectFailure = true;
+
+ sb.append("\t").append(name).append('\n');
+ }
+
+ return fspecs;
+ }
+
+ private int parseInt(String intValue, String errorMessage) throws IllegalArgumentException
+ {
+ try
+ {
+ return Integer.parseInt(intValue);
+ }
+ catch (NumberFormatException e)
+ {
+ System.out.println(errorMessage + e.getMessage());
+
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ // count how many pending transaction branches there are in the transaction log
+ private int getPendingUids()
+ {
+ try
+ {
+ return store.getIds(storeType).size();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+
+ return -1;
+ }
+ }
+
+ private CrashRem lookupCrashBean(String name) throws Exception
+ {
+ return (CrashRem) config.getNamingContext(serverName).lookup(name);
+ }
+
+ private CrashHelperRem lookupCrashHelper() throws Exception
+ {
+ return (CrashHelperRem) config.getNamingContext(serverName).lookup(CrashHelper.REMOTE_JNDI_NAME);
+ }
+
+ private UserTransaction startTx() throws NamingException, SystemException, NotSupportedException
+ {
+ UserTransaction tx = (UserTransaction) config.getNamingContext(serverName).lookup("UserTransaction");
+
+ tx.begin();
+
+ return tx;
+ }
+
+ private boolean crashTest(ASFailureSpec[] sa, String testEntityPK, boolean reverseOrder) throws Exception
+ {
+ UserTransaction tx = null;
+
+ try
+ {
+ CrashRem cr = lookupCrashBean(isCMT ? CrashRem.CMT_JNDI_NAME : CrashRem.BMT_JNDI_NAME);
+
+ if (clientTx)
+ tx = startTx();
+
+ String res = cr.testXA(testEntityPK, reverseOrder, sa);
+
+ return "Passed".equalsIgnoreCase(res);
+ }
+ catch (CannotConnectException e)
+ {
+ if (expectFailure)
+ {
+ print("Failure was expected: " + e.getMessage());
+
+ return recoverUids();
+ }
+ else
+ {
+ System.err.println("XACrashTest:crashTest: Caught[1] " + e);
+
+ e.printStackTrace();
+ }
+ }
+ catch (EJBTransactionRolledbackException re)
+ {
+ // try to recover, this failure was expected maybe?!
+ print("Failure was expected (maybe): " + re.getMessage());
+
+ return recoverUids();
+ }
+ catch (RuntimeException re)
+ {
+ if (re.getCause() instanceof HeuristicMixedException)
+ {
+ // try to recover, this failure was expected maybe?!
+ print("Failure was expected (maybe): " + re.getMessage());
+
+ return recoverUids();
+ }
+ else
+ {
+ System.err.println("XACrashTest:crashTest: Caught[2] " + re);
+ re.printStackTrace();
+ }
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ System.err.println("XACrashTest:crashTest: Caught[3] " + t);
+ }
+ finally {
+ if (clientTx)
+ try
+ {
+ tx.commit();
+ }
+ catch (Throwable e)
+ {
+ System.out.println("User tx commit failure: " + e.getMessage());
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Wait for any pending transactions to recover by restarting the AS.
+ * @return true if all pending branches have been recovered
+ * @throws IOException if the server cannot be started
+ */
+ private boolean recoverUids() throws IOException
+ {
+ int retryPeriod = 60000; // 1 minute
+ int maxWait = maxTestTime;
+
+ Set<RecoveredXid> xidsInDoubtAfterTest;
+ int pendingUids;
+ int pendingXidsInDoubt;
+ int totalExistingXidsInDoubt = existingXidsInDoubt.size();
+
+ // wait for the server to start up the first time through, we will need it for later database checking
+ suspendFor(2000); // a little waiting is needed sometimes in order to be able to start server again, 2 secs
+ config.startServer(serverName);
+
+ do
+ {
+ pendingUids = getPendingUids();
+ try
+ {
+ xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ pendingXidsInDoubt = xidsInDoubtAfterTest.size();
+
+ if (pendingUids == -1)
+ return false; // object store error
+
+ if (pendingUids <= existingUids && pendingXidsInDoubt <= totalExistingXidsInDoubt)
+ return true; // all uids in AS and txs in doubt in DB recovered
+
+ pendingUids -= existingUids;
+ pendingXidsInDoubt -= totalExistingXidsInDoubt;
+
+ print("waiting for " + pendingUids + " branches");
+ print("waiting for " + pendingXidsInDoubt + " txs in doubt");
+
+ suspendFor(retryPeriod);
+ maxWait -= retryPeriod;
+
+ } while (maxWait > 0);
+
+ // the test failed to recover some uids - clear them out ready for the next test
+ try
+ {
+ store.clearXids(storeType);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (pendingXidsInDoubt > 0)
+ {
+ print(pendingXidsInDoubt + " new txs in doubt in database after the test");
+
+ if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
+ wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
+ }
+
+ return false;
+ }
+
+ private void suspendFor(int millis)
+ {
+ try
+ {
+ Thread.sleep(millis);
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("Test " + getName() + " interupted");
+ }
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/WipeOutTxsInDoubt.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.crashrecovery.ASCrashRecovery01;
+
+import org.jboss.test.crashrecovery.taskdefs.JUnitClientTest;
+import org.jboss.test.crashrecovery.crash.CrashHelper;
+import org.jboss.test.crashrecovery.crash.CrashHelperRem;
+import org.apache.tools.ant.BuildException;
+
+import java.util.Map;
+
+/**
+ * Helper test just for wiping out of txs in doubt from DB.
+ * It can be called via the as-tests.xml script.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public class WipeOutTxsInDoubt extends JUnitClientTest
+{
+ private boolean isDebug = false;
+
+ private String serverName = "default";
+
+ public void testCrashRecovery()
+ {
+ for (Map.Entry<String, String> me : params.entrySet())
+ {
+ String key = me.getKey().trim();
+ String val = me.getValue().trim();
+
+ if ("name".equals(key))
+ setName(val);
+ else if ("serverName".equals(key))
+ serverName = val;
+ else if ("debug".equals(key))
+ isDebug = val.equalsIgnoreCase("true");
+ }
+
+ print("Executing test " + getName() + ":\n");
+
+ try
+ {
+ print("wiping out txs in doubt from database");
+ wipeOutTxsInDoubt();
+ }
+ catch (Exception e)
+ {
+ if (isDebug)
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ }
+
+
+ public boolean wipeOutTxsInDoubt()
+ {
+ try
+ {
+ CrashHelperRem helper = (CrashHelperRem) config.getNamingContext(serverName).lookup(CrashHelper.REMOTE_JNDI_NAME);
+ helper.wipeOutTxsInDoubt(null);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
Modified: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashBMTBean.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -20,87 +20,87 @@
*/
package org.jboss.test.crashrecovery.crash;
+import org.jboss.logging.Logger;
import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
import org.jboss.test.crashrecovery.recovery.TestASRecovery;
+import org.jboss.test.crashrecovery.recovery.TestASRecoveryWithJPA;
-import javax.ejb.SessionContext;
-import javax.ejb.SessionBean;
+import javax.annotation.Resource;
+import javax.ejb.EJBContext;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
-public class CrashBMTBean implements SessionBean {
- private SessionContext context;
+ at Stateless
+ at TransactionManagement(TransactionManagementType.BEAN)
+public class CrashBMTBean implements CrashLocal, CrashRem {
+ private static Logger log = Logger.getLogger(CrashBMTBean.class);
- public void setSessionContext(SessionContext context) { this.context = context; }
- public void ejbCreate() { }
- public void ejbActivate() { }
- public void ejbPassivate() { }
- public void ejbRemove() { }
+// @Resource
+// private UserTransaction utx;
+ @Resource
+ private EJBContext context;
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String ... args)
+ {
+ return "Passed";
+ }
- public CrashBMTBean()
- {
- }
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(ASFailureSpec... specs)
+ {
+ TestASRecovery xatest = new TestASRecovery();
+ String txStatus = getStatus(context.getUserTransaction());
- public String testXA(String ... args)
- {
- return "Passed";
- }
+ if (txStatus != null)
+ log.info("BMT method called with tx status: " + txStatus);
- public String testXA(ASFailureSpec... specs)
- {
- TestASRecovery xatest = new TestASRecovery();
- String txStatus = getStatus(context.getUserTransaction());
+ log.info("BMT testXA called with " + specs.length + " specs");
- 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);
- for (ASFailureSpec spec : specs)
- xatest.addResource(spec);
+ return xatest.startTest() ? "Passed" : "Failed";
+ }
- return xatest.startTest() ? "Passed" : "Failed";
- }
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs)
+ {
+ TestASRecoveryWithJPA xatest = new TestASRecoveryWithJPA();
+ String txStatus = getStatus(context.getUserTransaction());
- public String getStatus(UserTransaction tx)
- {
- if (tx == null)
- return null;
+ if (txStatus != null)
+ log.info("BMT method called with tx status: " + txStatus);
- 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();
- }
- }
+ log.info("BMT testXA called with " + specs.length + " specs and testEntityPK=" + testEntityPK + " reverseOrder=" + reverseOrder);
+
+ xatest.setTestEntityPK(testEntityPK);
+ xatest.setReverseOrder(reverseOrder);
+
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ return xatest.startTest() ? "Passed" : "Failed";
+ }
+
+ public String getStatus(UserTransaction tx)
+ {
+ if (tx == null)
+ return null;
+
+ try
+ {
+ return org.jboss.tm.TxUtils.getStatusAsString(tx.getStatus());
+ }
+ catch (SystemException e)
+ {
+ return "tx status error: " + e.getMessage();
+ }
+ }
+
}
Modified: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashCMTBean.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -20,57 +20,97 @@
*/
package org.jboss.test.crashrecovery.crash;
+import org.jboss.logging.Logger;
import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
import org.jboss.test.crashrecovery.recovery.TestASRecovery;
+import org.jboss.test.crashrecovery.recovery.TestASRecoveryWithJPA;
-import javax.ejb.SessionContext;
-import javax.ejb.SessionBean;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.transaction.Transaction;
-public class CrashCMTBean implements SessionBean {
- private SessionContext context;
+ at Stateless
+public class CrashCMTBean implements CrashLocal, CrashRem {
+ private static Logger log = Logger.getLogger(CrashCMTBean.class);
- public void setSessionContext(SessionContext context) { this.context = context; }
- public void ejbCreate() { }
- public void ejbActivate() { }
- public void ejbPassivate() { }
- public void ejbRemove() { }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String ... args)
+ {
+ return "Passed";
+ }
- public String testXA(String ... args)
- {
- return "Passed";
- }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(ASFailureSpec... specs)
+ {
+ log.info("CMT testXA called with " + specs.length + " specs");
- public String testXA(ASFailureSpec... specs)
- {
- System.out.println("CMT testXA called with " + specs.length + " specs");
+ TestASRecovery xatest = new TestASRecovery();
+ Transaction tx;
- TestASRecovery xatest = new TestASRecovery();
- Transaction tx;
+ try
+ {
+ tx = com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction();
+ }
+ catch (javax.transaction.SystemException e)
+ {
+ tx = null;
+ }
- try
- {
- tx = com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction();
- }
- catch (javax.transaction.SystemException e)
- {
- tx = null;
- }
+ if (tx == null)
+ {
+ log.error("CMT testXA called without a transaction");
- if (tx == null)
- {
- System.out.println("CMT testXA called without a transaction");
+ return "Failed";
+ }
+ else
+ {
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
- return "Failed";
- }
- else
- {
- for (ASFailureSpec spec : specs)
- xatest.addResource(spec);
+ xatest.startTest(tx);
- xatest.startTest(tx);
+ return "Passed";
+ }
+ }
- return "Passed";
- }
- }
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs)
+ {
+ log.info("CMT testXA called with " + specs.length + " specs and testEntityPK=" + testEntityPK + " reverseOrder=" + reverseOrder);
+
+ TestASRecoveryWithJPA xatest = new TestASRecoveryWithJPA();
+ Transaction tx;
+
+ try
+ {
+ tx = com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction();
+ }
+ catch (javax.transaction.SystemException e)
+ {
+ tx = null;
+ }
+
+ if (tx == null)
+ {
+ log.error("CMT testXA called without a transaction");
+
+ return "Failed";
+ }
+ else
+ {
+ xatest.setTestEntityPK(testEntityPK);
+ xatest.setReverseOrder(reverseOrder);
+
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ xatest.startTest(tx);
+
+ return "Passed";
+ }
+ }
+
}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelper.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.crash;
+
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+
+import com.arjuna.ats.internal.jbossatx.jta.AppServerJDBCXARecovery;
+
+
+/**
+ * Helper class for playing with txs in doubt.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class CrashHelper implements CrashHelperRem
+{
+ public static final String REMOTE_JNDI_NAME = CrashHelper.class.getSimpleName() + "/remote";
+ private static Logger log = Logger.getLogger(CrashHelper.class);
+
+ /**
+ * JNDI name of crash recovery datasource.
+ */
+ public static final String DS_JNDI_NAME = "CrashRecoveryDS";
+
+
+ /**
+ * Wipes out xids in doubt from database ({@link #DS_JNDI_NAME}) according to
+ * <code>xidToRecover</code> list. If xidToRecover is null, it wipes out all xids in doubt.
+ *
+ * @param xidToRecover list of Xids to recover
+ */
+ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+ public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
+ {
+ log.info("wipe out txs in doubt");
+ try
+ {
+ AppServerJDBCXARecovery appServerRecovery = new AppServerJDBCXARecovery();
+
+ if (appServerRecovery.initialise("jndiname=" + DS_JNDI_NAME))
+ {
+ if (appServerRecovery.hasMoreResources())
+ {
+ XAResource xares = appServerRecovery.getXAResource();
+
+ Xid[] txInDoubt = null;
+ try
+ {
+ txInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot start recovering on xares", e);
+
+ try
+ {
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (Exception e1)
+ {
+ }
+
+ return false;
+ }
+
+ if (txInDoubt == null || txInDoubt.length == 0)
+ return true;
+
+ log.info("There are " + txInDoubt.length + " xids in doubt");
+
+ for (int k=0; k < txInDoubt.length; k++)
+ {
+ RecoveredXid xid = convertToRecoveredXid(txInDoubt[k]);
+ if (xidsToRecover == null || xidsToRecover.contains(xid))
+ {
+ try
+ {
+ log.info("rollbacking of Xid " + xid);
+ xares.rollback(txInDoubt[k]);
+ }
+ catch (Exception e)
+ {
+ log.error("Error in rollback of Xid " + txInDoubt[k], e);
+ }
+ }
+ }
+
+ try
+ {
+ if (xares != null)
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot finish recovering on xares", e);
+ }
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ log.error("Cannot get any XAResource by AppServerJDBCXARecovery", e);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks xids in doubt in datasource with {@link #DS_JNDI_NAME}.
+ *
+ * @return number of xids in doubt
+ */
+ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+ public Set<RecoveredXid> checkXidsInDoubt()
+ {
+ Set<RecoveredXid> xids = new HashSet<RecoveredXid>();
+ try
+ {
+ AppServerJDBCXARecovery appServerRecovery = new AppServerJDBCXARecovery();
+
+ if (appServerRecovery.initialise("jndiname=" + DS_JNDI_NAME))
+ {
+ if (appServerRecovery.hasMoreResources())
+ {
+ XAResource xares = appServerRecovery.getXAResource();
+
+ try
+ {
+ Xid[] xidsInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
+
+ if (xidsInDoubt != null)
+ {
+ log.info("There are " + xidsInDoubt.length + " xids in doubt");
+
+ for (int k=0; k < xidsInDoubt.length; k++)
+ xids.add(convertToRecoveredXid(xidsInDoubt[k]));
+ }
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot start recover scan on xares", e);
+ }
+ finally
+ {
+ try
+ {
+ if (xares != null)
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot finish recover scan on xares", e);
+ }
+ }
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ log.error("Cannot get any XAResource by AppServerJDBCXARecovery", e);
+ }
+
+ return xids;
+ }
+
+ private RecoveredXid convertToRecoveredXid(Xid xid)
+ {
+ RecoveredXid recoveredXid = new RecoveredXid();
+
+ recoveredXid.setBranchQualifier(xid.getBranchQualifier());
+ recoveredXid.setFormatId(xid.getFormatId());
+ recoveredXid.setGlobalTransactionId(xid.getGlobalTransactionId());
+
+ return recoveredXid;
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashHelperRem.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.crash;
+
+import java.util.Set;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface CrashHelperRem
+{
+ public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover);
+ public Set<RecoveredXid> checkXidsInDoubt();
+}
Modified: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashLocal.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -20,9 +20,13 @@
*/
package org.jboss.test.crashrecovery.crash;
+import javax.ejb.Local;
+
import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
-public interface CrashLocal extends javax.ejb.EJBLocalObject {
+ at Local
+public interface CrashLocal {
String testXA(String ... args);
String testXA(ASFailureSpec... specs);
+ String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs);
}
Modified: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/CrashRem.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -22,14 +22,15 @@
import org.jboss.test.crashrecovery.recovery.ASFailureSpec;
-import javax.ejb.EJBObject;
-import java.rmi.RemoteException;
+import javax.ejb.Remote;
-public interface CrashRem extends EJBObject {
+ at Remote
+public interface CrashRem {
// 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 BMT_JNDI_NAME = "CrashBMTBean/remote";
+ String CMT_JNDI_NAME = "CrashCMTBean/remote";
- String testXA(String ... args) throws RemoteException;
- String testXA(ASFailureSpec... specs) throws RemoteException;
+ String testXA(String ... args);
+ String testXA(ASFailureSpec... specs);
+ String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs);
}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/RecoveredXid.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.crash;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class RecoveredXid implements Serializable
+{
+ private byte[] branchQualifier;
+ private int formatId;
+ private byte[] globalTransactionId;
+
+ public RecoveredXid()
+ {
+ }
+
+ public byte[] getBranchQualifier()
+ {
+ return branchQualifier;
+ }
+
+ public void setBranchQualifier(byte[] branchQualifier)
+ {
+ this.branchQualifier = branchQualifier;
+ }
+
+ public int getFormatId()
+ {
+ return formatId;
+ }
+
+ public void setFormatId(int formatId)
+ {
+ this.formatId = formatId;
+ }
+
+ public byte[] getGlobalTransactionId()
+ {
+ return globalTransactionId;
+ }
+
+ public void setGlobalTransactionId(byte[] globalTransactionId)
+ {
+ this.globalTransactionId = globalTransactionId;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(branchQualifier);
+ result = prime * result + formatId;
+ result = prime * result + Arrays.hashCode(globalTransactionId);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RecoveredXid other = (RecoveredXid) obj;
+ if (!Arrays.equals(branchQualifier, other.branchQualifier))
+ return false;
+ if (formatId != other.formatId)
+ return false;
+ if (!Arrays.equals(globalTransactionId, other.globalTransactionId))
+ return false;
+ return true;
+ }
+
+ @Override
+ /**
+ * Only for debugging purposes.
+ */
+ public String toString()
+ {
+ return "RecoveredXid [branchQualifier=" + Arrays.toString(branchQualifier) + ", formatId=" + formatId
+ + ", globalTransactionId=" + Arrays.toString(globalTransactionId) + "]";
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntity.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.crash;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * TestEntity for crash recovery tests.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Entity
+ at Table(name="testentity")
+public class TestEntity implements Serializable
+{
+ private String id;
+ private int a;
+
+ public TestEntity()
+ {
+ // default constructor
+ }
+
+ public TestEntity(String id, int a)
+ {
+ this.id = id;
+ this.a = a;
+ }
+
+ @Id
+ public String getId()
+ {
+ return id;
+ }
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+ public int getA()
+ {
+ return a;
+ }
+ public void setA(int a)
+ {
+ this.a = a;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TestEntity other = (TestEntity) obj;
+ if (id == null)
+ {
+ if (other.id != null)
+ return false;
+ }
+ else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TestEntity [a=" + a + ", id=" + id + "]";
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelper.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.crash;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.logging.Logger;
+
+
+/**
+ * Helper SLSB for playing (initiate, update, ...) with test entity.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class TestEntityHelper implements TestEntityHelperRem, TestEntityHelperLocal
+{
+ public static final String REMOTE_JNDI_NAME = TestEntityHelper.class.getSimpleName() + "/remote";
+ public static final String LOCAL_JNDI_NAME = TestEntityHelper.class.getSimpleName() + "/local";
+
+ public static final int TEST_ENTITY_INIT_VALUE = 1;
+
+ private static Logger log = Logger.getLogger(TestEntityHelper.class);
+
+
+ @PersistenceContext
+ EntityManager em;
+
+ /**
+ * Initiates test entity with <code>entityPK</code> key to the {@link #TEST_ENTITY_INIT_VALUE}.
+ * @param entityPK primary key of test entity
+ * @return initiated test entity
+ */
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public TestEntity initTestEntity(String entityPK)
+ {
+ TestEntity entity = em.find(TestEntity.class, entityPK);
+
+ if (entity == null)
+ {
+ entity = new TestEntity(entityPK, TEST_ENTITY_INIT_VALUE);
+ em.persist(entity);
+ }
+ else
+ {
+ entity.setA(TEST_ENTITY_INIT_VALUE);
+ }
+
+ return entity;
+ }
+
+ /**
+ * Finds test entity with <code>entityPK</code> key.
+ * @param entityPK primary key of test entity
+ * @return test entity
+ */
+ public TestEntity getTestEntity(String entityPK)
+ {
+ TestEntity entity = em.find(TestEntity.class, entityPK);
+ log.debug("TestEntityHelper#getTestEntity(" + entityPK + ") = " + entity);
+
+ return entity;
+ }
+
+ /**
+ * Updates test entity, i.e. increments its value.
+ * @param entityPK primary key of test entity
+ * @return true in success, false otherwise
+ */
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public boolean updateTestEntity(String entityPK)
+ {
+ try
+ {
+ TestEntity entity = em.find(TestEntity.class, entityPK);
+ entity.setA(entity.getA() + 1);
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot update a test entity", e);
+ }
+ return false;
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperLocal.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.crash;
+
+import javax.ejb.Local;
+
+ at Local
+public interface TestEntityHelperLocal
+{
+ public boolean updateTestEntity(String entityPK);
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/crash/TestEntityHelperRem.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.crash;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface TestEntityHelperRem
+{
+ public TestEntity initTestEntity(String entityPK);
+ public TestEntity getTestEntity(String entityPK);
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/recovery/TestASRecoveryWithJPA.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.recovery;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.Transaction;
+
+import org.jboss.test.crashrecovery.crash.TestEntityHelper;
+import org.jboss.test.crashrecovery.crash.TestEntityHelperLocal;
+
+/**
+ * Extends TestASRecovery class by adding JPA entity update.
+ */
+public class TestASRecoveryWithJPA extends TestASRecovery
+{
+ private String testEntityPK = null;
+ private boolean reverseOrder = false;
+
+ /**
+ * Primary key of test entity.
+ * Typically depends on the name of a particular test.
+ *
+ * @param testEntityPK
+ */
+ public void setTestEntityPK(String testEntityPK)
+ {
+ this.testEntityPK = testEntityPK;
+ }
+
+ /**
+ * Sets order of enlisting of XA resources.
+ * <ul><li>non-rev (b=false): 1. JPA XA resource, 2. crash XA resource
+ * <li>rev (b=true): 1. crash XA resource, 2. JPA XA resource</ul>
+ *
+ * @param b
+ */
+ public void setReverseOrder(boolean b)
+ {
+ this.reverseOrder = b;
+ }
+
+ public boolean startTest(Transaction tx)
+ {
+ boolean result = true;
+
+ if (reverseOrder)
+ {
+ result = result && super.startTest(tx); // this sequence denies usage of PRECOMMIT, but we don't need it for crash recovery tests
+ result = result && doJPAEntityUpdate();
+ }
+ else
+ {
+ result = result && doJPAEntityUpdate();
+ result = result && super.startTest(tx);
+ }
+
+
+ return result;
+ }
+
+ public boolean startTest()
+ {
+ return super.startTest();
+ }
+
+
+ /**
+ * Calls update of a test entity.
+ */
+ protected boolean doJPAEntityUpdate()
+ {
+ TestEntityHelperLocal testEntityHelper;
+ try
+ {
+ testEntityHelper = (TestEntityHelperLocal) new InitialContext().lookup(TestEntityHelper.LOCAL_JNDI_NAME);
+
+ return testEntityHelper.updateTestEntity(testEntityPK);
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/ClientTask.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,216 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.crashrecovery.taskdefs;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.jboss.test.crashrecovery.taskdefs.ClientAction;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Ant task for executing a chunk of java code. The interface name of the code to be executed is specified
+ * the impl field:
+ * @see ClientAction
+ *
+ * It the task completes successfully "Passed" is printed on system output, otherwise "Failed" is printed
+ */
+public class ClientTask extends Task
+{
+ /**
+ * The text to print on standard output if the client action returned the expected result.
+ * Note that these values can be overridden on per task basis
+ * When running under the DTF the text should correspond values defined in the file
+ * nodeconfig.xml. The DTF TaskRunner controlling the test will search the output stream
+ * for this text to determine success or failure.
+ */
+ public static final String PASS = "Passed";
+ public static final String FAIL = "Failed";
+
+ private String impl;
+ private String waitFor;
+ private String name;
+ private String passText = PASS;
+ private String failText = FAIL;
+ private List<TaskProperty> params = new ArrayList<TaskProperty>();
+ private boolean abortOnFail = true;
+
+ public void execute() throws BuildException
+ {
+ ASTestConfig config = (ASTestConfig) getProject().getReference(ASTestConfig.CONFIG_REF);
+ Map<String, String> args = new HashMap<String, String> ();
+
+ for (TaskProperty param : params)
+ args.put(param.getKey(), param.getValue());
+
+ ClientAction action = null;
+
+ try
+ {
+ suspendFor(waitFor);
+
+ action = (ClientAction) Class.forName(impl).newInstance();
+ }
+ catch (ClassCastException e)
+ {
+ System.err.println("Class " + impl + " does not implement " + ClientAction.class.getName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ System.err.println("Cannot locate class " + impl);
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InstantiationException e)
+ {
+ System.err.println("Class " + impl + " cannot be instantiated: " + e.getMessage());
+ }
+
+ try
+ {
+ printResult(action.execute(config, args));
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error executing test: " + e.getMessage());
+ printResult(false);
+ }
+
+ }
+
+ private void printResult(boolean passed)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if (name != null)
+ {
+ sb.append(name).append(' ');
+ }
+
+ System.out.println(sb.append(passed ? passText : failText));
+
+ if (!passed && abortOnFail)
+ throw new BuildException("Test failed");
+ }
+
+ /**
+ * Suspend the calling thread
+ * @param millis the number of milli seconds to suspend for
+ * @return false if interupted
+ * @throws IllegalArgumentException if millis is not a number or negative
+ */
+ static boolean suspendFor(String millis) throws IllegalArgumentException
+ {
+ try
+ {
+ try
+ {
+ if (millis != null)
+ Thread.sleep(Integer.parseInt(millis));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+
+ return true;
+ }
+ catch (InterruptedException e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Task property to set the test name. This name will be printed when the test completes
+ * followed by a string to indicate pass or failure.
+ * see org.jboss.test.crashrecovery.taskdefs.ASClientTask.PASS
+ * @param name the name of the test.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ /**
+ * Task property to force the task to suspend before executing the client action
+ *
+ * @param waitFor the number of milli seconds to suspend - a null value means don't suspend
+ * @throws IllegalArgumentException if waitFor is not a number or is negative
+ */
+ public void setWaitFor(String waitFor) throws IllegalArgumentException
+ {
+ this.waitFor = waitFor;
+ }
+
+ public void setAbortOnFail(String abortOnFail)
+ {
+ this.abortOnFail = "true".equals(abortOnFail);
+ }
+
+ /**
+ * Task property containing the fully qualified class name of the action to execute.
+ * This class must contain an empty constructor and implement:
+ * @see ClientAction
+ *
+ * @param impl the class name of the action that this task will instantiate and run
+ */
+ public void setImpl(String impl)
+ {
+ this.impl = impl;
+ }
+
+ /**
+ * Task parameters that are passed into the execute method of the client action
+ *
+ * @param param a task parameter
+ */
+ public void addParam(TaskProperty param)
+ {
+ params.add(param);
+ }
+
+ /**
+ * Task property defaults to
+ * see org.jboss.test.crashrecovery.taskdefs.ASTestConfig.PASS
+ *
+ * @param passText the text to print if the test succeeds
+ */
+ public void setPassText(String passText)
+ {
+ this.passText = passText;
+ }
+
+ /**
+ * Task property to
+ * see org.jboss.test.crashrecovery.taskdefs.ASTestConfig.FAIL
+ *
+ * @param failText the text to print if the test succeeds
+ */
+ public void setFailText(String failText)
+ {
+ this.failText = failText;
+ }
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientAction.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.crashrecovery.taskdefs;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Map;
+
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+/**
+ * General client action that can call JUnit based client tests
+ * and write their result to an xml report.
+ * @see JUnitClientTest
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public class JUnitClientAction implements ClientAction
+{
+ private boolean isDebug = false;
+
+
+ public boolean execute(ASTestConfig config, Map<String, String> params)
+ {
+ String testClass = null;
+ String name = "Test";
+ String serverName = "default";
+ String reportFile = null;
+
+ for (Map.Entry<String, String> me : params.entrySet())
+ {
+ String key = me.getKey().trim();
+ String val = me.getValue().trim();
+
+ if ("name".equals(key))
+ name = val;
+ else if ("serverName".equals(key))
+ serverName = val;
+ else if ("debug".equals(key))
+ isDebug = val.equalsIgnoreCase("true");
+ else if ("reportFile".equals(key))
+ reportFile = val;
+ else if ("testClass".equals(key))
+ testClass = val;
+ }
+
+ ClassLoader loader1 = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader2 = this.getClass().getClassLoader();
+
+ try
+ {
+ String serverPath = config.getServerPath(serverName);
+
+ TestResult result = new TestResult();
+
+ XMLJUnitResultFormatter resultFormatter = new XMLJUnitResultFormatter();
+
+ JUnitTest dummyJUnit = new JUnitTest(name);
+ resultFormatter.startTestSuite(dummyJUnit);
+
+ OutputStream writer = new FileOutputStream(new File(reportFile));
+ resultFormatter.setOutput(writer);
+
+ result.addListener(resultFormatter);
+
+ TestSuite suite = new TestSuite();
+
+ // 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);
+
+ JUnitClientTest test = null;
+ try
+ {
+ test = (JUnitClientTest) Class.forName(testClass).newInstance();
+ }
+ catch (ClassCastException e)
+ {
+ System.err.println("Class " + testClass + " does not implement " + JUnitClientTest.class.getName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ System.err.println("Cannot locate class " + testClass);
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InstantiationException e)
+ {
+ System.err.println("Class " + testClass + " cannot be instantiated: " + e.getMessage());
+ }
+
+ test.setName("testCrashRecovery");
+ test.init(config, params, serverPath);
+
+ suite.addTest(test);
+
+ long startTime = new Date().getTime();
+ suite.run(result);
+ long endTime = new Date().getTime();
+
+ dummyJUnit.setCounts(result.runCount(), result.failureCount(), result.errorCount());
+ dummyJUnit.setRunTime(endTime - startTime);
+
+ resultFormatter.endTestSuite(dummyJUnit);
+
+ writer.close();
+
+ return result.wasSuccessful();
+ }
+ catch (Exception e)
+ {
+ if (isDebug)
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(loader1);
+ }
+ }
+
+ public boolean cancel() throws UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ static void print(String msg)
+ {
+ System.out.println(msg);
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/JUnitClientTest.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.crashrecovery.taskdefs;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Abstract junit-based client test.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class JUnitClientTest extends TestCase
+{
+ protected ASTestConfig config = null;
+ protected Map<String, String> params = null;
+ protected String serverPath = null;
+
+ public JUnitClientTest()
+ {
+ super();
+ }
+
+ public JUnitClientTest(String name)
+ {
+ super(name);
+ }
+
+ public void init(ASTestConfig config, Map<String, String> params, String serverPath)
+ {
+ this.config = config;
+ this.params = params;
+ this.serverPath = serverPath;
+ }
+
+ /**
+ * The test method.
+ * Should be overridden.
+ */
+ public abstract void testCrashRecovery();
+
+
+ protected void print(String msg)
+ {
+ System.out.println(msg);
+ }
+
+}
Modified: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/crashrecovery/taskdefs/TransactionLog.java 2009-08-28 10:06:04 UTC (rev 92939)
@@ -26,11 +26,8 @@
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;
/**
@@ -38,131 +35,130 @@
*/
public class TransactionLog
{
- /**
- * Default object type for store operations
- */
- public static final String DEFAULT_OBJECT_TYPE = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
+ /**
+ * Default object type for store operations
+ */
+ public static final String DEFAULT_OBJECT_TYPE = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
- private ObjectStore store;
+ private ObjectStore store;
- public TransactionLog(String storeDir, String impleType)
- {
- init(storeDir, impleType);
- }
+ 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);
+ 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();
- }
+ 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);
+ /**
+ * 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);
+ for (Uid uid : uids)
+ store.remove_committed(uid, objectType);
- return uids.size();
- }
+ return uids.size();
+ }
- public Collection<Uid> getIds(String objectType) throws ObjectStoreException
- {
- return getIds(null, objectType);
- }
+ 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> ();
+ /**
+ * 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();
+ InputObjectState types = new InputObjectState();
- if (store.allTypes(types))
- {
- String theName;
+ if (store.allTypes(types))
+ {
+ String theName;
- try
+ try
+ {
+ boolean endOfList = false;
+
+ while (!endOfList)
{
- boolean endOfList = false;
+ theName = types.unpackString();
- while (!endOfList)
- {
- theName = types.unpackString();
+ if (theName.compareTo("") == 0)
+ endOfList = true;
+ else
+ {
+ if (objectType != null && !theName.equals(objectType))
+ continue;
- if (theName.compareTo("") == 0)
- endOfList = true;
- else
- {
- if (objectType != null && !theName.equals(objectType))
- continue;
+ InputObjectState uids = new InputObjectState();
- InputObjectState uids = new InputObjectState();
+ if (store.allObjUids(theName, uids))
+ {
+ try
+ {
+ boolean endOfUids = false;
- if (store.allObjUids(theName, uids))
+ while (!endOfUids)
{
- Uid theUid = new Uid(Uid.nullUid());
+ Uid theUid = new Uid(Uid.nullUid());
+ theUid.unpack(uids);
- 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!
- }
+ if (theUid.equals(Uid.nullUid()))
+ endOfUids = true;
+ else
+ ids.add(theUid);
}
+ }
+ catch (Exception e)
+ {
+ // end of uids!
+ }
+ }
- System.out.println();
- }
- }
+ System.out.println();
+ }
}
- catch (Exception e)
- {
- System.err.println(e);
+ }
+ catch (Exception e)
+ {
+ System.err.println(e);
- // end of list!
- }
- }
+ // end of list!
+ }
+ }
- return ids;
- }
+ return ids;
+ }
- public int getStatus(Uid uid)
- {
- AtomicAction action = new AtomicAction(uid);
+ public int getStatus(Uid uid)
+ {
+ AtomicAction action = new AtomicAction(uid);
- action.activate();
+ action.activate();
- return action.status();
- }
+ return action.status();
+ }
}
Deleted: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/ejb-jar.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,55 +0,0 @@
-<?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>
Deleted: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss-beans.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,11 +0,0 @@
-<?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>
Deleted: branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss.xml 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/jboss.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,22 +0,0 @@
-<?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/META-INF/persistence.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/persistence.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/META-INF/persistence.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence">
+ <persistence-unit name="ejb3">
+ <jta-data-source>java:/CrashRecoveryDS</jta-data-source>
+ <properties>
+ <property name="jboss.entity.manager.jndi.name" value="java:/CrashRecoveryManager" />
+ <property name="jboss.entity.manager.factory.jndi.name"
+ value="java:/CrashRecoveryManagerFactory" />
+ <property name="hibernate.hbm2ddl.auto" value="update"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/db2_97-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- Thanks to Horia Muntean <horia at bvb.ro> -->
+<!-- ===================================================================== -->
+
+<!-- $Id: db2-xa-ds.xml 77479 2008-08-26 10:33:09Z alex.loubyansky at jboss.com $ -->
+
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
+
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+
+ <!-- Note, as opposed to the Type2 driver, DB2 Type 4 requires the PortNumber. By default this is 50000-->
+ <xa-datasource-property name="PortNumber">50000</xa-datasource-property>
+ <xa-datasource-property name="ServerName">vmg06.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="DriverType">4</xa-datasource-property>
+
+ <!-- If driverType 4 is used, the following two tags are needed -->
+ <track-connection-by-tx></track-connection-by-tx>
+ <!-- Must be set if using multiple DB2 XA resources in same transaction -->
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <no-tx-separate-pools></no-tx-separate-pools>
+
+ <!-- uncomment to enable interleaving <interleaving/> -->
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
+ <metadata>
+ <type-mapping>DB2</type-mapping>
+ </metadata>
+ </xa-datasource>
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2005-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: mssql-xa-ds.xml 77479 2008-08-26 10:33:09Z alex.loubyansky at jboss.com $ -->
+ <!-- ==================================================================== -->
+ <!-- ConnectionManager setup for xa Microsoft SQL Server 2005, using -->
+ <!-- Microsoft's JDBC driver. -->
+ <!-- Thanks to Benjamin Geer <benjamin.geer at misys.com> -->
+ <!-- Be sure to set the JndiName property to the name you want to look up -->
+ <!-- the datasource under and set the location of your database in -->
+ <!-- the xa-datasource-property section. -->
+ <!-- Further information about the Microsoft JDBC Driver version 1.1 -->
+ <!-- can be found here: -->
+ <!-- http://msdn2.microsoft.com/en-us/library/aa496082.aspx -->
+ <!-- ==================================================================== -->
+
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">dev30.qa.atl.jboss.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">3918</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>MS SQLSERVER2000</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mssql2008-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: mssql-xa-ds.xml 77479 2008-08-26 10:33:09Z alex.loubyansky at jboss.com $ -->
+ <!-- ==================================================================== -->
+ <!-- ConnectionManager setup for xa Microsoft SQL Server 2005, using -->
+ <!-- Microsoft's JDBC driver. -->
+ <!-- Thanks to Benjamin Geer <benjamin.geer at misys.com> -->
+ <!-- Be sure to set the JndiName property to the name you want to look up -->
+ <!-- the datasource under and set the location of your database in -->
+ <!-- the xa-datasource-property section. -->
+ <!-- Further information about the Microsoft JDBC Driver version 1.1 -->
+ <!-- can be found here: -->
+ <!-- http://msdn2.microsoft.com/en-us/library/aa496082.aspx -->
+ <!-- ==================================================================== -->
+
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg04.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">1433</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>MS SQLSERVER2000</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql50-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
+<!-- Datasource config for MySQL using 3.0.9 available from:
+http://www.mysql.com/downloads/api-jdbc-stable.html
+-->
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg08.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">3306</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
+ <!-- sql to call when connection is created
+ <new-connection-sql>some arbitrary sql</new-connection-sql>
+ -->
+ <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>mySQL</type-mapping>
+ </metadata>
+ </xa-datasource>
+</datasources>
+
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/mysql51-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
+<!-- Datasource config for MySQL using 3.0.9 available from:
+http://www.mysql.com/downloads/api-jdbc-stable.html
+-->
+
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg02.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">3306</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
+ <!-- sql to call when connection is created
+ <new-connection-sql>some arbitrary sql</new-connection-sql>
+ -->
+ <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>mySQL</type-mapping>
+ </metadata>
+ </xa-datasource>
+</datasources>
+
Deleted: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,62 +0,0 @@
-<?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/oracle10-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle10-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle10-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: oracle-xa-ds.xml 71535 2008-04-01 07:05:03Z adrian at jboss.org $ -->
+
+<!-- ===================================================================== -->
+<!-- ATTENTION: DO NOT FORGET TO SET Pad=true IN transaction-service.xml -->
+<!-- ===================================================================== -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ <xa-datasource-property name="URL">jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
+ <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <!-- Checks the Oracle error codes and messages for fatal errors -->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+ <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
+ <no-tx-separate-pools/>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>Oracle9i</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/oracle11-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: oracle-xa-ds.xml 71535 2008-04-01 07:05:03Z adrian at jboss.org $ -->
+
+<!-- ===================================================================== -->
+<!-- ATTENTION: DO NOT FORGET TO SET Pad=true IN transaction-service.xml -->
+<!-- ===================================================================== -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ <xa-datasource-property name="URL">jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:qaora11</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
+ <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <!-- Checks the Oracle error codes and messages for fatal errors -->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+ <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
+ <no-tx-separate-pools/>
+
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>Oracle9i</type-mapping>
+ </metadata>
+ </xa-datasource>
+
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres82-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg01.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <!--xa-datasource-property name="ServerName">dev01.qa.atl.jboss.com</xa-datasource-property-->
+ <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ </xa-datasource>
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/postgres83-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <track-connection-by-tx>true</track-connection-by-tx>
+ <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
+ <xa-datasource-property name="ServerName">vmg03.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ </xa-datasource>
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase12-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- Thanks to kosulin in the forumns -->
+<!-- ===================================================================== -->
+
+<!-- $Id: sybase-xa-ds.xml 85945 2009-03-16 19:45:12Z dimitris at jboss.org $ -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <xa-datasource-class>com.sybase.jdbc3.jdbc.SybXADataSource</xa-datasource-class>
+ <xa-datasource-property name="NetworkProtocol">Tds</xa-datasource-property>
+ <xa-datasource-property name="ServerName">dev01.qa.atl.jboss.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">4100</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <min-pool-size>1</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <idle-timeout-minutes>15</idle-timeout-minutes>
+ <!--check-valid-connection-sql>select 1 from mytable</check-valid-connection-sql-->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.SybaseExceptionSorter</exception-sorter-class-name>
+ <type-mapping>Sybase</type-mapping>
+
+ </xa-datasource>
+
+</datasources>
Added: branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/resources/sybase15-xa-ds.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- JBoss Server Configuration -->
+<!-- Thanks to kosulin in the forumns -->
+<!-- ===================================================================== -->
+
+<!-- $Id: sybase-xa-ds.xml 85945 2009-03-16 19:45:12Z dimitris at jboss.org $ -->
+
+<datasources>
+
+ <xa-datasource>
+ <jndi-name>CrashRecoveryDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <xa-datasource-class>com.sybase.jdbc3.jdbc.SybXADataSource</xa-datasource-class>
+ <xa-datasource-property name="NetworkProtocol">Tds</xa-datasource-property>
+ <xa-datasource-property name="ServerName">dev77.qa.atl2.redhat.com</xa-datasource-property>
+ <xa-datasource-property name="PortNumber">4100</xa-datasource-property>
+ <xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <min-pool-size>1</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <idle-timeout-minutes>15</idle-timeout-minutes>
+ <!--check-valid-connection-sql>select 1 from mytable</check-valid-connection-sql-->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.SybaseExceptionSorter</exception-sorter-class-name>
+ <type-mapping>Sybase</type-mapping>
+
+ </xa-datasource>
+
+</datasources>
Modified: branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/as-tests.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,15 +1,14 @@
<?xml version="1.0"?>
-<project name="crashrecovery-tests" default="help" basedir="."
+<project name="crashrecovery-tests" default="as-tests" 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.dir" value="${product.dir}/qa/resources"/>
<property name="astest.jar.name" value="astest.jar"/>
<property name="astest.jar.deploy.dir" value="qa/lib"/>
<property name="jboss.server.manager.jar.dir" value="${product.dir}/qa/lib"/>
@@ -25,207 +24,561 @@
<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>
+ <pathelement location="${junit.junit.lib}/junit.jar" />
+ <pathelement location="${org.apache.ant.lib}/ant-junit.jar"/>
</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="-Djava.security.policy=../src/org/jboss/jbossts/qa/astests/resources/java.policy -Dproduct.dir=../../build/"
-${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>
+ <property name="driver.home" value="${product.dir}/dbdrivers"/>
<!--
import configuration settings for the tests
-->
<import file="imports/test-config.xml"/>
+
+
+ <!--
+ Main targets intended for JBossAS Testsuite optional task
+ -->
+ <target name="crash-tests" depends="want-all-dbs, want-all-tstypes, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
+
+ <target name="crash-tests-single-db" depends="set-db, want-all-tstypes, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
- <target name="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 name="crash-tests-single-db-tstype" depends="set-db, set-tstype, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
+
+ <target name="crash-tests-single" depends="init, prepare-drivers, set-db, set-tstype, set-tsdemarc, set-testcase, crash-tests-tstype-jta, crash-tests-tstype-jts" />
+
+
+ <!--
+ Other targets...
+ -->
+ <target name="init">
+ <property name="wipeOutTxsInDoubt" value="true" />
</target>
+
+ <target name="set-db">
+ <condition property="want.psql_8.2">
+ <equals arg1="${crash.db}" arg2="psql_8.2"/>
+ </condition>
+ <condition property="want.psql_8.3">
+ <equals arg1="${crash.db}" arg2="psql_8.3"/>
+ </condition>
+ <condition property="want.sybase_15">
+ <equals arg1="${crash.db}" arg2="sybase_15"/>
+ </condition>
+ <condition property="want.oracle_10">
+ <equals arg1="${crash.db}" arg2="oracle_10"/>
+ </condition>
+ <condition property="want.oracle_11">
+ <equals arg1="${crash.db}" arg2="oracle_11"/>
+ </condition>
+ <condition property="want.db2_9.7">
+ <equals arg1="${crash.db}" arg2="db2_9.7"/>
+ </condition>
+ <condition property="want.mysql_5.0">
+ <equals arg1="${crash.db}" arg2="mysql_5.0"/>
+ </condition>
+ <condition property="want.mysql_5.1">
+ <equals arg1="${crash.db}" arg2="mysql_5.1"/>
+ </condition>
+ <condition property="want.mssql_2005">
+ <equals arg1="${crash.db}" arg2="mssql_2005"/>
+ </condition>
+ <condition property="want.mssql_2008">
+ <equals arg1="${crash.db}" arg2="mssql_2008"/>
+ </condition>
+ </target>
+
+ <target name="want-all-dbs">
+ <property name="want.psql_8.2" value="true" />
+ <property name="want.psql_8.3" value="true" />
+ <property name="want.sybase_15" value="true" />
+ <property name="want.oracle_10" value="true" />
+ <property name="want.oracle_11" value="true" />
+ <property name="want.db2_9.7" value="true" />
+ <property name="want.mysql_5.0" value="true" />
+ <property name="want.mysql_5.1" value="true" />
+ <property name="want.mssql_2005" value="true" />
+ <property name="want.mssql_2008" value="true" />
+ <!-- DEPRECATED property name="want.sybase_12" value="true" /-->
+ <!-- DEPRECATED property name="want.db2_8.2" value="true" /-->
+ </target>
- <target name="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 name="set-tstype">
+ <condition property="want.tstype.jta">
+ <equals arg1="${crash.tstype}" arg2="jta"/>
+ </condition>
+ <condition property="want.tstype.jts">
+ <equals arg1="${crash.tstype}" arg2="jts"/>
+ </condition>
</target>
+
+ <target name="want-all-tstypes">
+ <property name="want.tstype.jta" value="true" />
+ <property name="want.tstype.jts" value="true" />
+ </target>
- <target name="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 name="set-tsdemarc">
+ <condition property="want.cmt">
+ <equals arg1="${crash.tsdemarc}" arg2="cmt"/>
+ </condition>
+ <condition property="want.bmt">
+ <equals arg1="${crash.tsdemarc}" arg2="bmt"/>
+ </condition>
</target>
+
+ <target name="want-all-tsdemarc">
+ <property name="want.cmt" value="true" />
+ <property name="want.bmt" value="true" />
+ </target>
- <target name="nulltest">
- <astest:action impl="org.jboss.test.crashrecovery.ASCrashRecovery01.Test01" />
+ <target name="set-testcase">
+ <condition property="want.none">
+ <equals arg1="${crash.testcase}" arg2="none"/>
+ </condition>
+ <condition property="want.none.rev">
+ <equals arg1="${crash.testcase}" arg2="none.rev"/>
+ </condition>
+ <condition property="want.prepare_ex">
+ <equals arg1="${crash.testcase}" arg2="prepare_ex"/>
+ </condition>
+ <condition property="want.prepare_ex.rev">
+ <equals arg1="${crash.testcase}" arg2="prepare_ex.rev"/>
+ </condition>
+ <condition property="want.prepare_halt">
+ <equals arg1="${crash.testcase}" arg2="prepare_halt"/>
+ </condition>
+ <condition property="want.prepare_halt.rev">
+ <equals arg1="${crash.testcase}" arg2="prepare_halt.rev"/>
+ </condition>
+ <condition property="want.commit_halt">
+ <equals arg1="${crash.testcase}" arg2="commit_halt"/>
+ </condition>
+ <condition property="want.commit_halt.rev">
+ <equals arg1="${crash.testcase}" arg2="commit_halt.rev"/>
+ </condition>
</target>
+
+ <target name="want-all-testcases">
+ <property name="want.prepare_ex" value="true" />
+ <property name="want.prepare_ex.rev" value="true" />
+ <property name="want.prepare_halt" value="true" />
+ <property name="want.prepare_halt.rev" value="true" />
+ <property name="want.commit_halt.rev" value="true" />
+ </target>
- <!--
- 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 name="crash-tests-tstype-jta" if="want.tstype.jta">
+ <antcall target="call-tests-for-all-dbs"><param name="tstype" value="jta"/><param name="call.target" value="crash-tests-for-database"/></antcall>
</target>
+
+ <target name="crash-tests-tstype-jts" if="want.tstype.jts">
+ <antcall target="call-tests-for-all-dbs"><param name="tstype" value="jts"/><param name="call.target" value="crash-tests-for-database"/></antcall>
+ </target>
- <target name="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 name="call-tests-for-all-dbs">
+ <antcall target="call-tests-for-psql_8.2"/>
+ <antcall target="call-tests-for-psql_8.3"/>
+ <antcall target="call-tests-for-oracle_10"/>
+ <antcall target="call-tests-for-oracle_11"/>
+ <antcall target="call-tests-for-mssql_2005"/>
+ <antcall target="call-tests-for-mssql_2008"/>
+ <antcall target="call-tests-for-mysql_5.0"/>
+ <antcall target="call-tests-for-mysql_5.1"/>
+ <antcall target="call-tests-for-db2_9.7"/>
+ <antcall target="call-tests-for-sybase_15"/>
</target>
+ <target name="call-tests-for-psql_8.2" if="want.psql_8.2">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="postgresql-8.2.jar"/>
+ <param name="datasource" value="postgres82-xa-ds.xml" />
+ <param name="dbname" value="psql82" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-psql_8.3" if="want.psql_8.3">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="postgresql-8.3.jar"/>
+ <param name="datasource" value="postgres83-xa-ds.xml" />
+ <param name="dbname" value="psql83" />
+ </antcall>
+ </target>
+ <target name="call-tests-for-oracle_10" if="want.oracle_10">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="ojdbc14.jar"/>
+ <param name="datasource" value="oracle10-xa-ds.xml" />
+ <param name="dbname" value="oracle10" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-oracle_11" if="want.oracle_11">
+ <!-- Oracle has qot different .jar for jdk 1.5 vs. 1.6 runtime -->
+ <condition property="oracle.driver" value="ojdbc6.jar">
+ <equals arg1="${java.specification.version}" arg2="1.6"/>
+ </condition>
+ <property name="oracle.driver" value="ojdbc5.jar"/>
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="${oracle.driver}"/>
+ <param name="datasource" value="oracle11-xa-ds.xml" />
+ <param name="dbname" value="oracle11" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mssql_2005" if="want.mssql_2005">
+ <!-- MSSQL needs different .jar for jdk 1.5 vs. 1.6 runtime -->
+ <condition property="mssql.driver" value="sqljdbc4.jar">
+ <equals arg1="${java.specification.version}" arg2="1.6"/>
+ </condition>
+ <property name="mssql.driver" value="sqljdbc.jar"/>
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="${mssql.driver}"/>
+ <param name="datasource" value="mssql2005-xa-ds.xml" />
+ <param name="dbname" value="mssql2005" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mssql_2008" if="want.mssql_2008">
+ <!-- MSSQL needs different .jar for jdk 1.5 vs. 1.6 runtime -->
+ <condition property="mssql.driver" value="sqljdbc4.jar">
+ <equals arg1="${java.specification.version}" arg2="1.6"/>
+ </condition>
+ <property name="mssql.driver" value="sqljdbc.jar"/>
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="${mssql.driver}"/>
+ <param name="datasource" value="mssql2008-xa-ds.xml" />
+ <param name="dbname" value="mssql2008" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mysql_5.0" if="want.mysql_5.0">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="mysql-connector-java-5.0.8.jar"/>
+ <param name="datasource" value="mysql50-xa-ds.xml" />
+ <param name="dbname" value="mysql50" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-mysql_5.1" if="want.mysql_5.1">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="mysql-connector-java-5.1.7.jar"/>
+ <param name="datasource" value="mysql51-xa-ds.xml" />
+ <param name="dbname" value="mysql51" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-db2_8.2" if="want.db2_8.2">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="DB2_v8.2_fp14/db2jcc*.jar"/>
+ <param name="datasource" value="db2_82-xa-ds.xml" />
+ <param name="dbname" value="db2_82" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-db2_9.7" if="want.db2_9.7">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="db2jcc.jar" />
+ <param name="datasource" value="db2_97-xa-ds.xml" />
+ <param name="dbname" value="db2_9" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-sybase_12" if="want.sybase_12">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="jconn3.jar"/>
+ <param name="datasource" value="sybase12-xa-ds.xml" />
+ <param name="dbname" value="sybase12" />
+ </antcall>
+ </target>
+
+ <target name="call-tests-for-sybase_15" if="want.sybase_15">
+ <antcall target="${call.target}">
+ <param name="dbdriver" value="jconn3.jar"/>
+ <param name="datasource" value="sybase15-xa-ds.xml" />
+ <param name="dbname" value="sybase15" />
+ </antcall>
+ </target>
+
+ <target name="crash-tests-for-database" depends="crash-tests-for-database-cmt, crash-tests-for-database-bmt" />
+
+ <target name="crash-tests-for-database-cmt" if="want.cmt">
+ <antcall target="crash-tests-all-testcases"><param name="cmt" value="true" /></antcall>
+ </target>
+
+ <target name="crash-tests-for-database-bmt" if="want.bmt">
+ <antcall target="crash-tests-all-testcases"><param name="cmt" value="false" /></antcall>
+ </target>
+
+
+ <target name="crash-tests-all-testcases"
+ depends="testcase-none,
+ testcase-none-rev,
+ testcase-prepare_ex,
+ testcase-prepare_ex-rev,
+ testcase-prepare_halt,
+ testcase-prepare_halt-rev,
+ testcase-commit_halt-rev" />
+
+ <target name="testcase-none" if="want.none">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="none"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-none-rev" if="want.none.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="none"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_ex" if="want.prepare_ex">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_ex"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_ex-rev" if="want.prepare_ex.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_ex"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_halt" if="want.prepare_halt">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_halt"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-prepare_halt-rev" if="want.prepare_halt.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="prepare_halt"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-commit_halt-rev" if="want.commit_halt.rev">
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="commit_halt"/><param name="reverseOrder" value="true"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="testcase-commit_halt" if="want.commit_halt">
+ <!-- DISABLED test-case: the test is invalid for the current version -->
+ <antcall target="execute-crash-recovery-test">
+ <param name="specs" value="commit_halt"/><param name="reverseOrder" value="false"/><param name="rollbackExpected" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="execute-crash-recovery-test" depends="hack-before-astest-run, crash-recovery-test, hack-after-astest-run" />
+
<!--
- Tests intended for JBossAS Testsuite optional task
+ Note: If you want to wipe out txs in doubt before and after test you have to set property 'wipeOutTxsInDoubt' to true.
-->
- <target name="as-tests" depends="as-tests-jta, as-tests-jts" />
+ <target name="crash-recovery-test">
+<!-- <attribute name="specs"/>
+ <attribute name="datasource"/>
+ <attribute name="dbdriver"/>
+ <attribute name="dbname"/>
+ <attribute name="cmt"/>
+ <attribute name="tstype"/>
+ <attribute name="reverseOrder"/>
+ <attribute name="rollbackExpected"/> -->
+ <sequential>
+
+ <condition property="test.name.cmt" value="cmt" else="bmt">
+ <istrue value="${cmt}"/>
+ </condition>
+ <condition property="test.name.reverseOrder" value="-reverse" else="">
+ <istrue value="${reverseOrder}"/>
+ </condition>
+ <property name="testname" value="${tstype}-${specs}-${test.name.cmt}${test.name.reverseOrder}"/>
- <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" />
+ <condition property="astest.app.jar.name" value="${astest.alternative.jar.name}">
+ <isset property="astest.alternative.jar.name"/>
+ </condition>
+ <property name="astest.app.jar.name" value="${astest.jar.name}" />
+
+ <condition property="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/ArjunaTransactionImple">
+ <equals arg1="${tstype}" arg2="jts" />
+ </condition>
+ <property name="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction" />
+
+ <astest:server method="start" serverName="crashrecovery-${tstype}" >
+ <deploy from="dbdrivers/${dbdriver}" to="lib/${dbdriver}" />
+ <deploy from="resources/${datasource}" to="deploy/${datasource}" />
+ <deploy from="${astest.jar.deploy.dir}/${astest.app.jar.name}" to="deploy/${astest.app.jar.name}" />
+ </astest:server>
+ <astest:action abortOnFail="false" waitFor="10000" impl="org.jboss.test.crashrecovery.taskdefs.JUnitClientAction">
+ <param key="testClass" value="org.jboss.test.crashrecovery.ASCrashRecovery01.TestWithJPA" />
+ <param key="name" value="${dbname}-${testname}" />
+ <param key="serverName" value="crashrecovery-${tstype}" />
+ <param key="specs" value="${specs}" />
+ <param key="cmt" value="${cmt}" />
+ <param key="storeType" value="${storeType}" />
+ <param key="reverseOrder" value="${reverseOrder}" />
+ <param key="rollbackExpected" value="${rollbackExpected}" />
+ <param key="wipeOutTxsInDoubtBeforeTest" value="${wipeOutTxsInDoubtBeforeTest}" />
+ <param key="wipeOutTxsInDoubt" value="${wipeOutTxsInDoubt}" />
+ <param key="debug" value="true" />
+ <param key="reportFile" value="${build.reports}/TEST-org.jboss.test.crashrecovery.ASCrashRecovery01.TestWithJPA-${dbname}-${testname}.xml" />
+ <param key="testTime" value="${testTime}" />
</astest:action>
- <astest: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>
+ <astest:server method="stop" serverName="crashrecovery-${tstype}" >
+ <undeploy from="deploy/${astest.app.jar.name}" />
+ <undeploy from="deploy/${datasource}" />
+ <undeploy from="lib/${dbdriver}" />
+ </astest:server>
+
+ <!-- archive the server log -->
+ <zip destfile="${jboss.home}/server/crashrecovery-${tstype}/log/server-${dbname}-${testname}.log.zip">
+ <fileset file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
+ </zip>
+ <delete file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
+ <copy todir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store-${dbname}-${testname}">
+ <fileset dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store" />
+ </copy>
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store"/>
+ <!-- delete work and tmp dirs otherwise tests failed due to permgen space - FIXME is this the right way how to ensure that? -->
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/work"/>
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/tmp"/>
+
+ </sequential>
+ </target>
- <target name="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" />
+ <target name="hack-before-astest-run" depends="hack-before-astest-run-for-db2_9.7" />
+
+ <target name="hack-after-astest-run" depends="hack-after-astest-run-for-db2_9.7" />
+
+ <target name="hack-before-astest-run-for-db2_9.7" if="want.db2_9.7">
+ <!-- deploy license .jar file -->
+ <copy file="${product.dir}/dbdrivers/db2jcc_license_cu.jar" todir="${jboss.home}/server/crashrecovery-${tstype}/lib" />
+
+ <!-- prepare hacked astest jar -->
+ <property name="astest.alternative.jar.name" value="db2-${astest.jar.name}" />
+
+ <available file="${astest.jar.dir}/${astest.alternative.jar.name}"
+ property="have.db2.astest.alternative.jar" />
+ <antcall target="prepare-db2-alternative-jar" />
+
+ </target>
+
+ <target name="prepare-db2-alternative-jar" unless="have.db2.astest.alternative.jar">
+ <mkdir dir="${astest.jar.dir}/${astest.alternative.jar.name}_content"/>
+ <unjar src="${astest.jar.dir}/${astest.jar.name}" dest="${astest.jar.dir}/${astest.alternative.jar.name}_content" />
+ <available file="${astest.jar.dir}/${astest.alternative.jar.name}_content/META-INF/persistence.xml"
+ property="have.persistence.xml" />
+ <antcall target="change-hbm2ddl-update-to-none" />
+ <jar destfile="${astest.jar.dir}/${astest.alternative.jar.name}">
+ <fileset dir="${astest.jar.dir}/${astest.alternative.jar.name}_content"/>
+ </jar>
+ <delete dir="${astest.jar.dir}/${astest.alternative.jar.name}_content" />
+ </target>
+
+ <target name="change-hbm2ddl-update-to-none" if="have.persistence.xml">
+ <replace file="${astest.jar.dir}/${astest.alternative.jar.name}_content/META-INF/persistence.xml" summary="true">
+ <replacetoken><![CDATA[name="hibernate.hbm2ddl.auto" value="update"]]></replacetoken>
+ <replacevalue><![CDATA[name="hibernate.hbm2ddl.auto" value="none" ]]></replacevalue>
+ </replace>
+ </target>
+
+ <target name="hack-after-astest-run-for-db2_9.7" if="want.db2_9.7">
+ <!-- undeploy license .jar file -->
+ <delete file="${jboss.home}/server/crashrecovery-${tstype}/lib/db2jcc_license_cu.jar" />
+ </target>
+
+
+
+ <!--
+ Do use this target if you want to wipe out txs in doubt in all databases.
+ -->
+ <target name="wipeout-txs-indoubt-all-dbs" depends="want-all-dbs, wipeout-txs-indoubt-single-db" />
+
+ <!--
+ Do use this target if you want to wipe out txs in doubt.
+ You can select the databases by setting crash.db property, see target set-db.
+ -->
+ <target name="wipeout-txs-indoubt-single-db" depends="set-db, prepare-drivers">
+ <property name="tstype" value="jta" />
+ <antcall target="call-tests-for-all-dbs"><param name="call.target" value="execute-wipeout-txs-indoubt"/></antcall>
+ </target>
+
+ <target name="execute-wipeout-txs-indoubt" depends="hack-before-astest-run, wipeout-txs-indoubt, hack-after-astest-run"/>
+
+ <target name="wipeout-txs-indoubt">
+ <condition property="astest.app.jar.name" value="${astest.alternative.jar.name}">
+ <isset property="astest.alternative.jar.name"/>
+ </condition>
+ <property name="astest.app.jar.name" value="${astest.jar.name}" />
+
+ <astest:server method="start" serverName="crashrecovery-jta" >
+ <deploy from="dbdrivers/${dbdriver}" to="lib/${dbdriver}" />
+ <deploy from="resources/${datasource}" to="deploy/${datasource}" />
+ <deploy from="${astest.jar.deploy.dir}/${astest.app.jar.name}" to="deploy/${astest.app.jar.name}" />
+ </astest:server>
+ <astest:action abortOnFail="false" waitFor="10000" impl="org.jboss.test.crashrecovery.taskdefs.JUnitClientAction">
+ <param key="testClass" value="org.jboss.test.crashrecovery.ASCrashRecovery01.WipeOutTxsInDoubt" />
+ <param key="name" value="test-wipeout-txs-indoubt-${dbname}" />
+ <param key="serverName" value="crashrecovery-${tstype}" />
+ <param key="debug" value="true" />
+ <param key="reportFile" value="${build.reports}/TEST-org.jboss.test.crashrecovery.ASCrashRecovery01.WipeOutTxsInDoubt-${dbname}.xml" />
</astest:action>
- <astest: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>
+ <astest:server method="stop" serverName="crashrecovery-jta" >
+ <undeploy from="deploy/${datasource}" />
+ <undeploy from="lib/${dbdriver}" />
+ <undeploy from="deploy/${astest.app.jar.name}" />
+ </astest:server>
</target>
+
+ <!-- ===== get db drivers - borrowed from https://svn.jboss.org/repos/labs/labs/jbosstm/trunk/qa/build.xml ==== -->
+ <!-- set these to the location(s) of the database drivers -->
+
+ <property name="driver.url" value="http://reports.qa.atl.jboss.com/jdbc-drivers/"/>
+
+ <target name="prepare-drivers">
+ <available file="${driver.home}" property="have.dbdrivers" value="true"/>
+ <antcall target="get.drivers" />
+ </target>
+
+ <target name="get.drivers" unless="have.dbdrivers">
+
+ <mkdir dir="${driver.home}" />
+
+ <get src="${driver.url}/maven2/com/oracle/ojdbc14/10.2.0.4/ojdbc14-10.2.0.4.jar"
+ dest="${driver.home}/ojdbc14.jar"/>
+ <get src="${driver.url}/maven2/com/oracle/ojdbc5/11.1.0.7.0/ojdbc5-11.1.0.7.0.jar"
+ dest="${driver.home}/ojdbc5.jar"/>
+ <get src="${driver.url}/maven2/com/oracle/ojdbc6/11.1.0.7.0/ojdbc6-11.1.0.7.0.jar"
+ dest="${driver.home}/ojdbc6.jar"/>
+
+ <get src="${driver.url}/maven2/com/microsoft/sqlserver/msjdbc/2.0.1008.2/msjdbc-2.0.1008.2.jar"
+ dest="${driver.home}/sqljdbc.jar"/>
+ <get src="${driver.url}/maven2/com/microsoft/sqlserver/msjdbc/2.0.1008.2/msjdbc-2.0.1008.2-4.jar"
+ dest="${driver.home}/sqljdbc4.jar"/>
+
+ <!-- FIXME postgresql v.8.3-605 and v.8.2-510-jdbc4 needed by EAP5 DB matrix -->
+ <get src="${driver.url}/maven2/postgresql/postgresql/8.3-604/postgresql-8.3-604-jdbc4.jar"
+ dest="${driver.home}/postgresql-8.3.jar"/>
+ <get src="${driver.url}/maven2/postgresql/postgresql/8.2-504/postgresql-8.2-504-jdbc3.jar"
+ dest="${driver.home}/postgresql-8.2.jar"/>
+
+ <!-- FIXME mysql v.5.1.8 needed by EAP5 DB matrix -->
+ <get src="${driver.url}/maven2/mysql/mysql-connector-java/5.1.7/mysql-connector-java-5.1.7.jar"
+ dest="${driver.home}/mysql-connector-java-5.1.7.jar"/>
+ <get src="${driver.url}/maven2/mysql/mysql-connector-java/5.0.8/mysql-connector-java-5.0.8.jar"
+ dest="${driver.home}/mysql-connector-java-5.0.8.jar"/>
+
+ <get src="${driver.url}/maven2/com/ibm/db2jcc/3.1.57/db2jcc-3.1.57.jar"
+ dest="${driver.home}/db2jcc.jar"/>
+ <get src="${driver.url}/maven2/com/ibm/db2jcc_license_cu/3.1.57/db2jcc_license_cu-3.1.57.jar"
+ dest="${driver.home}/db2jcc_license_cu.jar"/>
+
+ <!-- FIXME this one is build 26023, but we need build 26564 by EAP5 DB matrix -->
+ <get src="${driver.url}/maven2/com/sybase/jconnect/6.0.5/jconnect-6.0.5.jar"
+ dest="${driver.home}/jconn3.jar"/>
+
+ </target>
+
</project>
Modified: 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 2009-08-28 10:05:36 UTC (rev 92938)
+++ branches/Branch_5_x/testsuite/src/resources/crashrecovery/scripts/imports/test-config.xml 2009-08-28 10:06:04 UTC (rev 92939)
@@ -1,4 +1,4 @@
-<project name="crashrecovery-tests-server-config" default="help"
+<project name="crashrecovery-tests-server-config"
xmlns:astest="http://jboss.org/ns/test/ant/astest">
<taskdef name="config" classname="org.jboss.test.crashrecovery.taskdefs.ASTestConfig"
@@ -49,45 +49,12 @@
- 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_ex" mode="XAEXCEPTION" type="XARES_PREPARE" modeArg="XAER_RMFAIL" />
<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}">
@@ -100,6 +67,8 @@
<sysproperty key="sun.rmi.dgc.client.gcInterval" value="3600000" />
<sysproperty key="sun.rmi.dgc.server.gcInterval" value="3600000" />
<sysproperty key="xb.builder.useUnorderedSequence" value="true" />
+ <!--jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/-->
</server>
<server name="crashrecovery-jts" host="${node0}">
More information about the jboss-cvs-commits
mailing list