[jbpm-commits] JBoss JBPM SVN: r2495 - in jbpm3/trunk/modules/core: src/test/java/org/jbpm/job/executor and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 7 04:41:10 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-10-07 04:41:10 -0400 (Tue, 07 Oct 2008)
New Revision: 2495

Modified:
   jbpm3/trunk/modules/core/pom.xml
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
Log:
[JBPM-1771] Fix JobExecutorDbTest on postgresql

Modified: jbpm3/trunk/modules/core/pom.xml
===================================================================
--- jbpm3/trunk/modules/core/pom.xml	2008-10-06 23:29:44 UTC (rev 2494)
+++ jbpm3/trunk/modules/core/pom.xml	2008-10-07 08:41:10 UTC (rev 2495)
@@ -325,8 +325,6 @@
                 <exclude>org/jbpm/perf/StateUpdateTest.java</exclude>
                 <!-- https://jira.jboss.org/jira/browse/JBPM-1724 -->
                 <exclude>org/jbpm/seam/SeamPageFlowTest.java</exclude>
-                <!-- https://jira.jboss.org/jira/browse/JBPM-1771 -->
-                <exclude>org/jbpm/job/executor/JobExecutorDbTest.java</exclude>
                 <!-- https://jira.jboss.org/jira/browse/JBPM-1772 -->
                 <exclude>org/jbpm/jpdl/exe/JoinDbTest.java</exclude>
                 <exclude>org/jbpm/graph/exe/SubProcessPlusConcurrencyDbTest.java</exclude>

Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java	2008-10-06 23:29:44 UTC (rev 2494)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java	2008-10-07 08:41:10 UTC (rev 2495)
@@ -1,6 +1,8 @@
 package org.jbpm.job.executor;
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -20,46 +22,22 @@
 
 public class JobExecutorDbTest extends AbstractJbpmTestCase
 {
+  private static Log log = LogFactory.getLog(JobExecutorDbTest.class);
 
   static int nbrOfConcurrentProcessExecutions = 20;
   static int maxWaitTime = 60000;
-  static Set collectedResults = Collections.synchronizedSet(new TreeSet());
+  static Set<String> collectedResults = Collections.synchronizedSet(new TreeSet<String>());
 
-  protected static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/jbpm.test.cfg.xml");
+  static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/jbpm.test.cfg.xml");
 
-  static
+  static List<Long> allocatedProcessIds = Collections.synchronizedList(new ArrayList<Long>());
+  
   {
     jbpmConfiguration.getJobExecutor().nbrOfThreads = 5;
   }
 
-  protected JobExecutor jobExecutor;
+  private JobExecutor jobExecutor;
 
-  public static class AutomaticActivity implements ActionHandler
-  {
-    private static final long serialVersionUID = 1L;
-
-    public void execute(ExecutionContext executionContext) throws Exception
-    {
-      long id = executionContext.getProcessInstance().getId();
-      String nodeName = executionContext.getNode().getName();
-      collectedResults.add(id + nodeName);
-      executionContext.leaveNode();
-    }
-  }
-
-  public static class AsyncAction implements ActionHandler
-  {
-    private static final long serialVersionUID = 1L;
-
-    public void execute(ExecutionContext executionContext) throws Exception
-    {
-      long id = executionContext.getProcessInstance().getId();
-      Action action = executionContext.getAction();
-      String actionName = action.getName();
-      collectedResults.add(id + actionName);
-    }
-  }
-
   public void testJobExecutor()
   {
     jbpmConfiguration.createSchema();
@@ -137,19 +115,20 @@
     }
   }
 
-  public Set createExpectedResults()
+  public Set<String> createExpectedResults()
   {
-    Set expectedResults = new TreeSet();
-    for (int i = 1; i < nbrOfConcurrentProcessExecutions + 1; i++)
+    Set<String> expectedResults = new TreeSet<String>();
+    for (int i = 0; i < nbrOfConcurrentProcessExecutions; i++)
     {
-      expectedResults.add(i + "a");
-      expectedResults.add(i + "b");
-      expectedResults.add(i + "c");
-      expectedResults.add(i + "d");
-      expectedResults.add(i + "e");
-      expectedResults.add(i + "X");
-      expectedResults.add(i + "Y");
-      expectedResults.add(i + "Z");
+      String prefix = (i < 10 ? "0" : "");
+      expectedResults.add(prefix + i + "a");
+      expectedResults.add(prefix + i + "b");
+      expectedResults.add(prefix + i + "c");
+      expectedResults.add(prefix + i + "d");
+      expectedResults.add(prefix + i + "e");
+      expectedResults.add(prefix + i + "X");
+      expectedResults.add(prefix + i + "Y");
+      expectedResults.add(prefix + i + "Z");
     }
     return expectedResults;
   }
@@ -266,5 +245,44 @@
     }
   }
 
-  private static Log log = LogFactory.getLog(JobExecutorDbTest.class);
+  public static class AutomaticActivity implements ActionHandler
+  {
+    private static final long serialVersionUID = 1L;
+
+    public void execute(ExecutionContext executionContext) throws Exception
+    {
+      Long id = executionContext.getProcessInstance().getId();
+      String procIndex = getProcessIndex(id);
+      
+      String nodeName = executionContext.getNode().getName();
+      collectedResults.add(procIndex + nodeName);
+      executionContext.leaveNode();
+    }
+  }
+
+  public static class AsyncAction implements ActionHandler
+  {
+    private static final long serialVersionUID = 1L;
+
+    public void execute(ExecutionContext executionContext) throws Exception
+    {
+      Long id = executionContext.getProcessInstance().getId();
+      String procIndex = getProcessIndex(id);
+      
+      Action action = executionContext.getAction();
+      String actionName = action.getName();
+      collectedResults.add(procIndex + actionName);
+    }
+  }
+  
+  private static synchronized String getProcessIndex(Long id)
+  {
+    if (allocatedProcessIds.contains(id) == false)
+      allocatedProcessIds.add(id);
+    
+    int procIndex = allocatedProcessIds.indexOf(id);
+    String prefix = (procIndex < 10 ? "0" : "");
+
+    return prefix + procIndex;
+  }
 }




More information about the jbpm-commits mailing list