[jbpm-commits] JBoss JBPM SVN: r1857 - in jbpm4/jpdl/trunk/modules/core/src: main/java/org/jbpm/jpdl/activity and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Aug 9 10:08:19 EDT 2008
Author: tom.baeyens at jboss.com
Date: 2008-08-09 10:08:19 -0400 (Sat, 09 Aug 2008)
New Revision: 1857
Added:
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java
Removed:
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java
Modified:
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java
Log:
added more decision implementations
Added: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface DecisionHandler {
+
+ /** the name of the selected outgoing transition */
+ String decide(JpdlExecution execution);
+}
Added: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.activity;
+
+import java.util.List;
+
+import org.jbpm.jpdl.JpdlException;
+import org.jbpm.jpdl.JpdlExecution;
+import org.jbpm.pvm.model.Condition;
+import org.jbpm.pvm.model.Node;
+import org.jbpm.pvm.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionConditionActivity extends JpdlActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(JpdlExecution execution) throws Exception {
+ Transition transition = findTransition(execution);
+ if (transition==null) {
+ throw new JpdlException("no outgoing transition condition evaluated to true for decision "+execution.getNode());
+ }
+ execution.take(transition);
+ }
+
+ private Transition findTransition(JpdlExecution execution) {
+ Node node = execution.getNode();
+ List<Transition> outgoingTransitions = node.getOutgoingTransitions();
+ for (Transition transition : outgoingTransitions) {
+ Condition condition = transition.getGuardCondition();
+ if ( (condition==null)
+ || (condition.evaluate(execution))
+ ) {
+ return transition;
+ }
+ }
+ return null;
+ }
+}
Modified: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -23,10 +23,10 @@
import org.jbpm.jpdl.JpdlExecution;
import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.model.Transition;
import org.jbpm.pvm.env.EnvironmentHelper;
import org.jbpm.pvm.internal.model.NodeImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.model.Transition;
/**
* @author Tom Baeyens
@@ -37,21 +37,25 @@
protected String expr;
protected String lang;
-
+
public void execute(JpdlExecution execution) throws Exception {
+ NodeImpl node = execution.getNode();
+ String transitionName = null;
+
ScriptManager scriptManager = EnvironmentHelper.get(ScriptManager.class);
Object result = scriptManager.evaluateExpression(expr, execution, lang);
if ( (result!=null)
&& (! (result instanceof String))
) {
- throw new PvmException("decision expression '"+expr+"' returned "+result.getClass().getName()+" instead of a transitionName (String): "+result);
+ throw new PvmException("expression '"+expr+"' in decision '"+node.getName()+"' returned "+result.getClass().getName()+" instead of a transitionName (String): "+result);
}
- String transitionName = (String) result;
- NodeImpl node = execution.getNode();
- Transition transition = node.findOutgoingTransition(transitionName);
+ transitionName = (String) result;
+
+ Transition transition = node.getOutgoingTransition(transitionName);
if (transition==null) {
- throw new PvmException("decision expression '"+expr+"' returned unexisting outgoing transition name: "+transitionName);
+ throw new PvmException("expression '"+expr+"' in decision '"+node.getName()+"' returned unexisting outgoing transition name: "+transitionName);
}
+
execution.take(transition);
}
Added: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.activity;
+
+import org.jbpm.jpdl.DecisionHandler;
+import org.jbpm.jpdl.JpdlException;
+import org.jbpm.jpdl.JpdlExecution;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.env.EnvironmentHelper;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.model.Transition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionHandlerActivity extends JpdlActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String decisionHandlerName;
+ protected Descriptor decisionHandlerDescriptor;
+
+ public void execute(JpdlExecution execution) throws Exception {
+ NodeImpl node = execution.getNode();
+ String transitionName = null;
+
+ Object object = null;
+ if (decisionHandlerDescriptor!=null) {
+ object = WireContext.create(decisionHandlerDescriptor);
+ } else if (decisionHandlerName!=null) {
+ Environment environment = Environment.getCurrent();
+ object = environment.get(decisionHandlerName);
+ }
+
+ if (object==null) {
+ throw new JpdlException("decision handler for "+node+" is null");
+ }
+ if (! (object instanceof DecisionHandler)) {
+ throw new JpdlException("handler for decision is not a "+DecisionHandler.class.getName()+": "+object.getClass().getName());
+ }
+ DecisionHandler decisionHandler = (DecisionHandler) object;
+ transitionName = decisionHandler.decide(execution);
+
+ Transition transition = node.getOutgoingTransition(transitionName);
+ if (transition==null) {
+ throw new PvmException("handler in decision '"+node.getName()+"' returned unexisting outgoing transition name: "+transitionName);
+ }
+
+ execution.take(transition);
+ }
+
+}
Modified: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -21,52 +21,20 @@
*/
package org.jbpm.jpdl;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
import org.jbpm.jpdl.xml.JpdlParser;
import org.jbpm.pvm.client.ClientProcessDefinition;
import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.test.base.JbpmTestCase;
/**
* @author Tom Baeyens
*/
-public class JpdlTestCase extends TestCase {
+public class JpdlTestCase extends JbpmTestCase {
static protected Log log = Log.getLog(JpdlTestCase.class.getName());
- public void setUp() throws Exception {
- log.info("=== starting "+getName()+" =============================");
- }
-
- public void tearDown() throws Exception {
- log.info("=== ending "+getName()+" =============================\n");
- }
-
- public void assertTextPresent(String expected, String value) {
- if ( (value==null)
- || (value.indexOf(expected)==-1)
- ) {
- throw new AssertionFailedError("expected presence of '"+expected+"' but was '"+value+"'");
- }
- }
-
- protected void runTest() throws Throwable {
- try {
- super.runTest();
- } catch (AssertionFailedError e) {
- log.error("");
- log.error("ASSERTION FAILURE: "+e.getMessage());
- log.error("");
- throw e;
- } catch (Throwable t) {
- t.printStackTrace();
- throw t;
- }
- }
-
- public ClientProcessDefinition parseProcess(String xmlString) {
+ public ClientProcessDefinition parseJpdl(String xmlString) {
JpdlParser jpdlParser = new JpdlParser();
return (ClientProcessDefinition) jpdlParser.createParse()
.setString(xmlString)
Modified: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -33,7 +33,7 @@
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.jbpm.jpdl.controlflow");
//$JUnit-BEGIN$
- suite.addTestSuite(DecisionTest.class);
+ suite.addTestSuite(DecisionExpressionTest.class);
suite.addTestSuite(StateTest.class);
//$JUnit-END$
return suite;
Copied: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java (from rev 1852, jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java)
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.controlflow;
+
+import org.jbpm.jpdl.JpdlTestCase;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.client.ClientExecution;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionExpressionTest extends JpdlTestCase {
+
+ public void testDecisionOutgoingTransitionExpression() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b' expr='#{theWayToGo}'>" +
+ " <transition name='left' to='c' />" +
+ " <transition name='right' to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "left");
+ execution.signal();
+ assertEquals("c", execution.getNode().getName());
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "right");
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("expression '#{theWayToGo}' in decision 'b' returned unexisting outgoing transition name: null", e.getMessage());
+ }
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "up");
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("expression '#{theWayToGo}' in decision 'b' returned unexisting outgoing transition name: up", e.getMessage());
+ }
+ }
+
+ public void testDecisionOutgoingUnnamedTransitionExpression() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b' expr='#{theWayToGo}'>" +
+ " <transition name='left' to='c' />" +
+ " <transition to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+ }
+}
Property changes on: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Added: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.controlflow;
+
+import org.jbpm.jpdl.DecisionHandler;
+import org.jbpm.jpdl.JpdlExecution;
+import org.jbpm.jpdl.JpdlTestCase;
+import org.jbpm.pvm.client.ClientExecution;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionHandlerTest extends JpdlTestCase {
+
+ public static class GpsDecisionHandler implements DecisionHandler {
+ String theWayToGo;
+ public String decide(JpdlExecution execution) {
+ return theWayToGo;
+ }
+ }
+
+ public void testDecisionHandlerLeft() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b'>" +
+ " <handler class='"+GpsDecisionHandler.class.getName()+"'>" +
+ " <field name='theWayToGo'>" +
+ " <string value='left'/>" +
+ " </field>" +
+ " </handler>" +
+ " <transition name='left' to='c' />" +
+ " <transition name='right' to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "left");
+ execution.signal();
+ assertEquals("c", execution.getNode().getName());
+ }
+
+ /*
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "right");
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: null", e.getMessage());
+ }
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "up");
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: up", e.getMessage());
+ }
+ }
+
+ public void testDecisionOutgoingUnnamedTransitionExpression() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b' expr='#{theWayToGo}'>" +
+ " <transition name='left' to='c' />" +
+ " <transition to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+ }
+
+ */
+}
Deleted: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.jpdl.controlflow;
-
-import org.jbpm.jpdl.JpdlTestCase;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.client.ClientExecution;
-import org.jbpm.pvm.client.ClientProcessDefinition;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DecisionTest extends JpdlTestCase {
-
- public void testDecisionOutgoingTransitionExpression() {
- ClientProcessDefinition processDefinition = parseProcess(
- "<process initial='a' name='p'>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " </state>" +
- " <decision name='b' expr='#{theWayToGo}'>" +
- " <transition name='left' to='c' />" +
- " <transition name='right' to='d' />" +
- " </decision>" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- ClientExecution execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", "left");
- execution.signal();
- assertEquals("c", execution.getNode().getName());
-
- execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", "right");
- execution.signal();
- assertEquals("d", execution.getNode().getName());
-
- execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", null);
- try {
- execution.signal();
- fail("expected exception");
- } catch (PvmException e) {
- assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: null", e.getMessage());
- }
-
- execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", "up");
- try {
- execution.signal();
- fail("expected exception");
- } catch (PvmException e) {
- assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: up", e.getMessage());
- }
- }
-
- public void testDecisionOutgoingUnnamedTransitionExpression() {
- ClientProcessDefinition processDefinition = parseProcess(
- "<process initial='a' name='p'>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " </state>" +
- " <decision name='b' expr='#{theWayToGo}'>" +
- " <transition name='left' to='c' />" +
- " <transition to='d' />" +
- " </decision>" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- ClientExecution execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", null);
- execution.signal();
- assertEquals("d", execution.getNode().getName());
- }
-}
Modified: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -35,7 +35,7 @@
public class StateTest extends JpdlTestCase {
public void testWaitStatesSequence() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition to='b' />" +
@@ -61,7 +61,7 @@
}
public void testExternalDecision() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition name='left' to='b' />" +
@@ -88,7 +88,7 @@
}
public void testDefaultSignalWithNamedTransitions() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition name='left' to='b' />" +
@@ -110,7 +110,7 @@
}
public void testNamedSignalWithoutMatchingTransition() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition name='left' to='b' />" +
@@ -132,7 +132,7 @@
}
public void testDefaultSignalWithoutTransitions() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a' />" +
"</process>"
More information about the jbpm-commits
mailing list