After spending more than an hour in completing a testable process definition:
<?xml version="1.0" encoding="UTF-8"?>
  | <process-definition xmlns="http://jbpm.org/3/jpdl";
  |   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  |   xsi:schemaLocation="http://jbpm.org/3/jpdl 
http://jbpm.org/xsd/jpdl-3.0.xsd";
  |   name="loan-approval">
  |   <start-state name="start">
  |     <transition name="to-L" to="L"/>
  |   </start-state>
  |   <!--
  |   <swimlane name="st">
  |     <assignment class=""></assignment>
  |   </swimlane>
  |    -->
  |   <task-node name="L">
  |     <task name="t">
  |       <controller>
  |         <variable name="test" />
  |         <variable name="stv" />
  |       </controller>    
  |       <event type="task-create">
  |         <script>
  |           <expression>
  |             executionContext.getContextInstance().setVariable("stv", new 
Integer(11));
  |             executionContext.getContextInstance().createVariable("test", 
"eleven");
  |           </expression>
  |         </script>
  |       </event>
  |     </task>
  |     <transition name="to-end" to="end"/>
  |   </task-node>
  |   <end-state name="end"/>
  | </process-definition>
And writing a unit test with persistence support that shows the problem:
package com.sample;
  | 
  | import java.util.Collection;
  | import java.util.List;
  | 
  | import junit.framework.TestCase;
  | 
  | import org.jbpm.db.JbpmSession;
  | import org.jbpm.db.JbpmSessionFactory;
  | import org.jbpm.graph.def.ProcessDefinition;
  | import org.jbpm.graph.exe.ProcessInstance;
  | import org.jbpm.taskmgmt.exe.TaskFormParameter;
  | import org.jbpm.taskmgmt.exe.TaskInstance;
  | 
  | public class Topic73364Test extends TestCase {
  | 
  |   private ProcessDefinition definition;
  |   
  |   private static JbpmSessionFactory jbpmSessionFactory = 
JbpmSessionFactory.buildJbpmSessionFactory();
  |   
  |   static {
  |     // create the schema at runtime before we start the tests
  |     jbpmSessionFactory.getJbpmSchema().createSchema();
  |   }
  |   
  |   protected void setUp() throws Exception {
  |     JbpmSession jbpmSession = 
jbpmSessionFactory.openJbpmSessionAndBeginTransaction();
  |     // Extract a process definition from the processdefinition.xml file.
  |     definition = 
ProcessDefinition.parseXmlResource("topic73364.par/processdefinition.xml");
  |     // Save and close
  |     jbpmSession.getGraphSession().saveProcessDefinition(definition);
  |     jbpmSession.commitTransactionAndClose();
  |   }
  | 
  |   public void testSimpleProcess() throws Exception {
  |     JbpmSession jbpmSession = 
jbpmSessionFactory.openJbpmSessionAndBeginTransaction();
  |             // Create an instance of the process definition.
  |             ProcessInstance instance = new ProcessInstance(definition);
  |             // Move the process instance from its start state to the first 
state.
  |             instance.signal();
  |     // Remember the instance identity
  |     long instanceId = instance.getId();
  |     // Save and close
  |     jbpmSession.commitTransactionAndClose();
  | 
  |     jbpmSession = jbpmSessionFactory.openJbpmSessionAndBeginTransaction();
  |     // Reload process instance
  |     instance = 
jbpmSession.getGraphSession().loadProcessInstance(instanceId);
  |     // one task instance
  |     Collection taskInstances = 
instance.getTaskMgmtInstance().getTaskInstances();
  |     assertEquals(1, taskInstances.size());
  |     TaskInstance taskInstance = (TaskInstance) 
taskInstances.iterator().next();
  |     // two parameters
  |     List formParameters = taskInstance.getTaskFormParameters();
  |     assertEquals(2, formParameters.size());
  |     // parameter 'test'
  |     TaskFormParameter formParameter = (TaskFormParameter) 
formParameters.get(0);
  |     assertEquals("test", formParameter.getLabel());
  |     assertEquals("eleven", formParameter.getValue());
  |     // parameter 'stv'
  |     formParameter = (TaskFormParameter) formParameters.get(1);
  |     assertEquals("stv", formParameter.getLabel());
  |     assertEquals(new Integer(11), formParameter.getValue());
  |     
  |     // Move the process instance to the end state
  |     instance.signal();
  |     assertTrue("Instance has ended", instance.hasEnded());
  |     // Save and close
  |     jbpmSession.commitTransactionAndClose();
  |     }
  | }
  | 
You didn't specify a version, so I assumed the latest stable version, 3.0.2. I 
was surprised to see that the test failed. I say failed in the QA sense here, 
because a test that finds no errors is a test that doesn't improve the quality 
of the product.

I took this post as a proof of how difficult is it to answer a seemingly 
obvious question with incomplete definitions, absent test cases and 
insufficient environment information. This is why we sometimes hesitate so much 
to try and answer.

In my opinion, we should create a sticky topic that establishes guidelines for 
acceptable postings and answer posts that do not comply with them with a single 
link to that topic. There is simply no way to reply to all questions from the 
community in the current state of things.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3911065#3911065

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3911065


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to