[jboss-cvs] JBossAS SVN: r64601 - trunk/testsuite/src/main/org/jboss/test/tm/ejb.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 15 07:55:01 EDT 2007
Author: adrian at jboss.org
Date: 2007-08-15 07:55:01 -0400 (Wed, 15 Aug 2007)
New Revision: 64601
Modified:
trunk/testsuite/src/main/org/jboss/test/tm/ejb/TxTimeoutBean.java
Log:
Port the latest version of the Transaction timeout test from jboss-4.2
Modified: trunk/testsuite/src/main/org/jboss/test/tm/ejb/TxTimeoutBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/tm/ejb/TxTimeoutBean.java 2007-08-15 11:29:50 UTC (rev 64600)
+++ trunk/testsuite/src/main/org/jboss/test/tm/ejb/TxTimeoutBean.java 2007-08-15 11:55:01 UTC (rev 64601)
@@ -27,7 +27,11 @@
import javax.transaction.TransactionManager;
import org.jboss.test.util.ejb.SessionSupport;
+import org.jboss.tm.TxUtils;
+/**
+ * @version $Revision$
+ */
public class TxTimeoutBean extends SessionSupport
{
/** The serialVersionUID */
@@ -42,16 +46,10 @@
*/
public void testDefaultTimeout()
{
- try
- {
- Thread.sleep(12000);
- }
- catch (Exception ignored)
- {
- log.debug("Ignored", ignored);
- }
- if (getTxStatus() != Status.STATUS_MARKED_ROLLBACK)
- throw new EJBException("Should be marked rolled back " + getTxStatus());
+ sleep(12000, false);
+ int status = getTxStatus();
+ if (status != Status.STATUS_MARKED_ROLLBACK)
+ throw new EJBException("Should be marked rolled back: " + TxUtils.getStatusAsString(status));
}
/**
@@ -59,16 +57,19 @@
*/
public void testOverriddenTimeoutExpires()
{
- try
+ sleep(7000, false);
+ int status = getTxStatus();
+ log.info("testOverriddenTimeoutExpires: " + TxUtils.getStatusAsString(status));
+ if (TxUtils.isRollback(status) == false)
{
- Thread.sleep(8000);
+ // give it a second chance
+ sleep(2000, false);
+ status = getTxStatus();
+ log.info("testOverriddenTimeoutExpires: " + TxUtils.getStatusAsString(status));
+
+ if (TxUtils.isRollback(status) == false)
+ throw new EJBException("Should be marked rolled back: " + TxUtils.getStatusAsString(status));
}
- catch (Exception ignored)
- {
- log.debug("Ignored", ignored);
- }
- if (getTxStatus() != Status.STATUS_MARKED_ROLLBACK)
- throw new EJBException("Should be marked rolled back " + getTxStatus());
}
/**
@@ -76,29 +77,38 @@
*/
public void testOverriddenTimeoutDoesNotExpire()
{
+ sleep(12000, true);
+ int status = getTxStatus();
+ if (status != Status.STATUS_ACTIVE)
+ throw new EJBException("Should be active: " + TxUtils.getStatusAsString(status));
+ }
+
+ private int getTxStatus()
+ {
try
{
- Thread.sleep(12000);
+ InitialContext ctx = new InitialContext();
+ TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
+ return tm.getStatus();
}
catch (Exception e)
{
throw new EJBException(e);
}
- if (getTxStatus() != Status.STATUS_ACTIVE)
- throw new EJBException("Should be active " + getTxStatus());
}
- private int getTxStatus()
+ private void sleep(int timeout, boolean throwEJBException)
{
try
{
- InitialContext ctx = new InitialContext();
- TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
- return tm.getStatus();
+ Thread.sleep(timeout);
}
catch (Exception e)
{
- throw new EJBException(e);
+ if (throwEJBException)
+ throw new EJBException(e);
+ else
+ log.debug("Ignored", e);
}
}
}
More information about the jboss-cvs-commits
mailing list