1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.bpm.jbpm;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.transport.bpm.BPMS;
16 import org.mule.transport.bpm.ProcessConnector;
17 import org.mule.transport.bpm.jbpm.Jbpm;
18 import org.mule.util.NumberUtils;
19
20
21
22
23 public class SimpleJbpmTestCase extends AbstractJbpmTestCase
24 {
25
26 protected String getConfigResources()
27 {
28 return "jbpm-functional-test.xml";
29 }
30
31 public void testSimpleProcess() throws Exception {
32
33 ((Jbpm) bpms).deployProcess("simple-process.xml");
34
35 MuleMessage 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 MuleMessage 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 }