[jbpm-commits] JBoss JBPM SVN: r4158 - in jbpm3/branches/jbpm-3.2.5.SP/modules: core/src/main/java/org/jbpm/graph/def and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Mar 5 16:10:18 EST 2009


Author: alex.guizar at jboss.com
Date: 2009-03-05 16:10:18 -0500 (Thu, 05 Mar 2009)
New Revision: 4158

Added:
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java
Removed:
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/EventCallback.java
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm1755/gpd.xml
Modified:
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java
   jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
   jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java
Log:
throw exception if wait for event cannot be completed

Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/EventCallback.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/EventCallback.java	2009-03-05 16:26:51 UTC (rev 4157)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/EventCallback.java	2009-03-05 21:10:18 UTC (rev 4158)
@@ -1,144 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.jbpm;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.jbpm.graph.def.Event;
-
-public class EventCallback implements Serializable {
-
-  public static final int DEFAULT_TIMEOUT = 30 * 1000;
-
-  private static final long serialVersionUID = 1L;
-  private static final Log log = LogFactory.getLog(EventCallback.class);
-
-  private static Map<String, Semaphore> eventSemaphores = new HashMap<String, Semaphore>();
-
-  public void processStart() {
-    registerNotification(Event.EVENTTYPE_PROCESS_START);
-  }
-
-  public void processEnd() {
-    registerNotification(Event.EVENTTYPE_PROCESS_END);
-  }
-
-  public void nodeEnter() {
-    registerNotification(Event.EVENTTYPE_NODE_ENTER);
-  }
-
-  public void nodeLeave() {
-    registerNotification(Event.EVENTTYPE_NODE_LEAVE);
-  }
-
-  public void taskCreate() {
-    registerNotification(Event.EVENTTYPE_TASK_CREATE);
-  }
-
-  public void taskEnd() {
-    registerNotification(Event.EVENTTYPE_TASK_END);
-  }
-
-  public void timerCreate() {
-    registerNotification(Event.EVENTTYPE_TIMER_CREATE);
-  }
-
-  public void timer() {
-    registerNotification(Event.EVENTTYPE_TIMER);
-  }
-
-  public void transition() {
-    registerNotification(Event.EVENTTYPE_TRANSITION);
-  }
-
-  private static void registerNotification(final String event) {
-    Synchronization notification = new Synchronization() {
-
-      public void beforeCompletion() {
-      }
-
-      public void afterCompletion(int status) {
-        if (status == Status.STATUS_COMMITTED) {
-          log.debug("sending '" + event + "' notification");
-          Semaphore eventSemaphore = getEventSemaphore(event);
-          eventSemaphore.release();
-        }
-      }
-
-    };
-    JbpmContext.getCurrentJbpmContext()
-        .getSession()
-        .getTransaction()
-        .registerSynchronization(notification);
-  }
-
-  public static void waitForEvent(String event) {
-    waitForEvent(event, DEFAULT_TIMEOUT);
-  }
-
-  public static void waitForEvent(String event, long timeout) {
-    log.debug("waiting for " + event);
-    Semaphore eventSemaphore = getEventSemaphore(event);
-    try {
-      if (eventSemaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
-        log.debug("received '" + event + "' notification");
-      }
-      else {
-        log.warn("event '" + event + "' did not occur within " + timeout + " ms");
-      }
-    }
-    catch (InterruptedException e) {
-      // reassert interruption
-      Thread.currentThread().interrupt();
-    }
-  }
-
-  private static Semaphore getEventSemaphore(String event) {
-    synchronized (eventSemaphores) {
-      Semaphore semaphore = eventSemaphores.get(event);
-      if (semaphore == null) {
-        semaphore = new Semaphore(0);
-        eventSemaphores.put(event, semaphore);
-      }
-      return semaphore;
-    }
-  }
-
-  public static void clear() {
-    for (Map.Entry<String, Semaphore> entry : eventSemaphores.entrySet()) {
-      int permits = entry.getValue().drainPermits();
-      if (permits != 0) {
-        log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
-      }
-    }
-  }
-}
\ No newline at end of file

