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.module.client.MuleClient;
16 import org.mule.tck.FunctionalTestCase;
17
18 import org.jbpm.api.ProcessInstance;
19
20 public class ForkedProcessComponentTestCase extends FunctionalTestCase
21 {
22 @Override
23 protected String getConfigResources()
24 {
25 return "jbpm-component-functional-test.xml";
26 }
27
28 public void testForkedProcess() throws Exception
29 {
30 BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
31 assertNotNull(bpms);
32
33 MuleClient client = new MuleClient(muleContext);
34 try
35 {
36
37 MuleMessage response = client.send("vm://fork", "data", null);
38 ProcessInstance process = (ProcessInstance) response.getPayload();
39
40
41 String state = (String) bpms.getState(process);
42 assertTrue(state.contains("waitForResponseA"));
43 assertTrue(state.contains("waitForResponseB"));
44
45 Thread.sleep(2000);
46
47
48 process = (ProcessInstance) bpms.lookupProcess(process.getId());
49 assertEquals("waitForResponseA", bpms.getState(process));
50
51
52 muleContext.getRegistry().lookupService("ServiceA").resume();
53 Thread.sleep(2000);
54
55
56 process = (ProcessInstance) bpms.lookupProcess(process.getId());
57 assertTrue("Process should have ended, but is in state " + bpms.getState(process),
58 bpms.hasEnded(process));
59 }
60 finally
61 {
62 client.dispose();
63 }
64 }
65 }