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