1
2
3
4
5
6
7 package org.mule.module.jbpm;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.api.client.MuleClient;
11 import org.mule.module.bpm.BPMS;
12 import org.mule.module.bpm.Process;
13 import org.mule.tck.junit4.FunctionalTestCase;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertNotNull;
23 import static org.junit.Assert.assertTrue;
24
25
26
27
28
29 public class MessagingJbpmComponentTestCase extends FunctionalTestCase
30 {
31
32 @Override
33 protected String getConfigResources()
34 {
35 return "jbpm-component-functional-test.xml";
36 }
37
38 @Test
39 public void testSendMessageProcess() throws Exception
40 {
41 MuleClient client = muleContext.getClient();
42 BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
43 assertNotNull(bpms);
44
45
46 MuleMessage response = client.send("vm://message", "data", null);
47 Object process = response.getPayload();
48 assertTrue(bpms.isProcess(process));
49
50 String processId = (String)bpms.getId(process);
51
52 assertFalse(processId == null);
53 assertEquals("waitForResponse", bpms.getState(process));
54
55
56 Map props = new HashMap<String, Object>();
57 props.put(Process.PROPERTY_PROCESS_ID, processId);
58 response = client.send("vm://message", "data", props);
59 process = response.getPayload();
60
61
62 assertTrue(bpms.hasEnded(process));
63 }
64
65 }