[jbpm-commits] JBoss JBPM SVN: r5794 - in jbpm4/tags/jbpm-4.1/modules: test-upgrade and 7 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Oct 26 06:20:12 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-10-26 06:20:11 -0400 (Mon, 26 Oct 2009)
New Revision: 5794

Added:
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/.classpath
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/.project
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/.settings/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/pom.xml
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/jbpm/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/jbpm/upgrade/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/resources/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/test/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/test/java/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/test/resources/
   jbpm4/tags/jbpm-4.1/modules/test-upgrade/target/
Log:
added test-upgrade module

Added: jbpm4/tags/jbpm-4.1/modules/test-upgrade/.classpath
===================================================================
--- jbpm4/tags/jbpm-4.1/modules/test-upgrade/.classpath	                        (rev 0)
+++ jbpm4/tags/jbpm-4.1/modules/test-upgrade/.classpath	2009-10-26 10:20:11 UTC (rev 5794)
@@ -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>


Property changes on: jbpm4/tags/jbpm-4.1/modules/test-upgrade/.classpath
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/tags/jbpm-4.1/modules/test-upgrade/.project
===================================================================
--- jbpm4/tags/jbpm-4.1/modules/test-upgrade/.project	                        (rev 0)
+++ jbpm4/tags/jbpm-4.1/modules/test-upgrade/.project	2009-10-26 10:20:11 UTC (rev 5794)
@@ -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


Property changes on: jbpm4/tags/jbpm-4.1/modules/test-upgrade/.project
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/tags/jbpm-4.1/modules/test-upgrade/pom.xml
===================================================================
--- jbpm4/tags/jbpm-4.1/modules/test-upgrade/pom.xml	                        (rev 0)
+++ jbpm4/tags/jbpm-4.1/modules/test-upgrade/pom.xml	2009-10-26 10:20:11 UTC (rev 5794)
@@ -0,0 +1,43 @@
+<?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.1</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.jbpm.jbpm4</groupId>
+      <artifactId>jbpm-jpdl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <artifactId>hsqldb</artifactId>
+      <version>${hsqldb.version}</version>
+    </dependency>
+  </dependencies>
+  
+</project>


Property changes on: jbpm4/tags/jbpm-4.1/modules/test-upgrade/pom.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
===================================================================
--- jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java	                        (rev 0)
+++ jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java	2009-10-26 10:20:11 UTC (rev 5794)
@@ -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());
+    
+  }
+
+}


Property changes on: jbpm4/tags/jbpm-4.1/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the jbpm-commits mailing list