Copied: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java (from rev 4142, jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/EventCallback.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/EventCallback.java	2009-03-05 21:10:18 UTC (rev 4158)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbpm.graph.def;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.JbpmException;
+
+public class EventCallback implements Serializable {
+
+  public static final int DEFAULT_TIMEOUT = 5 * 60 * 1000;
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = LogFactory.getLog(EventCallback.class);
+
+  private static Map<String, Semaphore> eventSemaphores = new HashMap<String, Semaphore>();
+
+  public void processStart() {
+    registerNotification(Event.EVENTTYPE_PROCESS_START);
+  }
+
+  public void processEnd() {
+    registerNotification(Event.EVENTTYPE_PROCESS_END);
+  }
+
+  public void nodeEnter() {
+    registerNotification(Event.EVENTTYPE_NODE_ENTER);
+  }
+
+  public void nodeLeave() {
+    registerNotification(Event.EVENTTYPE_NODE_LEAVE);
+  }
+
+  public void taskCreate() {
+    registerNotification(Event.EVENTTYPE_TASK_CREATE);
+  }
+
+  public void taskEnd() {
+    registerNotification(Event.EVENTTYPE_TASK_END);
+  }
+
+  public void timerCreate() {
+    registerNotification(Event.EVENTTYPE_TIMER_CREATE);
+  }
+
+  public void timer() {
+    registerNotification(Event.EVENTTYPE_TIMER);
+  }
+
+  public void transition() {
+    registerNotification(Event.EVENTTYPE_TRANSITION);
+  }
+
+  private static void registerNotification(final String event) {
+    Synchronization notification = new Synchronization() {
+
+      public void beforeCompletion() {
+      }
+
+      public void afterCompletion(int status) {
+        if (status == Status.STATUS_COMMITTED) {
+          log.debug("sending '" + event + "' notification");
+          Semaphore eventSemaphore = getEventSemaphore(event);
+          eventSemaphore.release();
+        }
+      }
+
+    };
+    JbpmContext.getCurrentJbpmContext()
+        .getSession()
+        .getTransaction()
+        .registerSynchronization(notification);
+  }
+
+  public static void waitForEvent(String event) {
+    waitForEvent(1, event, DEFAULT_TIMEOUT);
+  }
+
+  public static void waitForEvent(String event, long timeout) {
+    waitForEvent(1, event, timeout);
+  }
+
+  public static void waitForEvent(int occurrences, String event) {
+    waitForEvent(occurrences, event, DEFAULT_TIMEOUT);
+  }
+
+  public static void waitForEvent(int occurrences, String event, long timeout) {
+    log.debug("waiting for " + event);
+    Semaphore eventSemaphore = getEventSemaphore(event);
+    try {
+      if (eventSemaphore.tryAcquire(occurrences, timeout, TimeUnit.MILLISECONDS)) {
+        log.debug("received '" + event + "' notification");
+      }
+      else {
+        throw new JbpmException("event '" + event + "' did not occur within " + timeout + " ms");
+      }
+    }
+    catch (InterruptedException e) {
+      throw new JbpmException("wait for event '" + event + "' was interrupted", e);
+    }
+  }
+
+  private static Semaphore getEventSemaphore(String event) {
+    synchronized (eventSemaphores) {
+      Semaphore semaphore = eventSemaphores.get(event);
+      if (semaphore == null) {
+        semaphore = new Semaphore(0);
+        eventSemaphores.put(event, semaphore);
+      }
+      return semaphore;
+    }
+  }
+
+  public static void clear() {
+    for (Map.Entry<String, Semaphore> entry : eventSemaphores.entrySet()) {
+      int permits = entry.getValue().drainPermits();
+      if (permits != 0) {
+        log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
+      }
+    }
+  }
+}
\ No newline at end of file

Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java	2009-03-05 16:26:51 UTC (rev 4157)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java	2009-03-05 21:10:18 UTC (rev 4158)
@@ -21,11 +21,11 @@
  */
 package org.jbpm.jbpm1072;
 
-import org.jbpm.EventCallback;
 import org.jbpm.JbpmConfiguration;
 import org.jbpm.db.AbstractDbTestCase;
 import org.jbpm.graph.def.ActionHandler;
 import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.EventCallback;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ExecutionContext;
 import org.jbpm.graph.exe.ProcessInstance;

Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java	2009-03-05 16:26:51 UTC (rev 4157)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java	2009-03-05 21:10:18 UTC (rev 4158)
@@ -21,9 +21,9 @@
  */
 package org.jbpm.jbpm1135;
 
-import org.jbpm.EventCallback;
 import org.jbpm.db.AbstractDbTestCase;
 import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.EventCallback;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 

Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java	2009-03-05 16:26:51 UTC (rev 4157)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm1755/JBPM1755Test.java	2009-03-05 21:10:18 UTC (rev 4158)
@@ -1,11 +1,9 @@
 package org.jbpm.jbpm1755;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.hibernate.LockMode;
-import org.jbpm.EventCallback;
 import org.jbpm.db.AbstractDbTestCase;
 import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.EventCallback;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.graph.node.Join;
@@ -19,30 +17,23 @@
  */
 public class JBPM1755Test extends AbstractDbTestCase {
 
-  private long processDefinitionId;
+  private ProcessDefinition processDefinition;
 
   private static final int processInstanceCount = 5;
-  private static final long maxWaitTime = 10 * 1000;
-  private static final Log log = LogFactory.getLog(JBPM1755Test.class);
 
   @Override
   protected void setUp() throws Exception {
     super.setUp();
-
-    ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("org/jbpm/jbpm1755/parallelprocess.xml");
-    jbpmContext.deployProcessDefinition(processDefinition);
-    processDefinitionId = processDefinition.getId();
-
+    processDefinition = ProcessDefinition.parseXmlResource("org/jbpm/jbpm1755/parallelprocess.xml");
     startJobExecutor();
   }
 
   @Override
   protected void tearDown() throws Exception {
     stopJobExecutor();
-    graphSession.deleteProcessDefinition(processDefinitionId);
-    super.tearDown();
-    
+    graphSession.deleteProcessDefinition(processDefinition.getId());
     EventCallback.clear();
+    super.tearDown();
   }
 
   public void testReadLock() {
@@ -58,48 +49,33 @@
   }
 
   private void launchProcessInstances(LockMode lockMode) {
-    ProcessDefinition processDefinition = graphSession.loadProcessDefinition(processDefinitionId);
     Join join = (Join) processDefinition.getNode("join1");
     join.setParentLockMode(lockMode.toString());
+    jbpmContext.deployProcessDefinition(processDefinition);
 
     long[] processInstanceIds = new long[processInstanceCount];
     for (int i = 0; i < processInstanceCount; i++) {
+      newTransaction();
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       processInstanceIds[i] = processInstance.getId();
       processInstance.getContextInstance().setVariable("eventCallback", new EventCallback());
       processInstance.signal();
       jbpmContext.save(processInstance);
     }
+
     commitAndCloseSession();
+    try {
+      EventCallback.waitForEvent(processInstanceCount, Event.EVENTTYPE_PROCESS_END);
+    }
+    finally {
+      beginSessionTransaction();
+    }
 
     for (int i = 0; i < processInstanceCount; i++) {
       long processInstanceId = processInstanceIds[i];
-      waitForProcessInstanceEnd(processInstanceId);
-      assertTrue(hasProcessInstanceEnded(processInstanceId));
+      assertTrue("expected process instance " + processInstanceId + " to have ended", 
+          jbpmContext.loadProcessInstance(processInstanceId).hasEnded());
     }
-
-    processJobs(maxWaitTime);
   }
 
-  private void waitForProcessInstanceEnd(long processInstanceId) {
-    long startTime = System.currentTimeMillis();
-    do {
-      EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END, 1000);
-      if (System.currentTimeMillis() - startTime > maxWaitTime) {
-        log.warn("process instance " + processInstanceId + " took too long");
-        break;
-      }
-    } while (!hasProcessInstanceEnded(processInstanceId));
-  }
-
-  private boolean hasProcessInstanceEnded(long processInstanceId) {
-    beginSessionTransaction();
-    try {
-      return jbpmContext.loadProcessInstance(processInstanceId).hasEnded();
-    }
-    finally {
-      commitAndCloseSession();
-    }
-  }
-
 }

