-
1. Re: Handling process state
jeevdav May 28, 2010 11:37 PM (in response to jeevdav)I was using the junit tests that come with jBPM 4.3. Does this have anything to do with the way the tests are set up? I tried commenting out repositoryService.deleteDeployment() lines in the test cases but it did not help
-
2. Re: Handling process state
rebody May 29, 2010 12:18 AM (in response to jeevdav)Hi David,
By default, the JbpmTestCase will clear database after each testcase. You could restart processEngine in a method to prevent this problem.
If this problem is still here. Please provide a testcase which could reproduce the scenario. So we could get more details to find out the reason.
-
3. Re: Handling process state
jeevdav May 29, 2010 8:10 PM (in response to rebody)This is what i am running.
testFindOne suceeds as expected, but testFindTwo and testFindThree fail unless all three are run together( when they are run together they use the same processengine and execution service)
The bottom line is that findProcessInstanceById works only when the same processengine is used. But in the realworld after i recycle my application how will i be able to resume my incomplete processes?
========================================================================
public class TestJBPM extends TestCase
{
protected static ProcessEngine processEngine = null;
protected static RepositoryService repositoryService;
protected static ExecutionService executionService;
protected static ManagementService managementService;
protected static TaskService taskService;
protected static HistoryService historyService;
protected static IdentityService identityService;@Override
protected void setUp() throws Exception {
super.setUp();
if (processEngine==null) {
processEngine = Configuration.getProcessEngine();
repositoryService = processEngine.get(RepositoryService.class);
executionService = processEngine.getExecutionService();
historyService = processEngine.getHistoryService();
managementService = processEngine.getManagementService();
taskService = processEngine.getTaskService();
identityService = processEngine.getIdentityService();
}
}
public void testFindOne() {
repositoryService.createDeployment()
.addResourceFromClasspath("com/test/Proc.jpdl.xml")
.deploy();
ProcessInstance processInstance = executionService.startProcessInstanceByKey("Proc","t");
System.out.println("process id "+processInstance.getId());
Execution executionInA = processInstance.findActiveExecutionIn("a");
assertNotNull(executionInA);//processInstance = executionService.signalExecutionById(executionInA.getId());
processInstance = executionService.findProcessInstanceById("Proc.t");
assertNotNull(processInstance);
}
public void testFindTwo() {ProcessInstance processInstance = executionService.findProcessInstanceById("Proc.t");
assertNotNull(processInstance);
}
public void testFindThree() {
repositoryService.createDeployment()
.addResourceFromClasspath("com/test/Proc.jpdl.xml")
.deploy();
ProcessInstance processInstance = executionService.findProcessInstanceById("Proc.t");
assertNotNull(processInstance);
}
}
===========================
The test process
=======================
<?xml version="1.0" encoding="UTF-8"?>
<process name="Proc" xmlns="http://jbpm.org/4.3/jpdl">
<start name="start1" g="121,59,48,48">
<transition name="to a" to="a" g="-25,-20"/>
</start>
<state name="a" g="107,134,92,52">
<transition name="to b" to="b" g="-26,-20"/>
</state>
<state name="b" g="111,207,92,52">
<transition name="to c" to="c" g="-25,-20"/>
</state>
<state name="c" g="118,271,92,52">
<transition name="to end1" to="end1" g="-45,-20"/>
</state>
<end name="end1" g="134,344,48,48"/>
</process> -
4. Re: Handling process state
rebody May 29, 2010 8:42 PM (in response to jeevdav)Hi David,
There is no guaranty that method in testcase will run sequence as you expect. So testFindTwo() and testFindThree() may be executed before testFindOne().
And You didn't re-create processEngine for each testcase.
-
5. Re: Handling process state
jeevdav May 29, 2010 10:40 PM (in response to rebody)Hi HuiSheng,
I ran the test cases one by one by right clicking on the method I wanted to run and choosing "Run as junit test" from eclipse. This ensured that they ran in the correct order. It aslo ensured that every time a new processengine is created.
- Jeeves
-
6. Re: Handling process state
swiderski.maciej May 30, 2010 4:41 AM (in response to jeevdav)It should run properly as soon as your process is persisted to a data base that is running regardless of your tests being executed or not. I mean that you have db server started as regular server and not in memory.
Could you post your hibernate config file?
-
7. Re: Handling process state
jeevdav May 30, 2010 12:51 PM (in response to swiderski.maciej)sure.
<?
xml version="1.0" encoding="utf-8"?>
<!
DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<
hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="hibernate.format_sql">true</property>
<mapping resource="jbpm.repository.hbm.xml" />
<mapping resource="jbpm.execution.hbm.xml" />
<mapping resource="jbpm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.identity.hbm.xml" />
</session-factory>
</
hibernate-configuration>
-
8. Re: Handling process state
swiderski.maciej May 30, 2010 2:16 PM (in response to jeevdav)1 of 1 people found this helpfulBased on your description and hibernate config file, it looks like each time you call your unit test method (starting new java process it will create new instance of in memory db, meaning that it will not contain any previously created processes.
I would suggest you to change hibernate config to point so already running db - just start hsqldb as regular server and then your process should be visible regardless of how many times you start your tests.
-
9. Re: Handling process state
jeevdav May 31, 2010 12:30 AM (in response to swiderski.maciej)Maciej,
You got it right.
Now I have this and my test works as expected. Thank you!
<property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost:1701</property>