[jboss-cvs] JBossAS SVN: r84111 - in projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test: appexception and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 12 02:31:07 EST 2009


Author: wolfc
Date: 2009-02-12 02:31:06 -0500 (Thu, 12 Feb 2009)
New Revision: 84111

Added:
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/Barfing.java
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/BarfingStatefulBean.java
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/DoNotRollbackAppException.java
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/NotAnAppException.java
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/SubAppException.java
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/unit/
   projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/unit/AppExceptionTestCase.java
Log:
EJBTHREE-1725: test application exception inheritance

Added: projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/Barfing.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/Barfing.java	                        (rev 0)
+++ projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/Barfing.java	2009-02-12 07:31:06 UTC (rev 84111)
@@ -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.ejb3.tx.test.appexception;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Barfing
+{
+   void barf(RuntimeException e);
+}

Added: projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/BarfingStatefulBean.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/BarfingStatefulBean.java	                        (rev 0)
+++ projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/BarfingStatefulBean.java	2009-02-12 07:31:06 UTC (rev 84111)
@@ -0,0 +1,40 @@
+/*
+ * 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.ejb3.tx.test.appexception;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at TransactionAttribute(TransactionAttributeType.MANDATORY)
+public class BarfingStatefulBean implements Barfing
+{
+   public void barf(RuntimeException e)
+   {
+      throw e;
+   }
+}

Added: projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/DoNotRollbackAppException.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/DoNotRollbackAppException.java	                        (rev 0)
+++ projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/DoNotRollbackAppException.java	2009-02-12 07:31:06 UTC (rev 84111)
@@ -0,0 +1,35 @@
+/*
+ * 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.ejb3.tx.test.appexception;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at ApplicationException(rollback=false)
+public class DoNotRollbackAppException extends RuntimeException
+{
+   private static final long serialVersionUID = 1L;
+
+}

Added: projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/NotAnAppException.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/NotAnAppException.java	                        (rev 0)
+++ projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/NotAnAppException.java	2009-02-12 07:31:06 UTC (rev 84111)
@@ -0,0 +1,32 @@
+/*
+ * 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.ejb3.tx.test.appexception;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class NotAnAppException extends RuntimeException
+{
+   private static final long serialVersionUID = 1L;
+   
+}

Added: projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/SubAppException.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/SubAppException.java	                        (rev 0)
+++ projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/SubAppException.java	2009-02-12 07:31:06 UTC (rev 84111)
@@ -0,0 +1,32 @@
+/*
+ * 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.ejb3.tx.test.appexception;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SubAppException extends DoNotRollbackAppException
+{
+   private static final long serialVersionUID = 1L;
+
+}

Added: projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/unit/AppExceptionTestCase.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/unit/AppExceptionTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/tx/test/appexception/unit/AppExceptionTestCase.java	2009-02-12 07:31:06 UTC (rev 84111)
@@ -0,0 +1,149 @@
+/*
+ * 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.ejb3.tx.test.appexception.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import javax.ejb.EJBTransactionRequiredException;
+import javax.ejb.EJBTransactionRolledbackException;
+import javax.naming.InitialContext;
+import javax.transaction.Status;
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.test.tx.common.AbstractTxTestCase;
+import org.jboss.ejb3.test.tx.common.StatefulContainer;
+import org.jboss.ejb3.tx.test.appexception.Barfing;
+import org.jboss.ejb3.tx.test.appexception.BarfingStatefulBean;
+import org.jboss.ejb3.tx.test.appexception.DoNotRollbackAppException;
+import org.jboss.ejb3.tx.test.appexception.NotAnAppException;
+import org.jboss.ejb3.tx.test.appexception.SubAppException;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * What happens on a sub class of an application exception that specified rollback false?
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AppExceptionTestCase extends AbstractTxTestCase
+{
+   private static TransactionManager tm;
+   private static StatefulContainer<BarfingStatefulBean> container;
+
+   @BeforeClass
+   public static void setUpBeforeClass() throws Throwable
+   {
+      AbstractTxTestCase.beforeClass();
+      
+      InitialContext ctx = new InitialContext();
+      tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
+      
+      container = new StatefulContainer<BarfingStatefulBean>("BarfingStatefulBean", "Stateful Container", BarfingStatefulBean.class);
+   }
+   
+   @Test
+   public void testDoNotRollbackAppException() throws Throwable
+   {
+      Barfing bean = container.constructProxy(Barfing.class);
+      
+      tm.begin();
+      try
+      {
+         bean.barf(new DoNotRollbackAppException());
+         fail("Should have thrown DoNotRollbackAppException (EJB 3.0 14.3.1 table 14)");
+      }
+      catch(DoNotRollbackAppException e)
+      {
+         // good
+         
+         int status = tm.getStatus();
+         assertEquals(Status.STATUS_ACTIVE, status);
+      }
+      finally
+      {
+         tm.rollback();
+      }
+   }
+   
+   /**
+    * Sanity check.
+    */
+   @Test
+   public void testMandatoryWithoutTx() throws Throwable
+   {
+      Barfing bean = container.constructProxy(Barfing.class);
+      
+      try
+      {
+         bean.barf(null);
+         fail("Should have thrown EJBTransactionRequiredException (EJB 3.0 13.6.2.5)");
+      }
+      catch(EJBTransactionRequiredException e)
+      {
+         // good
+      }
+   }
+
+   @Test
+   public void testNotAnAppException() throws Throwable
+   {
+      Barfing bean = container.constructProxy(Barfing.class);
+      
+      tm.begin();
+      try
+      {
+         bean.barf(new NotAnAppException());
+         fail("Should have thrown EJBTransactionRolledbackException (EJB 3.0 14.3.1 table 14)");
+      }
+      catch(EJBTransactionRolledbackException e)
+      {
+         // good
+      }
+      finally
+      {
+         tm.rollback();
+      }
+   }
+
+   @Test
+   public void testSubAppException() throws Throwable
+   {
+      Barfing bean = container.constructProxy(Barfing.class);
+      
+      tm.begin();
+      try
+      {
+         bean.barf(new SubAppException());
+         fail("Should have thrown EJBTransactionRolledbackException (EJB 3.0 14.3.1 table 14)");
+      }
+      catch(EJBTransactionRolledbackException e)
+      {
+         // good
+      }
+      finally
+      {
+         tm.rollback();
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list