[jbpm-commits] JBoss JBPM SVN: r5777 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api and 18 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Oct 23 07:30:26 EDT 2009
Author: jbarrez
Date: 2009-10-23 07:30:25 -0400 (Fri, 23 Oct 2009)
New Revision: 5777
Added:
jbpm4/trunk/modules/test-upgrade/
jbpm4/trunk/modules/test-upgrade/.classpath
jbpm4/trunk/modules/test-upgrade/.project
jbpm4/trunk/modules/test-upgrade/.settings/
jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs
jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs
jbpm4/trunk/modules/test-upgrade/pom.xml
jbpm4/trunk/modules/test-upgrade/src/
jbpm4/trunk/modules/test-upgrade/src/main/
jbpm4/trunk/modules/test-upgrade/src/main/java/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/
jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
jbpm4/trunk/modules/test-upgrade/src/main/resources/
jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties
jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties
jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml
jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml
jbpm4/trunk/modules/test-upgrade/src/test/
jbpm4/trunk/modules/test-upgrade/src/test/java/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java
jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java
jbpm4/trunk/modules/test-upgrade/src/test/resources/
jbpm4/trunk/modules/test-upgrade/target/
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
Log:
initial commit test-upgrade
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -36,8 +36,11 @@
/** select only process instances for the given process definition */
ProcessInstanceQuery processDefinitionId(String processDefinitionId);
- /** select only a specific process instances */
+ /** select only a specific process instances using the process instance id */
ProcessInstanceQuery processInstanceId(String processInstanceId);
+
+ /** select only specific process instances using a business key */
+ ProcessInstanceQuery processInstanceKey(String processInstanceKey);
/** select only suspended process definitions */
ProcessInstanceQuery suspended();
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -40,12 +40,17 @@
String PROPERTY_STATE = "state";
/** duration property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
String PROPERTY_DURATION = "duration";
+ /** Key propertu to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+ String PROPERTY_KEY = "key";
/** select only the process instances with the given id */
HistoryProcessInstanceQuery processInstanceId(String processInstanceId);
- /** select only process instances within the given process definition */
+ /** select only process instances with the given process definition */
HistoryProcessInstanceQuery processDefinitionId(String processDefinitionId);
+
+ /** select only process instances with the given business key */
+ HistoryProcessInstanceQuery processInstanceKey(String processInstanceKey);
/** select only process instances in the given state */
HistoryProcessInstanceQuery state(String state);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -38,6 +38,7 @@
protected String processDefinitionId;
protected String state;
protected String processInstanceId;
+ protected String processInstanceKey;
public String hql() {
StringBuilder hql = new StringBuilder();
@@ -58,6 +59,10 @@
appendWhereClause(" hpi.state = '"+state+"' ", hql);
}
+ if (processInstanceKey!=null) {
+ appendWhereClause(" hpi.key = '" + processInstanceKey + "'", hql);
+ }
+
appendOrderByClause(hql);
return hql.toString();
@@ -98,6 +103,11 @@
this.processDefinitionId = processDefinitionId;
return this;
}
+
+ public HistoryProcessInstanceQuery processInstanceKey(String processInstanceKey) {
+ this.processInstanceKey = processInstanceKey;
+ return this;
+ }
public HistoryProcessInstanceQuery state(String state) {
this.state = state;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -37,6 +37,7 @@
protected String processDefinitionId;
protected String processInstanceId;
+ protected String processInstanceKey;
protected Boolean suspended;
public ProcessInstance uniqueResult() {
@@ -64,13 +65,17 @@
}
}
- if (processInstanceId!=null) {
- appendWhereClause("processInstance.processInstance.id = '"+processInstanceId+"' ", hql);
+ if (processInstanceId != null) {
+ appendWhereClause("processInstance.processInstance.id = '" + processInstanceId+"' ", hql);
}
- if (processDefinitionId!=null) {
- appendWhereClause("processInstance.processDefinitionId = '"+processDefinitionId+"' ", hql);
+ if (processDefinitionId != null) {
+ appendWhereClause("processInstance.processDefinitionId = '" + processDefinitionId+"' ", hql);
}
+
+ if (processInstanceKey != null) {
+ appendWhereClause("processInstance.key = '" + processInstanceKey + "'", hql);
+ }
appendOrderByClause(hql);
@@ -110,8 +115,14 @@
return this;
}
+ public ProcessInstanceQuery processInstanceKey(String processInstanceKey) {
+ this.processInstanceKey = processInstanceKey;
+ return this;
+ }
+
public ProcessInstanceQuery notSuspended() {
this.suspended = false;
return this;
}
+
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-10-23 09:47:10 UTC (rev 5776)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -220,7 +220,8 @@
column="PROCESSINSTANCE_"
cascade="none"
foreign-key="none"
- index="IDX_JOB_PRINST"/>
+ index="IDX_JOB_PRINST"
+ lazy="false"/>
<many-to-one name="execution"
class="org.jbpm.pvm.internal.model.ExecutionImpl"
Added: jbpm4/trunk/modules/test-upgrade/.classpath
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.classpath (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.classpath 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: jbpm4/trunk/modules/test-upgrade/.project
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.project (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.project 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,23 @@
+<projectDescription>
+ <name>jbpm-test-upgrade</name>
+ <comment/>
+ <projects>
+ <project>api</project>
+ <project>jpdl</project>
+ <project>log</project>
+ <project>pvm</project>
+ <project>test-base</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.settings/org.eclipse.jdt.core.prefs 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,5 @@
+#Wed Oct 21 23:47:50 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
Added: jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/.settings/org.maven.ide.eclipse.prefs 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,9 @@
+#Wed Oct 21 23:32:38 CEST 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Added: jbpm4/trunk/modules/test-upgrade/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/pom.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/pom.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 3010 2008-11-20 08:30:16Z tom.baeyens at jboss.com $ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Module Info -->
+ <modelVersion>4.0.0</modelVersion>
+ <name>jBPM 4 - TEST-UPGRADE</name>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-upgrade</artifactId>
+ <packaging>jar</packaging>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm</artifactId>
+ <version>4.2-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <version>4.2-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
Added: jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,163 @@
+/*
+ * 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.upgrade;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.Configuration;
+import org.jbpm.api.Execution;
+import org.jbpm.api.ExecutionService;
+import org.jbpm.api.ManagementService;
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.RepositoryService;
+import org.jbpm.api.job.Job;
+
+/**
+ * Class to be executed during the upgrade test, before the actual schema
+ * upgrade is applied. This class will populate the 'old' DB schema with
+ * process, variables, history, ... data, that will be verified by the
+ * {@link AfterUpgrade} class.
+ *
+ * @author jbarrez
+ */
+public class BeforeUpgrade {
+
+ private ProcessEngine processEngine;
+
+ private RepositoryService repositoryService;
+
+ private ExecutionService executionService;
+
+ private ManagementService managementService;
+
+ private static final String TEST_PROCESS_1 = "testprocess1.jpdl.xml";
+
+ private static final String TEST_PROCESS_2 = "testprocess2.jpdl.xml";
+
+ private static final String TEST_PROCESS_3 = "testprocess3.jpdl.xml";
+
+ public static void main(String[] args) {
+ BeforeUpgrade beforeUpgrade = new BeforeUpgrade();
+ beforeUpgrade.generateProcess1Data();
+ beforeUpgrade.generateProcess2Data();
+ beforeUpgrade.generateProcess3Data();
+ }
+
+ public BeforeUpgrade() {
+ this.processEngine = new Configuration().buildProcessEngine();
+ this.repositoryService = processEngine.getRepositoryService();
+ this.executionService = processEngine.getExecutionService();
+ this.managementService = processEngine.getManagementService();
+ }
+
+
+ private void deploy(String processFile) {
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath(processFile);
+ deployment.deploy();
+ }
+
+ /**
+ * Process 1 is a simple process using fork/join and states
+ */
+ private void generateProcess1Data() {
+
+ // Deploy test processes
+ deploy(TEST_PROCESS_1);
+
+ // Start 5 instances of process1
+ List<String> ids = new ArrayList<String>();
+ for (int i = 0; i < 5; i++) {
+ String procDefKey = TEST_PROCESS_1.replace(".jpdl.xml", "");
+ String procInstKey = procDefKey + "-" + i;
+ ids.add(executionService.startProcessInstanceByKey(procDefKey, procInstKey).getId());
+ }
+
+ // Put these instances in various states
+
+ // First one: only in state 'print documents'
+ String execId = executionService.findProcessInstanceById(ids.get(0)).findActiveExecutionIn("send invoice").getId();
+ executionService.signalExecutionById(execId);
+
+ execId = executionService.findProcessInstanceById(ids.get(0)).findActiveExecutionIn("load truck").getId();
+ executionService.signalExecutionById(execId);
+
+ // Second one: put in state 'load truck' and 'send invoice'
+ execId = executionService.findProcessInstanceById(ids.get(1)).findActiveExecutionIn("print documents").getId();
+ executionService.signalExecutionById(execId);
+
+ // third one: finished
+ executionService.endProcessInstance(ids.get(2), Execution.STATE_ENDED);
+
+ }
+
+ /**
+ * Process 2 is a process using variables and a decision
+ */
+ private void generateProcess2Data() {
+
+ // Deploy test process
+ deploy(TEST_PROCESS_2);
+
+ // Start 6 instances, of which 3 will be ended
+ List<String> ids = new ArrayList<String>();
+ for (int i = 0; i < 7; i++) {
+
+ String procDefKey = TEST_PROCESS_2.replace(".jpdl.xml", "");
+ String procInstKey = procDefKey + "-" + i;
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("var", i * 2); // we store as var: 0, 2, 4, 6, 8, 10, 12
+ ids.add(executionService.startProcessInstanceByKey(procDefKey, vars, procInstKey).getId());
+ }
+
+
+ }
+
+ /**
+ * Process 3 is a basic process containing a human task and a timer
+ */
+ private void generateProcess3Data() {
+
+ // Deploy test process
+ deploy(TEST_PROCESS_3);
+
+ // Start 2 instances, 1 will have timer fired
+ List<String> ids = new ArrayList<String>();
+ for (int i = 0; i < 2; i++) {
+
+ String procDefKey = TEST_PROCESS_3.replace(".jpdl.xml", "");
+ String procInstKey = procDefKey + "-" + i;
+ ids.add(executionService.startProcessInstanceByKey(procDefKey, procInstKey).getId());
+ }
+
+ Job timer = managementService.createJobQuery()
+ .processInstanceId(ids.get(0)).uniqueResult();
+ managementService.executeJob(timer.getId());
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,10 @@
+# Using a property file here, since property values are easier to
+# replace than in the XML counterpart
+
+hibernate.dialect=org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class=org.hsqldb.jdbcDriver
+hibernate.connection.url=jdbc:hsqldb:hsql://localhost:1701
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.hbm2ddl.auto=create-drop
+hibernate.format_sql=true
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.cfg.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.tx.hibernate.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+</jbpm-configuration>
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/jbpm.hibernate.cfg.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <!-- Connection properties will be taken from hibernate.properties -->
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/logging.properties 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,18 @@
+handlers= java.util.logging.ConsoleHandler
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
+
+org.jbpm.level=FINE
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+org.hibernate.cfg.HbmBinder.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess1.jpdl.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <process name="testprocess1" xmlns="http://jbpm.org/4.2/jpdl">
+
+ <start>
+ <transition to="theFork"/>
+ </start>
+
+ <fork name="theFork">
+ <transition to="send invoice"/>
+ <transition to="load truck"/>
+ <transition to="print documents"/>
+ </fork>
+
+ <state name="send invoice">
+ <transition to="theJoin"/>
+ </state>
+
+ <state name="load truck">
+ <transition to="shipping join"/>
+ </state>
+
+ <state name="print documents">
+ <transition to="shipping join"/>
+ </state>
+
+ <join name="shipping join">
+ <transition to="drive truck"/>
+ </join>
+
+ <state name="drive truck">
+ <transition to="theJoin"/>
+ </state>
+
+ <join name="theJoin">
+ <transition to="end"/>
+ </join>
+
+ <end name="end"/>
+
+ </process>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess2.jpdl.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="testprocess2" xmlns="http://jbpm.org/4.2/jpdl">
+
+ <start>
+ <transition to="testVariable" />
+ </start>
+
+ <decision name="testVariable">
+ <transition to="end">
+ <condition expr="#{var < 6}" />
+ </transition>
+ <transition to="more than 5">
+ <condition expr="#{var > 5}" />
+ </transition>
+ </decision>
+
+ <state name="more than 5">
+ <transition to="testVariable" />
+ </state>
+
+ <end name="end" />
+
+</process>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/testprocess3.jpdl.xml 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="testprocess3" xmlns="http://jbpm.org/4.2/jpdl">
+
+ <start>
+ <transition to="do something important" />
+ </start>
+
+ <task name="do something important" assignee="johnDoe">
+ <transition name="timeout" to="timed out">
+ <timer duedate="3 days" />
+ </transition>
+ <transition name="done" to="end" />
+ </task>
+
+ <state name="timed out">
+ <transition to="end" />
+ </state>
+
+ <end name="end" />
+
+</process>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,68 @@
+package org.jbpm.test.upgrade;
+
+import java.util.List;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.upgrade.BeforeUpgrade;
+
+/**
+ * We cannot use the {@link JbpmTestCase} directly, since it will check if the
+ * database is clean. However, in the upgrade test, we expect to have data in
+ * the database that was put there before the upgrade. So this class adapts the
+ * {@link JbpmTestCase} where needed, so that the database is not checked to be
+ * clean.
+ *
+ * @author jbarrez
+ */
+public abstract class AfterUpgradeJbpmTestCase extends JbpmTestCase {
+
+ protected void tearDown() throws Exception {
+ // Do nothing -> the super.tearDown() will check the database to be
+ // clean, which now isn't happening due to the override.
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ //BeforeUpgrade.main(new String[] {}); // For testing locally
+ }
+
+ public abstract void testDataValid();
+
+ /*
+ * -------------- HELPER METHODS --------------
+ */
+
+ protected ProcessInstance findProcessInstanceByKey(String key) {
+ return executionService.createProcessInstanceQuery()
+ .processInstanceKey(key).uniqueResult();
+ }
+
+ protected HistoryProcessInstance findHistoryProcessInstanceByKey(String key) {
+ return historyService.createHistoryProcessInstanceQuery()
+ .processInstanceKey(key).uniqueResult();
+ }
+
+ protected List<HistoryProcessInstance> findEndedProcessInstancesByProcDef(String processDefinitionId){
+ return historyService.createHistoryProcessInstanceQuery()
+ .state(Execution.STATE_ENDED)
+ .processDefinitionId(processDefinitionId).list();
+ }
+
+ protected List<ProcessDefinition> findProcessDefinitionsByKey(String key) {
+ return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).list();
+ }
+
+ protected ProcessDefinition findProcessDefinitionByKey(String key) {
+ return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).uniqueResult();
+ }
+
+ protected List<ProcessInstance> findProcessInstancesByProcessDefinition(String procDefId) {
+ return executionService.createProcessInstanceQuery().processDefinitionId(procDefId).list();
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,43 @@
+package org.jbpm.test.upgrade;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+
+public class Process1AfterUpgradeTest extends AfterUpgradeJbpmTestCase {
+
+ private static final String PROCESS_1_KEY = "testprocess1";
+
+ public void testDataValid() {
+
+ // Check process1 deployment
+ List<ProcessDefinition> procDefs = findProcessDefinitionsByKey(PROCESS_1_KEY);
+ assertEquals(1, procDefs.size());
+
+ List<ProcessInstance> procInstances = findProcessInstancesByProcessDefinition(procDefs.get(0).getId());
+ assertEquals(4, procInstances.size());
+
+ // process instance 1 is in the 'print documents' state
+ ProcessInstance processInstance1 = findProcessInstanceByKey(PROCESS_1_KEY + "-0");
+ Set<String> activeActivities = processInstance1.findActiveActivityNames();
+ assertEquals(1, activeActivities.size());
+ assertActivityActive(processInstance1.getId(), "print documents");
+
+ // process instance 2 is in the 'load truck' and 'send invoice' state
+ ProcessInstance processInstance2 = findProcessInstanceByKey(PROCESS_1_KEY + "-1");
+ activeActivities = processInstance2.findActiveActivityNames();
+ assertActivitiesActive(processInstance2.getId(), "load truck", "send invoice");
+
+ // process instance 3 is finished
+ ProcessInstance processInstance3 = findProcessInstanceByKey(PROCESS_1_KEY + "-2");
+ assertNull(processInstance3);
+ HistoryProcessInstance histProcInst3 = findHistoryProcessInstanceByKey(PROCESS_1_KEY + "-2");
+ assertNotNull(histProcInst3);
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,34 @@
+package org.jbpm.test.upgrade;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+
+public class Process2AfterUpgradeTest extends AfterUpgradeJbpmTestCase {
+
+ private static final String PROCESS_2_KEY = "testprocess2";
+
+ public void testDataValid() {
+
+ // 4 process instances should be active
+ ProcessDefinition procDef = findProcessDefinitionByKey(PROCESS_2_KEY);
+ List<ProcessInstance> procInstances = findProcessInstancesByProcessDefinition(procDef.getId());
+ assertEquals(4, procInstances.size()); // 3 processes are already finished: 7-3=4 left
+
+ // These processes should be in the 'more than 5' state
+ for (ProcessInstance processInstance : procInstances) {
+ Set<String> activeActivities = processInstance.findActiveActivityNames();
+ assertEquals(1, activeActivities.size());
+ assertActivityActive(processInstance.getId(), "more than 5");
+ }
+
+ // 4 process instances should have ended
+ List<HistoryProcessInstance> histProcInsts = findEndedProcessInstancesByProcDef(procDef.getId());
+ assertEquals(3, histProcInsts.size());
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java (rev 0)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java 2009-10-23 11:30:25 UTC (rev 5777)
@@ -0,0 +1,36 @@
+package org.jbpm.test.upgrade;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+
+public class Process3AfterUpgradeTest extends AfterUpgradeJbpmTestCase {
+
+ private static final String PROCESS_3_KEY = "testprocess3";
+
+ public void testDataValid() {
+
+ // 2 process instances should be active
+ ProcessDefinition procDef = findProcessDefinitionByKey(PROCESS_3_KEY);
+ List<ProcessInstance> procInstances = findProcessInstancesByProcessDefinition(procDef.getId());
+ assertEquals(2, procInstances.size());
+
+ // process instance 1 should be in the 'timed out' state
+ ProcessInstance processInstance = findProcessInstanceByKey(PROCESS_3_KEY + "-0");
+ assertActivityActive(processInstance.getId(), "timed out");
+
+ // process instance 2 should have an uncompleted task
+ List<Task> tasks = taskService.createTaskQuery().assignee("johnDoe").list();
+ assertEquals(2, tasks.size());
+
+ // There should be one job unfinished
+ List<Job> jobs = managementService.createJobQuery().list();
+ assertEquals(1, jobs.size());
+ assertEquals(PROCESS_3_KEY + "-1", jobs.get(0).getProcessInstance().getKey());
+
+ }
+
+}
More information about the jbpm-commits
mailing list