Here is a unit test.
When aborting a child token, the child token is triggered to go to the next node (task
node).
So we create an additional task instance. Something we certainly don't want when
aborting the token.
public class AbortTokenTest {
|
| public static final String MAIN_PROCESS =
| "<process-definition name='MainProcess'>" +
| " <start-state>" +
| " <transition to='fork' />" +
| " </start-state>" +
| " <fork name='fork'>" +
| " <transition name='transition1' to='subProcess1'
/>" +
| " <transition name='transition2' to='subProcess2'
/>" +
| " </fork>" +
| " <process-state name='subProcess1'>" +
| " <sub-process name='SubProcess'/>" +
| " <transition to='taskNode1' />" +
| " </process-state>" +
| " <task-node name='taskNode1'>" +
| " <task name='generic' />" +
| " <transition to='join' />" +
| " </task-node>" +
| " <process-state name='subProcess2'>" +
| " <sub-process name='SubProcess'/>" +
| " <transition to='taskNode2' />" +
| " <task-node name='taskNode2'>" +
| " <task name='generic' />" +
| " <transition to='join' />" +
| " </task-node>" +
| " </process-state>" +
| " <join name='join' lock='UPGRADE'>" +
| " <transition to='end' />" +
| " </join>" +
| " <end-state name='end' />" +
| "</process-definition>";
|
| /**
| * Process definition with single root token and task node.
| */
| public static final String SUB_PROCESS =
| "<process-definition name='SubProcess'>" +
| " <start-state>" +
| " <transition to='taskNode' />" +
| " </start-state>" +
| " <task-node name='taskNode'>" +
| " <task name='generic' />" +
| " <transition to='end' />" +
| " </task-node>" +
| " <end-state name='end' />" +
| "</process-definition>";
|
| private JbpmContext jbpmContext;
|
| @Before
| public void initialize() {
| jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
|
| // Deploy sub process and main process
| jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(SUB_PROCESS));
|
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(MAIN_PROCESS));
| }
|
| @After
| public void uninitialize() {
| jbpmContext.close();
| }
|
| @Test
| public void cancelToken() {
| ProcessInstance processInstance =
jbpmContext.newProcessInstance("MainProcess");
| processInstance.signal();
| assertNull(processInstance.getTaskMgmtInstance().getTaskInstances());
|
| // Abort one of the child token's
| processInstance.getRootToken().getChild("transition1").end(false);
|
| // Unit test fails -> a task instance is created in the main process
| // This because the child token is signalled and is in taskNode1 now...
| assertNull(processInstance.getTaskMgmtInstance().getTaskInstances());
| }
| }
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4201344#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...