View Javadoc

1   /*
2    * $Id: SimpleJbpmComponentTestCase.java 22552 2011-07-25 07:18:19Z claude.mamo $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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 org.mule.api.MuleMessage;
19  import org.mule.api.client.MuleClient;
20  import org.mule.module.bpm.BPMS;
21  import org.mule.module.bpm.Process;
22  import org.mule.tck.AbstractServiceAndFlowTestCase;
23  
24  import java.util.Arrays;
25  import java.util.Collection;
26  import java.util.HashMap;
27  import java.util.Map;
28  
29  import org.junit.Test;
30  import org.junit.runners.Parameterized.Parameters;
31  
32  /**
33   * Tests jBPM component with a simple process.
34   */
35  public class SimpleJbpmComponentTestCase extends AbstractServiceAndFlowTestCase
36  {
37      public SimpleJbpmComponentTestCase(ConfigVariant variant, String configResources)
38      {
39          super(variant, configResources);
40      }
41  
42      @Parameters
43      public static Collection<Object[]> parameters()
44      {
45          return Arrays.asList(new Object[][]{
46              {ConfigVariant.SERVICE, "jbpm-component-functional-test-service.xml"},
47              {ConfigVariant.FLOW, "jbpm-component-functional-test-flow.xml"}
48          });
49      }      
50      
51      @Test
52      public void testSimpleProcess() throws Exception
53      {
54          MuleClient client = muleContext.getClient();
55          BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
56          assertNotNull(bpms);
57  
58          // Create a new process.
59          MuleMessage response = client.send("vm://simple", "data", null);
60          Object process = response.getPayload();
61  
62          String processId = (String)bpms.getId(process);
63          // The process should be started and in a wait state.
64          assertFalse(processId == null);
65          assertEquals("dummyState", bpms.getState(process));
66  
67          // Advance the process one step.
68          Map<String, Object> props = new HashMap<String, Object>();
69          props.put(Process.PROPERTY_PROCESS_ID, processId);
70          response = client.send("vm://simple", null, props);
71          process = response.getPayload();
72  
73          // The process should have ended.
74          assertTrue(bpms.hasEnded(process));
75      }
76  
77  }