Deleted: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm1755/gpd.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm1755/gpd.xml	2009-03-05 16:26:51 UTC (rev 4157)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm1755/gpd.xml	2009-03-05 21:10:18 UTC (rev 4158)
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<root-container name="raceCondition" width="798" height="531">
-  <node name="start" x="135" y="52" width="140" height="40">
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-  </node>
-  <node name="fork1" x="79" y="136" width="252" height="24">
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-  </node>
-  <node name="join1" x="79" y="311" width="252" height="24">
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-  </node>
-  <node name="node2" x="155" y="219" width="100" height="36">
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-  </node>
-  <node name="node3" x="276" y="220" width="98" height="36">
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-  </node>
-  <node name="node1" x="31" y="218" width="105" height="36">
-    <edge>
-      <label x="5" y="-10"/>
-    </edge>
-  </node>
-  <node name="end" x="134" y="377" width="140" height="40"/>
-</root-container>

Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java	2009-03-05 16:26:51 UTC (rev 4157)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/ejbtimer/EjbSchedulerTest.java	2009-03-05 21:10:18 UTC (rev 4158)
@@ -32,7 +32,6 @@
 import org.apache.cactus.ServletTestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jbpm.EventCallback;
 import org.jbpm.JbpmContext;
 import org.jboss.bpm.api.test.IntegrationTestSetup;
 import org.jbpm.command.Command;
