[jboss-cvs] JBossAS SVN: r70669 - in projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions: unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 10 12:29:56 EDT 2008
Author: alex.loubyansky at jboss.com
Date: 2008-03-10 12:29:56 -0400 (Mon, 10 Mar 2008)
New Revision: 70669
Added:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/RollbackError.java
Modified:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/Dao.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/DaoBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/unit/TxExceptionsTestCase.java
Log:
EJBTHREE-1072 testcase
Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/Dao.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/Dao.java 2008-03-10 16:25:55 UTC (rev 70668)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/Dao.java 2008-03-10 16:29:56 UTC (rev 70669)
@@ -21,8 +21,6 @@
*/
package org.jboss.ejb3.test.txexceptions;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
/**
* Comment
@@ -52,6 +50,8 @@
void createThrowRollbackRuntimeException(int id) throws RollbackRuntimeException;
+ void createThrowRollbackError(int id) throws RollbackError;
+
void remove(int id);
void testRequiresNewWithLookedUpEntityManager() throws Exception;
Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/DaoBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/DaoBean.java 2008-03-10 16:25:55 UTC (rev 70668)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/DaoBean.java 2008-03-10 16:29:56 UTC (rev 70669)
@@ -124,4 +124,10 @@
persist(id);
throw new RollbackRuntimeException();
}
+
+ public void createThrowRollbackError(int id) throws RollbackError
+ {
+ persist(id);
+ throw new RollbackError();
+ }
}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/RollbackError.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/RollbackError.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/RollbackError.java 2008-03-10 16:29:56 UTC (rev 70669)
@@ -0,0 +1,33 @@
+/*
+ * 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.ejb3.test.txexceptions;
+
+
+/**
+ * A RollbackError.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class RollbackError extends Error
+{
+}
Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/unit/TxExceptionsTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/unit/TxExceptionsTestCase.java 2008-03-10 16:25:55 UTC (rev 70668)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/txexceptions/unit/TxExceptionsTestCase.java 2008-03-10 16:29:56 UTC (rev 70669)
@@ -30,6 +30,7 @@
import org.jboss.ejb3.test.txexceptions.Dao;
import org.jboss.ejb3.test.txexceptions.NoRollbackRemoteException;
import org.jboss.ejb3.test.txexceptions.NoRollbackRuntimeException;
+import org.jboss.ejb3.test.txexceptions.RollbackError;
import org.jboss.ejb3.test.txexceptions.RollbackRemoteException;
import org.jboss.ejb3.test.txexceptions.RollbackRuntimeException;
import org.jboss.ejb3.test.txexceptions.SimpleEntity;
@@ -232,6 +233,31 @@
assertNull(entity);
}
+ public void testRollbackError() throws Exception
+ {
+ Dao dao = (Dao) getInitialContext().lookup("DaoBean/remote");
+
+ try
+ {
+ dao.createThrowRollbackError(1);
+ fail();
+ }
+ catch (EJBException e)
+ {
+ // AFAIK, the spec doesn't define how the causing error should be delivered
+ // so, this is based on the current impl
+ assertTrue(e.getCausedByException() instanceof RuntimeException);
+ assertTrue(((RuntimeException)e.getCausedByException()).getCause() instanceof RollbackError);
+ }
+
+ SimpleEntity entity = dao.get(1);
+
+ if (entity != null)
+ dao.remove(1);
+
+ assertNull(entity);
+ }
+
public static Test suite() throws Exception
{
return getDeploySetup(TxExceptionsTestCase.class, "txexceptions-test.jar");
More information about the jboss-cvs-commits
mailing list