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