@@ -41,6 +40,7 @@
 import org.jbpm.ejb.LocalCommandService;
 import org.jbpm.ejb.LocalCommandServiceHome;
 import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.EventCallback;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.graph.exe.Token;
@@ -167,7 +167,13 @@
     assertEquals("a", getProcessState(processId));
     // no more expirations
     cancelTimer("a", process.getRootToken().getId());
-    EventCallback.waitForEvent(Event.EVENTTYPE_TIMER, 2000);
+    try {
+      EventCallback.waitForEvent(Event.EVENTTYPE_TIMER, 2000);
+      fail("expected timeout exception");
+    }
+    catch (org.jbpm.JbpmException e) {
+      // timeout exception was expected
+    }
     signalProcess(processId);
     assertTrue(isProcessFinished(processId));
   }

Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java	2009-03-05 16:26:51 UTC (rev 4157)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/enterprise/src/test/java/org/jbpm/enterprise/jms/JmsMessageTest.java	2009-03-05 21:10:18 UTC (rev 4158)
@@ -33,7 +33,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.cfg.Environment;
 import org.jboss.bpm.api.test.IntegrationTestSetup;
-import org.jbpm.EventCallback;
 import org.jbpm.JbpmContext;
 import org.jbpm.command.Command;
 import org.jbpm.command.DeployProcessCommand;
@@ -41,6 +40,7 @@
 import org.jbpm.ejb.LocalCommandService;
 import org.jbpm.ejb.LocalCommandServiceHome;
 import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.EventCallback;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.msg.jms.JmsMessageService;
@@ -273,15 +273,16 @@
       processIds[i] = launchProcess("execution").getId();
       EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
     }
+
+    EventCallback.waitForEvent(processExecutionCount, Event.EVENTTYPE_NODE_LEAVE);
+    EventCallback.waitForEvent(processExecutionCount, Event.EVENTTYPE_PROCESS_END);
+
     for (int i = 0; i < processExecutionCount; i++)
     {
-      EventCallback.waitForEvent(Event.EVENTTYPE_NODE_LEAVE);
+      long processId = processIds[i];
+      assertTrue("expected process " + processId + " to have ended",
+          hasProcessEnded(processId));
     }
-    for (int i = 0; i < processExecutionCount; i++)
-    {
-      waitForProcessEnd(processIds[i]);
-      assertTrue(hasProcessEnded(processIds[i]));
-    }
   }
 
   private ProcessDefinition deployProcess(String xml)
@@ -310,19 +311,4 @@
     });
     return isFinished.booleanValue();
   }
-
-  private void waitForProcessEnd(long processId)
-  {
-    long startTime = System.currentTimeMillis();
-    do
-    {
-      EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END, 1000);
-      if (System.currentTimeMillis() - startTime > maxWaitTime)
-      {
-        log.warn("process " + processId + " took too long");
-        break;
-      }
-    }
-    while (!hasProcessEnded(processId));
-  }
 }




More information about the jbpm-commits mailing list