[jbpm-commits] JBoss JBPM SVN: r2054 - in jbpm4/pvm/trunk/modules/core/src: main/java/org/jbpm/pvm/internal/cmd and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Sep 1 06:53:57 EDT 2008


Author: tom.baeyens at jboss.com
Date: 2008-09-01 06:53:57 -0400 (Mon, 01 Sep 2008)
New Revision: 2054

Added:
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java
Modified:
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
   jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java
Log:
added executionId to variables methods in services and commands

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/ExecutionService.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -122,16 +122,32 @@
   Execution signalExecution(String executionId, Map<String, Object> parameters);
   
 
-  /** creates or overwrites a variable value on the referenced execution */ 
+  /** creates or overwrites a variable value on the referenced execution 
+   * TODO REMOVE */ 
   Execution setVariable(long executionDbid, String name, Object value);
   
-  /** creates or overwrites the variable values on the referenced execution */ 
+  /** creates or overwrites the variable values on the referenced execution 
+   * TODO REMOVE */ 
   Execution setVariables(long executionDbid, Map<String, Object> variables);
   
-  /** retrieves a variable */ 
+  /** retrieves a variable 
+   * TODO REMOVE */  
   Object getVariable(long executionDbid, String variableName);
   
-  /** retrieves a map of variables */ 
+  /** retrieves a map of variables 
+   * TODO REMOVE */  
   Map<String, Object> getVariables(long executionDbid, List<String> variableNames);
 
+  /** creates or overwrites a variable value on the referenced execution */ 
+  Execution setVariable(String executionId, String name, Object value);
+  
+  /** creates or overwrites the variable values on the referenced execution */ 
+  Execution setVariables(String executionId, Map<String, Object> variables);
+  
+  /** retrieves a variable */ 
+  Object getVariable(String executionId, String variableName);
+  
+  /** retrieves a map of variables */ 
+  Map<String, Object> getVariables(String executionId, List<String> variableNames);
+
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/AbstractCommand.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -25,16 +25,27 @@
 import org.jbpm.pvm.env.Environment;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.session.DbSession;
