[jbpm-commits] JBoss JBPM SVN: r3693 - jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/jbpm1798.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jan 21 00:11:44 EST 2009


Author: alex.guizar at jboss.com
Date: 2009-01-21 00:11:44 -0500 (Wed, 21 Jan 2009)
New Revision: 3693

Modified:
   jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java
Log:
JBPM-1798 test left active job executor running!

Modified: jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java	2009-01-21 05:10:26 UTC (rev 3692)
+++ jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java	2009-01-21 05:11:44 UTC (rev 3693)
@@ -4,55 +4,62 @@
 import org.jbpm.graph.def.ActionHandler;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
 
 /**
- * Potential nullpointer in asynchronous jobs when process ends
- * 
+ * Potential null pointer in asynchronous jobs when process ends
  * https://jira.jboss.org/jira/browse/JBPM-1798
  * 
  * @author Thomas.Diesler at jboss.com
  */
-public class JBPM1798Test extends AbstractDbTestCase
-{
-  public void testJobExecution()
-  {
-    if (true)
-    {
-      System.out.println("FIXME: [JBPM-1798] Potential nullpointer in asynchronous jobs when process ends");
-      return;
-    }
-    
+public class JBPM1798Test extends AbstractDbTestCase {
+
+  private static final long maxWaitTime = 10 * 1000;
+
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    getJbpmConfiguration().getJobExecutor().setNbrOfThreads(2);
+  }
+
+  @Override
+  protected void tearDown() throws Exception {
+    getJbpmConfiguration().getJobExecutor().setNbrOfThreads(1);
+    super.tearDown();
+  }
+
+  public void testJobExecution() {
     ProcessDefinition pd = getProcessDefinition();
     jbpmContext.deployProcessDefinition(pd);
-    
-    pd.createProcessInstance();
-    
     newTransaction();
-    
-    startJobExecutor();
+    try {
+      pd.createProcessInstance();
+      newTransaction();
+      assertEquals(2, getNbrOfJobsAvailable());
+      processJobs(maxWaitTime);
+    }
+    finally {
+      graphSession.deleteProcessDefinition(pd.getId());
+    }
   }
 
-  private ProcessDefinition getProcessDefinition()
-  {
-    ProcessDefinition pd = ProcessDefinition.parseXmlString(
-        "<process-definition name='customjobexecution' initial='start'>" +
-        " <node name='start'>" +
-        " <transition to='end'>" +
-        " <action async='true' class='" + AsyncAction.class.getName() + "' />" +
-        " </transition>" +
-        " </node>" +
-        " <end-state name='end' />" +
-        "</process-definition>");
+  private ProcessDefinition getProcessDefinition() {
+    ProcessDefinition pd = ProcessDefinition.parseXmlString("<process-definition name='customjobexecution' initial='start'>"
+        + "  <node name='start'>"
+        + "    <transition to='end'>"
+        + "      <action async='true' class='"
+        + AsyncAction.class.getName()
+        + "' />"
+        + "    </transition>"
+        + "  </node>"
+        + "  <end-state name='end' />"
+        + "</process-definition>");
     return pd;
   }
 
-  public static class AsyncAction implements ActionHandler
-  {
+  public static class AsyncAction implements ActionHandler {
     private static final long serialVersionUID = 1L;
 
-    public void execute(ExecutionContext executionContext) throws Exception
-    {
+    public void execute(ExecutionContext executionContext) throws Exception {
       System.out.println("do stuff");
     }
   }




More information about the jbpm-commits mailing list