From do-not-reply at jboss.org Sun May 30 14:53:45 2010 Content-Type: multipart/mixed; boundary="===============1756462654857207296==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: jbpm-commits at lists.jboss.org Subject: [jbpm-commits] JBoss JBPM SVN: r6382 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/model and 1 other directories. Date: Sun, 30 May 2010 14:53:45 -0400 Message-ID: <201005301853.o4UIrjYl027136@svn01.web.mwc.hst.phx2.redhat.com> --===============1756462654857207296== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: swiderski.maciej Date: 2010-05-30 14:53:44 -0400 (Sun, 30 May 2010) New Revision: 6382 Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subproc= ess/SubProcessSignalTest.java Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/Execut= ionImpl.java Log: JBPM-2874: exposed subProcessInstance via Execution interface and ensure th= at signal cannot be mode on process instance that has active subprocess + = test case Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java 2010-= 05-28 06:19:37 UTC (rev 6381) +++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java 2010-= 05-30 18:53:44 UTC (rev 6382) @@ -184,6 +184,12 @@ * structure. Null will be returned in case this execution itself i= s the = * main execution path. */ Execution getProcessInstance(); + = + /** + * the sub path of execution in the execution = + * structure. Null will be returned in case there is no sub process = execution. = + */ + Execution getSubProcessInstance(); = /** the parent execution in the execution = * structure. Null will be returned in case this execution itself i= s the = Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model= /ExecutionImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/Execu= tionImpl.java 2010-05-28 06:19:37 UTC (rev 6381) +++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/Execu= tionImpl.java 2010-05-30 18:53:44 UTC (rev 6382) @@ -1069,6 +1069,9 @@ protected void checkActive() { if (!isActive()) { throw new JbpmException(toString()+" is not active: "+state); + } else if (this.subProcessInstance !=3D null && !Execution.STATE_ENDED= .equals(this.subProcessInstance.getState())) { + throw new JbpmException(toString() + " has running subprocess: " = + + this.subProcessInstance.toString() + " in state " + this.s= ubProcessInstance.getState()); } } = Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/sub= process/SubProcessSignalTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subpro= cess/SubProcessSignalTest.java (rev 0) +++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subpro= cess/SubProcessSignalTest.java 2010-05-30 18:53:44 UTC (rev 6382) @@ -0,0 +1,125 @@ +/* + * 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.jbpm.api.ProcessInstance; +import org.jbpm.pvm.internal.model.ExecutionImpl; +import org.jbpm.test.JbpmTestCase; + + +/** + * Test case for signal of subprocess state activities. + * = + * @author Maciej Swiderski + */ +public class SubProcessSignalTest extends JbpmTestCase { + = + = + = + private static final String SUB_PROCESS_WITH_WAIT_STATE =3D + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; = + = + = + = + private static final String MAIN_PROCESS_SUB_EL_ID =3D + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; = + = + = + public void testSubProcessWithStateFailure() { + deployJpdlXmlString(SUB_PROCESS_WITH_WAIT_STATE); + deployJpdlXmlString(MAIN_PROCESS_SUB_EL_ID); + = + Map vars =3D new HashMap(); + vars.put("dynamic_subprocess", "SubProcessReview-1"); + = + ProcessInstance processInstance =3D executionService.startProcessInsta= nceByKey("mainProcess", vars); + = + try { + processInstance =3D executionService.signalExecut! ionById(processInstance.getId()); + = + fail("Should fail since signal was made on a process with subprocess= stil active"); + } catch (Exception e) { + = + //expected exception since we are signaling main process while sub = process is not finished + assertTrue(e.getMessage().indexOf("has running subprocess") !=3D -1= ); + = + // clean up to let other tests execute + executionService.signalExecutionById(processInstance.getSubProcessI= nstance().getId()); + executionService.signalExecutionById(processInstance.getSubProcessI= nstance().getId()); + = + processInstance =3D executionService.signalExecutionById(processIns= tance.getId()); + = + } + = + } + = + public void testSubProcessWithStateSuccess() { + deployJpdlXmlString(SUB_PROCESS_WITH_WAIT_STATE); + deployJpdlXmlString(MAIN_PROCESS_SUB_EL_ID); + = + Map vars =3D new HashMap(); + vars.put("dynamic_subprocess", "SubPr! ocessReview-1"); + = + ProcessInstance processInstance =3D e! xecution Service.startProcessInstanceByKey("mainProcess", vars); + String subId =3D processInstance.getSubProcessInstance().getId(); + executionService.signalExecutionById(processInstance.getSubProcessInst= ance().getId()); + executionService.signalExecutionById(processInstance.getSubProcessInst= ance().getId()); + = + processInstance =3D executionService.signalExecutionById(processInstan= ce.getId()); + = + assertProcessInstanceEnded(processInstance); = + ProcessInstance subProcessInstance =3D executionService.findProcessIns= tanceById(subId); + assertNull(subProcessInstance); + = + } + = +} --===============1756462654857207296==--