<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
blocking task in start-state does not block
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/laszlovandenhoek">László van den Hoek</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/600661#600661">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>{code}</p><p>package nl.travelcard.das.workflow;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import java.util.HashMap;</p><p>import java.util.Map;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import junit.framework.TestCase;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.jbpm.graph.def.ProcessDefinition;</p><p>import org.jbpm.graph.exe.ProcessInstance;</p><p>import org.jbpm.taskmgmt.exe.TaskInstance;</p><p>import org.junit.Before;</p><p>import org.junit.Test;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class JbpmTest extends TestCase {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    private ProcessDefinition pd;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    @Before</p><p>    public void setUp() {</p><p>        this.pd = ProcessDefinition.parseXmlString(            </p><p>            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + </p><p>            "<process-definition  xmlns=\"\"  name=\"blockingStartTask\">" +</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>            "    <start-state name=\"start\">" +</p><p>            "        <task blocking=\"true\" name=\"blocking task in start node\"></task>" +</p><p>            "        <transition to=\"task\"></transition>" +</p><p>            "    </start-state>" +</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>            "    <task-node name=\"task\">" +</p><p>            "        <task blocking=\"true\" name=\"blocking task in task node\" ></task>" +</p><p>            "        <transition to=\"end\"></transition>" +</p><p>            "    </task-node>" +</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>            "    <end-state name=\"end\"></end-state>" +</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>            "</process-definition>"</p><p>        );</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    @Test</p><p>    public void testBlockingStartTask() {</p><p>        ProcessInstance pi = pd.createProcessInstance();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        //I would have expected a task instance to have been created by now; I guess that's not how it works.</p><p>        //assertEquals("expected task was not created", 1, pi.getTaskMgmtInstance().getTaskInstances().size());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        TaskInstance ti = pi.getTaskMgmtInstance().createStartTaskInstance();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        assertEquals("expected task was not created", 1, pi.getTaskMgmtInstance().getTaskInstances().size());</p><p>        assertEquals("task has wrong name", "blocking task in start node", ti.getName());</p><p>        assertTrue(ti.isBlocking());</p><p>        assertTrue(ti.isStartTaskInstance());</p><p>        assertTrue(pi.getTaskMgmtInstance().hasBlockingTaskInstances(pi.getRootToken()));</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        try {</p><p>            pi.getRootToken().signal();</p><p>            fail("task that should be blocking nevertheless did not block");</p><p>        } catch (IllegalStateException e) {</p><p>            assertEquals("state changed despite blocking task", "start", pi.getRootToken().getNode().getName());</p><p>        }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        assertEquals("start", pi.getRootToken().getNode().getName());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    @Test</p><p>    public void testBlockingRegularTask() {</p><p>        ProcessInstance pi = pd.createProcessInstance();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        assertEquals("start", pi.getRootToken().getNode().getName());</p><p>        pi.signal(); //this ought to go wrong, but it doesn't (see previous test case)</p><p>        assertEquals("task", pi.getRootToken().getNode().getName());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        assertEquals("expected task was not created", 1, pi.getTaskMgmtInstance().getTaskInstances().size());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        TaskInstance ti = pi.getTaskMgmtInstance().getTaskInstances().iterator().next();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        assertEquals("task has wrong name", "blocking task in task node", ti.getName());</p><p>        assertTrue(ti.isBlocking());</p><p>        assertFalse(ti.isStartTaskInstance());</p><p>        assertTrue(pi.getTaskMgmtInstance().hasBlockingTaskInstances(pi.getRootToken()));</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        try {</p><p>            pi.getRootToken().signal();</p><p>            fail("task that should be blocking nevertheless did not block");</p><p>        } catch (IllegalStateException e) {</p><p>            assertEquals("state changed despite blocking task", "task", pi.getRootToken().getNode().getName());</p><p>        }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        assertEquals("task", pi.getRootToken().getNode().getName());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        ti.end();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        assertEquals("end", pi.getRootToken().getNode().getName());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    }</p><p>}</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Any thoughts?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks in advance!</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/600661#600661">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>