1   /*
2    * $Id: MessagingJbpmTestCase.java 11134 2008-02-29 18:00:10Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.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.util.NumberUtils;
17  
18  /**
19   * Tests the connector against jBPM with a process which generates a Mule message and
20   * processes its response. jBPM is instantiated by Spring using the Spring jBPM
21   * module.
22   */
23  public class MessagingJbpmTestCase extends AbstractJbpmTestCase
24  {
25  
26      protected String getConfigResources()
27      {
28          return "jbpm-functional-test.xml";
29      }
30  
31      public void testSendMessageProcess() throws Exception
32      {
33          // Deploy the process definition.
34          ((Jbpm)bpms).deployProcess("message-process.xml");
35  
36          MuleMessage response;
37          Object process;
38          BPMS bpms = connector.getBpms();
39          MuleClient client = new MuleClient();
40          try
41          {
42              // Create a new process.
43              response = client.send("bpm://message", "data", null);
44              process = response.getPayload();
45  
46              long processId = NumberUtils.toLong(bpms.getId(process));
47              // The process should be started and in a wait state.
48              assertFalse(processId == -1);
49              assertEquals("sendMessage", bpms.getState(process));
50  
51              // Advance the process one step.
52              response = client.send("bpm://message/" + processId, "data", null);
53              process = response.getPayload();
54  
55              // The process should have ended.
56              assertTrue(bpms.hasEnded(process));
57          }
58          finally
59          {
60              client.dispose();
61          }
62      }
63  }