[jbpm-commits] JBoss JBPM SVN: r1821 - jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/tx.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 5 03:36:52 EDT 2008


Author: tom.baeyens at jboss.com
Date: 2008-08-05 03:36:52 -0400 (Tue, 05 Aug 2008)
New Revision: 1821

Modified:
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/tx/BasicTransactionTest.java
Log:
added checked exception test

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/tx/BasicTransactionTest.java	2008-08-05 07:28:14 UTC (rev 1820)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/tx/BasicTransactionTest.java	2008-08-05 07:36:52 UTC (rev 1821)
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import org.hibernate.Session;
+import org.jbpm.pvm.PvmException;
 import org.jbpm.pvm.env.Environment;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.model.CommentImpl;
@@ -54,20 +55,20 @@
   }
   
   
-  public static class MyOwnException extends RuntimeException {
+  public static class MyOwnRuntimeException extends RuntimeException {
   }
   
-  public void testRollback() {
+  public void testRollbackRuntimeException() {
     try {
       commandService.execute(new Command<Object>(){
         public Object execute(Environment environment) {
           Session session = environment.get(Session.class);
           session.save(new CommentImpl("if i only had the time to write code"));
-          throw new MyOwnException();
+          throw new MyOwnRuntimeException();
         }
       });
       fail("expected exception");
-    } catch (MyOwnException e) {
+    } catch (MyOwnRuntimeException e) {
       // OK
     }
     
@@ -80,4 +81,32 @@
       }
     });
   }
+
+  public static class MyOwnCheckedException extends Exception {
+  }
+  
+  public void testRollbackCheckedException() {
+    try {
+      commandService.execute(new Command<Object>(){
+        public Object execute(Environment environment) throws Exception {
+          Session session = environment.get(Session.class);
+          session.save(new CommentImpl("if i only had the time to write code"));
+          throw new MyOwnCheckedException();
+        }
+      });
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertSame(MyOwnCheckedException.class, e.getCause().getClass());
+    }
+    
+    commandService.execute(new Command<Object>(){
+      public Object execute(Environment environment) {
+        Session session = environment.get(Session.class);
+        List<CommentImpl> comments = session.createQuery("from "+CommentImpl.class.getName()).list();
+        assertEquals(0, comments.size());
+        return null;
+      }
+    });
+  }
 }




More information about the jbpm-commits mailing list