Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java =================================================================== --- modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java (revision 6345) +++ modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java (working copy) @@ -376,6 +376,9 @@ fire(Event.END, getProcessDefinition()); if (superProcessExecution!=null) { + if (dbSession!=null) { + dbSession.delete(this); + } log.trace(toString()+" signals super process execution"); superProcessExecution.signal(); Index: modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/DynamicSubProcessTest.java =================================================================== --- modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/DynamicSubProcessTest.java (revision 0) +++ modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/DynamicSubProcessTest.java (revision 0) @@ -0,0 +1,116 @@ +/* + * 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.activity.subprocess; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.jdt.internal.compiler.ast.AssertStatement; +import org.jbpm.api.JbpmException; +import org.jbpm.api.ProcessInstance; +import org.jbpm.api.task.Task; +import org.jbpm.test.JbpmTestCase; + + +/** + * Test case for different usages of the subprocess activity. + * + * @author Joram Barrez + */ +public class DynamicSubProcessTest extends JbpmTestCase { + + private static final String SUB_PROCESS = + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + private static final String MAIN_PROCESS_SUB_EL = + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public void testDynamicSubProcess() { + deployJpdlXmlString(SUB_PROCESS); + deployJpdlXmlString(MAIN_PROCESS_SUB_EL); + + Map vars = new HashMap(); + vars.put("dynamic_subprocess", "SubProcessReview"); + ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess",vars); + Task task = taskService.findPersonalTasks("johndoe").get(0); + taskService.completeTask(task.getId(), "reject"); + assertProcessInstanceEnded(processInstance); + } + + public void testDynamicSubProcessNotFound() { + String expectedError = "Subprocess 'DOES_NOT_EXIST' could not be found."; + deployJpdlXmlString(SUB_PROCESS); + deployJpdlXmlString(MAIN_PROCESS_SUB_EL); + + Map vars = new HashMap(); + vars.put("dynamic_subprocess", "DOES_NOT_EXIST"); + try { + ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess",vars); + fail("Should not happen, error expected: " + expectedError); + } catch (JbpmException je) { + assertEquals(expectedError, je.getMessage()); + } + } + + public void testDynamicSubProcessWrongProperty() { + String expectedError = "Subprocess key '#{dynamic_subprocess}' could not be resolved."; + deployJpdlXmlString(SUB_PROCESS); + deployJpdlXmlString(MAIN_PROCESS_SUB_EL); + + Map vars = new HashMap(); + vars.put("WRONG_PROPERTY", "VALUE_DOES_NOT_MATTER"); + try { + ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess",vars); + fail("Should not happen, error expected: " + expectedError); + } catch (JbpmException je) { + assertEquals(expectedError, je.getMessage()); + } + } + +} Index: modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java =================================================================== --- modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java (revision 6352) +++ modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java (working copy) @@ -41,21 +41,97 @@ " " + "" ); - + deployJpdlXmlString( "" + " " + " " + " " + - " " + + " " + " " + - " " + + " " + " " + - "" + "" ); - + String pid = executionService.startProcessInstanceByKey("MainProcess").getId(); - + + assertEquals(2, executionService.createProcessInstanceQuery().list().size()); + executionService.deleteProcessInstance(pid); + + assertEquals(0, executionService.createProcessInstanceQuery().list().size()); + + assertEquals(0, taskService.createTaskQuery().list().size()); } + + public void testMultipleSubProcess() { + deployJpdlXmlString( + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + ); + + deployJpdlXmlString( + "" + + " " + + " " + + " " + + " " + + "" + ); + + String pid = executionService.startProcessInstanceByKey("MainProcess").getId(); + + assertEquals(1, executionService.createProcessInstanceQuery().list().size()); + + executionService.deleteProcessInstance(pid); + + assertEquals(0, executionService.createProcessInstanceQuery().list().size()); + } + + public void testSubProcessWithFork() { + deployJpdlXmlString( + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + ); + + deployJpdlXmlString( + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + ); + + String pid = executionService.startProcessInstanceByKey("MainProcess").getId(); + + assertEquals(1, executionService.createProcessInstanceQuery().list().size()); + + executionService.deleteProcessInstance(pid); + + assertEquals(0, executionService.createProcessInstanceQuery().list().size()); + } } Index: modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java =================================================================== --- modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java (revision 6352) +++ modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java (working copy) @@ -20,7 +20,7 @@ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ /** - * + * */ package org.jbpm.test.activity.subprocess; @@ -36,11 +36,11 @@ /** * Test case for different usages of the subprocess activity. - * + * * @author Joram Barrez */ public class SubProcessTest extends JbpmTestCase { - + private static final String MAIN_PROCESS = "" + " " + @@ -52,10 +52,12 @@ " " + " " + " " + - " " + + " " + + " " + + " " + " " + - ""; - + ""; + private static final String SUB_PROCESS = "" + " " + @@ -69,8 +71,8 @@ " " + " " + " " + - ""; - + ""; + private static final String MAIN_PROCESS_NO_WAIT_STATE = "" + " " + @@ -80,101 +82,58 @@ " " + " " + " " + - ""; - + ""; + private static final String SUB_PROCESS_NO_WAIT_STATE = "" + " " + " " + " " + " " + - ""; - - private static final String MAIN_PROCESS_SUB_EL = - "" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - ""; - + ""; + public void testSubProcessOutcomeToState() { deployJpdlXmlString(SUB_PROCESS); deployJpdlXmlString(MAIN_PROCESS); - + ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess"); + + assertEquals(2, executionService.createProcessInstanceQuery().list().size()); + Task task = taskService.findPersonalTasks("johndoe").get(0); taskService.completeTask(task.getId(), "nok"); + assertActivityActive(processInstance.getId(), "update"); - } - - public void testDynamicSubProcess() { - deployJpdlXmlString(SUB_PROCESS); - deployJpdlXmlString(MAIN_PROCESS_SUB_EL); - - Map vars = new HashMap(); - vars.put("dynamic_subprocess", "SubProcessReview"); - ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess",vars); - Task task = taskService.findPersonalTasks("johndoe").get(0); - taskService.completeTask(task.getId(), "reject"); - assertProcessInstanceEnded(processInstance); + processInstance = executionService.signalExecutionById(processInstance.getId()); + + assertProcessInstanceEnded(processInstance); + assertEquals(0, executionService.createProcessInstanceQuery().list().size()); } - - public void testDynamicSubProcessNotFound() { - String expectedError = "Subprocess 'DOES_NOT_EXIST' could not be found."; - deployJpdlXmlString(SUB_PROCESS); - deployJpdlXmlString(MAIN_PROCESS_SUB_EL); - - Map vars = new HashMap(); - vars.put("dynamic_subprocess", "DOES_NOT_EXIST"); - try { - ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess",vars); - fail("Should not happen, error expected: " + expectedError); - } catch (JbpmException je) { - assertEquals(expectedError, je.getMessage()); - } - } - - public void testDynamicSubProcessWrongProperty() { - String expectedError = "Subprocess key '#{dynamic_subprocess}' could not be resolved."; - deployJpdlXmlString(SUB_PROCESS); - deployJpdlXmlString(MAIN_PROCESS_SUB_EL); - - Map vars = new HashMap(); - vars.put("WRONG_PROPERTY", "VALUE_DOES_NOT_MATTER"); - try { - ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess",vars); - fail("Should not happen, error expected: " + expectedError); - } catch (JbpmException je) { - assertEquals(expectedError, je.getMessage()); - } - } - + public void testSubProcessOutcomeToEnd() { deployJpdlXmlString(SUB_PROCESS); deployJpdlXmlString(MAIN_PROCESS); - + ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess"); + + assertEquals(2, executionService.createProcessInstanceQuery().list().size()); + Task task = taskService.findPersonalTasks("johndoe").get(0); taskService.completeTask(task.getId(), "reject"); - assertProcessInstanceEnded(processInstance); + assertProcessInstanceEnded(processInstance); } - + // Test for JBPM-2651 public void testSubProcessNoWaitStates() { deployJpdlXmlString(SUB_PROCESS_NO_WAIT_STATE); deployJpdlXmlString(MAIN_PROCESS_NO_WAIT_STATE); - - executionService.startProcessInstanceByKey("mainProcess"); + + ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess"); + assertProcessInstanceEnded(processInstance); + + assertEquals(0, executionService.createProcessInstanceQuery().list().size()); } - + }