[jbpm-commits] JBoss JBPM SVN: r6729 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/execution and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Oct 3 09:56:44 EDT 2010
Author: rebody
Date: 2010-10-03 09:56:44 -0400 (Sun, 03 Oct 2010)
New Revision: 6729
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrencyGraphBasedTest.java
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrentEndTest.java
Log:
JBPM-2932 fix NullPointerException when invoking endProcessInstance() on a process with end eventListener.
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java 2010-10-03 00:53:36 UTC (rev 6728)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java 2010-10-03 13:56:44 UTC (rev 6729)
@@ -382,8 +382,11 @@
}
public static ClassLoader installDeploymentClassLoader(ProcessDefinitionImpl processDefinition) {
+ if (processDefinition == null) {
+ return null;
+ }
String deploymentId = processDefinition.getDeploymentId();
- if (deploymentId==null) {
+ if (deploymentId == null) {
return null;
}
@@ -392,7 +395,7 @@
RepositoryCache repositoryCache = EnvironmentImpl.getFromCurrent(RepositoryCache.class);
DeploymentClassLoader deploymentClassLoader = repositoryCache.getDeploymentClassLoader(deploymentId, original);
- if (deploymentClassLoader==null) {
+ if (deploymentClassLoader == null) {
deploymentClassLoader = new DeploymentClassLoader(original, deploymentId);
repositoryCache.setDeploymentClassLoader(deploymentId, original, deploymentClassLoader);
}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrencyGraphBasedTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrencyGraphBasedTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrencyGraphBasedTest.java 2010-10-03 13:56:44 UTC (rev 6729)
@@ -0,0 +1,154 @@
+/*
+ * 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 java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConcurrencyGraphBasedTest extends JbpmTestCase {
+
+ public void testConcurrencyGraphBased() {
+ deployJpdlXmlString("<?xml version='1.0' encoding='UTF-8'?>"
+
+ +"<process name='ConcurrencyGraphBased'>"
+
+ +"<on event='start'>"
+ +"<event-listener class='" + TestEventListener.class.getName() + "'>"
+ +"</event-listener>"
+ +"</on>"
+
+ +"<on event='end'>"
+ +"<event-listener class='" + TestEventListener.class.getName() + "'>"
+ +"</event-listener>"
+ +"</on>"
+
+ +"<start g='16,102,48,48'>"
+ +"<transition to='fork'/>"
+ +"</start>"
+
+ +"<fork name='fork' g='96,102,48,48'>"
+ +"<transition to='send invoice' g='120,41:'/>"
+ +"<transition to='load truck'/>"
+ +"<transition to='print shipping documents' g='120,213:'/>"
+ +"</fork>"
+
+ +"<state name='send invoice' g='176,16,149,52'>"
+ +"<transition to='final join' g='606,41:'/>"
+ +"</state>"
+
+ +"<state name='load truck' g='176,100,149,52'>"
+ +"<transition to='shipping join' g='377,126:'/>"
+ +"</state>"
+
+ +"<state name='print shipping documents' g='176,184,149,58'>"
+ +"<transition to='shipping join' g='378,213:'/>"
+ +"</state>"
+
+ +"<join name='shipping join' g='353,145,48,48'>"
+ +"<transition to='drive truck to destination'/>"
+ +"</join>"
+
+ +"<state name='drive truck to destination' g='431,140,148,52'>"
+ +"<transition to='final join' g='607,165:'/>"
+ +"</state>"
+
+ +"<join name='final join' g='583,73,48,48'>"
+ +"<transition to='end'/>"
+ +"</join>"
+
+ +"<end name='end' g='666,74,48,48'/>"
+
+ +"</process>");
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ConcurrencyGraphBased");
+ String pid = processInstance.getId();
+
+ Set<String> expectedActivityNames = new HashSet<String>();
+ expectedActivityNames.add("send invoice");
+ expectedActivityNames.add("load truck");
+ expectedActivityNames.add("print shipping documents");
+
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ assertNotNull(processInstance.findActiveExecutionIn("send invoice"));
+ assertNotNull(processInstance.findActiveExecutionIn("load truck"));
+ assertNotNull(processInstance.findActiveExecutionIn("print shipping documents"));
+
+ String sendInvoiceExecutionId = processInstance.findActiveExecutionIn("send invoice").getId();
+ processInstance = executionService.signalExecutionById(sendInvoiceExecutionId);
+
+ expectedActivityNames.remove("send invoice");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ assertNotNull(processInstance.findActiveExecutionIn("load truck"));
+ assertNotNull(processInstance.findActiveExecutionIn("print shipping documents"));
+
+ String loadTruckExecutionId = processInstance.findActiveExecutionIn("load truck").getId();
+ processInstance = executionService.signalExecutionById(loadTruckExecutionId);
+
+ expectedActivityNames.remove("load truck");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ assertNotNull(processInstance.findActiveExecutionIn("print shipping documents"));
+
+ String printShippingDocumentsId = processInstance.findActiveExecutionIn("print shipping documents").getId();
+ processInstance = executionService.signalExecutionById(printShippingDocumentsId);
+
+ expectedActivityNames.remove("print shipping documents");
+ expectedActivityNames.add("drive truck to destination");
+ assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
+
+ assertNotNull(processInstance.findActiveExecutionIn("drive truck to destination"));
+
+ String driveTruckExecutionId = processInstance.findActiveExecutionIn("drive truck to destination").getId();
+
+
+ processInstance = executionService.signalExecutionById(driveTruckExecutionId, "ERROR"); // KM specify an ERROR transition, not the default
+ assertNotNull("execution "+pid+" should exist", executionService.findExecutionById(pid)); // ProcessInstance is still execution
+
+// Would like to force the Process Instance to end in this scenario, but I am not sure how to do it ?
+
+// ExecutionImpl execution = (ExecutionImpl) executionService.findExecutionById(pid);
+// execution.end(); // throws org.jbpm.api.JbpmException: no environment to get org.jbpm.pvm.internal.session.RepositorySession
+
+ processEngine.getExecutionService().endProcessInstance(pid,ProcessInstance.STATE_ENDED);
+ assertNull("execution "+pid+" should not exist", executionService.findExecutionById(pid)); // ProcessInstance is still execution
+
+
+ }
+
+ public static class TestEventListener implements EventListener {
+ public void notify(EventListenerExecution execution) {
+ }
+ }
+}
Modified: 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 2010-10-03 00:53:36 UTC (rev 6728)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/ConcurrentEndTest.java 2010-10-03 13:56:44 UTC (rev 6729)
@@ -46,7 +46,7 @@
" <end name='end' />" +
"</process>"
);
-
+
ProcessInstance processInstance = executionService.startProcessInstanceByKey("ConcurrentEnd");
assertEquals(Execution.STATE_ENDED, processInstance.getState());
}
@@ -65,11 +65,11 @@
" <end name='end' />" +
"</process>"
);
-
+
ProcessInstance processInstance = executionService.startProcessInstanceByKey("ConcurrentEnd");
assertEquals(Execution.STATE_ENDED, processInstance.getState());
}
-
+
public void testConcurrentEndScenario3() {
deployJpdlXmlString(
"<process name='ConcurrentEnd'>" +
@@ -95,5 +95,5 @@
ProcessInstance processInstance = executionService.startProcessInstanceByKey("ConcurrentEnd");
assertEquals(Execution.STATE_ENDED, processInstance.getState());
- }
+ }
}
More information about the jbpm-commits
mailing list