[jbpm-commits] JBoss JBPM SVN: r2921 - in projects/spec/trunk/modules: cts/src/test/java/org/jbpm/test/cts/task/waitstate and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Nov 14 04:11:15 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-11-14 04:11:15 -0500 (Fri, 14 Nov 2008)
New Revision: 2921
Modified:
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java
Log:
Exclusive split - ok
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java 2008-11-14 09:07:25 UTC (rev 2920)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java 2008-11-14 09:11:15 UTC (rev 2921)
@@ -24,9 +24,12 @@
// $Id$
import java.io.IOException;
-import java.util.List;
+import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
+import org.jbpm.api.client.Token;
+import org.jbpm.api.client.Process.ProcessStatus;
+import org.jbpm.api.client.Token.TokenStatus;
import org.jbpm.api.model.Expression.ExpressionLanguage;
import org.jbpm.api.model.Gateway.GatewayType;
import org.jbpm.api.model.builder.GatewayBuilder;
@@ -34,12 +37,10 @@
import org.jbpm.api.runtime.BasicAttachments;
import org.jbpm.api.service.ProcessBuilderService;
import org.jbpm.api.test.CTSTestCase;
-import org.jbpm.preview.client.ProcessAsync;
-import org.jbpm.preview.model.Signal;
/**
- * Exclusive data-based gateway that has conditional outgoing sequence flows.
- * Only one of the gates is taken. It is an error if no gate is applicable.
+ * Exclusive data-based gateway that has conditional outgoing sequence flows. Only one of the gates is taken. It is an
+ * error if no gate is applicable.
*
* @author thomas.diesler at jboss.com
* @since 06-Aug-2008
@@ -49,44 +50,48 @@
public void testGateA() throws Exception
{
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
- ProcessAsync proc = (ProcessAsync)procDef.newInstance();
+ Process proc = procDef.newInstance();
BasicAttachments att = new BasicAttachments();
att.addAttachment("foo", "5");
- proc.startProcessAsync(att);
- proc.waitForEnd(5000);
- List<Signal> endSignals = getSignals(Signal.SignalType.SYSTEM_END_EVENT_EXIT);
- assertEquals(1, endSignals.size());
- assertEquals("EndA", endSignals.get(0).getFromRef().getKeyProperty("name"));
+ Token tok = proc.startProcess(att);
+
+ String nodeName = tok.getCurrentNode().getName();
+ assertEquals("EndA", nodeName);
+
+ assertEquals(TokenStatus.Destroyed, tok.getTokenStatus());
+ assertEquals(ProcessStatus.Completed, proc.getProcessStatus());
}
public void testGateB() throws Exception
{
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
- ProcessAsync proc = (ProcessAsync)procDef.newInstance();
+ Process proc = procDef.newInstance();
BasicAttachments att = new BasicAttachments();
att.addAttachment("foo", "15");
- proc.startProcessAsync(att);
- proc.waitForEnd(5000);
+
+ Token tok = proc.startProcess(att);
- List<Signal> endSignals = getSignals(Signal.SignalType.SYSTEM_END_EVENT_EXIT);
- assertEquals(1, endSignals.size());
- assertEquals("EndB", endSignals.get(0).getFromRef().getKeyProperty("name"));
+ String nodeName = tok.getCurrentNode().getName();
+ assertEquals("EndB", nodeName);
+
+ assertEquals(TokenStatus.Destroyed, tok.getTokenStatus());
+ assertEquals(ProcessStatus.Completed, proc.getProcessStatus());
}
public void testInvalidGate() throws Exception
{
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
- ProcessAsync proc = (ProcessAsync)procDef.newInstance();
+ Process proc = procDef.newInstance();
BasicAttachments att = new BasicAttachments();
att.addAttachment("foo", "10");
- proc.startProcessAsync(att);
+
try
{
- proc.waitForEnd(5000);
+ proc.startProcess(att);
fail("No gate defined for foo==10");
}
catch (RuntimeException rte)
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java 2008-11-14 09:07:25 UTC (rev 2920)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java 2008-11-14 09:11:15 UTC (rev 2921)
@@ -28,6 +28,7 @@
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.client.Token;
+import org.jbpm.api.client.Process.ProcessStatus;
import org.jbpm.api.client.Token.TokenStatus;
import org.jbpm.api.model.Task.TaskType;
import org.jbpm.api.model.builder.ProcessBuilder;
@@ -48,28 +49,30 @@
Process proc = procDef.newInstance();
// Start the Process
- Token token = proc.startProcess();
- String nodeName = token.getCurrentNode().getName();
- assertEquals(TokenStatus.Suspended, token.getTokenStatus());
+ Token tok = proc.startProcess();
+ String nodeName = tok.getCurrentNode().getName();
+ assertEquals(TokenStatus.Suspended, tok.getTokenStatus());
assertEquals("TaskA", nodeName);
- token.signal();
+ tok.signal();
- nodeName = token.getCurrentNode().getName();
- assertEquals(TokenStatus.Suspended, token.getTokenStatus());
+ nodeName = tok.getCurrentNode().getName();
+ assertEquals(TokenStatus.Suspended, tok.getTokenStatus());
assertEquals("TaskB", nodeName);
- token.signal();
+ tok.signal();
- nodeName = token.getCurrentNode().getName();
- assertEquals(TokenStatus.Suspended, token.getTokenStatus());
+ nodeName = tok.getCurrentNode().getName();
+ assertEquals(TokenStatus.Suspended, tok.getTokenStatus());
assertEquals("TaskC", nodeName);
- token.signal();
+ tok.signal();
- nodeName = token.getCurrentNode().getName();
- assertEquals(TokenStatus.Destroyed, token.getTokenStatus());
+ nodeName = tok.getCurrentNode().getName();
assertEquals("End", nodeName);
+
+ assertEquals(TokenStatus.Destroyed, tok.getTokenStatus());
+ assertEquals(ProcessStatus.Completed, proc.getProcessStatus());
}
public ProcessDefinition getProcessDefinition() throws IOException
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java 2008-11-14 09:07:25 UTC (rev 2920)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java 2008-11-14 09:11:15 UTC (rev 2921)
@@ -42,6 +42,7 @@
import org.jbpm.api.service.ProcessInstanceService;
import org.jbpm.preview.runtime.TokenExecutor;
import org.jbpm.ri.service.ProcessServiceImpl;
+import org.jbpm.ri.model.ProcessImpl;
/**
* A Token is a descriptive construct used to describe how the flow of a Process will proceed at runtime.
@@ -199,18 +200,35 @@
}
// Travers the token along the nodes
- while (continueTokenExecution())
+ try
{
- // Get the target node
- node = getCurrentNode();
+ while (continueTokenExecution())
+ {
+ // Get the target node
+ node = getCurrentNode();
- // Create a Token that includes node properties
- DelegatingToken tokCopy = new DelegatingToken(this);
- rtContext.setToken(tokCopy);
+ // Create a Token that includes node properties
+ DelegatingToken tokCopy = new DelegatingToken(this);
+ rtContext.setToken(tokCopy);
- // Call the interceptor chain
- rtContext.next();
+ // Call the interceptor chain
+ rtContext.next();
+ }
}
+ catch (RuntimeException rte)
+ {
+ ProcessImpl procImpl = (ProcessImpl)getProcess();
+ procImpl.setRuntimeException(rte);
+ procImpl.setProcessStatus(ProcessStatus.Aborted);
+ throw rte;
+ }
+
+ // Set Process to completed
+ if (getRootToken().getTokenStatus() == TokenStatus.Destroyed)
+ {
+ ProcessImpl procImpl = (ProcessImpl)getProcess();
+ procImpl.setProcessStatus(ProcessStatus.Completed);
+ }
}
private boolean continueTokenExecution()
More information about the jbpm-commits
mailing list