[jbpm-commits] JBoss JBPM SVN: r2004 - in jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704: jpdl/jar/src/test/java/org/jbpm/job/executor and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 26 00:37:20 EDT 2008


Author: alex.guizar at jboss.com
Date: 2008-08-26 00:37:20 -0400 (Tue, 26 Aug 2008)
New Revision: 2004

Added:
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTests.java
Modified:
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.project
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/ConcurrencyTest.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java
   jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java
Log:
[JBPM-1704] rehabilitated most job executor tests and hooked them to test suite

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.project
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.project	2008-08-26 01:11:36 UTC (rev 2003)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/.project	2008-08-26 04:37:20 UTC (rev 2004)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>jbpm.3_HEAD</name>
+	<name>jbpm.3_JBPM-1704</name>
 	<comment></comment>
 	<projects>
 	</projects>

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/ConcurrencyTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/ConcurrencyTest.java	2008-08-26 01:11:36 UTC (rev 2003)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/ConcurrencyTest.java	2008-08-26 04:37:20 UTC (rev 2004)
@@ -119,7 +119,6 @@
     try {
       jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(SUBPROCESS_XML));
       jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_XML));
-
     }
     finally {
       jbpmContext.close();
@@ -129,30 +128,33 @@
     Map testVariables = new HashMap();
     testVariables.put("test", "true");
 
-    for (int i = 0; i < 10; i++) {
+    final int processCount = 10;
+    long[] piIds = new long[processCount];
+    for (int i = 0; i < processCount; i++) {
       log.info("#################### TEST: starting process " + i + " ####################");
 
-      ProcessInstance pi = null;
-
       jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
-        pi = jbpmContext.newProcessInstance("simpletest");
+        ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("simpletest");
         pi.getContextInstance().addVariables(testVariables);
-        jbpmContext.save(pi);
         pi.signal();
-
+        piIds[i] = pi.getId();
       }
       finally {
         jbpmContext.close();
       }
+    }
+
+    for (int i = 0; i < processCount; i++) {
       log.info("### TEST: wait for process completion ###");
 
-      waitFor(pi.getId());
+      long piId = piIds[i];
+      waitFor(piId);
 
       jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
-        ProcessInstance pi2 = jbpmContext.getProcessInstance(pi.getId());
-        assertEquals("end-state-success", pi2.getRootToken().getNode().getName());
+        ProcessInstance pi = jbpmContext.loadProcessInstance(piId);
+        assertEquals("end-state-success", pi.getRootToken().getNode().getName());
       }
       finally {
         jbpmContext.close();
@@ -172,10 +174,9 @@
         return;
       }
 
-      log.info("waiting for workflow completion...."); // + pi.getRootToken().getNode().getName()
-      // );
+      log.info("waiting for workflow completion....");
       try {
-        Thread.sleep(5000);
+        Thread.sleep(1000);
       }
       catch (InterruptedException e) {
         log.error("wait for workflow was interruputed", e);
@@ -184,7 +185,7 @@
 
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
-        if (jbpmContext.getProcessInstance(piId).hasEnded())
+        if (jbpmContext.loadProcessInstance(piId).hasEnded())
           break;
       }
       finally {
@@ -213,7 +214,6 @@
           + "): begin");
 
       for (int i = 0; i < 5; i++) {
-        Thread.sleep(500);
         log.info("ACTION (process="
             + processName
             + ",node="
@@ -221,7 +221,7 @@
             + ",token="
             + tokenName
             + "): working...");
-        Thread.sleep(500);
+        Thread.sleep(100);
       }
 
       log.info("ACTION (process="

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java	2008-08-26 01:11:36 UTC (rev 2003)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java	2008-08-26 04:37:20 UTC (rev 2004)
@@ -22,7 +22,7 @@
 public class JobExecutorDbTest extends TestCase {
 
   static int nbrOfConcurrentProcessExecutions = 20;
-  static int maxWaitTime = 20000;
+  static int maxWaitTime = 60000;
   static Set collectedResults = Collections.synchronizedSet(new TreeSet());
   
   protected static JbpmConfiguration jbpmConfiguration = 
@@ -37,7 +37,7 @@
   public static class AutomaticActivity implements ActionHandler {
     private static final long serialVersionUID = 1L;
     public void execute(ExecutionContext executionContext) throws Exception {
-      String id = (String) Long.toString(executionContext.getProcessInstance().getId());
+      long id = executionContext.getProcessInstance().getId();
       String nodeName = executionContext.getNode().getName();
       collectedResults.add(id+nodeName);
       executionContext.leaveNode();
@@ -47,7 +47,7 @@
   public static class AsyncAction implements ActionHandler {
     private static final long serialVersionUID = 1L;
     public void execute(ExecutionContext executionContext) throws Exception {
-      String id = (String) Long.toString(executionContext.getProcessInstance().getId());
+      long id = executionContext.getProcessInstance().getId();
       Action action = executionContext.getAction();
       String actionName = action.getName();
       collectedResults.add(id+actionName);

Added: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTests.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTests.java	                        (rev 0)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobExecutorDbTests.java	2008-08-26 04:37:20 UTC (rev 2004)
@@ -0,0 +1,41 @@
+/*
+ * 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.job.executor;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class JobExecutorDbTests {
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite("org.jbpm.job.executor");
+    // $JUnit-BEGIN$
+    suite.addTestSuite(JobExecutorDbTest.class);
+    suite.addTestSuite(NoJobExecutorDbTest.class);
+    suite.addTestSuite(MultiJobExecutorTest.class);
+    suite.addTestSuite(ConcurrencyTest.class);
+    suite.addTestSuite(TimerOnTimerDbTest.class);
+    // $JUnit-END$
+    return suite;
+  }
+
+}

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java	2008-08-26 01:11:36 UTC (rev 2003)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java	2008-08-26 04:37:20 UTC (rev 2004)
@@ -24,16 +24,16 @@
 
   static Set finishedProcesses = Collections.synchronizedSet(new HashSet());
   long start;
-
-  static {   
-    jbpmConfiguration.createSchema();      
-  }
   
   protected void setUp() throws Exception {
-	  super.setUp();
+	  jbpmConfiguration.createSchema();
 	  start = System.currentTimeMillis();
   }
-  
+
+  protected void tearDown() throws Exception {
+    jbpmConfiguration.dropSchema();
+  }
+
   private boolean timeIsUp(int maxWait) {
 	  return System.currentTimeMillis() - start > maxWait;
   }

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java	2008-08-26 01:11:36 UTC (rev 2003)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java	2008-08-26 04:37:20 UTC (rev 2004)
@@ -18,7 +18,7 @@
 public class JobLoadSubProcessTest extends TestCase {
 
   // TODO see JobLoadJoinTest, but instead of the joins, use a process with a sub process
-  private static Log log = LogFactory.getLog(JobLoadJoinTest.class);
+  private static Log log = LogFactory.getLog(JobLoadSubProcessTest.class);
 
   static Set finishedProcesses = Collections.synchronizedSet(new HashSet());
   long start;
@@ -26,15 +26,15 @@
   private static JbpmConfiguration jbpmConfiguration = 
     JbpmConfiguration.getInstance("org/jbpm/job/executor/loadtests.jbpm.cfg.xml");
 
-  static {   
-    jbpmConfiguration.createSchema();      
-  }
-		  
   protected void setUp() throws Exception {
-	  super.setUp();
+	  jbpmConfiguration.createSchema();
 	  start = System.currentTimeMillis();
   }
-  
+
+  protected void tearDown() throws Exception {
+    jbpmConfiguration.dropSchema();
+  }
+
   private boolean timeIsUp(int maxWait) {
 	  return System.currentTimeMillis() - start > maxWait;
   }

Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java	2008-08-26 01:11:36 UTC (rev 2003)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/jpdl/jar/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java	2008-08-26 04:37:20 UTC (rev 2004)
@@ -33,7 +33,7 @@
   public static final String PROCESS_DEFINITION = "<?xml version='1.0' encoding='UTF-8'?>"
       + "<process-definition xmlns='' name='TestProcess'>"
       + "<event type='process-end'>"
-      + "<action name='endAction' class='"
+      + "<action class='"
       + EndAction.class.getName()
       + "' />"
       + "</event>"
@@ -41,22 +41,18 @@
       + "<transition to='Service 1'></transition>"
       + "</start-state>"
       + "<node name='Service 1'>"
-      + "<action name='esbAction' "
-      + "class='"
+      + "<action class='"
       + SimpleAction.class.getName()
-      + "'>"
-      + "</action>"
-      + "<transition to='Service 2'></transition>"
+      + "' />"
+      + "<transition to='Service 2' />"
       + "</node>"
       + "<node name='Service 2' async='true'>"
-      + "<action name='esbAction' "
-      + "class='"
+      + "<action class='"
       + SimpleAction2.class.getName()
-      + "'>"
-      + "</action>"
-      + "<transition to='end-state1'></transition>"
+      + "' />"
+      + "<transition to='end-state1' />"
       + "</node>"
-      + "<end-state name='end-state1'></end-state>"
+      + "<end-state name='end-state1' />"
       + "</process-definition>";
 
   protected void setUp() throws SQLException {




More information about the jbpm-commits mailing list