1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.jbpm;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertFalse;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertTrue;
17
18 import org.mule.api.MuleMessage;
19 import org.mule.api.client.MuleClient;
20 import org.mule.module.bpm.BPMS;
21 import org.mule.module.bpm.Process;
22 import org.mule.tck.AbstractServiceAndFlowTestCase;
23
24 import java.util.Arrays;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.Map;
28
29 import org.junit.Test;
30 import org.junit.runners.Parameterized.Parameters;
31
32
33
34
35
36 public class MessagingJbpmComponentTestCase extends AbstractServiceAndFlowTestCase
37 {
38 public MessagingJbpmComponentTestCase(ConfigVariant variant, String configResources)
39 {
40 super(variant, configResources);
41 }
42
43 @Parameters
44 public static Collection<Object[]> parameters()
45 {
46 return Arrays.asList(new Object[][]{
47 {ConfigVariant.SERVICE, "jbpm-component-functional-test-service.xml"},
48 {ConfigVariant.FLOW, "jbpm-component-functional-test-flow.xml"}
49 });
50 }
51
52 @Test
53 public void testSendMessageProcess() throws Exception
54 {
55 MuleClient client = muleContext.getClient();
56 BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
57 assertNotNull(bpms);
58
59
60 MuleMessage response = client.send("vm://message", "data", null);
61 Object process = response.getPayload();
62 assertTrue(bpms.isProcess(process));
63
64 String processId = (String)bpms.getId(process);
65
66 assertFalse(processId == null);
67 assertEquals("waitForResponse", bpms.getState(process));
68
69
70 Map<String, Object> props = new HashMap<String, Object>();
71 props.put(Process.PROPERTY_PROCESS_ID, processId);
72 response = client.send("vm://message", "data", props);
73 process = response.getPayload();
74
75
76 assertTrue(bpms.hasEnded(process));
77 }
78
79 }