View Javadoc

1   /*
2    * $Id: SimpleJbpmComponentTestCase.java 20121 2010-11-08 17:33:48Z tcarlson $
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 org.mule.api.MuleMessage;
14  import org.mule.api.client.MuleClient;
15  import org.mule.module.bpm.BPMS;
16  import org.mule.module.bpm.Process;
17  import org.mule.tck.FunctionalTestCase;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  /**
23   * Tests jBPM component with a simple process.
24   */
25  public class SimpleJbpmComponentTestCase extends FunctionalTestCase
26  {
27      protected String getConfigResources()
28      {
29          return "jbpm-component-functional-test.xml";
30      }
31  
32      public void testSimpleProcess() throws Exception 
33      {
34          MuleClient client = muleContext.getClient();
35          BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
36          assertNotNull(bpms);
37  
38          // Create a new process.
39          MuleMessage response = client.send("vm://simple", "data", null);
40          Object process = response.getPayload();
41  
42          String processId = (String)bpms.getId(process);
43          // The process should be started and in a wait state.
44          assertFalse(processId == null);
45          assertEquals("dummyState", bpms.getState(process));
46  
47          // Advance the process one step.
48          Map props = new HashMap();
49          props.put(Process.PROPERTY_PROCESS_ID, processId);
50          response = client.send("vm://simple", null, props);
51          process = response.getPayload();
52  
53          // The process should have ended.
54          assertTrue(bpms.hasEnded(process));
55      }
56  }