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.module.bpm.Process;
16 import org.mule.module.client.MuleClient;
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 @Override
26 protected String getConfigResources()
27 {
28 return "jbpm-component-functional-test.xml";
29 }
30
31 public void testVariables() throws Exception
32 {
33 BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
34 assertNotNull(bpms);
35
36 MuleClient client = new MuleClient(muleContext);
37 try
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", 3000);
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", 3000);
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 finally
66 {
67 client.dispose();
68 }
69 }
70 }