[jbpm-commits] JBoss JBPM SVN: r2587 - jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Oct 22 11:14:21 EDT 2008
Author: tom.baeyens at jboss.com
Date: 2008-10-22 11:14:20 -0400 (Wed, 22 Oct 2008)
New Revision: 2587
Removed:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java
Log:
[JBPM-1721] Remove JobLoadJoinTest
Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java 2008-10-22 15:12:35 UTC (rev 2586)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java 2008-10-22 15:14:20 UTC (rev 2587)
@@ -1,148 +0,0 @@
-package org.jbpm.job.executor;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.db.AbstractDbTestCase;
-import org.jbpm.graph.def.ActionHandler;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
-
-public class JobLoadJoinTest extends AbstractDbTestCase
-{
-
- private static Log log = LogFactory.getLog(JobLoadJoinTest.class);
-
- static Set finishedProcesses = Collections.synchronizedSet(new HashSet());
- long start;
-
- @Override
- protected String getJbpmTestConfig()
- {
- return "org/jbpm/job/executor/loadtests.jbpm.cfg.xml";
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- start = System.currentTimeMillis();
- }
-
- private boolean timeout(int maxWait)
- {
- return System.currentTimeMillis() - start > maxWait;
- }
-
- public void testJobLoadWithJoin() throws Exception
- {
- int processes = 20;
- int maxWait = 20000;
-
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='asyncjoin' initial='yenom'>" +
- " <node name='yenom' async='true'>" +
- " <transition to='rof' />" +
- " </node>" +
- " <fork name='rof'>" +
- " <transition to='gnihton' />" +
- " <transition to='skihc' />" +
- " </fork>" +
- " <node name='gnihton' async='true'>" +
- " <transition to='eerf' />" +
- " </node>" +
- " <node name='skihc' async='true'>" +
- " <transition to='eerf' />" +
- " </node>" +
- " <join name='eerf'>" +
- " <transition to='ymtnawi' />" +
- " </join>" +
- " <node name='ymtnawi' async='true'>" +
- " <transition to='vtm' />" +
- " </node>" +
- " <end-state name='vtm' />" +
- " <event type='process-end'>" +
- " <action class='"+ProcessFinished.class.getName()+"' />" +
- " </event>" +
- "</process-definition>"
- );
-
- jbpmContext.deployProcessDefinition(processDefinition);
- long processDefinitionId = processDefinition.getId();
-
- commitAndCloseSession();
-
- try {
- getJbpmConfiguration().startJobExecutor();
-
- Set expectedProcesses = new HashSet();
- for (int i = 0; i < processes; i++)
- {
- Integer number = new Integer(i);
- expectedProcesses.add(number);
- Thread thread = new StartNewExecutionThread(getJbpmConfiguration(), number);
- thread.start();
- }
-
- while (!expectedProcesses.equals(finishedProcesses) && !timeout(maxWait))
- {
- Thread.sleep(200);
- }
- log.info("number of finished processes: " + finishedProcesses);
- log.info("number of expected processes: " + expectedProcesses);
- assertEquals(expectedProcesses, finishedProcesses);
-
- } catch (Exception e) {
- e.printStackTrace();
-
- } finally {
- beginSessionTransaction();
- graphSession.deleteProcessDefinition(processDefinitionId);
- }
- }
-
- public static class StartNewExecutionThread extends Thread
- {
- Integer number;
- JbpmConfiguration jbpmConfiguration;
-
- public StartNewExecutionThread(JbpmConfiguration jbpmConfiguration, Integer number)
- {
- this.jbpmConfiguration = jbpmConfiguration;
- this.number = number;
- }
-
- public void run()
- {
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- ProcessInstance processInstance = jbpmContext.newProcessInstance("asyncjoin");
- processInstance.getContextInstance().setVariable("number", number);
- jbpmContext.save(processInstance);
- }
- finally
- {
- jbpmContext.close();
- }
- }
- }
-
- public static class ProcessFinished implements ActionHandler
- {
- private static final long serialVersionUID = 1L;
-
- public void execute(ExecutionContext executionContext) throws Exception
- {
- Integer number = (Integer)executionContext.getVariable("number");
- log.info("process " + number + " finished");
- finishedProcesses.add(number);
- }
- }
-}
More information about the jbpm-commits
mailing list