1   /*
2    * $Id: MessagingJbpmSpringTestCase.java 8707 2007-09-29 12:43:09Z romikk $
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.providers.bpm.jbpm;
12  
13  import org.mule.config.ConfigurationBuilder;
14  import org.mule.extras.client.MuleClient;
15  import org.mule.extras.spring.config.SpringConfigurationBuilder;
16  import org.mule.providers.bpm.BPMS;
17  import org.mule.umo.UMOMessage;
18  import org.mule.util.NumberUtils;
19  
20  /**
21   * Tests the connector against jBPM with a process which generates a Mule message and processes its response. jBPM is
22   * instantiated by Spring using the Spring jBPM module.
23   */
24  public class MessagingJbpmSpringTestCase extends AbstractJbpmTestCase
25  {
26  
27      protected ConfigurationBuilder getBuilder() throws Exception
28      {
29          return new SpringConfigurationBuilder();
30      }
31  
32      protected String getConfigResources()
33      {
34          return "mule-jbpm-spring-config.xml";
35      }
36  
37      public void testSendMessageProcess() throws Exception
38      {
39          // Deploy the process definition.
40          ((Jbpm) bpms).deployProcess("message-process.xml");
41  
42          UMOMessage response;
43          Object process;
44          BPMS bpms = connector.getBpms();
45          MuleClient client = new MuleClient();
46          try
47          {
48              // Create a new process.
49              response = client.send("bpm://message", "data", null);
50              process = response.getPayload();
51  
52              long processId = NumberUtils.toLong(bpms.getId(process));
53              // The process should be started and in a wait state.
54              assertFalse(processId == -1);
55              assertEquals("sendMessage", bpms.getState(process));
56  
57              // Advance the process one step.
58              response = client.send("bpm://message/" + processId, "data", null);
59              process = response.getPayload();
60  
61              // The process should have ended.
62              assertTrue(bpms.hasEnded(process));
63          }
64          finally
65          {
66              client.dispose();
67          }
68      }
69  }