1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.jbpm;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertFalse;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertTrue;
17
18 import java.util.Arrays;
19 import java.util.Collection;
20 import java.util.HashMap;
21 import java.util.Map;
22
23 import org.junit.Test;
24 import org.junit.runners.Parameterized.Parameters;
25 import org.mule.api.MuleMessage;
26 import org.mule.api.client.MuleClient;
27 import org.mule.module.bpm.BPMS;
28 import org.mule.module.bpm.Process;
29 import org.mule.tck.AbstractServiceAndFlowTestCase;
30
31
32
33
34
35 public class SpringJbpmComponentTestCase extends AbstractServiceAndFlowTestCase
36 {
37
38 public SpringJbpmComponentTestCase(ConfigVariant variant, String configResources)
39 {
40 super(variant, configResources);
41 }
42
43 @Parameters
44 public static Collection<Object[]> parameters()
45 {
46 return Arrays.asList(new Object[][]{{ConfigVariant.SERVICE, "spring-jbpm-component-service.xml"},
47 {ConfigVariant.FLOW, "spring-jbpm-component-flow.xml"}});
48 }
49
50 @Test
51 public void testSimpleProcess() throws Exception
52 {
53 MuleClient client = muleContext.getClient();
54 BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
55 assertNotNull(bpms);
56
57
58 MuleMessage response = client.send("vm://simple", "data", null);
59 Object process = response.getPayload();
60
61 String processId = (String) bpms.getId(process);
62
63 assertFalse(processId == null);
64 assertEquals("dummyState", bpms.getState(process));
65
66
67 Map<String, Object> props = new HashMap<String, Object>();
68 props.put(Process.PROPERTY_PROCESS_ID, processId);
69 response = client.send("vm://simple", null, props);
70 process = response.getPayload();
71
72
73 assertTrue(bpms.hasEnded(process));
74 }
75
76 }