1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.bpm.jbpm;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.providers.bpm.BPMS;
15 import org.mule.providers.bpm.ProcessConnector;
16 import org.mule.umo.UMOMessage;
17 import org.mule.util.NumberUtils;
18
19
20
21
22 public class SimpleJbpmTestCase extends AbstractJbpmTestCase
23 {
24
25 protected String getConfigResources()
26 {
27 return "mule-jbpm-config.xml";
28 }
29
30 public void testSimpleProcess() throws Exception
31 {
32
33 ((Jbpm) bpms).deployProcess("simple-process.xml");
34
35 UMOMessage response;
36 Object process;
37 BPMS bpms = connector.getBpms();
38 MuleClient client = new MuleClient();
39 try
40 {
41
42 response = client.send("bpm://simple", "data", null);
43 process = response.getPayload();
44
45 long processId = NumberUtils.toLong(bpms.getId(process));
46
47 assertFalse(processId == -1);
48 assertEquals("dummyState", bpms.getState(process));
49
50
51 response = client.send("bpm://simple/" + processId, null, null);
52 process = response.getPayload();
53
54
55 assertTrue(bpms.hasEnded(process));
56 }
57 finally
58 {
59 client.dispose();
60 }
61 }
62
63 public void testSimpleProcessWithParameters() throws Exception
64 {
65
66 ((Jbpm) bpms).deployProcess("simple-process.xml");
67
68 UMOMessage response;
69 Object process;
70 BPMS bpms = connector.getBpms();
71 MuleClient client = new MuleClient();
72 try
73 {
74
75 response = client.send("bpm://?" +
76 ProcessConnector.PROPERTY_ACTION + "=" + ProcessConnector.ACTION_START +
77 "&" + ProcessConnector.PROPERTY_PROCESS_TYPE + "=simple", "data", null);
78 process = response.getPayload();
79
80 long processId =
81 response.getLongProperty(ProcessConnector.PROPERTY_PROCESS_ID, -1);
82
83 assertFalse(processId == -1);
84 assertEquals("dummyState", bpms.getState(process));
85
86
87 response = client.send("bpm://?" +
88 ProcessConnector.PROPERTY_ACTION + "=" + ProcessConnector.ACTION_ADVANCE +
89 "&" + ProcessConnector.PROPERTY_PROCESS_TYPE + "=simple&" +
90 ProcessConnector.PROPERTY_PROCESS_ID + "=" + processId, "data", null);
91 process = response.getPayload();
92
93
94 assertTrue(bpms.hasEnded(process));
95 }
96 finally
97 {
98 client.dispose();
99 }
100 }
101 }