[jboss-cvs] JBossAS SVN: r63545 - in branches/Branch_4_2: testsuite/imports/sections and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 18 08:21:57 EDT 2007
Author: adrian at jboss.org
Date: 2007-06-18 08:21:57 -0400 (Mon, 18 Jun 2007)
New Revision: 63545
Added:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java
branches/Branch_4_2/testsuite/src/resources/tm/bmtcleanup/
branches/Branch_4_2/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml
Modified:
branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
branches/Branch_4_2/testsuite/imports/sections/tm.xml
Log:
[JBAS-4487] - Added test and also applied same fix to badStateful checking.
Modified: branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
===================================================================
--- branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java 2007-06-18 12:03:06 UTC (rev 63544)
+++ branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java 2007-06-18 12:21:57 UTC (rev 63545)
@@ -244,20 +244,22 @@
}
finally
{
+ Transaction tx = null;
try
{
- Transaction tx = tm.suspend();
- if (tx != null)
- {
- String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName()
- + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ;
- log.error(msg);
- }
+ tx = tm.suspend();
}
catch (SystemException ex)
{
log.error("Failed to suspend transaction", ex);
}
+ if (tx != null)
+ {
+ String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName()
+ + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ;
+ log.error(msg);
+ throw new RemoteException(msg);
+ }
}
}
@@ -274,23 +276,45 @@
log.error("Failed to get status", ex);
}
- switch (status)
+ try
{
- case Status.STATUS_COMMITTING :
- case Status.STATUS_MARKED_ROLLBACK :
- case Status.STATUS_PREPARING :
- case Status.STATUS_ROLLING_BACK :
- try
- {
- tm.rollback();
- }
- catch (Exception ex)
- {
- log.error("Failed to rollback", ex);
- }
- String msg = "BMT stateful bean '" + container.getBeanMetaData().getEjbName()
- + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status);
+
+ switch (status)
+ {
+ case Status.STATUS_COMMITTING :
+ case Status.STATUS_MARKED_ROLLBACK :
+ case Status.STATUS_PREPARING :
+ case Status.STATUS_ROLLING_BACK :
+ try
+ {
+ tm.rollback();
+ }
+ catch (Exception ex)
+ {
+ log.error("Failed to rollback", ex);
+ }
+ String msg = "BMT stateful bean '" + container.getBeanMetaData().getEjbName()
+ + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status);
+ log.error(msg);
+ }
+ }
+ finally
+ {
+ Transaction tx = null;
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (SystemException ex)
+ {
+ log.error("Failed to suspend transaction", ex);
+ }
+ if (tx != null)
+ {
+ String msg = "BMT stateful bean " + container.getBeanMetaData().getEjbName()
+ + " did not complete user transaction properly tx=" + tx;
log.error(msg);
+ }
}
}
Modified: branches/Branch_4_2/testsuite/imports/sections/tm.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/tm.xml 2007-06-18 12:03:06 UTC (rev 63544)
+++ branches/Branch_4_2/testsuite/imports/sections/tm.xml 2007-06-18 12:21:57 UTC (rev 63545)
@@ -36,5 +36,17 @@
<include name="org/jboss/test/tm/interfaces/**"/>
</fileset>
</jar>
+
+ <!-- build bmtcleanuptest.jar -->
+ <jar destfile="${build.lib}/bmtcleanuptest.jar">
+ <metainf dir="${build.resources}/tm/bmtcleanup">
+ <include name="*.xml"/>
+ </metainf>
+ <fileset dir="${build.classes}">
+ <patternset refid="common.test.client.classes"/>
+ <include name="org/jboss/test/tm/ejb/**"/>
+ <include name="org/jboss/test/tm/interfaces/**"/>
+ </fileset>
+ </jar>
</target>
</project>
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/ejb/BMTCleanUpBean.java 2007-06-18 12:21:57 UTC (rev 63545)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tm.ejb;
+
+import java.rmi.RemoteException;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.jboss.test.tm.interfaces.BMTCleanUp;
+import org.jboss.test.util.ejb.SessionSupport;
+import org.jboss.tm.TransactionManagerLocator;
+
+/**
+ * BMTCleanUpBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BMTCleanUpBean extends SessionSupport
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6750278789142406435L;
+
+ public void ejbCreate()
+ {
+ }
+
+ public void doNormal() throws RemoteException
+ {
+ UserTransaction ut = sessionCtx.getUserTransaction();
+ try
+ {
+ ut.begin();
+ ut.commit();
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+
+ public void testIncomplete() throws RemoteException
+ {
+ BMTCleanUp remote = (BMTCleanUp) sessionCtx.getEJBObject();
+ try
+ {
+ remote.doIncomplete();
+ }
+ catch (RemoteException expected)
+ {
+ // expected
+ }
+ checkTransaction();
+ remote.doNormal();
+ }
+
+ public void doIncomplete() throws RemoteException
+ {
+ UserTransaction ut = sessionCtx.getUserTransaction();
+ try
+ {
+ ut.begin();
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+
+ public void testTxTimeout() throws RemoteException
+ {
+ BMTCleanUp remote = (BMTCleanUp) sessionCtx.getEJBObject();
+ try
+ {
+ remote.doTimeout();
+ }
+ catch (RemoteException expected)
+ {
+ // expected
+ }
+ checkTransaction();
+ remote.doNormal();
+ }
+
+ public void doTimeout() throws RemoteException
+ {
+ UserTransaction ut = sessionCtx.getUserTransaction();
+ try
+ {
+ ut.setTransactionTimeout(5);
+ ut.begin();
+ Thread.sleep(10000);
+ }
+ catch (InterruptedException ignored)
+ {
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+
+ private void checkTransaction() throws RemoteException
+ {
+ TransactionManager tm = TransactionManagerLocator.getInstance().locate();
+ try
+ {
+ Transaction tx = tm.getTransaction();
+ if (tx != null)
+ throw new RemoteException("There should be no transaction context: " + tx);
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RemoteException("Error", e);
+ }
+ }
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUp.java 2007-06-18 12:21:57 UTC (rev 63545)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tm.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * BMTCleanUp.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface BMTCleanUp extends EJBObject
+{
+ void doNormal() throws RemoteException;
+
+ void testIncomplete() throws RemoteException;
+
+ void doIncomplete() throws RemoteException;
+
+ void testTxTimeout() throws RemoteException;
+
+ void doTimeout() throws RemoteException;
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/interfaces/BMTCleanUpHome.java 2007-06-18 12:21:57 UTC (rev 63545)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tm.interfaces;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * BMTCleanUpHome.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface BMTCleanUpHome extends EJBHome
+{
+ BMTCleanUp create() throws CreateException, RemoteException;
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/tm/test/BMTCleanUpUnitTestCase.java 2007-06-18 12:21:57 UTC (rev 63545)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tm.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestSetup;
+import org.jboss.test.tm.interfaces.BMTCleanUp;
+import org.jboss.test.tm.interfaces.BMTCleanUpHome;
+
+/**
+ * Tests for BMT CleanUp
+ *
+ * @author adrian at jboss.com
+ * @version $Revision: 60501 $
+ */
+public class BMTCleanUpUnitTestCase extends JBossTestCase
+{
+ public BMTCleanUpUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return new JBossTestSetup(getDeploySetup(BMTCleanUpUnitTestCase.class, "bmtcleanuptest.jar"));
+ }
+
+ public void testIncomplete() throws Exception
+ {
+ BMTCleanUp bean = getBean();
+ bean.testIncomplete();
+ }
+
+ public void testTxTimeout() throws Exception
+ {
+ BMTCleanUp bean = getBean();
+ bean.testTxTimeout();
+ }
+
+ private BMTCleanUp getBean() throws Exception
+ {
+ BMTCleanUpHome home = (BMTCleanUpHome) getInitialContext().lookup("BMTCleanUp");
+ return home.create();
+ }
+}
Added: branches/Branch_4_2/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/tm/bmtcleanup/ejb-jar.xml 2007-06-18 12:21:57 UTC (rev 63545)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!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>
+ <display-name>TimeoutTests</display-name>
+
+ <enterprise-beans>
+ <session>
+ <description>A stateless bean used for bmt cleanup tests</description>
+ <ejb-name>BMTCleanUp</ejb-name>
+ <home>org.jboss.test.tm.interfaces.BMTCleanUpHome</home>
+ <remote>org.jboss.test.tm.interfaces.BMTCleanUp</remote>
+ <ejb-class>org.jboss.test.tm.ejb.BMTCleanUpBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Bean</transaction-type>
+ </session>
+ </enterprise-beans>
+
+</ejb-jar>
More information about the jboss-cvs-commits
mailing list