View Javadoc

1   /*
2    * $Id: JbpmUnitTestCase.java 22377 2011-07-11 12:41:42Z dirk.olmes $
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.tck.junit4.AbstractMuleTestCase;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  import static org.junit.Assert.assertNotNull;
19  import static org.junit.Assert.assertTrue;
20  
21  /**
22   * Tests the jBPM wrapper with a simple process.
23   */
24  public class JbpmUnitTestCase extends AbstractMuleTestCase
25  {
26      @Test
27      public void testDeployAndRun() throws Exception 
28      {
29          Jbpm jbpm = new Jbpm();
30          jbpm.initialise();
31  
32          // Deploy the process
33          jbpm.deployProcess("simple-process.jpdl.xml");
34  
35          // Start the process
36          Object process = jbpm.startProcess("simple", null, null);
37          assertNotNull(process);
38          Object processId = jbpm.getId(process);
39          
40          // The process should be started and in a wait state.
41          process = jbpm.lookupProcess(processId);
42          assertNotNull(process);             
43          assertEquals("dummyState", jbpm.getState(process));
44  
45          // Advance the process one step.
46          process = jbpm.advanceProcess(processId);
47  
48          // The process should have ended.
49          assertNotNull(process);             
50          assertTrue(jbpm.hasEnded(process));
51  
52          jbpm.dispose();
53      }
54  }