László van den Hoek [
http://community.jboss.org/people/laszlovandenhoek] created the
discussion
"blocking task in start-state does not block"
To view the discussion, visit:
http://community.jboss.org/message/600661#600661
--------------------------------------------------------------
Hi,
I'm running into the problem that a blocking task in a start-state node does not
prevent a token to proceed to the next node, but a "regular" blocking task in a
task-node does. I'm using the jBPM 3.2 runtime included with the latest JBoss SOA-P
5.1.
The below JUnit test code illustrates the problem. There are two test cases; the only real
difference is that the one tests a blocking start task and the other tests a blocking
"regular" task. For me, the first test case fails but the second one succeeds.
The way they are written, I would expect this to be the other way around.
I understand from {thread:id=390489} that creating a new ProcessInstance will not
automatically create a TaskInstance for the task defined in the start-state, if any. While
this strikes me as odd, I can accept that is the way things work. However, once I manually
create the StartTaskInstance, I do expect it to block progress to the next node.
{code}
package nl.travelcard.das.workflow;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.junit.Before;
import org.junit.Test;
public class JbpmTest extends TestCase {
private ProcessDefinition pd;
@Before
public void setUp() {
this.pd = ProcessDefinition.parseXmlString(
"<?xml version=\"1.0\"
encoding=\"UTF-8\"?>" +
"<process-definition xmlns=\"\"
name=\"blockingStartTask\">" +
" <start-state name=\"start\">" +
" <task blocking=\"true\" name=\"blocking task
in start node\"></task>" +
" <transition
to=\"task\"></transition>" +
" </start-state>" +
" <task-node name=\"task\">" +
" <task blocking=\"true\" name=\"blocking task
in task node\" ></task>" +
" <transition to=\"end\"></transition>"
+
" </task-node>" +
" <end-state name=\"end\"></end-state>" +
"</process-definition>"
);
}
@Test
public void testBlockingStartTask() {
ProcessInstance pi = pd.createProcessInstance();
//I would have expected a task instance to have been created by now; I guess
that's not how it works.
//assertEquals("expected task was not created", 1,
pi.getTaskMgmtInstance().getTaskInstances().size());
TaskInstance ti = pi.getTaskMgmtInstance().createStartTaskInstance();
assertEquals("expected task was not created", 1,
pi.getTaskMgmtInstance().getTaskInstances().size());
assertEquals("task has wrong name", "blocking task in start
node", ti.getName());
assertTrue(ti.isBlocking());
assertTrue(ti.isStartTaskInstance());
assertTrue(pi.getTaskMgmtInstance().hasBlockingTaskInstances(pi.getRootToken()));
try {
pi.getRootToken().signal();
fail("task that should be blocking nevertheless did not block");
} catch (IllegalStateException e) {
assertEquals("state changed despite blocking task",
"start", pi.getRootToken().getNode().getName());
}
assertEquals("start", pi.getRootToken().getNode().getName());
}
@Test
public void testBlockingRegularTask() {
ProcessInstance pi = pd.createProcessInstance();
assertEquals("start", pi.getRootToken().getNode().getName());
pi.signal(); //this ought to go wrong, but it doesn't (see previous test
case)
assertEquals("task", pi.getRootToken().getNode().getName());
assertEquals("expected task was not created", 1,
pi.getTaskMgmtInstance().getTaskInstances().size());
TaskInstance ti = pi.getTaskMgmtInstance().getTaskInstances().iterator().next();
assertEquals("task has wrong name", "blocking task in task
node", ti.getName());
assertTrue(ti.isBlocking());
assertFalse(ti.isStartTaskInstance());
assertTrue(pi.getTaskMgmtInstance().hasBlockingTaskInstances(pi.getRootToken()));
try {
pi.getRootToken().signal();
fail("task that should be blocking nevertheless did not block");
} catch (IllegalStateException e) {
assertEquals("state changed despite blocking task",
"task", pi.getRootToken().getNode().getName());
}
assertEquals("task", pi.getRootToken().getNode().getName());
ti.end();
assertEquals("end", pi.getRootToken().getNode().getName());
}
}
{code}
Any thoughts?
Thanks in advance!
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/600661#600661]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]