[jbpm-commits] JBoss JBPM SVN: r5039 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/activities and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jun 15 09:34:14 EDT 2009
Author: jbarrez
Date: 2009-06-15 09:34:13 -0400 (Mon, 15 Jun 2009)
New Revision: 5039
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ForkJoinInSameTransactionTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/IncrementVariableActivity.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/PassThroughActivity.java
Modified:
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
Log:
JBPM-2286 : Added test case for fork/join in same transaction
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-06-15 12:02:58 UTC (rev 5038)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-06-15 13:34:13 UTC (rev 5039)
@@ -180,4 +180,12 @@
}
return null;
}
+
+ // execution helper methods //////////////////////////////////////////
+
+ public void assertProcessInstanceEnded(String processInstanceId) {
+ assertNull("Error: a process instance with id " + processInstanceId + " was found",
+ executionService.findProcessInstanceById(processInstanceId));
+ }
+
}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ForkJoinInSameTransactionTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ForkJoinInSameTransactionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ForkJoinInSameTransactionTest.java 2009-06-15 13:34:13 UTC (rev 5039)
@@ -0,0 +1,165 @@
+/*
+ * 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.test.activities;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * Test case for fork/join constructs in one transaction
+ *
+ * @author Joram Barrez
+ */
+public class ForkJoinInSameTransactionTest extends JbpmTestCase {
+
+ /**
+ * Test for JBPM-2286
+ */
+ public void testForkToJoinInOneTransaction() {
+ deployJpdlXmlString(
+ "<process name='ForkJoinInOneTransaction'>" +
+ " <start>" +
+ " <transition to='theFork' />" +
+ " </start>" +
+ " <fork name='theFork'>" +
+ " <transition to='theJoin' />" +
+ " <transition to='theJoin' />" +
+ " </fork>" +
+ " <join name='theJoin'>" +
+ " <transition to='end' />" +
+ " </join>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ForkJoinInOneTransaction");
+ assertProcessInstanceEnded(processInstance.getId());
+ }
+
+ /**
+ * Test for JBPM-2286
+ */
+ public void testForkToJoinAfterStateInOneTransaction() {
+ deployJpdlXmlString(
+ "<process name='ForkJoinInOneTransaction'>" +
+ " <start>" +
+ " <transition to='wait' />" +
+ " </start>" +
+ " <state name='wait'>" +
+ " <transition name='go on' to='theFork' />" +
+ " </state>" +
+ " <fork name='theFork'>" +
+ " <transition to='theJoin' />" +
+ " <transition to='theJoin' />" +
+ " </fork>" +
+ " <join name='theJoin'>" +
+ " <transition to='end' />" +
+ " </join>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ForkJoinInOneTransaction");
+ executionService.signalExecutionById(processInstance.getId(), "go on");
+ assertProcessInstanceEnded(processInstance.getId());
+ }
+
+ /**
+ * Test for JBPM-2286
+ */
+ public void testForkToJoinWithActivitiesInOneTransaction() {
+ deployJpdlXmlString(
+ "<process name='ForkJoinInOneTransaction'>" +
+ " <start>" +
+ " <transition to='theFork' />" +
+ " </start>" +
+ " <fork name='theFork'>" +
+ " <transition to='left' />" +
+ " <transition to='right' />" +
+ " </fork>" +
+ " <custom name='left' class='org.jbpm.test.activities.PassThroughActivity' >" +
+ " <transition to='theJoin' />" +
+ " </custom>" +
+ " <custom name='right' class='org.jbpm.test.activities.PassThroughActivity' >" +
+ " <transition to='theJoin' />" +
+ " </custom>" +
+ " <join name='theJoin'>" +
+ " <transition to='end' />" +
+ " </join>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ForkJoinInOneTransaction");
+ assertProcessInstanceEnded(processInstance.getId());
+ }
+
+ /**
+ * Test for JBPM-2286
+ */
+ public void testForkToJoinInLoopInOneTransaction() {
+ deployJpdlXmlString(
+ "<process name='ForkJoinInOneTransaction'>" +
+ " <start>" +
+ " <transition to='checkLoop' />" +
+ " </start>" +
+ " <decision name='checkLoop'>" +
+ " <transition to='end'>" +
+ " <condition expr='#{testVar > 10}' />" +
+ " </transition>" +
+ " <transition to='theFork' />" +
+ " </decision>" +
+ " <fork name='theFork'>" +
+ " <transition to='left' />" +
+ " <transition to='right' />" +
+ " </fork>" +
+ " <custom name='left' class='org.jbpm.test.activities.PassThroughActivity' >" +
+ " <transition to='theJoin' />" +
+ " </custom>" +
+ " <custom name='right' class='org.jbpm.test.activities.PassThroughActivity' >" +
+ " <transition to='theJoin' />" +
+ " </custom>" +
+ " <join name='theJoin'>" +
+ " <transition to='incrementLoopVar' />" +
+ " </join>" +
+ " <custom name='incrementLoopVar' class='org.jbpm.test.activities.IncrementVariableActivity' >" +
+ " <transition to='checkLoop' />" +
+ " </custom>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("testVar", new Integer(0));
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ForkJoinInOneTransaction", vars);
+ assertProcessInstanceEnded(processInstance.getId());
+ }
+
+}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/IncrementVariableActivity.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/IncrementVariableActivity.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/IncrementVariableActivity.java 2009-06-15 13:34:13 UTC (rev 5039)
@@ -0,0 +1,57 @@
+/*
+ * 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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.activity.ExternalActivityBehaviour;
+
+
+/**
+ * Activity that increments the variable 'testVar' by one.
+ *
+ * @author Joram Barrez
+ */
+public class IncrementVariableActivity implements ExternalActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String TEST_VAR = "testVar";
+
+ public void execute(ActivityExecution execution) throws Exception {
+
+ Integer testVar = (Integer) execution.getVariable(TEST_VAR);
+ testVar = testVar + 1;
+ execution.setVariable(TEST_VAR, testVar);
+
+ execution.takeDefaultTransition();
+ }
+
+ public void signal(ActivityExecution execution, String signalName, Map<String, ? > parameters) throws Exception {
+ execution.take(signalName);
+ }
+
+}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/PassThroughActivity.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/PassThroughActivity.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/PassThroughActivity.java 2009-06-15 13:34:13 UTC (rev 5039)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.activity.ExternalActivityBehaviour;
+
+
+/**
+ * Activity implementation that just takes the default transition.
+ *
+ * @author Joram Barrez
+ */
+public class PassThroughActivity implements ExternalActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+
+ public void signal(ActivityExecution execution, String signalName, Map<String, ? > parameters) throws Exception {
+ execution.take(signalName);
+ }
+
+ public void execute(ActivityExecution execution) throws Exception {
+ execution.takeDefaultTransition();
+ }
+
+
+}
More information about the jbpm-commits
mailing list