View Javadoc

1   /*
2    * $Id: MessagingJbpmTestCase.java 19710 2010-09-23 16:29:07Z 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.transport.jbpm;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.bpm.BPMS;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.transport.bpm.ProcessConnector;
18  
19  /**
20   * Tests the connector against jBPM with a process which generates 
21   * a Mule message and processes its response. jBPM is instantiated by Spring. 
22   * 
23   * @deprecated It is recommended to configure BPM as a component rather than a transport for 3.x
24   */
25  public class MessagingJbpmTestCase extends FunctionalTestCase
26  {
27      protected String getConfigResources()
28      {
29          return "jbpm-functional-test.xml";
30      }
31  
32      public void testSendMessageProcess() throws Exception
33      {
34          ProcessConnector connector = (ProcessConnector) muleContext.getRegistry().lookupConnector("bpmConnector");
35          BPMS bpms = connector.getBpms();
36          assertNotNull(bpms);
37  
38          MuleClient client = new MuleClient(muleContext);
39          try
40          {
41              // Create a new process.
42              MuleMessage response = client.send("bpm://message", "data", null);
43              Object process = response.getPayload();
44              assertTrue(bpms.isProcess(process)); 
45  
46              String processId = (String)bpms.getId(process);
47              // The process should have sent a synchronous message, followed by an asynchronous message and now be in a wait state.
48              assertFalse(processId == null);
49              assertEquals("waitForResponse", 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  }