[jbpm-commits] JBoss JBPM SVN: r4363 - in jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test: java/org/jbpm/jbpm2094 and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 31 03:12:28 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-03-31 03:12:28 -0400 (Tue, 31 Mar 2009)
New Revision: 4363

Added:
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/gpd.xml
   jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml
Log:
[JBPM-2094] provide test case based on bpm_orchestration 4

Added: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/EsbActionHandler.java	2009-03-31 07:12:28 UTC (rev 4363)
@@ -0,0 +1,60 @@
+/*
+ * 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.jbpm2094;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.job.ExecuteActionJob;
+import org.jbpm.job.executor.JobExecutorThread;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class EsbActionHandler implements ActionHandler {
+
+  private String esbCategoryName;
+  private String esbServiceName;
+  private List<String> bpmToEsbVars;
+  private List<String> esbToBpmVars;
+
+  private static final long serialVersionUID = 1L;
+  private static final Log log = LogFactory.getLog(EsbActionHandler.class);
+
+  public void execute(ExecutionContext executionContext) throws Exception {
+    if (Thread.currentThread() instanceof JobExecutorThread) {
+      log.debug("invoking " + esbCategoryName + "::" + esbServiceName);
+      executionContext.leaveNode();
+    }
+    else {
+      ExecuteActionJob job = new ExecuteActionJob(executionContext.getToken());
+      job.setAction(executionContext.getAction());
+      job.setDueDate(new Date());
+      executionContext.getJbpmContext().getServices().getMessageService().send(job);
+    }
+  }
+
+}

Added: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jbpm2094/JBPM2094Test.java	2009-03-31 07:12:28 UTC (rev 4363)
@@ -0,0 +1,82 @@
+/*
+ * 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.jbpm2094;
+
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * Unindexed foreign keys cause deadlocks in oracle.
+ * 
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-2094">JBPM-2094</a>
+ * @author Alejandro Guizar
+ */
+public class JBPM2094Test extends AbstractDbTestCase {
+
+  private static final int TIMEOUT = 60 * 1000;
+  private static final int INSTANCE_COUNT = 10;
+
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    getJbpmConfiguration().getJobExecutor().setNbrOfThreads(4);
+  }
+
+  @Override
+  protected void tearDown() throws Exception {
+    jbpmConfiguration.getJobExecutor().setNbrOfThreads(1);
+    super.tearDown();
+  }
+
+  public void testJobExecutorDeadlock() {
+    // Won't fix [JBPM-2094] unindexed foreign keys cause deadlocks in oracle
+    if (getHibernateDialect().contains("HSQL")) return;
+
+    ProcessDefinition processDefinition = ProcessDefinition
+        .parseXmlResource("org/jbpm/jbpm2094/processdefinition.xml");
+    jbpmContext.deployProcessDefinition(processDefinition);
+
+    newTransaction();
+    try {
+      long[] processInstanceIds = new long[INSTANCE_COUNT];
+      for (int i = 0; i < INSTANCE_COUNT; i++) {
+        ProcessInstance processInstance = new ProcessInstance(processDefinition);
+        processInstance.signal();
+        jbpmContext.save(processInstance);
+        processInstanceIds[i] = processInstance.getId();
+
+        newTransaction();
+      }
+
+      processJobs(TIMEOUT);
+
+      for (int i = 0; i < INSTANCE_COUNT; i++) {
+        ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceIds[i]);
+        assertTrue("expected " + processInstance + " to have ended", processInstance.hasEnded());
+      }
+    }
+    finally {
+      graphSession.deleteProcessDefinition(processDefinition.getId());
+    }
+  }
+}

Added: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/gpd.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/gpd.xml	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/gpd.xml	2009-03-31 07:12:28 UTC (rev 4363)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root-container name="processDefinition1" width="806" height="809">
+  <node name="start" x="181" y="26" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="Receive Order" x="350" y="26" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="Validate Order" x="350" y="89" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="fork1" x="117" y="224" width="252" height="24">
+    <edge>
+      <label x="-65" y="-8"/>
+    </edge>
+    <edge>
+      <label x="-107" y="-14"/>
+    </edge>
+    <edge>
+      <label x="21" y="-11"/>
+    </edge>
+  </node>
+  <node name="Los Angeles WHSE" x="178" y="298" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="Dallas WHSE" x="22" y="300" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="Atlanta WHSE" x="325" y="295" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="join1" x="118" y="386" width="252" height="24">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="Shipment Notice" x="177" y="442" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="end1" x="176" y="511" width="132" height="36"/>
+  <node name="Credit Check" x="178" y="88" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="Inventory Check" x="177" y="154" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+</root-container>

Added: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/resources/org/jbpm/jbpm2094/processdefinition.xml	2009-03-31 07:12:28 UTC (rev 4363)
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="processDefinition1">
+
+  <start-state name="start">
+    <transition name="" to="Receive Order"/>
+  </start-state>
+
+  <node name="Receive Order">
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_Service1</esbCategoryName>
+      <esbServiceName>Service1</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition to="Validate Order"/>
+  </node>
+
+  <node name="Validate Order">
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_Service2</esbCategoryName>
+      <esbServiceName>Service2</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition to="Credit Check"/>
+  </node>
+
+  <fork name="fork1">
+    <transition to="Los Angeles WHSE" name="to Los Angeles WHSE"/>
+    <transition to="Dallas WHSE" name="to Dallas WHSE"/>
+    <transition name="to Atlanta WHSE" to="Atlanta WHSE"/>
+  </fork>
+
+  <node name="Los Angeles WHSE">
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_Service5</esbCategoryName>
+      <esbServiceName>Service5</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="la" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition name="" to="join1"/>
+  </node>
+
+  <node name="Dallas WHSE">
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_Service6</esbCategoryName>
+      <esbServiceName>Service6</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="dallas" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition name="" to="join1"/>
+  </node>
+
+  <node name="Atlanta WHSE">
+
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_Service7</esbCategoryName>
+      <esbServiceName>Service7</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="atlanta" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition name="" to="join1"/>
+  </node>
+
+  <join name="join1">
+    <transition to="Shipment Notice"/>
+  </join>
+
+  <node name="Shipment Notice">
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_ResultsService
+      </esbCategoryName>
+      <esbServiceName>ResultsService</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="atlanta" esb="atlanta" />
+        <mapping bpm="la" esb="la" />
+        <mapping bpm="dallas" esb="dallas" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition name="" to="end1"/>
+  </node>
+
+  <end-state name="end1"/>
+
+  <node name="Credit Check">
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_Service3</esbCategoryName>
+      <esbServiceName>Service3</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition to="Inventory Check"/>
+  </node>
+
+  <node name="Inventory Check">
+    <action name="esbAction" class="org.jbpm.jbpm2094.EsbActionHandler">
+      <esbCategoryName>BPM_Orchestration2_Service4</esbCategoryName>
+      <esbServiceName>Service4</esbServiceName>
+      <bpmToEsbVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </bpmToEsbVars>
+      <esbToBpmVars>
+        <mapping bpm="theBody" esb="BODY_CONTENT" />
+      </esbToBpmVars>
+    </action>
+    <transition to="fork1"/>
+  </node>
+
+</process-definition>




More information about the jbpm-commits mailing list