[jbpm-commits] JBoss JBPM SVN: r5789 - in jbpm4/trunk/modules/test-upgrade/src: main/resources and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Oct 26 05:05:42 EDT 2009


Author: jbarrez
Date: 2009-10-26 05:05:41 -0400 (Mon, 26 Oct 2009)
New Revision: 5789

Modified:
   jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java
   jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties
   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
Log:
Updates to test-upgrade AfterUpgrade tests

Modified: 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	2009-10-24 21:50:36 UTC (rev 5788)
+++ jbpm4/trunk/modules/test-upgrade/src/main/java/org/jbpm/upgrade/BeforeUpgrade.java	2009-10-26 09:05:41 UTC (rev 5789)
@@ -26,6 +26,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.hibernate.SessionFactory;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
 import org.jbpm.api.Configuration;
 import org.jbpm.api.Execution;
 import org.jbpm.api.ExecutionService;

Modified: jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties
===================================================================
--- jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties	2009-10-24 21:50:36 UTC (rev 5788)
+++ jbpm4/trunk/modules/test-upgrade/src/main/resources/hibernate.properties	2009-10-26 09:05:41 UTC (rev 5789)
@@ -6,5 +6,6 @@
 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
+hibernate.hbm2ddl.auto=update
+hibernate.format_sql=true
+hibernate.jdbc.batch_size=0
\ No newline at end of file

Modified: 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	2009-10-24 21:50:36 UTC (rev 5788)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/AfterUpgradeJbpmTestCase.java	2009-10-26 09:05:41 UTC (rev 5789)
@@ -25,13 +25,34 @@
     // clean, which now isn't happening due to the override.
   }
   
-  @Override
+  public static boolean DONE = false;
+  
+  /*@Override
   protected void setUp() throws Exception {
     super.setUp();
-    //BeforeUpgrade.main(new String[] {}); // For testing locally
-  }
+    if (!DONE) {
+      BeforeUpgrade.main(new String[] {}); // For testing locally
+      DONE = true;
+    }
+  }*/
 
+  /**
+   * Implementations must test here if the data that was produced before 
+   * the upgrade still is valid after the upgrade.   * 
+   */
   public abstract void testDataValid();
+  
+  /**
+   * Implementations must test here if process instances that were in a given
+   * state before the upgrade, still can be continued/finished after the upgrade.
+   */
+  public abstract void testContinueExistingInstance();
+  
+  /**
+   * Implementations must test here if new process instances can be created
+   * starting from a deployment done before the upgrade.
+   */
+  public abstract void testStartFreshProcessInstance();
 
   /*
    * -------------- HELPER METHODS --------------

Modified: 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	2009-10-24 21:50:36 UTC (rev 5788)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process1AfterUpgradeTest.java	2009-10-26 09:05:41 UTC (rev 5789)
@@ -1,9 +1,9 @@
 package org.jbpm.test.upgrade;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 
+import org.jbpm.api.Execution;
 import org.jbpm.api.ProcessDefinition;
 import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.history.HistoryProcessInstance;
@@ -11,14 +11,15 @@
 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());
+    List<ProcessInstance> procInstances = 
+      findProcessInstancesByProcessDefinition(procDefs.get(0).getId());
     assertEquals(4, procInstances.size());
 
     // process instance 1 is in the 'print documents' state
@@ -40,4 +41,54 @@
     
   }
   
+  public void testContinueExistingInstance() {
+    continueProcessInstance1();
+    continueProcessInstance4();
+  }
+  
+  /* Process instance 1 is waiting in the state 'print documents' */
+  private void continueProcessInstance1() {
+    
+    ProcessInstance pi = findProcessInstanceByKey(PROCESS_1_KEY + "-0");
+    String activeState = "print documents";
+    Execution execution = pi.findActiveExecutionIn(activeState);
+    
+    // Signalling it will cause the process instance to go to 'drive truck'
+    executionService.signalExecutionById(execution.getId());
+    
+    pi = findProcessInstanceByKey(PROCESS_1_KEY + "-0");
+    activeState = "drive truck";
+    assertActivityActive(pi.getId(), activeState);
+    
+    // Signalling the process instance will now cause it to end
+    execution = pi.findActiveExecutionIn(activeState);
+    executionService.signalExecutionById(execution.getId());
+    assertProcessInstanceEnded(pi.getId());
+  }
+  
+  /* Process instance 4 is waiting in all the states */
+  private void continueProcessInstance4() {
+    
+    ProcessInstance pi = findProcessInstanceByKey(PROCESS_1_KEY + "-3");
+    Set<String> activeActivities = pi.findActiveActivityNames();
+    assertTrue(activeActivities.contains("send invoice"));
+    assertTrue(activeActivities.contains("load truck"));
+    assertTrue(activeActivities.contains("print documents"));
+    
+    // Signalling these states will cause the process instance to go to 'drive truck'
+    for (String activeActivity : pi.findActiveActivityNames()) {
+      Execution execution = pi.findActiveExecutionIn(activeActivity);
+      executionService.signalExecutionById(execution.getId());
+      pi = findProcessInstanceByKey(PROCESS_1_KEY + "-3");
+    }
+    
+    assertEquals(1, pi.findActiveActivityNames().size());
+    assertEquals("drive truck", pi.findActiveActivityNames().iterator().next());
+  }
+  
+  public void testStartFreshProcessInstance() {
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey(PROCESS_1_KEY);
+    assertActivitiesActive(processInstance.getId(), "load truck", "send invoice", "print documents");
+  }
+  
 }

Modified: 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	2009-10-24 21:50:36 UTC (rev 5788)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process2AfterUpgradeTest.java	2009-10-26 09:05:41 UTC (rev 5789)
@@ -30,5 +30,13 @@
     assertEquals(3, histProcInsts.size());
     
   }
+
+  @Override
+  public void testContinueExistingInstance() {
+  }
+
+  @Override
+  public void testStartFreshProcessInstance() {
+  }
   
 }

Modified: 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	2009-10-24 21:50:36 UTC (rev 5788)
+++ jbpm4/trunk/modules/test-upgrade/src/test/java/org/jbpm/test/upgrade/Process3AfterUpgradeTest.java	2009-10-26 09:05:41 UTC (rev 5789)
@@ -32,5 +32,13 @@
     assertEquals(PROCESS_3_KEY + "-1", jobs.get(0).getProcessInstance().getKey());
     
   }
+
+  @Override
+  public void testContinueExistingInstance() {
+  }
+
+  @Override
+  public void testStartFreshProcessInstance() {
+  }
   
 }



More information about the jbpm-commits mailing list