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.api.client.MuleClient;
15 import org.mule.module.bpm.BPMS;
16 import org.mule.module.bpm.Process;
17 import org.mule.tck.FunctionalTestCase;
18
19 import java.util.Date;
20 import java.util.HashMap;
21 import java.util.Map;
22
23 public class VariablesComponentTestCase extends FunctionalTestCase
24 {
25 private final int TIMEOUT = 5000;
26
27 @Override
28 protected String getConfigResources()
29 {
30 return "jbpm-component-functional-test.xml";
31 }
32
33 public void testVariables() throws Exception
34 {
35 MuleClient client = muleContext.getClient();
36 BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
37 assertNotNull(bpms);
38
39 Map<String, Object> props = new HashMap<String, Object>();
40 props.put("foo", "bar");
41 MuleMessage response = client.send("vm://variables", "data", props);
42 String processId = (String)bpms.getId(response.getPayload());
43 assertNotNull(processId);
44
45 response = client.request("vm://queueA", TIMEOUT);
46 assertNotNull(response);
47 assertEquals("bar", response.getInboundProperty("foo"));
48 assertEquals(0.75, response.getInboundProperty("fraction"));
49
50
51 props = new HashMap<String, Object>();
52 props.put(Process.PROPERTY_PROCESS_ID, processId);
53 props.put("straw", "berry");
54 props.put("time", new Date());
55 response = client.send("vm://variables", "data", props);
56
57 response = client.request("vm://queueB", TIMEOUT);
58 assertNotNull(response);
59 assertEquals("bar", response.getInboundProperty("foo"));
60 assertEquals(0.75, response.getInboundProperty("fraction"));
61 assertEquals("berry", response.getInboundProperty("straw"));
62 final Object o = response.getInboundProperty("time");
63 assertTrue(o instanceof Date);
64 }
65 }