[jbpm-commits] JBoss JBPM SVN: r5028 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/model and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jun 11 10:45:17 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-06-11 10:45:17 -0400 (Thu, 11 Jun 2009)
New Revision: 5028
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrentEndTest.java
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
Log:
JBPM-2275 verify combination of async messages and end of process instance
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java 2009-06-11 10:34:50 UTC (rev 5027)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java 2009-06-11 14:45:17 UTC (rev 5028)
@@ -85,6 +85,10 @@
concurrentExecution.setActivity(activity);
concurrentExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
concurrentExecution.take(transition);
+
+ if (concurrentRoot.isEnded()) {
+ break;
+ }
}
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java 2009-06-11 10:34:50 UTC (rev 5027)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java 2009-06-11 14:45:17 UTC (rev 5028)
@@ -49,7 +49,16 @@
execution.fire(signalName, activity);
- Transition transition = activity.findOutgoingTransition(signalName);
+ Transition transition = null;
+ if ( (signalName==null)
+ && (activity.getOutgoingTransitions()!=null)
+ && (activity.getOutgoingTransitions().size()==1)
+ ) {
+ transition = activity.getOutgoingTransitions().get(0);
+ } else {
+ transition = activity.findOutgoingTransition(signalName);
+ }
+
if (transition!=null) {
execution.historyActivityEnd(signalName);
execution.take(transition);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-06-11 10:34:50 UTC (rev 5027)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-06-11 14:45:17 UTC (rev 5028)
@@ -266,6 +266,10 @@
parent.setState(STATE_ACTIVE_ROOT);
}
+ // capture the parent execution cause the
+ // subsequent invocation of end() will set the parent to null
+ ExecutionImpl parent = this.parent;
+
end();
return parent;
@@ -763,9 +767,11 @@
return (ExecutionImpl) (executionsMap!=null ? executionsMap.get(name) : null);
}
- public void removeExecution(Execution child) {
+ public void removeExecution(ExecutionImpl child) {
if (executions!=null) {
if (executions.remove(child)) {
+ child.setParent(null);
+
// invalidate the executionsMap cache
executionsMap = null;
} else {
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java 2009-06-11 14:45:17 UTC (rev 5028)
@@ -0,0 +1,71 @@
+/*
+ * 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.execution;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncEndCombinationTest extends JbpmTestCase {
+
+ public void testConcurrentEndScenario1() {
+ deployJpdlXmlString(
+ "<process name='AsyncEndCombination'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <fork name='f'>" +
+ " <transition to='a' continue='async' />" +
+ " <transition to='end' />" +
+ " </fork>" +
+ " <state name='a' />" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEndCombination");
+ assertEquals(Execution.STATE_ENDED, processInstance.getState());
+ }
+
+ public void testConcurrentScenario2() {
+ deployJpdlXmlString(
+ "<process name='AsyncEndCombination'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <fork name='f'>" +
+ " <transition to='end' />" +
+ " <transition to='a' continue='async' />" +
+ " </fork>" +
+ " <state name='a' />" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEndCombination");
+ assertEquals(Execution.STATE_ENDED, processInstance.getState());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEndCombinationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java 2009-06-11 14:45:17 UTC (rev 5028)
@@ -0,0 +1,108 @@
+/*
+ * 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.execution;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncEventListenerOnEndTest extends JbpmTestCase {
+
+ public static class AsyncEventListener implements EventListener {
+ private static final long serialVersionUID = 1L;
+ public void notify(EventListenerExecution execution) throws Exception {
+ }
+ }
+
+ public void testAsyncEventListenerAfterWaitState() {
+ deployJpdlXmlString(
+ "<process name='AsyncEventListenerOnEnd'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition name='start-to-end' to='end'>" +
+ " <event-listener continue='async' class='"+AsyncEventListener.class.getName()+"' />" +
+ " </transition>" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListenerOnEnd");
+
+ processInstance = executionService.signalExecutionById(processInstance.getId());
+
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ assertNotNull(job);
+
+ managementService.executeJob(job.getDbid());
+
+ assertEquals(Execution.STATE_ENDED,
+ historyService.createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult()
+ .getState() );
+ }
+
+ public void testAsyncEventListenerInStartTransaction() {
+ deployJpdlXmlString(
+ "<process name='AsyncEventListenerOnEnd'>" +
+ " <start name='start'>" +
+ " <transition name='start-to-end' to='end'>" +
+ " <event-listener continue='async' class='"+AsyncEventListener.class.getName()+"' />" +
+ " </transition>" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListenerOnEnd");
+ assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ assertNotNull(job);
+
+ managementService.executeJob(job.getDbid());
+
+ assertEquals(Execution.STATE_ENDED,
+ historyService.createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult()
+ .getState() );
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/AsyncEventListenerOnEndTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrentEndTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrentEndTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrentEndTest.java 2009-06-11 14:45:17 UTC (rev 5028)
@@ -0,0 +1,71 @@
+/*
+ * 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.execution;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConcurrentEndTest extends JbpmTestCase {
+
+ public void testConcurrentEndScenario1() {
+ deployJpdlXmlString(
+ "<process name='ConcurrentEnd'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <fork name='f'>" +
+ " <transition to='a' />" +
+ " <transition to='end' />" +
+ " </fork>" +
+ " <state name='a' />" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ConcurrentEnd");
+ assertEquals(Execution.STATE_ENDED, processInstance.getState());
+ }
+
+ public void testConcurrentEndScenario2() {
+ deployJpdlXmlString(
+ "<process name='ConcurrentEnd'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <fork name='f'>" +
+ " <transition to='end' />" +
+ " <transition to='a' />" +
+ " </fork>" +
+ " <state name='a' />" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ConcurrentEnd");
+ assertEquals(Execution.STATE_ENDED, processInstance.getState());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrentEndTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jbpm-commits
mailing list