<!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/600666#600666">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,  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:java} 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(                               "</p><p>" +                 "" +                                "     " +                "          " +                "          " +                "     " +                                "     " +                "          " +                "          " +                "     " +                                "     " +                                ""           );      }            @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!</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/600666#600666">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>