+import org.jbpm.pvm.session.PvmDbSession;
 
 /**
  * @author Tom Baeyens
  */
 public abstract class AbstractCommand<T> implements Command<T> {
-  
-  protected ClientExecution getExecution(Environment environment, long executionId) {
+
+  // TODO: REMOVE
+  protected ClientExecution getExecution(Environment environment, long executionDbid) {
     DbSession dbSession = environment.get(DbSession.class);
-    ClientExecution execution = dbSession.get(ExecutionImpl.class, executionId);
+    ClientExecution execution = dbSession.get(ExecutionImpl.class, executionDbid);
     if (execution==null) {
+      throw new CommandException("execution "+executionDbid+" doesn't exist");
+    }
+    return execution;
+  }
+
+  protected ClientExecution getExecution(Environment environment, String executionId) {
+    PvmDbSession dbSession = environment.get(PvmDbSession.class);
+    ClientExecution execution = dbSession.findExecutionById(executionId);
+    if (execution==null) {
       throw new CommandException("execution "+executionId+" doesn't exist");
     }
     return execution;

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -25,7 +25,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.client.ClientExecution;
 import org.jbpm.pvm.env.Environment;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.session.PvmDbSession;
@@ -37,7 +37,8 @@
 
   private static final long serialVersionUID = 1L;
   
-  protected long executionDbid;
+  protected long executionDbid = -1;
+  protected String executionId;
   protected List<String> variableNames;
   
   public GetVariablesCmd(long executionDbid, List<String> variableNames) {
@@ -45,9 +46,23 @@
     this.variableNames = variableNames;
   }
 
+  public GetVariablesCmd(String executionId, List<String> variableNames) {
+    this.executionId = executionId;
+    this.variableNames = variableNames;
+  }
+
   public Map<String, Object> execute(Environment environment) throws Exception {
-    ExecutionImpl execution = environment.get(PvmDbSession.class).get(ExecutionImpl.class, executionDbid);
+    PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
     
+    
+    ClientExecution execution = null;
+    
+    if (executionId!=null) {
+      execution = pvmDbSession.findExecutionById(executionId);
+    } else {
+      execution = pvmDbSession.get(ExecutionImpl.class, executionDbid);
+    }
+    
     Map<String, Object> variables = new HashMap<String, Object>();
     for (String variableName : variableNames) {
       Object value = execution.getVariable(variableName);

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -21,8 +21,6 @@
  */
 package org.jbpm.pvm.internal.cmd;
 
-import java.util.Map;
-
 import org.jbpm.pvm.Execution;
 import org.jbpm.pvm.client.ClientExecution;
 import org.jbpm.pvm.env.Environment;
@@ -35,35 +33,48 @@
   
   private static final long serialVersionUID = 1L;
   
-  protected long executionId;
+  protected long executionDbid;
+  protected String executionId = null;
   
   public SetVariablesCmd() {
   }
 
-  public SetVariablesCmd(long executionId) {
-    this.executionId = executionId;
+  // TODO: REMOVE
+  public SetVariablesCmd(long executionDbid) {
+    this.executionDbid = executionDbid;
   }
 
-  public SetVariablesCmd(long executionId, Map<String, Object> variables) {
+  // TODO: REMOVE
+  public SetVariablesCmd(long executionDbid, String key, Object variable) {
+    this.executionDbid = executionDbid;
+    addVariable(key, variable);
+  }
+
+  public SetVariablesCmd(String executionId) {
     this.executionId = executionId;
-    this.variables = variables;
   }
 
-  public SetVariablesCmd(long executionId, String key, Object variable) {
+  public SetVariablesCmd(String executionId, String key, Object variable) {
     this.executionId = executionId;
     addVariable(key, variable);
   }
 
   public Execution execute(Environment environment) throws Exception {
-    ClientExecution execution = getExecution(environment, executionId);
+    ClientExecution execution = null;
+    if (executionId!=null) {
+      execution = getExecution(environment, executionId);
+    } else {
+      execution = getExecution(environment, executionDbid);
+    }
+    
     execution.setVariables(variables);
     return execution;
   }
 
   public long getExecutionId() {
-    return executionId;
+    return executionDbid;
   }
   public void setExecutionId(long executionId) {
-    this.executionId = executionId;
+    this.executionDbid = executionId;
   }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -31,6 +31,13 @@
 
   Map<String, Object> variables;
 
+  public void addVariable(String key, Object variable) {
+    if (variables==null) {
+      variables = new HashMap<String, Object>();
+    }
+    variables.put(key, variable);
+  }
+
   public Map<String, Object> getVariables() {
     return variables;
   }
@@ -38,11 +45,4 @@
   public void setVariables(Map<String, Object> variables) {
     this.variables = variables;
   }
-
-  public void addVariable(String key, Object variable) {
-    if (variables==null) {
-      variables = new HashMap<String, Object>();
-    }
-    variables.put(key, variable);
-  }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/svc/CommandExecutionService.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.pvm.internal.svc;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -147,21 +148,50 @@
     return commandService.execute(new FindExecutionCmd(executionId));
   }
 
+  // TODO: REMOVE
   public Object getVariable(long executionDbid, String variableName) {
     return commandService.execute(new GetVariableCmd(executionDbid, variableName));
   }
 
+  // TODO: REMOVE
   public Map<String, Object> getVariables(long executionDbid, List<String> variableNames) {
     return commandService.execute(new GetVariablesCmd(executionDbid, variableNames));
   }
 
+  // TODO: REMOVE
   public Execution setVariable(long executionDbid, String name, Object value) {
     Map<String, Object> variables = new HashMap<String, Object>();
     variables.put(name, value);
     return setVariables(executionDbid, variables);
   }
 
+  // TODO: REMOVE
   public Execution setVariables(long executionDbid, Map<String, Object> variables) {
-    return commandService.execute(new SetVariablesCmd(executionDbid, variables));
+    SetVariablesCmd cmd = new SetVariablesCmd(executionDbid);
+    cmd.setVariables(variables);
+    return commandService.execute(cmd);
   }
+
+  
+  public Object getVariable(String executionId, String variableName) {
+    List<String> variableNames = new ArrayList<String>();
+    variableNames.add(variableName);
+    return commandService.execute(new GetVariablesCmd(executionId, variableNames));
+  }
+
+  public Map<String, Object> getVariables(String executionId, List<String> variableNames) {
+    return commandService.execute(new GetVariablesCmd(executionId, variableNames));
+  }
+
+  public Execution setVariable(String executionId, String name, Object value) {
+    SetVariablesCmd cmd = new SetVariablesCmd(executionId);
+    cmd.addVariable(name, value);
+    return commandService.execute(cmd);
+  }
+
+  public Execution setVariables(String executionId, Map<String, Object> variables) {
+    SetVariablesCmd cmd = new SetVariablesCmd(executionId);
+    cmd.setVariables(variables);
+    return commandService.execute(cmd);
+  }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -30,8 +30,6 @@
 import org.jbpm.pvm.Execution;
 import org.jbpm.pvm.ExecutionService;
 import org.jbpm.pvm.ProcessService;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
 import org.jbpm.pvm.client.ClientProcessDefinition;
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.model.ProcessFactory;
@@ -43,19 +41,11 @@
  */
 public class ExecutionServiceTest extends DbTestCase {
   
-  public static class WaitState implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      execution.waitForSignal();
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
-      throw new UnsupportedOperationException();
-    }
-  }
-
   public void testStartExecutionById() {
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
 
+    // deploy process with key 'NCLFU' and version 1
+    // then we know that the key for this process will be 'NCLFU:1'
     ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
       .version(1)
       .key("NCLFU")
@@ -67,6 +57,7 @@
     
     ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
 
+    // start an execution for the process with the given id
     Execution execution = executionService.startExecution("NCLFU:1");
     assertNotNull(execution);
 
@@ -79,12 +70,14 @@
     // if there is no user defined name or key specified in the execution,
     // the default id generator will create a unique id like this: processDefinitionId/execution.dbid
     assertEquals("NCLFU:1/", execution.getId().substring(0,8));
+    // the last part of the execution key should be the dbid.
     Long.parseLong(execution.getId().substring(8));
   }
 
-  public void testStartExecutionByIdWithKey() {
+  public void testStartExecutionByIdWithGivenExecutionKey() {
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-  
+
+    // deploy the same process with a given key and version
     ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
       .version(1)
       .key("NCLFU")
@@ -120,13 +113,15 @@
     .done();
   
     processService.deploy(new Deployment(processDefinition));
-  
+
+    // create the map with variables
     Map<String, Object> variables = new HashMap<String, Object>();
     variables.put("a", new Integer(1));
     variables.put("b", "text");
   
     ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
   
+    // provide the variables in the start execution method
     Execution execution = executionService.startExecution("NCLFU:1", variables);
   
     long executionDbid = execution.getDbid();

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java	2008-08-31 12:29:31 UTC (rev 2053)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -28,8 +28,6 @@
 import org.jbpm.pvm.ProcessDefinition;
 import org.jbpm.pvm.ProcessService;
 import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.api.db.svc.ExecutionServiceTest.WaitState;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.model.ProcessFactory;
 import org.jbpm.pvm.test.base.DbTestCase;
 
@@ -205,46 +203,29 @@
   public void testFindProcessDefinitionByNameAndVersion() {
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
 
-    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(1);
+    // create a process with a user specified version
+    ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
+      .version(35)
+      .node("initial").initial().behaviour(WaitState.class)
+    .done();
+
+    // deploy it
+    Deployment deployment = new Deployment(processDefinition);
+    processService.deploy(deployment);
     
-    processService.deploy(new Deployment(processDefinition));
+    // load it with by name and version
+    processDefinition = processService.findProcessDefinition("nuclear fusion", 35);
     
-    ProcessDefinition retrieved = processService.findProcessDefinition("nuclear fusion", 1);
-    assertNotNull(retrieved);
-    assertEquals("nuclear fusion", retrieved.getName());
-    assertEquals(1, retrieved.getVersion());
+    // verify that the right process definition was returned
+    assertEquals("nuclear fusion", processDefinition.getName());
+    assertEquals(35, processDefinition.getVersion());
   }
 
   public void testFindProcessDefinitionNames() {
+    deployMultipleVersionsOfProcesses();
+    
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
-    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
     
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(2);
-    processService.deploy(new Deployment(processDefinition));
-
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("ultimate seduction");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("publish book");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(3);
-    processService.deploy(new Deployment(processDefinition));
-    
     List<String> processNames = processService.findProcessDefinitionNames();
     
     List<String> expected = new ArrayList<String>();
@@ -256,33 +237,10 @@
   }
 
   public void testFindProcessDefinitions() {
+    deployMultipleVersionsOfProcesses();
+    
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
 
-    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(2);
-    processService.deploy(new Deployment(processDefinition));
-
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("ultimate seduction");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("publish book");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(3);
-    processService.deploy(new Deployment(processDefinition));
-    
     List<ProcessDefinition> processDefinitions = processService.findProcessDefinitions("nuclear fusion");
     assertNotNull(processDefinitions);
     
@@ -298,33 +256,10 @@
   }
 
   public void testFindLatestProcessDefinition() {
+    deployMultipleVersionsOfProcesses();
+    
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
 
-    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(2);
-    processService.deploy(new Deployment(processDefinition));
-
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("ultimate seduction");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("publish book");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(3);
-    processService.deploy(new Deployment(processDefinition));
-    
     ProcessDefinition retrieved = processService.findLatestProcessDefinition("nuclear fusion");
     assertNotNull(retrieved);
     
@@ -333,37 +268,57 @@
   }
 
   public void testLatestProcessDefinition() {
+    deployMultipleVersionsOfProcesses();
+    
     ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
 
-    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(2);
-    processService.deploy(new Deployment(processDefinition));
-
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("ultimate seduction");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("publish book");
-    processDefinition.setVersion(1);
-    processService.deploy(new Deployment(processDefinition));
-    
-    processDefinition = new ProcessDefinitionImpl();
-    processDefinition.setName("nuclear fusion");
-    processDefinition.setVersion(3);
-    processService.deploy(new Deployment(processDefinition));
-    
     ProcessDefinition retrieved = processService.findLatestProcessDefinition("nuclear fusion");
     assertNotNull(retrieved);
     
     assertEquals("nuclear fusion", retrieved.getName());
     assertEquals(3, retrieved.getVersion());
   }
+  
+
+  /** deploys 3 versions of process with name 'nuclear fusion', and one version 
+   * of the processes 'ultimate seduction' and 'publish book' */
+  void deployMultipleVersionsOfProcesses() {
+    ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+    
+    ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
+      .node("initial").initial().behaviour(WaitState.class)
+    .done();
+    Deployment deployment = new Deployment(processDefinition);
+    processService.deploy(deployment);
+    
+    processDefinition = ProcessFactory.build("ultimate seduction")
+      .node("initial").initial().behaviour(WaitState.class)
+    .done();
+    deployment = new Deployment(processDefinition);
+    processService.deploy(deployment);
+  
+    processDefinition = ProcessFactory.build("ultimate seduction")
+      .node("initial").initial().behaviour(WaitState.class)
+    .done();
+    deployment = new Deployment(processDefinition);
+    processService.deploy(deployment);
+  
+    processDefinition = ProcessFactory.build("nuclear fusion")
+      .node("initial").initial().behaviour(WaitState.class)
+    .done();
+    deployment = new Deployment(processDefinition);
+    processService.deploy(deployment);
+    
+    processDefinition = ProcessFactory.build("publish book")
+      .node("initial").initial().behaviour(WaitState.class)
+    .done();
+    deployment = new Deployment(processDefinition);
+    processService.deploy(deployment);
+  
+    processDefinition = ProcessFactory.build("nuclear fusion")
+      .node("initial").initial().behaviour(WaitState.class)
+    .done();
+    deployment = new Deployment(processDefinition);
+    processService.deploy(deployment);
+  }
 }

Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java	2008-09-01 10:53:57 UTC (rev 2054)
@@ -0,0 +1,37 @@
+/*
+ * 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.pvm.api.db.svc;
+
+import java.util.Map;
+
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+
+public class WaitState implements ExternalActivity {
+  private static final long serialVersionUID = 1L;
+  public void execute(ActivityExecution execution) {
+    execution.waitForSignal();
+  }
+  public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    throw new UnsupportedOperationException();
+  }
+}
\ No newline at end of file




More information about the jbpm-commits mailing list