[jbpm-commits] JBoss JBPM SVN: r3579 - in jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm: executionmode and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Dec 29 06:59:53 EST 2008


Author: tom.baeyens at jboss.com
Date: 2008-12-29 06:59:53 -0500 (Mon, 29 Dec 2008)
New Revision: 3579

Added:
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/AutomaticActivity.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/WaitState.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/ExternalActivityExampleTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/WaitState.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AutomaticActivity.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ContinuationTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/Recorder.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/WaitState.java
Log:
pvm test suite cleanup

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example03/AutomaticActivity.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,38 @@
+/*
+ * 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.executionmode.embedded;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+
+/** a node behaviour implementation that records its execution and then 
+ * just proceeds.
+ *  
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements Activity {
+
+  private static final long serialVersionUID = 1L;
+  
+  public void execute(ActivityExecution execution) throws Exception {
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/AutomaticActivity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example03/EmbeddedExecutionModeTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/EmbeddedExecutionModeTest.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,106 @@
+/*
+ * 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.executionmode.embedded;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EmbeddedExecutionModeTest extends JbpmTestCase {
+
+  SessionFactory sessionFactory;
+  Session session;
+  Transaction transaction;
+
+  public void testLoanApprove() {
+    Configuration configuration = new Configuration();
+    configuration.configure("org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml");
+    sessionFactory = configuration.buildSessionFactory();
+
+    startTransaction();
+
+    Loan loan = new Loan("john doe", 234.0);
+    session.save(loan);
+    assertEquals("evaluate", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("evaluate", loan.getState());
+    loan.approve();
+    assertEquals("archive", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("archive", loan.getState());
+    loan.archiveComplete();
+    assertEquals("end", loan.getState());
+
+    commitTransaction();
+  }
+  
+  public void testLoanReject() {
+    Configuration configuration = new Configuration();
+    configuration.configure("org/jbpm/pvm/executionmode/embedded/hibernate.cfg.xml");
+    sessionFactory = configuration.buildSessionFactory();
+
+    startTransaction();
+
+    Loan loan = new Loan("john doe", 234.0);
+    session.save(loan);
+    assertEquals("evaluate", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("evaluate", loan.getState());
+    loan.reject();
+    assertEquals("end", loan.getState());
+    
+    newTransaction();
+    
+    loan = (Loan) session.get(Loan.class, loan.getDbid());
+    assertEquals("end", loan.getState());
+  }
+
+
+  void newTransaction() {
+    commitTransaction();
+    startTransaction();
+  }
+
+  void startTransaction() {
+    session = sessionFactory.openSession();
+    transaction = session.beginTransaction();
+  }
+
+  void commitTransaction() {
+    transaction.commit();
+    session.close();
+  }
+}

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example03/Loan.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/Loan.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,101 @@
+/*
+ * 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.executionmode.embedded;
+
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Loan {
+
+  /** the loan process definition as a static resource */
+  private static final ClientProcessDefinition processDefinition = createLoanProcess();
+  
+  private static ClientProcessDefinition createLoanProcess() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+      .node("submit loan request").initial().behaviour(AutomaticActivity.class)
+        .transition().to("evaluate")
+      .node("evaluate").behaviour(WaitState.class)
+        .transition("approve").to("wire money")
+        .transition("reject").to("end")
+      .node("wire money").behaviour(AutomaticActivity.class)
+        .transition().to("archive")
+      .node("archive").behaviour(WaitState.class)
+        .transition().to("end")
+      .node("end").behaviour(WaitState.class)
+    .done();
+    
+    return processDefinition;
+  }
+
+  /** exposes the process definition to the execution hibernate type */
+  private static ClientProcessDefinition getProcessDefinition() {
+    return processDefinition;
+  }
+
+  long dbid;
+  String customer;
+  double amount;
+  ClientExecution execution;
+  
+  /** constructor for persistence */
+  protected Loan() {
+  }
+
+  public Loan(String customer, double amount) {
+    this.customer = customer;
+    this.amount = amount;
+    this.execution = processDefinition.startProcessInstance();
+  }
+
+  public void approve() {
+    execution.signal("approve");
+  }
+
+  public void reject() {
+    execution.signal("reject");
+  }
+
+  public void archiveComplete() {
+    execution.signal();
+  }
+
+  public String getState() {
+    return execution.getNodeName();
+  }
+  
+  // getters //////////////////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getCustomer() {
+    return customer;
+  }
+  public double getAmount() {
+    return amount;
+  }
+}

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example03/WaitState.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,46 @@
+/*
+ * 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.executionmode.embedded;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  public WaitState() {
+  }
+
+  public void execute(ActivityExecution execution) throws Exception {
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+    execution.take(signalName);
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/AutomaticActivity.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example01/AutomaticActivity.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/AutomaticActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/AutomaticActivity.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -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.executionmode.object;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements Activity {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+  }
+
+}


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/AutomaticActivity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example01/ObjectExecutionModeTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,57 @@
+/*
+ * 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.executionmode.object;
+
+import junit.framework.TestCase;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+public class ObjectExecutionModeTest extends TestCase {
+
+  
+  public void testObjectExecutionMode(){
+    ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+      .node("submit loan request").initial().behaviour(AutomaticActivity.class)
+        .transition().to("evaluate")
+      .node("evaluate").behaviour(WaitState.class)
+        .transition("approve").to("wire money")
+        .transition("reject").to("end")
+      .node("wire money").behaviour(AutomaticActivity.class)
+        .transition().to("archive")
+      .node("archive").behaviour(WaitState.class)
+        .transition().to("end")
+      .node("end").behaviour(WaitState.class)
+    .done();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    assertEquals("evaluate", execution.getNodeName());
+    
+    execution.signal("approve");
+    
+    execution.signal();
+    assertEquals("end", execution.getNodeName());
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/WaitState.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example01/WaitState.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/WaitState.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/WaitState.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,44 @@
+/*
+ * 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.executionmode.object;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+
+/**
+ * @author Tom Baeyens
+ */
+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) {
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/WaitState.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/ExternalActivityExampleTest.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example05/ExternalActivityExampleTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/ExternalActivityExampleTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/ExternalActivityExampleTest.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,48 @@
+/*
+ * 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.externalactivity;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+public class ExternalActivityExampleTest extends JbpmTestCase {
+
+  public void testExternalActivityExample() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+        .node("a").initial().behaviour(new WaitState())
+          .transition().to("b")
+        .node("b").behaviour(new WaitState())
+    .done();
+    
+    ClientExecution execution = processDefinition.startProcessInstance();
+    
+    assertEquals("a", execution.getNodeName());
+    
+    execution.signal();
+    
+    assertEquals("b", execution.getNodeName());
+  }
+  
+}


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/ExternalActivityExampleTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/WaitState.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example05/WaitState.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/WaitState.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/WaitState.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,42 @@
+/*
+ * 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.externalactivity;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.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) {
+    execution.take(signalName);
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/externalactivity/WaitState.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AutomaticActivity.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/AutomaticActivity.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AutomaticActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AutomaticActivity.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,42 @@
+/*
+ * 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.internal.jobexecutor;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+
+/** a node behaviour implementation that records its execution and then 
+ * just proceeds.
+ *  
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements Activity {
+
+  private static final long serialVersionUID = 1L;
+  
+  public AutomaticActivity() {
+  }
+  
+  public void execute(ActivityExecution execution) throws Exception {
+    ContinuationTest.recorder.record(execution.getDbid(), "execute("+execution.getNode().getName()+")");
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AutomaticActivity.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ContinuationTest.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/ContinuationTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ContinuationTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ContinuationTest.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,101 @@
+/*
+ * 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.internal.jobexecutor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ContinuationTest extends JobExecutorTestCase {
+
+  // private static final Log log = Log.getLog(ContinuationTest.class.getName());
+
+  static Recorder recorder = new Recorder();
+
+  int nbrOfExecutions = 1;
+
+  public void testContinuations() {
+
+    try {
+      deployProcess();
+      startExecutions();
+      jobExecutor.start();
+      waitTillNoMoreMessages();
+
+    } finally {
+      jobExecutor.stop(true);
+    }
+
+    List<String> expectedLogs = new ArrayList<String>();
+    expectedLogs.add("execute(start)");
+    expectedLogs.add("execute(a)");
+    expectedLogs.add("execute(b)");
+    expectedLogs.add("execute(c)");
+    expectedLogs.add("execute(end)");
+    
+    assertEquals(nbrOfExecutions, recorder.executionEvents.size());
+    for (List<String> executionLogs : recorder.executionEvents.values()) {
+      assertEquals(expectedLogs, executionLogs);
+    }
+  }
+
+  public void deployProcess() {
+    commandService.execute(new Command<Object>() {
+      public Object execute(Environment environment) throws Exception {
+        OpenProcessDefinition processDefinition = ProcessFactory.build("continuations")
+          .key("continuations")
+          .node("start").initial().behaviour(AutomaticActivity.class)
+            .asyncExecute()
+            .transition().to("a")
+          .node("a").behaviour(AutomaticActivity.class)
+            .asyncExecute()
+            .transition().to("b")
+          .node("b").behaviour(AutomaticActivity.class)
+            .asyncExecute()
+            .transition().to("c")
+          .node("c").behaviour(AutomaticActivity.class)
+            .asyncExecute()
+            .transition().to("end")
+          .node("end").behaviour(WaitState.class)
+        .done();
+        
+        Session session = environment.get(Session.class);
+        session.save(processDefinition);
+        return null;
+      }
+    });
+  }
+
+  public void startExecutions() {
+    for (int i = 0; i < nbrOfExecutions; i++) {
+      executionService.startExecutionByKey("continuations");
+    }
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ContinuationTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/Recorder.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/Recorder.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/Recorder.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/Recorder.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,51 @@
+/*
+ * 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.internal.jobexecutor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** 
+ * @author Tom Baeyens
+ */
+public class Recorder {
+
+  public Map<Object, List<String>> executionEvents = null;
+  
+  public synchronized void record(long executionDbid, String event) {
+    if (executionEvents==null) {
+      executionEvents = new HashMap<Object, List<String>>();
+    }
+    List<String> events = executionEvents.get(executionDbid);
+    if (events == null) {
+      events = new ArrayList<String>();
+      executionEvents.put(executionDbid, events);
+    }
+    events.add(event); 
+  }
+  
+  public void reset() {
+    executionEvents = null;
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/Recorder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/WaitState.java (from rev 3570, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/WaitState.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/WaitState.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/WaitState.java	2008-12-29 11:59:53 UTC (rev 3579)
@@ -0,0 +1,46 @@
+/*
+ * 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.internal.jobexecutor;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivity {
+
+  private static final long serialVersionUID = 1L;
+  
+  public WaitState() {
+  }
+
+  public void execute(ActivityExecution execution) throws Exception {
+    ContinuationTest.recorder.record(execution.getDbid(), "execute("+execution.getNode().getName()+")");
+  }
+
+  public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+    throw new UnsupportedOperationException();
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/WaitState.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list