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