1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.jbpm;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.bpm.BPMS;
15 import org.mule.tck.FunctionalTestCase;
16
17 import org.jbpm.api.ProcessInstance;
18
19 public class ForkedProcessComponentTestCase extends FunctionalTestCase
20 {
21 @Override
22 protected String getConfigResources()
23 {
24 return "jbpm-component-functional-test.xml";
25 }
26
27 public void testForkedProcess() throws Exception
28 {
29 BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
30 assertNotNull(bpms);
31
32
33 MuleMessage response = muleContext.getClient().send("vm://fork", "data", null);
34 ProcessInstance process = (ProcessInstance) response.getPayload();
35
36
37 String state = (String) bpms.getState(process);
38 assertTrue(state.contains("waitForResponseA"));
39 assertTrue(state.contains("waitForResponseB"));
40
41 Thread.sleep(2000);
42
43
44 process = (ProcessInstance) bpms.lookupProcess(process.getId());
45 assertEquals("waitForResponseA", bpms.getState(process));
46
47
48 muleContext.getRegistry().lookupService("ServiceA").resume();
49 Thread.sleep(2000);
50
51
52 process = (ProcessInstance) bpms.lookupProcess(process.getId());
53 assertTrue("Process should have ended, but is in state " + bpms.getState(process),
54 bpms.hasEnded(process));
55 }
56 }