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

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jul 18 10:11:32 EDT 2008


Author: tom.baeyens at jboss.com
Date: 2008-07-18 10:11:32 -0400 (Fri, 18 Jul 2008)
New Revision: 1675

Added:
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/CheckInTests.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/AutomaticDecisionTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/BasicExecutionFlowTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventPropagationTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExceptionHandlerTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExecutionStateTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExternalDecisionTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/FunctionalActivityTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/LoopingTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/PvmClientTests.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeStateTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableDeclarationTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/SubProcessTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionAsWaitStateTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionBasedConcurrencyTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionEventsTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/VariableTest.java
Removed:
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/AllTests.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/AutomaticDecisionTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/BasicExecutionFlowTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventPropagationTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExceptionHandlerTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExecutionStateTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExternalDecisionTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/FunctionalActivityTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/LoopingTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/PvmClientTests.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeStateTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableDeclarationTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/SubProcessTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionAsWaitStateTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionBasedConcurrencyTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionEventsTest.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/VariableTest.java
Log:
restructuring of the test suite

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/AllTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/AllTests.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/AllTests.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,45 +0,0 @@
-/*
- * 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;
-
-import org.jbpm.pvm.client.PvmClientTests;
-import org.jbpm.wire.WireTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-/**
- * @author Tom Baeyens
- */
-public class AllTests {
-
-  public static Test suite() {
-    TestSuite suite = new TestSuite("Test for org.jbpm");
-    //$JUnit-BEGIN$
-    suite.addTest(PvmClientTests.suite());
-    suite.addTest(WireTests.suite());
-    //$JUnit-END$
-    return suite;
-  }
-
-}

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/CheckInTests.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/AllTests.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/CheckInTests.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/CheckInTests.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckInTests {
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite("Test for org.jbpm");
+    //$JUnit-BEGIN$
+    suite.addTest(NonDbTests.suite());
+    suite.addTest(DbTests.suite());
+    //$JUnit-END$
+    return suite;
+  }
+
+}


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

Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DbTests {
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite("Test for org.jbpm.pvm");
+    //$JUnit-BEGIN$
+    
+    // TODO
+    
+    //$JUnit-END$
+    return suite;
+  }
+
+}

Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jbpm.pvm.basicfeatures.PvmClientTests;
+import org.jbpm.wire.WireTests;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class NonDbTests {
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite("Test for org.jbpm.pvm");
+    //$JUnit-BEGIN$
+    suite.addTest(PvmClientTests.suite());
+    suite.addTest(WireTests.suite());
+    //$JUnit-END$
+    return suite;
+  }
+
+}

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/AutomaticDecisionTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/AutomaticDecisionTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/AutomaticDecisionTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/AutomaticDecisionTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,109 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+/** shows an automatic decision.
+ * 
+ * @author Tom Baeyens
+ */
+public class AutomaticDecisionTest extends JbpmTestCase {
+
+  public static class AutomaticCreditRating implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      int creditRate = (Integer) execution.getVariable("creditRate");
+      
+      if (creditRate > 5) {
+        execution.take("good");
+
+      } else if (creditRate < -5) {
+        execution.take("bad");
+        
+      } else {
+        execution.take("average");
+      }
+    }
+  }
+  
+  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) {
+      execution.take(signalName);
+    }
+  }
+
+  public static ClientProcessDefinition createCreditProcess() {
+    return ProcessFactory.build()
+      .node("creditRate?").initial().behaviour(new AutomaticCreditRating())
+        .transition("good").to("priority delivery")
+        .transition("average").to("bulk delivery")
+        .transition("bad").to("payment upfront")
+      .node("priority delivery").behaviour(new WaitState())
+      .node("bulk delivery").behaviour(new WaitState())
+      .node("payment upfront").behaviour(new WaitState())
+    .done();
+  }
+
+  public void testGoodRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    
+    ClientProcessInstance execution = processDefinition.createProcessInstance();
+    execution.setVariable("creditRate", 7);
+    execution.begin();
+
+    assertEquals("priority delivery", execution.getNode().getName());
+  }
+
+  public void testAverageRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    
+    ClientProcessInstance execution = processDefinition.createProcessInstance();
+    execution.setVariable("creditRate", 2);
+    execution.begin();
+
+    assertEquals("bulk delivery", execution.getNode().getName());
+  }
+  
+  public void testBadRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    
+    ClientProcessInstance execution = processDefinition.createProcessInstance();
+    execution.setVariable("creditRate", -7);
+    execution.begin();
+
+    assertEquals("payment upfront", execution.getNode().getName());
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/BasicExecutionFlowTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/BasicExecutionFlowTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/BasicExecutionFlowTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/BasicExecutionFlowTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,144 @@
+/*
+  * 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.basicfeatures;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/** shows wait states and automatic activities in a simple 
+ * sequence based on transitions.
+ * 
+ * @author Tom Baeyens
+ */
+public class BasicExecutionFlowTest extends JbpmTestCase {
+  
+  // automatic activity will log an event in a given list
+  
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    List<String> events;
+    public AutomaticActivity(List<String> events) {
+      this.events = events;
+    }
+    public void execute(ActivityExecution execution) {
+      events.add("execute["+execution.getNodeName()+"]");
+    }
+  }
+
+  public static class WaitState implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    List<String> events;
+    public WaitState(List<String> events) {
+      this.events = events;
+    }
+    public void execute(ActivityExecution execution) {
+      events.add("execute["+execution.getNodeName()+"]");
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+      events.add("signal["+execution.getNodeName()+"]");
+      execution.take(signalName);
+    }
+  }
+
+  public void testChainOfAutomaticActivitiesAndWaitStates() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
+    WaitState waitState = new WaitState(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(automaticActivity)
+        .transition().to("b")
+      .node("b").behaviour(automaticActivity)
+        .transition().to("c")
+      .node("c").behaviour(waitState)
+        .transition().to("d")
+      .node("d").behaviour(waitState)
+        .transition().to("e")
+      .node("e").behaviour(automaticActivity)
+        .transition().to("f")
+      .node("f").behaviour(automaticActivity)
+    .done();
+
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    
+    expectedEvents.add("execute[a]");
+    expectedEvents.add("execute[b]");
+    expectedEvents.add("execute[c]");
+
+    assertEquals("c", processInstance.getNodeName());
+    assertFalse(processInstance.isEnded());
+    assertEquals(expectedEvents, recordedEvents);
+
+    processInstance.signal();
+
+    expectedEvents.add("signal[c]");
+    expectedEvents.add("execute[d]");
+
+    assertEquals("d", processInstance.getNodeName());
+    assertFalse(processInstance.isEnded());
+    assertEquals(expectedEvents, recordedEvents);
+
+    processInstance.signal();
+
+    expectedEvents.add("signal[d]");
+    expectedEvents.add("execute[e]");
+    expectedEvents.add("execute[f]");
+
+    assertEquals("f", processInstance.getNodeName());
+    assertTrue(processInstance.isEnded());
+    assertEquals(expectedEvents, recordedEvents);
+  }
+  
+  public void testDelayedBegin() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState(recordedEvents))
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    // here, inbetween create and begin of a process instance, the variables can be initialized  
+    // or subprocessinstance-superprocessinstance relation can be set up
+
+    // so we verify that the process execution didn't start yet
+    List<String> expectedEvents = new ArrayList<String>();
+    assertEquals(expectedEvents, recordedEvents);
+    
+    processInstance.begin();
+
+    expectedEvents.add("execute[a]");
+    assertEquals(expectedEvents, recordedEvents);
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventPropagationTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventPropagationTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventPropagationTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventPropagationTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,358 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.listener.EventListener;
+import org.jbpm.pvm.listener.EventListenerExecution;
+import org.jbpm.pvm.model.Event;
+import org.jbpm.pvm.model.Node;
+import org.jbpm.pvm.model.ObservableElement;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventPropagationTest extends JbpmTestCase
+{
+  
+  public class Recorder implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public List<Object> events = new ArrayList<Object>();
+    public void notify(EventListenerExecution execution) {
+      ObservableElement element = execution.getEventSource();
+      String elementName = element.getName();
+      events.add(execution.getEvent()+" on "+(elementName!=null ? elementName : element));
+    }
+  }
+  
+  public static class FireableState 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.fire(signalName, execution.getNode());
+    }
+  }
+
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+    }
+  }
+  
+  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){
+    }
+  }
+
+  public void testListenToNodeLeaveOnProcessForProcessNodes(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event(Event.NODE_END) 
+          .listener(recorder)
+        .node("initial").initial().behaviour(new WaitState())
+          .transition().to("end")
+        .node("end").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    execution.signal();
+    
+    assertEquals("event(node-end) on initial", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+  }
+
+  public void testListenToNodeEnterOnProcessForProcessNodes(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event(Event.NODE_BEGIN) 
+          .listener(recorder)
+        .node("initial").initial().behaviour(new WaitState())
+          .transition().to("end")
+        .node("end").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    execution.signal();
+    
+    assertEquals("event(node-begin) on end", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+  }
+
+  public void testListenToTransitionOnProcessForTransitionBetweenProcessNodes(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event(Event.TRANSITION_TAKE) 
+          .listener(recorder)
+        .node("initial").initial().behaviour(new WaitState())
+          .transition("go").to("end")
+        .node("end").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    execution.signal();
+    
+    assertEquals("event(transition-take) on go", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+  }
+
+  // propagation of process elements in composite nodes ///////////////////////
+  
+  public static class Sequence implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      List<Node> nodes = execution.getNode().getNodes();
+      if ( (nodes!=null)
+           && (!nodes.isEmpty())
+         ) {
+        execution.execute(nodes.get(0));
+      }
+    }
+    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) {
+      Node previous = execution.getPreviousNode();
+      List<Node> nodes = execution.getNode().getNodes();
+      int index = nodes.indexOf(previous);
+      index++;
+      if (index < nodes.size()) {
+        Node next = nodes.get(index);
+        execution.execute(next);
+      }
+    }
+  }
+
+  
+  public void testListenToNodeLeaveOnProcessForSequenceChildNodes(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event(Event.NODE_END) 
+          .listener(recorder)
+        .compositeNode("sequence").initial().behaviour(new Sequence())
+          .needsPrevious()
+            .node("one").behaviour(new WaitState())
+            .node("two").behaviour(new WaitState())
+            .node("three").behaviour(new WaitState())
+        .compositeEnd()
+        .node("end").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    assertEquals(0, recorder.events.size());
+    execution.signal();
+    assertEquals("event(node-end) on one", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+    execution.signal();
+    assertEquals("event(node-end) on two", recorder.events.get(1));
+    assertEquals(2, recorder.events.size());
+    execution.signal();
+    assertEquals("event(node-end) on three", recorder.events.get(2));
+    assertEquals(3, recorder.events.size());
+  }
+
+  public void testListenToNodeLeaveOnProcessForTransitionBetweenSequenceChildNodes(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event(Event.NODE_END) 
+          .listener(recorder)
+        .compositeNode("sequence").initial().behaviour(new Sequence())
+            .node("one").behaviour(new WaitState())
+              .transition().to("two")
+            .node("two").behaviour(new WaitState())
+        .compositeEnd()
+        .node("end").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals(0, recorder.events.size());
+    execution.signal();
+    assertEquals("event(node-end) on one", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+    execution.signal();
+    assertEquals("event(node-end) on two", recorder.events.get(1));
+    assertEquals(2, recorder.events.size());
+  }
+
+
+  public void testListenToNodeEnterOnProcessForSequenceChildNodes(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event(Event.NODE_BEGIN) 
+          .listener(recorder)
+        .compositeNode("sequence").initial().behaviour(new Sequence())
+          .needsPrevious()
+            .node("one").behaviour(new WaitState())
+            .node("two").behaviour(new WaitState())
+            .node("three").behaviour(new WaitState())
+        .compositeEnd()
+        .node("end").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    assertEquals("event(node-begin) on one", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+    execution.signal();
+    assertEquals("event(node-begin) on two", recorder.events.get(1));
+    assertEquals(2, recorder.events.size());
+    execution.signal();
+    assertEquals("event(node-begin) on three", recorder.events.get(2));
+    assertEquals(3, recorder.events.size());
+  }
+
+  public void testListenToTransitionTakeOnProcessForTransitionBetweenSequenceChildNodes(){
+    Recorder recorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event(Event.TRANSITION_TAKE) 
+          .listener(recorder)
+        .compositeNode("sequence").initial().behaviour(new Sequence())
+            .node("one").behaviour(new WaitState())
+              .transition("increment").to("two")
+            .node("two").behaviour(new WaitState())
+          .compositeEnd()
+        .node("end").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    
+    assertEquals(0, recorder.events.size());
+    execution.signal();
+    assertEquals("event(transition-take) on increment", recorder.events.get(0));
+    assertEquals(1, recorder.events.size());
+  }
+
+  public void testDeeplyNestedCustomEvent(){
+    Recorder processRecorder = new Recorder();
+    Recorder outerRecorder = new Recorder();
+    Recorder middelRecorder = new Recorder();
+    Recorder innerRecorder = new Recorder();
+    Recorder nestedStateRecorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event("hello") 
+          .listener(processRecorder)
+        .compositeNode("outer").initial().behaviour(new Sequence())
+          .event("hello") 
+            .listener(outerRecorder)
+            .compositeNode("middel").behaviour(new Sequence())
+              .event("hello") 
+                .listener(middelRecorder)
+                .compositeNode("inner").behaviour(new Sequence())
+                  .event("hello") 
+                    .listener(innerRecorder)
+                    .node("nested state").behaviour(new FireableState())
+                      .event("hello") 
+                        .listener(nestedStateRecorder)
+                .compositeEnd()
+            .compositeEnd()
+        .compositeEnd()
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    
+    assertEquals(0, processRecorder.events.size());
+    execution.signal("hello");
+    
+    assertEquals("event(hello) on nested state", processRecorder.events.get(0));
+    assertEquals(1, processRecorder.events.size());
+
+    assertEquals("event(hello) on nested state", outerRecorder.events.get(0));
+    assertEquals(1, outerRecorder.events.size());
+
+    assertEquals("event(hello) on nested state", middelRecorder.events.get(0));
+    assertEquals(1, middelRecorder.events.size());
+
+    assertEquals("event(hello) on nested state", innerRecorder.events.get(0));
+    assertEquals(1, innerRecorder.events.size());
+
+    assertEquals("event(hello) on nested state", nestedStateRecorder.events.get(0));
+    assertEquals(1, nestedStateRecorder.events.size());
+  }
+
+  public void testPropagatedEventsDisabled(){
+    Recorder processRecorder = new Recorder();
+    Recorder outerRecorder = new Recorder();
+    Recorder middleRecorder = new Recorder();
+    Recorder innerRecorder = new Recorder();
+    Recorder nestedStateRecorder = new Recorder();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
+        .event("hello") 
+          .listener(processRecorder)
+        .compositeNode("outer").initial().behaviour(new Sequence())
+          .event("hello") 
+            .listener(outerRecorder)
+          .compositeNode("middle").behaviour(new Sequence())
+            .event("hello") 
+              .listener(middleRecorder)
+            .propagationDisabled()
+            .compositeNode("inner").behaviour(new Sequence())
+              .event("hello") 
+                .listener(innerRecorder)
+                .node("nested state").behaviour(new FireableState())
+                  .event("hello") 
+                    .listener(nestedStateRecorder)
+            .compositeEnd()
+          .compositeEnd()
+        .compositeEnd()
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    // the middle action should not be executed for an event that was propagated from the nested state 
+    execution.signal("hello");
+    
+    assertEquals("event(hello) on nested state", processRecorder.events.get(0));
+    assertEquals(1, processRecorder.events.size());
+
+    assertEquals("event(hello) on nested state", outerRecorder.events.get(0));
+    assertEquals(1, outerRecorder.events.size());
+
+    assertEquals(0, middleRecorder.events.size());
+
+    assertEquals("event(hello) on nested state", innerRecorder.events.get(0));
+    assertEquals(1, innerRecorder.events.size());
+
+    assertEquals("event(hello) on nested state", nestedStateRecorder.events.get(0));
+    assertEquals(1, nestedStateRecorder.events.size());
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/EventTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,266 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.listener.EventListener;
+import org.jbpm.pvm.listener.EventListenerExecution;
+import org.jbpm.pvm.model.Event;
+import org.jbpm.pvm.model.Node;
+import org.jbpm.pvm.model.ObservableElement;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/** shows how actions are listeners to following processDefinition events:
+ * <ul>
+ *   <li>node-leave</li>
+ *   <li>transition</li>
+ *   <li>node-enter</li>
+ *   <li>custom event</li>
+ * </ul>
+ *
+ * @author Tom Baeyens
+ */
+public class EventTest extends JbpmTestCase {
+  
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+    }
+  }
+  
+  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){
+      execution.take(signalName);
+    }
+  }
+
+  
+  // node leave action ////////////////////////////////////////////////////////
+  
+  public static class NodeLeaveAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      execution.setVariable("msg", "Kilroy was here");
+
+      assertEquals("initial", execution.getNode().getName());
+      assertEquals("initial", execution.getEventSource().getName());
+      assertEquals("leave node action test", execution.getProcessDefinition().getName());
+      assertEquals("end", execution.getTransition().getDestination().getName());
+    }
+  }
+  
+  public void testEventListenerOnNodeEnd() {
+    NodeLeaveAction nodeLeaveAction = new NodeLeaveAction();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("leave node action test")
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(nodeLeaveAction)
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    execution.signal();
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+  }
+
+  // transition action ////////////////////////////////////////////////////////
+
+  public static class TransitionAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) throws Exception {
+      execution.setVariable("msg", "Kilroy was here");
+      
+      assertNull(execution.getNode());
+      assertEquals("t", execution.getEventSource().getName());
+      assertEquals("transition action test", execution.getProcessDefinition().getName());
+      assertEquals("end", execution.getTransition().getDestination().getName());
+    }
+  }
+  
+  public void testEventListenerOnTransition() {
+    TransitionAction transitionAction = new TransitionAction();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("transition action test")
+      .node("initial").initial().behaviour(new WaitState())
+        .transition("t").to("end")
+          .listener(transitionAction)
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    execution.signal("t");
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+  }
+
+  // node enter action ////////////////////////////////////////////////////////
+
+  public static class NodeBeginAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) throws Exception {
+      execution.setVariable("msg", "Kilroy was here");
+      
+      assertEquals("end", execution.getNode().getName());
+      assertEquals("end", execution.getEventSource().getName());
+      assertEquals("enter node action test", execution.getProcessDefinition().getName());
+      assertEquals("end", execution.getTransition().getDestination().getName());
+    }
+  }
+  
+  public void testEventListenerOnNodeBegin() {
+    NodeBeginAction nodeBeginAction = new NodeBeginAction();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("enter node action test")
+      .node("initial").initial().behaviour(new WaitState())
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+        .event(Event.NODE_BEGIN)
+          .listener(nodeBeginAction)
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    execution.signal();
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+  }
+
+  // custom event ////////////////////////////////////////////////////////////
+  
+  public static class WaitStateWithCustomEvent implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+      Node node = execution.getNode();
+      if ( (signal!=null)
+           && (node!=null)
+           && (node.hasEvent(signal))
+         ) {
+        execution.fire(signal, node);
+        execution.waitForSignal();
+      }
+    }
+  }
+
+  public static class CheckRivetsAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) throws Exception {
+      execution.setVariable("msg", "Kilroy was here");
+      
+      assertEquals("initial", execution.getNode().getName());
+      assertEquals("initial", execution.getEventSource().getName());
+      assertEquals("custom node action test", execution.getProcessDefinition().getName());
+      assertNull(execution.getTransition());
+    }
+  }
+
+  public void testCustomEventInNode() {
+    CheckRivetsAction checkRivetsAction = new CheckRivetsAction();
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("custom node action test")
+      .node("initial").initial().behaviour(new WaitStateWithCustomEvent())
+        .event("end of riveter shift") // http://en.wikipedia.org/wiki/Kilroy_was_here
+          .listener(checkRivetsAction)
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    assertNull(execution.getVariable("msg"));
+
+    execution.signal("end of riveter shift");
+
+    assertEquals("initial", execution.getNode().getName());
+    assertEquals("Kilroy was here", execution.getVariable("msg"));
+    
+    execution.signal();
+
+    assertEquals("end", execution.getNode().getName());
+  }
+
+  public static class EndState implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.end();
+    }
+  }
+
+  public static class RecordingProcessDefinition extends ProcessDefinitionImpl {
+    private static final long serialVersionUID = 1L;
+    protected ExecutionImpl newProcessInstance() {
+      return new RecordingExecution();
+    }
+  }
+  
+  public static class RecordingExecution extends ExecutionImpl {
+    private static final long serialVersionUID = 1L;
+    List<String> events = new ArrayList<String>();
+    public void fire(String eventName, ObservableElement eventSource) {
+      events.add(eventName+" on "+eventSource);
+    }
+  }
+  
+  public void testBasicEventSequence() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build("basic", new RecordingProcessDefinition())
+        .node("initial").initial().behaviour(new AutomaticActivity())
+          .transition().to("end")
+        .node("end").behaviour(new EndState())
+    .done();
+
+    RecordingExecution execution = (RecordingExecution) processDefinition.beginProcessInstance();
+
+    int index = 0;
+    assertEquals("process-begin on processDefinition(basic)", execution.events.get(index));
+    index++;
+    assertEquals("node-end on node(initial)", execution.events.get(index));
+    index++;
+    assertEquals("transition-take on (initial)-->(end)", execution.events.get(index));
+    index++;
+    assertEquals("node-begin on node(end)", execution.events.get(index));
+    index++;
+    assertEquals("process-end on processDefinition(basic)", execution.events.get(index));
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExceptionHandlerTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExceptionHandlerTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExceptionHandlerTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExceptionHandlerTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,325 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.listener.EventListener;
+import org.jbpm.pvm.listener.EventListenerExecution;
+import org.jbpm.pvm.model.Event;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExceptionHandlerTest extends JbpmTestCase
+{
+  
+  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){
+    }
+  }
+
+  public static class Catcher implements EventListener {
+    private static final long serialVersionUID = 1L;
+    int timesInvoked = 0;
+    public void notify(EventListenerExecution execution) {
+      timesInvoked++;
+    }
+  }
+
+  public static class Batter implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      throw new RuntimeException("catch me");
+    }
+  }
+  
+  public void testExceptionHandlerOnProcessDefinition() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .exceptionHandler(RuntimeException.class)
+        .listener(catcher)
+      .exceptionHandlerEnd()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(new Batter())
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    assertEquals(0, catcher.timesInvoked);
+    execution.signal();
+    assertEquals(1, catcher.timesInvoked);
+    assertEquals("end", execution.getNode().getName());
+  }
+
+  public void testExceptionHandlerOnEvent() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .exceptionHandler(RuntimeException.class)
+            .listener(catcher)
+          .exceptionHandlerEnd()
+          .listener(new Batter())
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    assertEquals(0, catcher.timesInvoked);
+    execution.signal();
+    assertEquals(1, catcher.timesInvoked);
+    assertEquals("end", execution.getNode().getName());
+  }
+
+  public void testExceptionHandlerOnAction() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(new Batter())
+            .exceptionHandler(RuntimeException.class)
+              .listener(catcher)
+            .exceptionHandlerEnd()
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    assertEquals(0, catcher.timesInvoked);
+    execution.signal();
+    assertEquals(1, catcher.timesInvoked);
+    assertEquals("end", execution.getNode().getName());
+  }
+
+  public void testExceptionHandlerOnOtherNode() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(new Batter())
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+        .exceptionHandler(RuntimeException.class)
+          .listener(catcher)
+        .exceptionHandlerEnd()
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    assertEquals(0, catcher.timesInvoked);
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      // OK
+    }
+  }
+
+  public void testExceptionHandlerOnOtherEvent() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event("other")
+          .exceptionHandler(RuntimeException.class)
+            .listener(catcher)
+          .exceptionHandlerEnd()
+        .event(Event.NODE_END)
+          .listener(new Batter())
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      // OK
+    }
+  }
+
+  public static class BehavedAction implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      // behaving.  not throwing any exception
+    }
+  }
+
+  public void testExceptionHandlerOnOtherAction() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(new BehavedAction())
+            .exceptionHandler(RuntimeException.class)
+              .listener(catcher)
+            .exceptionHandlerEnd()
+          .listener(new Batter())
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      // OK
+    }
+  }
+
+  public void testUnmatchedExceptionHandlerOnAction() {
+    Catcher catcher = new Catcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(new Batter())
+            .exceptionHandler(NullPointerException.class)
+              .listener(catcher)
+            .exceptionHandlerEnd()
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      // OK
+    }
+  }
+
+  public static class RethrowingCatcher implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public void notify(EventListenerExecution execution) {
+      // this exception handler will itself throw an exception
+      throw new RuntimeException("greetz from the retrhowing catcher");
+    }
+  }
+
+
+  public void testRethrowingExceptionHandler() {
+    RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(new Batter())
+            .exceptionHandler(RuntimeException.class)
+              .listener(rethrowingCatcher)
+            .exceptionHandlerEnd()
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
+    }
+  }
+
+  public void testRethrowingExceptionHandlerCaughtByTheOuterExceptionHandler() {
+    
+    // just like in java, when an exception handler rethrows, the search 
+    // for a matching exception handler will continue in the outer scope 
+    // (=the surrounding process element)
+    
+    RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .exceptionHandler(RuntimeException.class)
+            .listener(new Catcher())
+          .exceptionHandlerEnd()
+          .listener(new Batter())
+            .exceptionHandler(RuntimeException.class)
+              .listener(rethrowingCatcher)
+            .exceptionHandlerEnd()
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("initial", execution.getNode().getName());
+    execution.signal();
+  }
+
+  public void testRethrowingExceptionHandlerIgnoredByTheSubsequentExceptionHandlerInTheSameScope() {
+    
+    // just like in java, subsequent exception handlers will be skipped when the 
+    // an exception handler rethrows
+    
+    RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("initial").initial().behaviour(new WaitState())
+        .event(Event.NODE_END)
+          .listener(new Batter())
+            .exceptionHandler(RuntimeException.class)
+              .listener(rethrowingCatcher)
+            .exceptionHandlerEnd()
+            .exceptionHandler(RuntimeException.class)
+              .listener(new Catcher())
+            .exceptionHandlerEnd()
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+      .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    try {
+      execution.signal();
+      fail("expected exception");
+    } catch (RuntimeException e) {
+      assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
+    }
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExecutionStateTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExecutionStateTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExecutionStateTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExecutionStateTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,221 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/** shows the basics of the state property on the execution.
+ * 
+ * The state is automatically managed by the execution.
+ * An execution can only receive external triggers in case it is in 
+ * the active state.  
+ * 
+ * Nested executions can occur in case of scoped executions
+ * and in case of concurrent executions.  In both cases, only 
+ * leave executions in the execution hierarchy are active.
+ * 
+ * Executions are either locked or active.  So in any state which 
+ * is not active, the execution is locked and cannot accept external 
+ * signals.  Executions can be ended in 3 ways:
+ * 
+ *  1) with execution.end() : then the state will be set to 'ended'
+ *  2) with execution.cancel() : then the state will be set to 'cancelled'
+ *  3) with execution.end(String) : then the state will be set to the 
+ *     given state string.  An exception will be raised if the given 
+ *     state maches any of the known states.
+ * 
+ * @author Tom Baeyens
+ */
+public class ExecutionStateTest extends JbpmTestCase {
+
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+    }
+  }
+
+  public static class WaitState implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.take(signalName);
+    }
+  }
+  
+  public void testBasicState() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new AutomaticActivity())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .transition().to("c")
+      .node("c").behaviour(new AutomaticActivity())
+    .done();
+
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    assertEquals(Execution.STATE_CREATED, processInstance.getState());
+    
+    processInstance.begin();
+
+    assertEquals(Execution.STATE_ACTIVE, processInstance.getState());
+
+    processInstance.signal();
+
+    assertEquals(Execution.STATE_ENDED, processInstance.getState());
+  }
+
+  public void testSignalOnInactiveExecution() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new AutomaticActivity())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .scope()
+        .transition().to("c")
+      .node("c").behaviour(new AutomaticActivity())
+    .done();
+  
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.begin();
+  
+    assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
+  
+    try {
+      processInstance.signal();
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("process-instance is not active: inactive", e.getMessage());
+    }
+  }
+  
+  public void testCancel() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new AutomaticActivity())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .transition().to("c")
+      .node("c").behaviour(new AutomaticActivity())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.begin();
+    processInstance.cancel();
+    
+    assertEquals(Execution.STATE_CANCELLED, processInstance.getState());
+    
+    try {
+      processInstance.signal();
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("process-instance is not active: cancelled", e.getMessage());
+    }
+  }
+
+  public void testCustomState() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new AutomaticActivity())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .transition().to("c")
+      .node("c").behaviour(new AutomaticActivity())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.begin();
+    processInstance.end("error");
+    
+    assertEquals("error", processInstance.getState());
+    
+    try {
+      processInstance.signal();
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("process-instance is not active: error", e.getMessage());
+    }
+  }
+
+  public void testInvalidCustomStates() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new AutomaticActivity())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .transition().to("c")
+      .node("c").behaviour(new AutomaticActivity())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.begin();
+    
+    try {
+      processInstance.end("active");
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("invalid end state: active", e.getMessage());
+    }
+    try {
+      processInstance.end("suspended");
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("invalid end state: suspended", e.getMessage());
+    }
+    try {
+      processInstance.end("created");
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("invalid end state: created", e.getMessage());
+    }
+    try {
+      processInstance.end("async");
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("invalid end state: async", e.getMessage());
+    }
+    try {
+      processInstance.end("inactive");
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("invalid end state: inactive", e.getMessage());
+    }
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExternalDecisionTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExternalDecisionTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExternalDecisionTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ExternalDecisionTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,100 @@
+/*
+ * 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.basicfeatures;
+
+import junit.framework.TestCase;
+import org.jbpm.pvm.samples.activities.AutomaticActivity;
+import org.jbpm.pvm.samples.activities.WaitState;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.samples.ex04.Decision;
+import org.jbpm.pvm.model.ProcessFactory;
+
+import java.util.Map;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExternalDecisionTest extends TestCase {
+  
+  public static class ExternalDecision implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    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);
+    }
+  }
+  
+  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) {
+      execution.take(signalName);
+    }
+  }
+
+  public static ClientProcessDefinition createCreditProcess() {
+    return ProcessFactory.build()
+      .node("creditRate?").initial().behaviour(new ExternalDecision())
+        .transition("good").to("priority delivery")
+        .transition("average").to("bulk delivery")
+        .transition("bad").to("payment upfront")
+      .node("priority delivery").behaviour(new WaitState())
+      .node("bulk delivery").behaviour(new WaitState())
+      .node("payment upfront").behaviour(new WaitState())
+    .done();
+  }
+
+  public void testGoodRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    execution.signal("good");
+
+    assertEquals("priority delivery", execution.getNode().getName());
+  }
+
+  public void testAverageRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    execution.signal("average");
+    
+    assertEquals("bulk delivery", execution.getNode().getName());
+  }
+  
+  public void testBadRating() {
+    ClientProcessDefinition processDefinition = createCreditProcess(); 
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    execution.signal("bad");
+
+    assertEquals("payment upfront", execution.getNode().getName());
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/FunctionalActivityTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/FunctionalActivityTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/FunctionalActivityTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/FunctionalActivityTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,158 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.listener.EventListener;
+import org.jbpm.pvm.listener.EventListenerExecution;
+import org.jbpm.pvm.model.Node;
+import org.jbpm.pvm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+/** shows how functional nodes (nodes that have a specific function 
+ * not related to control flow) can be implemented.
+ * 
+ * Examples of functional nodes could be sending an email, doing a 
+ * SQL update on a database, generating a file and so on.
+ * 
+ * Functional nodes can be used as node behaviour in a transition based 
+ * process, event listener and as node behaviour in nested node 
+ * execution.
+ * 
+ * @author Tom Baeyens
+ */
+public class FunctionalActivityTest extends JbpmTestCase
+{
+
+  public static class FunctionalActivity implements Activity, EventListener {
+    private static final long serialVersionUID = 1L;
+    List<String> events;
+    public FunctionalActivity(List<String> events) {
+      this.events = events;
+    }
+    public void execute(ActivityExecution execution) {
+      perform(execution);
+    }
+    public void notify(EventListenerExecution execution) {
+      perform(execution);
+    }
+    void perform(OpenExecution execution) {
+      events.add("performed automatic activity");
+    }
+  }
+
+  public void testFunctionalActivityAsNodeBehaviourWithTransitions() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(functionalActivity)
+        .transition().to("b")
+      .node("b").behaviour(functionalActivity)
+        .transition().to("c")
+      .node("c").behaviour(functionalActivity)
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    
+    assertEquals("a", processInstance.getNodeName());
+    assertFalse(processInstance.isEnded());
+    assertEquals(expectedEvents, recordedEvents);
+    
+    processInstance.begin();
+    
+    expectedEvents.add("performed automatic activity");
+    expectedEvents.add("performed automatic activity");
+    expectedEvents.add("performed automatic activity");
+
+    assertEquals(expectedEvents, recordedEvents);
+  }
+
+  
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+    }
+  }
+
+  public void testFunctionalActivityAsEventListener() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new AutomaticActivity())
+        .transition().to("b")
+          .listener(functionalActivity)
+      .node("b").behaviour(new AutomaticActivity())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.begin();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    expectedEvents.add("performed automatic activity");
+
+    assertEquals(expectedEvents, recordedEvents);
+  }
+
+  public static class Composite implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      Node nestedNode = execution.getNode().getNodes().get(0);
+      execution.execute(nestedNode);
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    }
+  }
+
+  public void testFunctionalActivityAsNestedNode() {
+    List<String> recordedEvents = new ArrayList<String>(); 
+    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
+
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .compositeNode("a").initial().behaviour(new Composite())
+        .node().behaviour(functionalActivity)
+      .compositeEnd()
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.begin();
+    
+    List<String> expectedEvents = new ArrayList<String>();
+    expectedEvents.add("performed automatic activity");
+
+    assertEquals(expectedEvents, recordedEvents);
+  }
+
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/LoopingTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/LoopingTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/LoopingTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/LoopingTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,105 @@
+package org.jbpm.pvm.basicfeatures;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+
+public class LoopingTest extends JbpmTestCase
+{
+  
+  public static class For implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+
+    int startIndex = 0;
+    int loops;
+    int increment = 1;
+    String indexKey = "index";
+
+    public For(int loops) {
+      this.loops = loops;
+    }
+
+    public void execute(ActivityExecution execution) throws Exception {
+      Integer index = (Integer) execution.getVariable(indexKey);
+
+      if (index==null) {
+        execution.setVariable(indexKey, startIndex);
+        execution.take("loop");
+        
+      } else {
+        index++;
+        if (index<(startIndex+loops)){
+          execution.setVariable(indexKey, index);
+          execution.take("loop");
+          
+        } else {
+          execution.removeVariable(indexKey);
+          execution.take("done");
+        }
+      }
+    }
+    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+      throw new UnsupportedOperationException();
+    }
+    
+    public void setStartIndex(int startIndex) {
+      this.startIndex = startIndex;
+    }
+    public void setLoops(int loops) {
+      this.loops = loops;
+    }
+    public void setIncrement(int increment) {
+      this.increment = increment;
+    }
+    public void setIndexVariable(String indexVariable) {
+      this.indexKey = indexVariable;
+    }
+  }
+
+  static List<Object> recordedIndexes = new ArrayList<Object>();
+  
+  public static class Recorder implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      recordedIndexes.add(execution.getVariable("index"));
+    }
+  }
+
+  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){
+    }
+  }
+
+  public void testWhile() {
+    int loops = 20;
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("for").initial().behaviour(new For(loops))
+        .transition("loop").to("recorder")
+        .transition("done").to("end")
+      .node("recorder").behaviour(new Recorder())
+        .transition().to("for")
+      .node("end").behaviour(new WaitState())
+    .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+    
+    List<Object> expectedIndexes = new ArrayList<Object>();
+    for (int i=0; i<loops; i++) expectedIndexes.add(i); 
+
+    assertEquals(expectedIndexes, recordedIndexes);
+    assertEquals("end", execution.getNode().getName());
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/PvmClientTests.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/PvmClientTests.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/PvmClientTests.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/PvmClientTests.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -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.basicfeatures;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class PvmClientTests {
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite("Test for org.jbpm.pvm.client");
+    //$JUnit-BEGIN$
+    suite.addTestSuite(BasicExecutionFlowTest.class);
+    suite.addTestSuite(TransitionAsWaitStateTest.class);
+    suite.addTestSuite(TransitionBasedConcurrencyTest.class);
+    suite.addTestSuite(ScopeStateTest.class);
+    suite.addTestSuite(SubProcessTest.class);
+    suite.addTestSuite(ExecutionStateTest.class);
+    suite.addTestSuite(ExceptionHandlerTest.class);
+    suite.addTestSuite(FunctionalActivityTest.class);
+    suite.addTestSuite(ScopeVariableDeclarationTest.class);
+    suite.addTestSuite(LoopingTest.class);
+    suite.addTestSuite(TransitionEventsTest.class);
+    suite.addTestSuite(ExternalDecisionTest.class);
+    suite.addTestSuite(VariableTest.class);
+    suite.addTestSuite(ScopeVariableTest.class);
+    suite.addTestSuite(EventTest.class);
+    suite.addTestSuite(AutomaticDecisionTest.class);
+    suite.addTestSuite(EventPropagationTest.class);
+    //$JUnit-END$
+    return suite;
+  }
+
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeStateTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeStateTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeStateTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeStateTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,85 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScopeStateTest extends JbpmTestCase
+{
+
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+    }
+  }
+
+  public static class WaitState implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+      assertEquals(Execution.STATE_ACTIVE, execution.getState());
+      execution.take(signalName);
+    }
+  }
+
+  public void testInactivationWhenCreatingNestedExecution() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new AutomaticActivity())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .scope()
+        .transition().to("c")
+      .node("c").behaviour(new WaitState())
+    .done();
+  
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    
+    assertEquals(Execution.STATE_CREATED, processInstance.getState());
+    
+    processInstance.begin();
+    Execution scopeExecution = processInstance.getExecutions().iterator().next();
+
+    assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
+    assertEquals(Execution.STATE_ACTIVE, scopeExecution.getState());
+    
+    processInstance.signal(scopeExecution);
+
+    assertEquals(Execution.STATE_ENDED, scopeExecution.getState());
+    assertEquals(Execution.STATE_ACTIVE, processInstance.getState());
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableDeclarationTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableDeclarationTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableDeclarationTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableDeclarationTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,223 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.Node;
+import org.jbpm.pvm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScopeVariableDeclarationTest extends JbpmTestCase
+{
+
+  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) {
+      execution.take(signalName);
+    }
+  }
+  
+  public static class Composite implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      Node child = execution.getNode().getNodes().get(0);
+      execution.execute(child);
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    }
+  }
+  
+  public void testProcessInstanceVariableDeclaration() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .variable("flight")
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+
+    assertTrue(processInstance.hasVariable("flight"));
+    assertNull(processInstance.getVariable("flight"));
+  }
+
+  public void testProcessInstanceVariableDeclarationWithInitialValue() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .variable("flight", "B52")
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+
+    assertTrue(processInstance.hasVariable("flight"));
+    assertEquals("B52", processInstance.getVariable("flight"));
+  }
+
+  public void testNestedScopeDeclarations() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .variable("flight", "B52")
+      .compositeNode("outer").behaviour(new Composite())
+        .variable("duration", "22 minutes")
+        .compositeNode("middle").behaviour(new Composite())
+          .variable("altitude", "31000 ft")
+          .compositeNode("inner").behaviour(new Composite())
+            .variable("passengers", "52")
+            .compositeNode("start").initial().behaviour(new WaitState())
+              .variable("fuel", "kerosine")
+            .compositeEnd()
+          .compositeEnd()
+        .compositeEnd()
+      .compositeEnd()
+    .done();
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    expectedVariables.put("flight", "B52");
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    OpenExecution outerExecution = processInstance.getExecution("outer");
+    expectedVariables.put("duration", "22 minutes");
+    assertEquals(expectedVariables, outerExecution.getVariables());
+
+    OpenExecution middleExecution = outerExecution.getExecution("middle");
+    expectedVariables.put("altitude", "31000 ft");
+    assertEquals(expectedVariables, middleExecution.getVariables());
+
+    OpenExecution innerExecution = middleExecution.getExecution("inner");
+    expectedVariables.put("passengers", "52");
+    assertEquals(expectedVariables, innerExecution.getVariables());
+
+    OpenExecution startExecution = innerExecution.getExecution("start");
+    expectedVariables.put("fuel", "kerosine");
+    assertEquals(expectedVariables, startExecution.getVariables());
+  }
+
+  public void testHiddenVariable() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .variable("flight", "B52")
+      .compositeNode("c").behaviour(new Composite())
+        .variable("flight", "U2")
+        .node("i").initial().behaviour(new WaitState())
+          .variable("flight", "C130")
+      .compositeEnd()
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    OpenExecution executionC = processInstance.getExecution("c");
+    OpenExecution executionI = executionC.getExecution("i");
+    
+    assertEquals("B52", processInstance.getVariable("flight"));
+    assertEquals("U2", executionC.getVariable("flight"));
+    assertEquals("C130", executionI.getVariable("flight"));
+  }
+
+  public void testAutomaticScopeManagement() {
+    /*
+    process 
+     ${flight} = 'B52'
+    +--------------------------------------------------------------------+
+    | outer                                                              |
+    |  ${duration} = '22 minutes'                                        |
+    | +-------------------------------+                                  |  
+    | | left-middle                   |                                  |
+    | |  ${altitude} = '31000 ft'     |                                  |
+    | | +---------------------------+ |   +----------------------------+ |
+    | | | left-inner                | |   | right-middle               | |       
+    | | |  ${passengers}            | |   |  ${customer} = 'coca cola' | |       
+    | | | +-----------------------+ | |   |  +--------------------+    | |
+    | | | | left-start            | -------> | right-inner        |    | |
+    | | | |  ${fuel} = 'kerosine' | | |   |  |  ${date} = 'today' |    | |
+    | | | +-----------------------+ | |   |  +--------------------+    | |
+    | | +---------------------------+ |   +----------------------------+ |
+    +--------------------------------------------------------------------+
+    */
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .variable("flight", "B52")
+      .compositeNode("outer").behaviour(new Composite())
+        .variable("duration", "22 minutes")
+        .compositeNode("left-middle").behaviour(new Composite())
+          .variable("altitude", "31000 ft")
+          .compositeNode("left-inner").behaviour(new Composite())
+            .variable("passengers", "52")
+            .compositeNode("left-start").initial().behaviour(new WaitState())
+              .variable("fuel", "kerosine")
+              .transition().to("right-inner")
+            .compositeEnd()
+          .compositeEnd()
+        .compositeEnd()
+        .compositeNode("right-middle").behaviour(new Composite())
+          .variable("customer", "coca-cola")
+          .compositeNode("right-inner").behaviour(new WaitState())
+            .variable("date", "today")
+          .compositeEnd()
+        .compositeEnd()
+      .compositeEnd()
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    OpenExecution outerExecution = processInstance.getExecution("outer");
+    OpenExecution leftMiddleExecution = outerExecution.getExecution("left-middle");
+    OpenExecution leftInnerExecution = leftMiddleExecution.getExecution("left-inner");
+    OpenExecution leftStartExecution = leftInnerExecution.getExecution("left-start");
+
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("flight", "B52");
+    expectedVariables.put("duration", "22 minutes");
+    expectedVariables.put("altitude", "31000 ft");
+    expectedVariables.put("passengers", "52");
+    expectedVariables.put("fuel", "kerosine");
+    assertEquals(expectedVariables, leftStartExecution.getVariables());
+
+    processInstance.signal(leftStartExecution);
+
+    OpenExecution rightMiddleExecution = outerExecution.getExecution("right-middle");
+    OpenExecution rightInnerExecution = rightMiddleExecution.getExecution("right-inner");
+
+    expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("flight", "B52");
+    expectedVariables.put("duration", "22 minutes");
+    
+    assertEquals(expectedVariables, outerExecution.getVariables());
+    
+    expectedVariables.put("customer", "coca-cola");
+    assertEquals(expectedVariables, rightMiddleExecution.getVariables());
+
+    expectedVariables.put("date", "today");
+    assertEquals(expectedVariables, rightInnerExecution.getVariables());
+  }
+
+
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/ScopeVariableTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,187 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ *  
+ *    +---+     +--------+     +---+ 
+ *    | a |     | b      |     | c |
+ *    |   | --> |        | --> |   |  
+ *    |   |     | SCOPE! |     |   |
+ *    +---+     +--------+     +---+  
+ *
+ * @author Tom Baeyens
+ */
+public class ScopeVariableTest extends JbpmTestCase
+{
+
+  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) {
+      execution.take(signalName);
+    }
+  }
+  
+  public void testOuterscopeLookup() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .scope() // !!!!
+        .transition().to("c")
+      .node("c").behaviour(new WaitState())
+    .done();
+  
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    processInstance.setVariable("destination", "anywhere");
+    
+    processInstance.signal();
+    
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    // check if the global vars are still visible within the scope for b.
+    assertEquals("anywhere", bScope.getVariable("destination"));
+    
+    bScope.createVariable("temp", "23C");
+    assertEquals("23C", bScope.getVariable("temp"));
+    assertNull(processInstance.getVariable("temp"));
+  }
+
+  public void testLocalVariableLookup() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .scope() // !!!!
+        .transition().to("c")
+      .node("c").behaviour(new WaitState())
+    .done();
+  
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.createVariable("temp", "23C");
+    
+    assertEquals("23C", bScope.getVariable("temp"));
+    assertNull(processInstance.getVariable("temp"));
+    
+    processInstance.signal(bScope);
+    
+    assertTrue(bScope.isEnded());
+    assertNull(processInstance.getVariable("temp"));
+  }
+
+  public void testLocalVariableUpdate() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .scope() // !!!!
+        .transition().to("c")
+      .node("c").behaviour(new WaitState())
+    .done();
+  
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.createVariable("temp", "23C");
+    bScope.setVariable("temp", "28C");
+    
+    assertEquals("28C", bScope.getVariable("temp"));
+    
+    processInstance.signal(bScope);
+    
+    assertTrue(bScope.isEnded());
+    assertNull(processInstance.getVariable("temp"));
+  }
+
+  public void testDefaultCreationOnGlobalScope() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .scope() // !!!!
+        .transition().to("c")
+      .node("c").behaviour(new WaitState())
+    .done();
+  
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.setVariable("temp", "28C");
+    assertEquals("28C", bScope.getVariable("temp"));
+    
+    processInstance.signal(bScope);
+    
+    assertTrue(bScope.isEnded());
+    assertEquals("28C", processInstance.getVariable("temp"));
+  }
+
+  public void testVariableUpdatesOnEndedScope() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+        .transition().to("b")
+      .node("b").behaviour(new WaitState())
+        .scope() // !!!!
+        .transition().to("c")
+      .node("c").behaviour(new WaitState())
+    .done();
+  
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+
+    processInstance.signal();
+    OpenExecution bScope = processInstance.getExecution("b");
+
+    bScope.createVariable("temp", "28C");
+    
+    processInstance.signal(bScope);
+    
+    try {
+      bScope.setVariable("temp", "21C");
+      fail("expected exception");
+    } catch (PvmException e) {
+      // OK
+      assertTextPresent("can't update variable 'temp' on execution[b]", e.getMessage());
+    }
+  }
+
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/SubProcessTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/SubProcessTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/SubProcessTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/SubProcessTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,108 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubProcessTest extends JbpmTestCase
+{
+
+  public static class SubProcess implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    ClientProcessDefinition subProcess;
+    public SubProcess(ClientProcessDefinition subProcess) {
+      this.subProcess = subProcess;
+    }
+    public void execute(ActivityExecution execution) throws Exception {
+      ClientProcessInstance subProcessInstance = execution.beginSubProcessInstance(subProcess);
+      if (!subProcessInstance.isEnded()) {
+        execution.waitForSignal();
+      }
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+    }
+  }
+  
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+    }
+  }
+  
+  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){
+    }
+  }
+
+  public static class EndState implements Activity {
+    public void execute(ActivityExecution execution) throws Exception {
+      execution.end();
+    }
+  }
+
+  public void testSubProcess() {
+    ClientProcessDefinition subProcess = ProcessFactory.build("sub")
+      .node("sub1").initial().behaviour(new AutomaticActivity())
+        .transition().to("sub2")
+      .node("sub2").behaviour(new WaitState())
+        .transition().to("sub3")
+      .node("sub3").behaviour(new EndState())
+    .done();
+    
+    ClientProcessDefinition superProcess = ProcessFactory.build("super")
+      .node("super1").initial().behaviour(new AutomaticActivity())
+        .transition().to("super2")
+      .node("super2").behaviour(new SubProcess(subProcess))
+        .transition().to("super3")
+      .node("super3").behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance superProcesInstance = superProcess.beginProcessInstance();
+    assertEquals("super2", superProcesInstance.getNode().getName());
+
+    ClientProcessInstance subProcessInstance = (ClientProcessInstance) superProcesInstance.getSubProcessInstance(); 
+    assertNotNull(subProcessInstance);
+    assertEquals("sub2", subProcessInstance.getNode().getName());
+    
+    subProcessInstance.signal();
+    
+    assertEquals("sub3", subProcessInstance.getNode().getName());
+    assertTrue(subProcessInstance.isEnded());
+    
+    assertEquals("super3", superProcesInstance.getNode().getName());
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionAsWaitStateTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionAsWaitStateTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionAsWaitStateTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionAsWaitStateTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,83 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.listener.Condition;
+import org.jbpm.pvm.listener.EventListenerExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/** this test shows how to implement a transition that behaves as a 
+ * wait state.
+ * 
+ * @author Tom Baeyens
+ */
+public class TransitionAsWaitStateTest extends JbpmTestCase
+{
+
+  public static class AlwaysTrue implements Condition {
+    private static final long serialVersionUID = 1L;
+    public boolean evaluate(EventListenerExecution execution) {
+      return true;
+    }
+  };
+  
+  public static class AutomaticActivity implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+    }
+  }
+  
+  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){
+    }
+  }
+
+  public void testSmallAmount() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("make loss").initial().behaviour(new AutomaticActivity())
+        .transition("use jbpm").to("make profit")
+          .waitCondition(new AlwaysTrue())
+      .node("make profit").behaviour(new WaitState())
+    .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertNull(execution.getNode());
+    
+    execution.signal();
+    
+    assertEquals("make profit", execution.getNode().getName());
+  }  
+
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionBasedConcurrencyTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionBasedConcurrencyTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionBasedConcurrencyTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionBasedConcurrencyTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,170 @@
+package org.jbpm.pvm.basicfeatures;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.Node;
+import org.jbpm.pvm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.model.Transition;
+
+/**
+ * concurrent execution where synchronization is done by checking if the 
+ * number of expected child executions arrived at the join.
+ * 
+ * @author Tom Baeyens
+ */
+public class TransitionBasedConcurrencyTest extends JbpmTestCase
+{
+  
+  public static class Fork implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      Node node = execution.getNode();
+      List<Transition> outgoingTransitions = node.getOutgoingTransitions();
+
+      // for each outgoing transition
+      for (Transition outgoingTransition: outgoingTransitions) {
+        // launch a concurrent path of execution
+        String childExecutionName = outgoingTransition.getName();
+        // creating the execution will cause the execution to become inactive
+        Execution childExecution = execution.createExecution(childExecutionName);
+        execution.take(outgoingTransition, childExecution);
+      }
+    }
+  }
+
+  public static class Join implements Activity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) throws Exception {
+      // end the child execution execution
+      // this will also remove the execution from it's parent
+      execution.end();
+      
+      Node join = execution.getNode();
+      List<OpenExecution> joinedExecutions = findJoinedExecutions(execution, join);
+      
+      if (isComplete(joinedExecutions, join)) {
+        remove(joinedExecutions, execution);
+        OpenExecution processInstance = execution.getProcessInstance();
+        
+        Execution outgoingExecution = null;
+        if ( processInstance.getExecutions()==null
+             || processInstance.getExecutions().isEmpty() 
+           ) {
+          outgoingExecution = processInstance;
+        } else {
+          outgoingExecution = execution.createExecution(processInstance);
+        }
+        
+        execution.move(join, outgoingExecution);
+        Transition transition = join.getDefaultTransition();
+        execution.take(transition, outgoingExecution);
+      }
+    }
+    
+    List<OpenExecution> findJoinedExecutions(OpenExecution execution, Node join) {
+      List<OpenExecution> joinedExecutions = new ArrayList<OpenExecution>();
+      scanRecursive(execution.getProcessInstance(), join, joinedExecutions);
+      return joinedExecutions;
+    }
+
+    void scanRecursive(OpenExecution execution, Node join, List<OpenExecution> joinedExecutions) {
+      // if the execution is positioned in the join
+      if (join.equals(execution.getNode())) {
+        joinedExecutions.add(execution);
+      }
+      Collection<OpenExecution> childExecutions = execution.getExecutions();
+      if (childExecutions!=null) {
+        for (OpenExecution childExecution: childExecutions) {
+          scanRecursive(childExecution, join, joinedExecutions);
+        }
+      }
+    }
+
+    boolean isComplete(List<OpenExecution> joinedExecutions, Node join) {
+      int executionsToJoin = join.getIncomingTransitions().size();
+      return (executionsToJoin==joinedExecutions.size());
+    }
+
+    void remove(List<OpenExecution> joinedExecutions, ActivityExecution execution) {
+      for (OpenExecution joinedExecution: joinedExecutions) {
+        execution.removeExecution(joinedExecution, joinedExecution.getParent());
+      }
+    }
+  }
+
+  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) {
+      execution.take(signalName);
+    }
+  }
+
+  public void testTransitionBasedConcurrency() {
+
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("fork").initial().behaviour(new Fork())
+        .transition("billing").to("bill")
+        .transition("shipping").to("ship")
+      .node("bill").behaviour(new WaitState())
+        .transition().to("join")
+      .node("ship").behaviour(new WaitState())
+        .transition().to("join")
+      .node("join").behaviour(new Join())
+        .transition().to("end")
+      .node("end").behaviour(new WaitState())
+    .done();
+
+    ClientProcessInstance main = processDefinition.beginProcessInstance();
+    
+    assertEquals("fork", main.getNode().getName());
+    assertEquals(Execution.STATE_INACTIVE, main.getState());
+    
+    Execution billing = main.getExecution("billing");
+    assertNotNull(billing);
+    assertEquals("bill", billing.getNodeName());
+    assertFalse(billing.isEnded());
+    
+    Execution shipping = main.getExecution("shipping");
+    
+    assertNotNull(shipping);
+    assertEquals("ship", shipping.getNodeName());
+    assertFalse(shipping.isEnded());
+    assertTrue(main.getExecutions().contains(billing));
+    assertTrue(main.getExecutions().contains(shipping));
+
+    main.signal(billing);
+    
+    assertEquals("fork", main.getNodeName());
+    assertEquals("join", billing.getNodeName());
+    assertTrue(billing.isEnded());
+    assertEquals("ship", shipping.getNodeName());
+    assertFalse(shipping.isEnded());
+    assertTrue(billing.isEnded());
+    assertEquals(Execution.STATE_INACTIVE, main.getState());
+
+    main.signal(shipping);
+    
+    assertEquals(Execution.STATE_ACTIVE, main.getState());
+    assertEquals("end", main.getNodeName());
+    assertEquals("join", billing.getNodeName());
+    assertTrue(billing.isEnded());
+    assertEquals("join", shipping.getNodeName());
+    assertTrue(shipping.isEnded());
+    assertFalse(main.getExecutions().contains(billing));
+    assertFalse(main.getExecutions().contains(shipping));
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionEventsTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionEventsTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionEventsTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/TransitionEventsTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,454 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.listener.EventListener;
+import org.jbpm.pvm.listener.EventListenerExecution;
+import org.jbpm.pvm.model.Event;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionEventsTest extends JbpmTestCase
+{
+  
+  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){
+    }
+  }
+  
+  public class Recorder implements EventListener {
+    private static final long serialVersionUID = 1L;
+    public List<Object> events = new ArrayList<Object>();
+    public void notify(EventListenerExecution execution) {
+      events.add(execution.getEvent()+" on "+execution.getEventSource());
+    }
+  }
+
+
+  public void testCompositeLeave(){
+    Recorder processListener = new Recorder();
+    Recorder outsideListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+    +--------------+
+    | composite    |
+    |  +--------+  |     +---------+    
+    |  | inside |------->| outside |
+    |  +--------+  |     +---------+    
+    +--------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
+        .event(Event.NODE_END) 
+          .listener(processListener)
+        .event(Event.NODE_BEGIN) 
+          .listener(processListener)
+        .event(Event.TRANSITION_TAKE) 
+          .listener(processListener)
+        .compositeNode("composite")
+          .event(Event.NODE_END) 
+            .listener(compositeListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(compositeListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(compositeListener)
+            .node("inside").initial().behaviour(new WaitState())
+              .event(Event.NODE_END) 
+                .listener(insideListener)
+              .event(Event.NODE_BEGIN) 
+                .listener(insideListener)
+              .event(Event.TRANSITION_TAKE) 
+                .listener(insideListener)
+              .transition().to("outside")
+          .compositeEnd()
+        .node("outside").behaviour(new WaitState())
+          .event(Event.NODE_END) 
+            .listener(outsideListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(outsideListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(outsideListener)
+    .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals(0, processListener.events.size());
+    assertEquals(0, outsideListener.events.size());
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+    
+    assertEquals("inside", execution.getNode().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(node-end) on node(inside), " +
+                  "event(node-end) on node(composite), " +
+                  "event(transition-take) on (inside)-->(outside), " +
+                  "event(node-begin) on node(outside)]", 
+                 processListener.events.toString());
+    
+    assertEquals("[event(node-begin) on node(outside)]",
+                 outsideListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(inside), " +
+                  "event(node-end) on node(composite)]",
+                 compositeListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(inside)]",
+                 insideListener.events.toString());
+  }
+
+  public void testCompositeEnter(){
+    Recorder processListener = new Recorder();
+    Recorder outsideListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+                   +--------------+
+                   | composite    |
+    +---------+    |  +--------+  |
+    | outside |------>| inside |  |
+    +---------+    |  +--------+  |
+                   +--------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("enter a super state")
+        .event(Event.NODE_END) 
+          .listener(processListener)
+        .event(Event.NODE_BEGIN) 
+          .listener(processListener)
+        .event(Event.TRANSITION_TAKE) 
+          .listener(processListener)
+        .node("outside").initial().behaviour(new WaitState())
+          .event(Event.NODE_END) 
+            .listener(outsideListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(outsideListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(outsideListener)
+          .transition().to("inside")
+        .compositeNode("composite")
+          .event(Event.NODE_END) 
+            .listener(compositeListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(compositeListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(compositeListener)
+          .node("inside").behaviour(new WaitState())
+            .event(Event.NODE_END) 
+              .listener(insideListener)
+            .event(Event.NODE_BEGIN) 
+              .listener(insideListener)
+            .event(Event.TRANSITION_TAKE) 
+              .listener(insideListener)
+        .compositeEnd()
+    .done();
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals(0, processListener.events.size());
+    assertEquals(0, outsideListener.events.size());
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+
+    execution.signal();
+    
+    assertEquals("[event(node-end) on node(outside), " +
+    		          "event(transition-take) on (outside)-->(inside), " +
+    		          "event(node-begin) on node(composite), " +
+    		          "event(node-begin) on node(inside)]", 
+                 processListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(outside)]",
+                 outsideListener.events.toString());
+    
+    assertEquals("[event(node-begin) on node(composite), " +
+    		           "event(node-begin) on node(inside)]",
+    		         compositeListener.events.toString());
+    
+    assertEquals("[event(node-begin) on node(inside)]",
+                 insideListener.events.toString());
+  }
+
+  public void testSelfTransition(){
+    Recorder processListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+    +-----------------+
+    | composite       |
+    |  +--------+     |    
+    |  | inside |---+ |
+    |  |        |   | |
+    |  |        |<--+ |
+    |  +--------+     |    
+    +-----------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
+        .event(Event.NODE_END) 
+          .listener(processListener)
+        .event(Event.NODE_BEGIN) 
+          .listener(processListener)
+        .event(Event.TRANSITION_TAKE) 
+          .listener(processListener)
+        .compositeNode("composite")
+          .event(Event.NODE_END) 
+            .listener(compositeListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(compositeListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(compositeListener)
+          .node("inside").initial().behaviour(new WaitState())
+            .event(Event.NODE_END) 
+              .listener(insideListener)
+            .event(Event.NODE_BEGIN) 
+              .listener(insideListener)
+            .event(Event.TRANSITION_TAKE) 
+              .listener(insideListener)
+            .transition().to("inside")
+        .compositeEnd()
+    .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals(0, processListener.events.size());
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+    
+    assertEquals("inside", execution.getNode().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(node-end) on node(inside), " +
+                  "event(transition-take) on (inside)-->(inside), " +
+                  "event(node-begin) on node(inside)]", 
+                 processListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(inside), " +
+                 "event(transition-take) on (inside)-->(inside), " +
+                 "event(node-begin) on node(inside)]",
+                 compositeListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(inside), " +
+    		          "event(node-begin) on node(inside)]",
+                 insideListener.events.toString());
+  }
+
+
+  public void testCompositeLeaveInheritedTransition(){
+    Recorder processListener = new Recorder();
+    Recorder outsideListener = new Recorder();
+    Recorder compositeListener = new Recorder();
+    Recorder insideListener = new Recorder();
+
+    /*
+    +--------------+        +---------+ 
+    | composite    |------->| outside |
+    |  +--------+  |        +---------+   
+    |  | inside |  |
+    |  +--------+  |
+    +--------------+
+    */
+    
+    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
+        .event(Event.NODE_END) 
+          .listener(processListener)
+        .event(Event.NODE_BEGIN) 
+          .listener(processListener)
+        .event(Event.TRANSITION_TAKE) 
+          .listener(processListener)
+        .compositeNode("composite")
+          .event(Event.NODE_END) 
+            .listener(compositeListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(compositeListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(compositeListener)
+          .transition().to("outside")
+          .node("inside").initial().behaviour(new WaitState())
+            .event(Event.NODE_END) 
+              .listener(insideListener)
+            .event(Event.NODE_BEGIN) 
+              .listener(insideListener)
+            .event(Event.TRANSITION_TAKE) 
+              .listener(insideListener)
+        .compositeEnd()
+        .node("outside").behaviour(new WaitState())
+          .event(Event.NODE_END) 
+            .listener(outsideListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(outsideListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(outsideListener)
+    .done();
+
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals(0, processListener.events.size());
+    assertEquals(0, outsideListener.events.size());
+    assertEquals(0, compositeListener.events.size());
+    assertEquals(0, insideListener.events.size());
+    
+    assertEquals("inside", execution.getNode().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(node-end) on node(inside), " +
+                  "event(node-end) on node(composite), " +
+                  "event(transition-take) on (composite)-->(outside), " +
+                  "event(node-begin) on node(outside)]", 
+                 processListener.events.toString());
+    
+    assertEquals("[event(node-begin) on node(outside)]",
+                 outsideListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(inside), " +
+                  "event(node-end) on node(composite)]",
+                 compositeListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(inside)]",
+                 insideListener.events.toString());
+  }
+
+  public void testCompositeLeaveInheritedTransitionExtraNesting(){
+    Recorder processListener = new Recorder();
+    Recorder sourceOutsideListener = new Recorder();
+    Recorder sourceMiddleListener = new Recorder();
+    Recorder sourceInsideListener = new Recorder();
+    Recorder destinationOutsideListener = new Recorder();
+    Recorder destinationInsideListener = new Recorder();
+
+    /*
+    +--------------------------+ 
+    | source outside           |
+    |  +--------------------+  |      +--------------------------+ 
+    |  | source middle      |  |      | destination outside      |
+    |  |  +---------------+ |  |      |  +--------------------+  |   
+    |  |  | source inside | |----------->| destination inside |  |
+    |  |  +---------------+ |  |      |  +--------------------+  |
+    |  +--------------------+  |      +--------------------------+
+    +--------------------------+
+    */
+
+    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
+        .event(Event.NODE_END) 
+          .listener(processListener)
+        .event(Event.NODE_BEGIN) 
+          .listener(processListener)
+        .event(Event.TRANSITION_TAKE) 
+          .listener(processListener)
+        .compositeNode("source outside")
+          .event(Event.NODE_END) 
+            .listener(sourceOutsideListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(sourceOutsideListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(sourceOutsideListener)
+          .compositeNode("source middle")
+            .event(Event.NODE_END) 
+              .listener(sourceMiddleListener)
+            .event(Event.NODE_BEGIN) 
+              .listener(sourceMiddleListener)
+            .event(Event.TRANSITION_TAKE) 
+              .listener(sourceMiddleListener)
+            .transition().to("destination inside")
+            .node("source inside").initial().behaviour(new WaitState())
+              .event(Event.NODE_END) 
+                .listener(sourceInsideListener)
+              .event(Event.NODE_BEGIN) 
+                .listener(sourceInsideListener)
+              .event(Event.TRANSITION_TAKE) 
+                .listener(sourceInsideListener)
+          .compositeEnd()
+        .compositeEnd()
+        .compositeNode("destination outside")
+          .event(Event.NODE_END) 
+            .listener(destinationOutsideListener)
+          .event(Event.NODE_BEGIN) 
+            .listener(destinationOutsideListener)
+          .event(Event.TRANSITION_TAKE) 
+            .listener(destinationOutsideListener)
+          .node("destination inside").behaviour(new WaitState())
+            .event(Event.NODE_END) 
+              .listener(destinationInsideListener)
+            .event(Event.NODE_BEGIN) 
+              .listener(destinationInsideListener)
+            .event(Event.TRANSITION_TAKE) 
+              .listener(destinationInsideListener)
+        .compositeEnd()
+    .done();
+
+    
+    ClientProcessInstance execution = processDefinition.beginProcessInstance();
+
+    assertEquals("source inside", execution.getNode().getName());
+
+    execution.signal();
+    
+    assertEquals("[event(node-end) on node(source inside), " +
+                  "event(node-end) on node(source middle), " +
+                  "event(node-end) on node(source outside), " +
+                  "event(transition-take) on (source middle)-->(destination inside), " +
+                  "event(node-begin) on node(destination outside), " +
+                  "event(node-begin) on node(destination inside)]", 
+                 processListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(source inside), " +
+                  "event(node-end) on node(source middle), " +
+                  "event(node-end) on node(source outside)]", 
+                 sourceOutsideListener.events.toString());
+    
+    assertEquals("[event(node-end) on node(source inside), " +
+                  "event(node-end) on node(source middle)]", 
+                 sourceMiddleListener.events.toString());
+
+    assertEquals("[event(node-end) on node(source inside)]", 
+                 sourceInsideListener.events.toString());
+
+    assertEquals("[event(node-begin) on node(destination outside), " +
+                  "event(node-begin) on node(destination inside)]", 
+                 destinationOutsideListener.events.toString());
+
+    assertEquals("[event(node-begin) on node(destination inside)]", 
+                 destinationInsideListener.events.toString());
+  }
+}


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

Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/VariableTest.java (from rev 1674, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/VariableTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/VariableTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/basicfeatures/VariableTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -0,0 +1,247 @@
+/*
+ * 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.basicfeatures;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariableTest extends JbpmTestCase {
+  
+  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){
+    }
+  }
+  
+  public void testSetAndGetVariable() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    assertEquals("coca-cola", processInstance.getVariable("customer"));
+    
+    processInstance.setVariable("address", "usa");
+    assertEquals("usa", processInstance.getVariable("address"));
+
+    processInstance.setVariable("size", "big");
+    assertEquals("big", processInstance.getVariable("size"));
+  }
+
+  public void testHasVariable() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+
+    assertTrue(processInstance.hasVariable("customer"));
+    assertFalse(processInstance.hasVariable("address"));
+  }
+
+  public void testSetVariables() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("customer", "coca-cola");
+    variables.put("address", "usa");
+    variables.put("size", "big");
+
+    processInstance.setVariables(variables);
+
+    assertEquals("coca-cola", processInstance.getVariable("customer"));
+    assertEquals("usa", processInstance.getVariable("address"));
+    assertEquals("big", processInstance.getVariable("size"));
+  }
+
+  public void testGetVariables() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("customer", "coca-cola");
+    expectedVariables.put("address", "usa");
+    expectedVariables.put("size", "big");
+    assertEquals(expectedVariables, processInstance.getVariables());
+  }
+
+  public void testRemoveVariable() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("customer", "coca-cola");
+    expectedVariables.put("address", "usa");
+    expectedVariables.put("size", "big");
+    
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    processInstance.removeVariable("address");
+    expectedVariables.remove("address");
+
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    processInstance.removeVariable("customer");
+    expectedVariables.remove("customer");
+
+    assertEquals(expectedVariables, processInstance.getVariables());
+    
+    processInstance.removeVariable("size");
+    expectedVariables.remove("size");
+
+    assertEquals(expectedVariables, processInstance.getVariables());
+  }
+
+  public void testRemoveVariables() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    processInstance.removeVariables();
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    assertEquals(expectedVariables, processInstance.getVariables());
+  }
+
+  public void testGetVariableKeys() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.setVariable("address", "usa");
+    processInstance.setVariable("size", "big");
+    
+    Set<String> expectedVariableKeys = new HashSet<String>();
+    expectedVariableKeys.add("customer");
+    expectedVariableKeys.add("address");
+    expectedVariableKeys.add("size");
+    assertEquals(expectedVariableKeys, new HashSet<String>(processInstance.getVariableKeys()));
+  }
+
+  public void testGetUnexistingVariable() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    assertNull(processInstance.getVariable("answer to life, the universe and everything"));
+  }
+
+  public static class VariableActivity implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      assertEquals("coca-cola", execution.getVariable("customer"));
+      execution.setVariable("message", "Killroy was here");
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+    }
+  }
+
+  public void testInitialiseVariablesBeforeProcessInstanceBegin() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new VariableActivity())
+    .done();
+    
+    // here, the process instance is created first, and only later it is begun
+    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+    processInstance.setVariable("customer", "coca-cola");
+    processInstance.begin();
+    assertEquals("Killroy was here", processInstance.getVariable("message"));
+  }
+  
+  public void testNullValue() {
+    ClientProcessDefinition processDefinition = ProcessFactory.build()
+      .node("a").initial().behaviour(new WaitState())
+    .done();
+    
+    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
+    
+    processInstance.setVariable("niks", null);
+    processInstance.setVariable("nada", null);
+
+    assertTrue(processInstance.hasVariables());
+    assertTrue(processInstance.hasVariable("niks"));
+    assertTrue(processInstance.hasVariable("nada"));
+
+    assertNull(processInstance.getVariable("niks"));
+    assertNull(processInstance.getVariable("nada"));
+    
+    Set<String> expectedKeys = new HashSet<String>();
+    expectedKeys.add("niks");
+    expectedKeys.add("nada");
+    assertEquals(expectedKeys, new HashSet<String>(processInstance.getVariableKeys()));
+    
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    expectedVariables.put("niks", null);
+    expectedVariables.put("nada", null);
+    assertEquals(expectedVariables, new HashMap<String, Object>(processInstance.getVariables()));
+  }
+
+}


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

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/AutomaticDecisionTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/AutomaticDecisionTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/AutomaticDecisionTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,107 +0,0 @@
-/*
- * 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.client;
-
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.ProcessFactory;
-
-
-/** shows an automatic decision.
- * 
- * @author Tom Baeyens
- */
-public class AutomaticDecisionTest extends JbpmTestCase {
-
-  public static class AutomaticCreditRating implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      int creditRate = (Integer) execution.getVariable("creditRate");
-      
-      if (creditRate > 5) {
-        execution.take("good");
-
-      } else if (creditRate < -5) {
-        execution.take("bad");
-        
-      } else {
-        execution.take("average");
-      }
-    }
-  }
-  
-  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) {
-      execution.take(signalName);
-    }
-  }
-
-  public static ClientProcessDefinition createCreditProcess() {
-    return ProcessFactory.build()
-      .node("creditRate?").initial().behaviour(new AutomaticCreditRating())
-        .transition("good").to("priority delivery")
-        .transition("average").to("bulk delivery")
-        .transition("bad").to("payment upfront")
-      .node("priority delivery").behaviour(new WaitState())
-      .node("bulk delivery").behaviour(new WaitState())
-      .node("payment upfront").behaviour(new WaitState())
-    .done();
-  }
-
-  public void testGoodRating() {
-    ClientProcessDefinition processDefinition = createCreditProcess(); 
-    
-    ClientProcessInstance execution = processDefinition.createProcessInstance();
-    execution.setVariable("creditRate", 7);
-    execution.begin();
-
-    assertEquals("priority delivery", execution.getNode().getName());
-  }
-
-  public void testAverageRating() {
-    ClientProcessDefinition processDefinition = createCreditProcess(); 
-    
-    ClientProcessInstance execution = processDefinition.createProcessInstance();
-    execution.setVariable("creditRate", 2);
-    execution.begin();
-
-    assertEquals("bulk delivery", execution.getNode().getName());
-  }
-  
-  public void testBadRating() {
-    ClientProcessDefinition processDefinition = createCreditProcess(); 
-    
-    ClientProcessInstance execution = processDefinition.createProcessInstance();
-    execution.setVariable("creditRate", -7);
-    execution.begin();
-
-    assertEquals("payment upfront", execution.getNode().getName());
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/BasicExecutionFlowTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/BasicExecutionFlowTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/BasicExecutionFlowTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,142 +0,0 @@
-/*
-  * 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.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/** shows wait states and automatic activities in a simple 
- * sequence based on transitions.
- * 
- * @author Tom Baeyens
- */
-public class BasicExecutionFlowTest extends JbpmTestCase {
-  
-  // automatic activity will log an event in a given list
-  
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    List<String> events;
-    public AutomaticActivity(List<String> events) {
-      this.events = events;
-    }
-    public void execute(ActivityExecution execution) {
-      events.add("execute["+execution.getNodeName()+"]");
-    }
-  }
-
-  public static class WaitState implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    List<String> events;
-    public WaitState(List<String> events) {
-      this.events = events;
-    }
-    public void execute(ActivityExecution execution) {
-      events.add("execute["+execution.getNodeName()+"]");
-      execution.waitForSignal();
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
-      events.add("signal["+execution.getNodeName()+"]");
-      execution.take(signalName);
-    }
-  }
-
-  public void testChainOfAutomaticActivitiesAndWaitStates() {
-    List<String> recordedEvents = new ArrayList<String>(); 
-    AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
-    WaitState waitState = new WaitState(recordedEvents);
-
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(automaticActivity)
-        .transition().to("b")
-      .node("b").behaviour(automaticActivity)
-        .transition().to("c")
-      .node("c").behaviour(waitState)
-        .transition().to("d")
-      .node("d").behaviour(waitState)
-        .transition().to("e")
-      .node("e").behaviour(automaticActivity)
-        .transition().to("f")
-      .node("f").behaviour(automaticActivity)
-    .done();
-
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    List<String> expectedEvents = new ArrayList<String>();
-    
-    expectedEvents.add("execute[a]");
-    expectedEvents.add("execute[b]");
-    expectedEvents.add("execute[c]");
-
-    assertEquals("c", processInstance.getNodeName());
-    assertFalse(processInstance.isEnded());
-    assertEquals(expectedEvents, recordedEvents);
-
-    processInstance.signal();
-
-    expectedEvents.add("signal[c]");
-    expectedEvents.add("execute[d]");
-
-    assertEquals("d", processInstance.getNodeName());
-    assertFalse(processInstance.isEnded());
-    assertEquals(expectedEvents, recordedEvents);
-
-    processInstance.signal();
-
-    expectedEvents.add("signal[d]");
-    expectedEvents.add("execute[e]");
-    expectedEvents.add("execute[f]");
-
-    assertEquals("f", processInstance.getNodeName());
-    assertTrue(processInstance.isEnded());
-    assertEquals(expectedEvents, recordedEvents);
-  }
-  
-  public void testDelayedBegin() {
-    List<String> recordedEvents = new ArrayList<String>(); 
-
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState(recordedEvents))
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    
-    // here, inbetween create and begin of a process instance, the variables can be initialized  
-    // or subprocessinstance-superprocessinstance relation can be set up
-
-    // so we verify that the process execution didn't start yet
-    List<String> expectedEvents = new ArrayList<String>();
-    assertEquals(expectedEvents, recordedEvents);
-    
-    processInstance.begin();
-
-    expectedEvents.add("execute[a]");
-    assertEquals(expectedEvents, recordedEvents);
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventPropagationTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventPropagationTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventPropagationTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,356 +0,0 @@
-/*
- * 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.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.listener.EventListener;
-import org.jbpm.pvm.listener.EventListenerExecution;
-import org.jbpm.pvm.model.Event;
-import org.jbpm.pvm.model.Node;
-import org.jbpm.pvm.model.ObservableElement;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- * @author Tom Baeyens
- */
-public class EventPropagationTest extends JbpmTestCase
-{
-  
-  public class Recorder implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public List<Object> events = new ArrayList<Object>();
-    public void notify(EventListenerExecution execution) {
-      ObservableElement element = execution.getEventSource();
-      String elementName = element.getName();
-      events.add(execution.getEvent()+" on "+(elementName!=null ? elementName : element));
-    }
-  }
-  
-  public static class FireableState 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.fire(signalName, execution.getNode());
-    }
-  }
-
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-    }
-  }
-  
-  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){
-    }
-  }
-
-  public void testListenToNodeLeaveOnProcessForProcessNodes(){
-    Recorder recorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event(Event.NODE_END) 
-          .listener(recorder)
-        .node("initial").initial().behaviour(new WaitState())
-          .transition().to("end")
-        .node("end").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    execution.signal();
-    
-    assertEquals("event(node-end) on initial", recorder.events.get(0));
-    assertEquals(1, recorder.events.size());
-  }
-
-  public void testListenToNodeEnterOnProcessForProcessNodes(){
-    Recorder recorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event(Event.NODE_BEGIN) 
-          .listener(recorder)
-        .node("initial").initial().behaviour(new WaitState())
-          .transition().to("end")
-        .node("end").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    execution.signal();
-    
-    assertEquals("event(node-begin) on end", recorder.events.get(0));
-    assertEquals(1, recorder.events.size());
-  }
-
-  public void testListenToTransitionOnProcessForTransitionBetweenProcessNodes(){
-    Recorder recorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event(Event.TRANSITION_TAKE) 
-          .listener(recorder)
-        .node("initial").initial().behaviour(new WaitState())
-          .transition("go").to("end")
-        .node("end").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    execution.signal();
-    
-    assertEquals("event(transition-take) on go", recorder.events.get(0));
-    assertEquals(1, recorder.events.size());
-  }
-
-  // propagation of process elements in composite nodes ///////////////////////
-  
-  public static class Sequence implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      List<Node> nodes = execution.getNode().getNodes();
-      if ( (nodes!=null)
-           && (!nodes.isEmpty())
-         ) {
-        execution.execute(nodes.get(0));
-      }
-    }
-    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) {
-      Node previous = execution.getPreviousNode();
-      List<Node> nodes = execution.getNode().getNodes();
-      int index = nodes.indexOf(previous);
-      index++;
-      if (index < nodes.size()) {
-        Node next = nodes.get(index);
-        execution.execute(next);
-      }
-    }
-  }
-
-  
-  public void testListenToNodeLeaveOnProcessForSequenceChildNodes(){
-    Recorder recorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event(Event.NODE_END) 
-          .listener(recorder)
-        .compositeNode("sequence").initial().behaviour(new Sequence())
-          .needsPrevious()
-            .node("one").behaviour(new WaitState())
-            .node("two").behaviour(new WaitState())
-            .node("three").behaviour(new WaitState())
-        .compositeEnd()
-        .node("end").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    assertEquals(0, recorder.events.size());
-    execution.signal();
-    assertEquals("event(node-end) on one", recorder.events.get(0));
-    assertEquals(1, recorder.events.size());
-    execution.signal();
-    assertEquals("event(node-end) on two", recorder.events.get(1));
-    assertEquals(2, recorder.events.size());
-    execution.signal();
-    assertEquals("event(node-end) on three", recorder.events.get(2));
-    assertEquals(3, recorder.events.size());
-  }
-
-  public void testListenToNodeLeaveOnProcessForTransitionBetweenSequenceChildNodes(){
-    Recorder recorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event(Event.NODE_END) 
-          .listener(recorder)
-        .compositeNode("sequence").initial().behaviour(new Sequence())
-            .node("one").behaviour(new WaitState())
-              .transition().to("two")
-            .node("two").behaviour(new WaitState())
-        .compositeEnd()
-        .node("end").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals(0, recorder.events.size());
-    execution.signal();
-    assertEquals("event(node-end) on one", recorder.events.get(0));
-    assertEquals(1, recorder.events.size());
-    execution.signal();
-    assertEquals("event(node-end) on two", recorder.events.get(1));
-    assertEquals(2, recorder.events.size());
-  }
-
-
-  public void testListenToNodeEnterOnProcessForSequenceChildNodes(){
-    Recorder recorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event(Event.NODE_BEGIN) 
-          .listener(recorder)
-        .compositeNode("sequence").initial().behaviour(new Sequence())
-          .needsPrevious()
-            .node("one").behaviour(new WaitState())
-            .node("two").behaviour(new WaitState())
-            .node("three").behaviour(new WaitState())
-        .compositeEnd()
-        .node("end").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    assertEquals("event(node-begin) on one", recorder.events.get(0));
-    assertEquals(1, recorder.events.size());
-    execution.signal();
-    assertEquals("event(node-begin) on two", recorder.events.get(1));
-    assertEquals(2, recorder.events.size());
-    execution.signal();
-    assertEquals("event(node-begin) on three", recorder.events.get(2));
-    assertEquals(3, recorder.events.size());
-  }
-
-  public void testListenToTransitionTakeOnProcessForTransitionBetweenSequenceChildNodes(){
-    Recorder recorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event(Event.TRANSITION_TAKE) 
-          .listener(recorder)
-        .compositeNode("sequence").initial().behaviour(new Sequence())
-            .node("one").behaviour(new WaitState())
-              .transition("increment").to("two")
-            .node("two").behaviour(new WaitState())
-          .compositeEnd()
-        .node("end").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    
-    assertEquals(0, recorder.events.size());
-    execution.signal();
-    assertEquals("event(transition-take) on increment", recorder.events.get(0));
-    assertEquals(1, recorder.events.size());
-  }
-
-  public void testDeeplyNestedCustomEvent(){
-    Recorder processRecorder = new Recorder();
-    Recorder outerRecorder = new Recorder();
-    Recorder middelRecorder = new Recorder();
-    Recorder innerRecorder = new Recorder();
-    Recorder nestedStateRecorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event("hello") 
-          .listener(processRecorder)
-        .compositeNode("outer").initial().behaviour(new Sequence())
-          .event("hello") 
-            .listener(outerRecorder)
-            .compositeNode("middel").behaviour(new Sequence())
-              .event("hello") 
-                .listener(middelRecorder)
-                .compositeNode("inner").behaviour(new Sequence())
-                  .event("hello") 
-                    .listener(innerRecorder)
-                    .node("nested state").behaviour(new FireableState())
-                      .event("hello") 
-                        .listener(nestedStateRecorder)
-                .compositeEnd()
-            .compositeEnd()
-        .compositeEnd()
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    
-    assertEquals(0, processRecorder.events.size());
-    execution.signal("hello");
-    
-    assertEquals("event(hello) on nested state", processRecorder.events.get(0));
-    assertEquals(1, processRecorder.events.size());
-
-    assertEquals("event(hello) on nested state", outerRecorder.events.get(0));
-    assertEquals(1, outerRecorder.events.size());
-
-    assertEquals("event(hello) on nested state", middelRecorder.events.get(0));
-    assertEquals(1, middelRecorder.events.size());
-
-    assertEquals("event(hello) on nested state", innerRecorder.events.get(0));
-    assertEquals(1, innerRecorder.events.size());
-
-    assertEquals("event(hello) on nested state", nestedStateRecorder.events.get(0));
-    assertEquals(1, nestedStateRecorder.events.size());
-  }
-
-  public void testPropagatedEventsDisabled(){
-    Recorder processRecorder = new Recorder();
-    Recorder outerRecorder = new Recorder();
-    Recorder middleRecorder = new Recorder();
-    Recorder innerRecorder = new Recorder();
-    Recorder nestedStateRecorder = new Recorder();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("propagate")
-        .event("hello") 
-          .listener(processRecorder)
-        .compositeNode("outer").initial().behaviour(new Sequence())
-          .event("hello") 
-            .listener(outerRecorder)
-          .compositeNode("middle").behaviour(new Sequence())
-            .event("hello") 
-              .listener(middleRecorder)
-            .propagationDisabled()
-            .compositeNode("inner").behaviour(new Sequence())
-              .event("hello") 
-                .listener(innerRecorder)
-                .node("nested state").behaviour(new FireableState())
-                  .event("hello") 
-                    .listener(nestedStateRecorder)
-            .compositeEnd()
-          .compositeEnd()
-        .compositeEnd()
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    // the middle action should not be executed for an event that was propagated from the nested state 
-    execution.signal("hello");
-    
-    assertEquals("event(hello) on nested state", processRecorder.events.get(0));
-    assertEquals(1, processRecorder.events.size());
-
-    assertEquals("event(hello) on nested state", outerRecorder.events.get(0));
-    assertEquals(1, outerRecorder.events.size());
-
-    assertEquals(0, middleRecorder.events.size());
-
-    assertEquals("event(hello) on nested state", innerRecorder.events.get(0));
-    assertEquals(1, innerRecorder.events.size());
-
-    assertEquals("event(hello) on nested state", nestedStateRecorder.events.get(0));
-    assertEquals(1, nestedStateRecorder.events.size());
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/EventTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,264 +0,0 @@
-/*
- * 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.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.listener.EventListener;
-import org.jbpm.pvm.listener.EventListenerExecution;
-import org.jbpm.pvm.model.Event;
-import org.jbpm.pvm.model.Node;
-import org.jbpm.pvm.model.ObservableElement;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/** shows how actions are listeners to following processDefinition events:
- * <ul>
- *   <li>node-leave</li>
- *   <li>transition</li>
- *   <li>node-enter</li>
- *   <li>custom event</li>
- * </ul>
- *
- * @author Tom Baeyens
- */
-public class EventTest extends JbpmTestCase {
-  
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-    }
-  }
-  
-  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){
-      execution.take(signalName);
-    }
-  }
-
-  
-  // node leave action ////////////////////////////////////////////////////////
-  
-  public static class NodeLeaveAction implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public void notify(EventListenerExecution execution) {
-      execution.setVariable("msg", "Kilroy was here");
-
-      assertEquals("initial", execution.getNode().getName());
-      assertEquals("initial", execution.getEventSource().getName());
-      assertEquals("leave node action test", execution.getProcessDefinition().getName());
-      assertEquals("end", execution.getTransition().getDestination().getName());
-    }
-  }
-  
-  public void testEventListenerOnNodeEnd() {
-    NodeLeaveAction nodeLeaveAction = new NodeLeaveAction();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("leave node action test")
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(nodeLeaveAction)
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    execution.signal();
-    assertEquals("Kilroy was here", execution.getVariable("msg"));
-  }
-
-  // transition action ////////////////////////////////////////////////////////
-
-  public static class TransitionAction implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public void notify(EventListenerExecution execution) throws Exception {
-      execution.setVariable("msg", "Kilroy was here");
-      
-      assertNull(execution.getNode());
-      assertEquals("t", execution.getEventSource().getName());
-      assertEquals("transition action test", execution.getProcessDefinition().getName());
-      assertEquals("end", execution.getTransition().getDestination().getName());
-    }
-  }
-  
-  public void testEventListenerOnTransition() {
-    TransitionAction transitionAction = new TransitionAction();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("transition action test")
-      .node("initial").initial().behaviour(new WaitState())
-        .transition("t").to("end")
-          .listener(transitionAction)
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    execution.signal("t");
-    assertEquals("Kilroy was here", execution.getVariable("msg"));
-  }
-
-  // node enter action ////////////////////////////////////////////////////////
-
-  public static class NodeBeginAction implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public void notify(EventListenerExecution execution) throws Exception {
-      execution.setVariable("msg", "Kilroy was here");
-      
-      assertEquals("end", execution.getNode().getName());
-      assertEquals("end", execution.getEventSource().getName());
-      assertEquals("enter node action test", execution.getProcessDefinition().getName());
-      assertEquals("end", execution.getTransition().getDestination().getName());
-    }
-  }
-  
-  public void testEventListenerOnNodeBegin() {
-    NodeBeginAction nodeBeginAction = new NodeBeginAction();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("enter node action test")
-      .node("initial").initial().behaviour(new WaitState())
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-        .event(Event.NODE_BEGIN)
-          .listener(nodeBeginAction)
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    execution.signal();
-    assertEquals("Kilroy was here", execution.getVariable("msg"));
-  }
-
-  // custom event ////////////////////////////////////////////////////////////
-  
-  public static class WaitStateWithCustomEvent implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) throws Exception {
-      execution.waitForSignal();
-    }
-    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
-      Node node = execution.getNode();
-      if ( (signal!=null)
-           && (node!=null)
-           && (node.hasEvent(signal))
-         ) {
-        execution.fire(signal, node);
-        execution.waitForSignal();
-      }
-    }
-  }
-
-  public static class CheckRivetsAction implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public void notify(EventListenerExecution execution) throws Exception {
-      execution.setVariable("msg", "Kilroy was here");
-      
-      assertEquals("initial", execution.getNode().getName());
-      assertEquals("initial", execution.getEventSource().getName());
-      assertEquals("custom node action test", execution.getProcessDefinition().getName());
-      assertNull(execution.getTransition());
-    }
-  }
-
-  public void testCustomEventInNode() {
-    CheckRivetsAction checkRivetsAction = new CheckRivetsAction();
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("custom node action test")
-      .node("initial").initial().behaviour(new WaitStateWithCustomEvent())
-        .event("end of riveter shift") // http://en.wikipedia.org/wiki/Kilroy_was_here
-          .listener(checkRivetsAction)
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    assertNull(execution.getVariable("msg"));
-
-    execution.signal("end of riveter shift");
-
-    assertEquals("initial", execution.getNode().getName());
-    assertEquals("Kilroy was here", execution.getVariable("msg"));
-    
-    execution.signal();
-
-    assertEquals("end", execution.getNode().getName());
-  }
-
-  public static class EndState implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) throws Exception {
-      execution.end();
-    }
-  }
-
-  public static class RecordingProcessDefinition extends ProcessDefinitionImpl {
-    private static final long serialVersionUID = 1L;
-    protected ExecutionImpl newProcessInstance() {
-      return new RecordingExecution();
-    }
-  }
-  
-  public static class RecordingExecution extends ExecutionImpl {
-    private static final long serialVersionUID = 1L;
-    List<String> events = new ArrayList<String>();
-    public void fire(String eventName, ObservableElement eventSource) {
-      events.add(eventName+" on "+eventSource);
-    }
-  }
-  
-  public void testBasicEventSequence() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build("basic", new RecordingProcessDefinition())
-        .node("initial").initial().behaviour(new AutomaticActivity())
-          .transition().to("end")
-        .node("end").behaviour(new EndState())
-    .done();
-
-    RecordingExecution execution = (RecordingExecution) processDefinition.beginProcessInstance();
-
-    int index = 0;
-    assertEquals("process-begin on processDefinition(basic)", execution.events.get(index));
-    index++;
-    assertEquals("node-end on node(initial)", execution.events.get(index));
-    index++;
-    assertEquals("transition-take on (initial)-->(end)", execution.events.get(index));
-    index++;
-    assertEquals("node-begin on node(end)", execution.events.get(index));
-    index++;
-    assertEquals("process-end on processDefinition(basic)", execution.events.get(index));
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExceptionHandlerTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExceptionHandlerTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExceptionHandlerTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,323 +0,0 @@
-/*
- * 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.client;
-
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.listener.EventListener;
-import org.jbpm.pvm.listener.EventListenerExecution;
-import org.jbpm.pvm.model.Event;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- * @author Tom Baeyens
- */
-public class ExceptionHandlerTest extends JbpmTestCase
-{
-  
-  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){
-    }
-  }
-
-  public static class Catcher implements EventListener {
-    private static final long serialVersionUID = 1L;
-    int timesInvoked = 0;
-    public void notify(EventListenerExecution execution) {
-      timesInvoked++;
-    }
-  }
-
-  public static class Batter implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public void notify(EventListenerExecution execution) {
-      throw new RuntimeException("catch me");
-    }
-  }
-  
-  public void testExceptionHandlerOnProcessDefinition() {
-    Catcher catcher = new Catcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .exceptionHandler(RuntimeException.class)
-        .listener(catcher)
-      .exceptionHandlerEnd()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(new Batter())
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    assertEquals(0, catcher.timesInvoked);
-    execution.signal();
-    assertEquals(1, catcher.timesInvoked);
-    assertEquals("end", execution.getNode().getName());
-  }
-
-  public void testExceptionHandlerOnEvent() {
-    Catcher catcher = new Catcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .exceptionHandler(RuntimeException.class)
-            .listener(catcher)
-          .exceptionHandlerEnd()
-          .listener(new Batter())
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    assertEquals(0, catcher.timesInvoked);
-    execution.signal();
-    assertEquals(1, catcher.timesInvoked);
-    assertEquals("end", execution.getNode().getName());
-  }
-
-  public void testExceptionHandlerOnAction() {
-    Catcher catcher = new Catcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(new Batter())
-            .exceptionHandler(RuntimeException.class)
-              .listener(catcher)
-            .exceptionHandlerEnd()
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    assertEquals(0, catcher.timesInvoked);
-    execution.signal();
-    assertEquals(1, catcher.timesInvoked);
-    assertEquals("end", execution.getNode().getName());
-  }
-
-  public void testExceptionHandlerOnOtherNode() {
-    Catcher catcher = new Catcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(new Batter())
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-        .exceptionHandler(RuntimeException.class)
-          .listener(catcher)
-        .exceptionHandlerEnd()
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    assertEquals(0, catcher.timesInvoked);
-    try {
-      execution.signal();
-      fail("expected exception");
-    } catch (RuntimeException e) {
-      // OK
-    }
-  }
-
-  public void testExceptionHandlerOnOtherEvent() {
-    Catcher catcher = new Catcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event("other")
-          .exceptionHandler(RuntimeException.class)
-            .listener(catcher)
-          .exceptionHandlerEnd()
-        .event(Event.NODE_END)
-          .listener(new Batter())
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    try {
-      execution.signal();
-      fail("expected exception");
-    } catch (RuntimeException e) {
-      // OK
-    }
-  }
-
-  public static class BehavedAction implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public void notify(EventListenerExecution execution) {
-      // behaving.  not throwing any exception
-    }
-  }
-
-  public void testExceptionHandlerOnOtherAction() {
-    Catcher catcher = new Catcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(new BehavedAction())
-            .exceptionHandler(RuntimeException.class)
-              .listener(catcher)
-            .exceptionHandlerEnd()
-          .listener(new Batter())
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    try {
-      execution.signal();
-      fail("expected exception");
-    } catch (RuntimeException e) {
-      // OK
-    }
-  }
-
-  public void testUnmatchedExceptionHandlerOnAction() {
-    Catcher catcher = new Catcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(new Batter())
-            .exceptionHandler(NullPointerException.class)
-              .listener(catcher)
-            .exceptionHandlerEnd()
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    try {
-      execution.signal();
-      fail("expected exception");
-    } catch (RuntimeException e) {
-      // OK
-    }
-  }
-
-  public static class RethrowingCatcher implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public void notify(EventListenerExecution execution) {
-      // this exception handler will itself throw an exception
-      throw new RuntimeException("greetz from the retrhowing catcher");
-    }
-  }
-
-
-  public void testRethrowingExceptionHandler() {
-    RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(new Batter())
-            .exceptionHandler(RuntimeException.class)
-              .listener(rethrowingCatcher)
-            .exceptionHandlerEnd()
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    try {
-      execution.signal();
-      fail("expected exception");
-    } catch (RuntimeException e) {
-      assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
-    }
-  }
-
-  public void testRethrowingExceptionHandlerCaughtByTheOuterExceptionHandler() {
-    
-    // just like in java, when an exception handler rethrows, the search 
-    // for a matching exception handler will continue in the outer scope 
-    // (=the surrounding process element)
-    
-    RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .exceptionHandler(RuntimeException.class)
-            .listener(new Catcher())
-          .exceptionHandlerEnd()
-          .listener(new Batter())
-            .exceptionHandler(RuntimeException.class)
-              .listener(rethrowingCatcher)
-            .exceptionHandlerEnd()
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("initial", execution.getNode().getName());
-    execution.signal();
-  }
-
-  public void testRethrowingExceptionHandlerIgnoredByTheSubsequentExceptionHandlerInTheSameScope() {
-    
-    // just like in java, subsequent exception handlers will be skipped when the 
-    // an exception handler rethrows
-    
-    RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("initial").initial().behaviour(new WaitState())
-        .event(Event.NODE_END)
-          .listener(new Batter())
-            .exceptionHandler(RuntimeException.class)
-              .listener(rethrowingCatcher)
-            .exceptionHandlerEnd()
-            .exceptionHandler(RuntimeException.class)
-              .listener(new Catcher())
-            .exceptionHandlerEnd()
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-      .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    try {
-      execution.signal();
-      fail("expected exception");
-    } catch (RuntimeException e) {
-      assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
-    }
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExecutionStateTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExecutionStateTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExecutionStateTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,219 +0,0 @@
-/*
- * 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.client;
-
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.Execution;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/** shows the basics of the state property on the execution.
- * 
- * The state is automatically managed by the execution.
- * An execution can only receive external triggers in case it is in 
- * the active state.  
- * 
- * Nested executions can occur in case of scoped executions
- * and in case of concurrent executions.  In both cases, only 
- * leave executions in the execution hierarchy are active.
- * 
- * Executions are either locked or active.  So in any state which 
- * is not active, the execution is locked and cannot accept external 
- * signals.  Executions can be ended in 3 ways:
- * 
- *  1) with execution.end() : then the state will be set to 'ended'
- *  2) with execution.cancel() : then the state will be set to 'cancelled'
- *  3) with execution.end(String) : then the state will be set to the 
- *     given state string.  An exception will be raised if the given 
- *     state maches any of the known states.
- * 
- * @author Tom Baeyens
- */
-public class ExecutionStateTest extends JbpmTestCase {
-
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      assertEquals(Execution.STATE_ACTIVE, execution.getState());
-    }
-  }
-
-  public static class WaitState implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      assertEquals(Execution.STATE_ACTIVE, execution.getState());
-      execution.waitForSignal();
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
-      assertEquals(Execution.STATE_ACTIVE, execution.getState());
-      execution.take(signalName);
-    }
-  }
-  
-  public void testBasicState() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new AutomaticActivity())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .transition().to("c")
-      .node("c").behaviour(new AutomaticActivity())
-    .done();
-
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    
-    assertEquals(Execution.STATE_CREATED, processInstance.getState());
-    
-    processInstance.begin();
-
-    assertEquals(Execution.STATE_ACTIVE, processInstance.getState());
-
-    processInstance.signal();
-
-    assertEquals(Execution.STATE_ENDED, processInstance.getState());
-  }
-
-  public void testSignalOnInactiveExecution() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new AutomaticActivity())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .scope()
-        .transition().to("c")
-      .node("c").behaviour(new AutomaticActivity())
-    .done();
-  
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    processInstance.begin();
-  
-    assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
-  
-    try {
-      processInstance.signal();
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("process-instance is not active: inactive", e.getMessage());
-    }
-  }
-  
-  public void testCancel() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new AutomaticActivity())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .transition().to("c")
-      .node("c").behaviour(new AutomaticActivity())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    processInstance.begin();
-    processInstance.cancel();
-    
-    assertEquals(Execution.STATE_CANCELLED, processInstance.getState());
-    
-    try {
-      processInstance.signal();
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("process-instance is not active: cancelled", e.getMessage());
-    }
-  }
-
-  public void testCustomState() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new AutomaticActivity())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .transition().to("c")
-      .node("c").behaviour(new AutomaticActivity())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    processInstance.begin();
-    processInstance.end("error");
-    
-    assertEquals("error", processInstance.getState());
-    
-    try {
-      processInstance.signal();
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("process-instance is not active: error", e.getMessage());
-    }
-  }
-
-  public void testInvalidCustomStates() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new AutomaticActivity())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .transition().to("c")
-      .node("c").behaviour(new AutomaticActivity())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    processInstance.begin();
-    
-    try {
-      processInstance.end("active");
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("invalid end state: active", e.getMessage());
-    }
-    try {
-      processInstance.end("suspended");
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("invalid end state: suspended", e.getMessage());
-    }
-    try {
-      processInstance.end("created");
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("invalid end state: created", e.getMessage());
-    }
-    try {
-      processInstance.end("async");
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("invalid end state: async", e.getMessage());
-    }
-    try {
-      processInstance.end("inactive");
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("invalid end state: inactive", e.getMessage());
-    }
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExternalDecisionTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExternalDecisionTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ExternalDecisionTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,98 +0,0 @@
-/*
- * 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.client;
-
-import junit.framework.TestCase;
-import org.jbpm.pvm.samples.activities.AutomaticActivity;
-import org.jbpm.pvm.samples.activities.WaitState;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.samples.ex04.Decision;
-import org.jbpm.pvm.model.ProcessFactory;
-
-import java.util.Map;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExternalDecisionTest extends TestCase {
-  
-  public static class ExternalDecision implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    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);
-    }
-  }
-  
-  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) {
-      execution.take(signalName);
-    }
-  }
-
-  public static ClientProcessDefinition createCreditProcess() {
-    return ProcessFactory.build()
-      .node("creditRate?").initial().behaviour(new ExternalDecision())
-        .transition("good").to("priority delivery")
-        .transition("average").to("bulk delivery")
-        .transition("bad").to("payment upfront")
-      .node("priority delivery").behaviour(new WaitState())
-      .node("bulk delivery").behaviour(new WaitState())
-      .node("payment upfront").behaviour(new WaitState())
-    .done();
-  }
-
-  public void testGoodRating() {
-    ClientProcessDefinition processDefinition = createCreditProcess(); 
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    execution.signal("good");
-
-    assertEquals("priority delivery", execution.getNode().getName());
-  }
-
-  public void testAverageRating() {
-    ClientProcessDefinition processDefinition = createCreditProcess(); 
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    execution.signal("average");
-    
-    assertEquals("bulk delivery", execution.getNode().getName());
-  }
-  
-  public void testBadRating() {
-    ClientProcessDefinition processDefinition = createCreditProcess(); 
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    execution.signal("bad");
-
-    assertEquals("payment upfront", execution.getNode().getName());
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/FunctionalActivityTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/FunctionalActivityTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/FunctionalActivityTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,156 +0,0 @@
-/*
- * 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.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.listener.EventListener;
-import org.jbpm.pvm.listener.EventListenerExecution;
-import org.jbpm.pvm.model.Node;
-import org.jbpm.pvm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-
-
-/** shows how functional nodes (nodes that have a specific function 
- * not related to control flow) can be implemented.
- * 
- * Examples of functional nodes could be sending an email, doing a 
- * SQL update on a database, generating a file and so on.
- * 
- * Functional nodes can be used as node behaviour in a transition based 
- * process, event listener and as node behaviour in nested node 
- * execution.
- * 
- * @author Tom Baeyens
- */
-public class FunctionalActivityTest extends JbpmTestCase
-{
-
-  public static class FunctionalActivity implements Activity, EventListener {
-    private static final long serialVersionUID = 1L;
-    List<String> events;
-    public FunctionalActivity(List<String> events) {
-      this.events = events;
-    }
-    public void execute(ActivityExecution execution) {
-      perform(execution);
-    }
-    public void notify(EventListenerExecution execution) {
-      perform(execution);
-    }
-    void perform(OpenExecution execution) {
-      events.add("performed automatic activity");
-    }
-  }
-
-  public void testFunctionalActivityAsNodeBehaviourWithTransitions() {
-    List<String> recordedEvents = new ArrayList<String>(); 
-    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
-
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(functionalActivity)
-        .transition().to("b")
-      .node("b").behaviour(functionalActivity)
-        .transition().to("c")
-      .node("c").behaviour(functionalActivity)
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    
-    List<String> expectedEvents = new ArrayList<String>();
-    
-    assertEquals("a", processInstance.getNodeName());
-    assertFalse(processInstance.isEnded());
-    assertEquals(expectedEvents, recordedEvents);
-    
-    processInstance.begin();
-    
-    expectedEvents.add("performed automatic activity");
-    expectedEvents.add("performed automatic activity");
-    expectedEvents.add("performed automatic activity");
-
-    assertEquals(expectedEvents, recordedEvents);
-  }
-
-  
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-    }
-  }
-
-  public void testFunctionalActivityAsEventListener() {
-    List<String> recordedEvents = new ArrayList<String>(); 
-    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
-
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new AutomaticActivity())
-        .transition().to("b")
-          .listener(functionalActivity)
-      .node("b").behaviour(new AutomaticActivity())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    processInstance.begin();
-    
-    List<String> expectedEvents = new ArrayList<String>();
-    expectedEvents.add("performed automatic activity");
-
-    assertEquals(expectedEvents, recordedEvents);
-  }
-
-  public static class Composite implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      Node nestedNode = execution.getNode().getNodes().get(0);
-      execution.execute(nestedNode);
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
-    }
-  }
-
-  public void testFunctionalActivityAsNestedNode() {
-    List<String> recordedEvents = new ArrayList<String>(); 
-    FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
-
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .compositeNode("a").initial().behaviour(new Composite())
-        .node().behaviour(functionalActivity)
-      .compositeEnd()
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    processInstance.begin();
-    
-    List<String> expectedEvents = new ArrayList<String>();
-    expectedEvents.add("performed automatic activity");
-
-    assertEquals(expectedEvents, recordedEvents);
-  }
-
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/LoopingTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/LoopingTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/LoopingTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,103 +0,0 @@
-package org.jbpm.pvm.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.ProcessFactory;
-
-public class LoopingTest extends JbpmTestCase
-{
-  
-  public static class For implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-
-    int startIndex = 0;
-    int loops;
-    int increment = 1;
-    String indexKey = "index";
-
-    public For(int loops) {
-      this.loops = loops;
-    }
-
-    public void execute(ActivityExecution execution) throws Exception {
-      Integer index = (Integer) execution.getVariable(indexKey);
-
-      if (index==null) {
-        execution.setVariable(indexKey, startIndex);
-        execution.take("loop");
-        
-      } else {
-        index++;
-        if (index<(startIndex+loops)){
-          execution.setVariable(indexKey, index);
-          execution.take("loop");
-          
-        } else {
-          execution.removeVariable(indexKey);
-          execution.take("done");
-        }
-      }
-    }
-    public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
-      throw new UnsupportedOperationException();
-    }
-    
-    public void setStartIndex(int startIndex) {
-      this.startIndex = startIndex;
-    }
-    public void setLoops(int loops) {
-      this.loops = loops;
-    }
-    public void setIncrement(int increment) {
-      this.increment = increment;
-    }
-    public void setIndexVariable(String indexVariable) {
-      this.indexKey = indexVariable;
-    }
-  }
-
-  static List<Object> recordedIndexes = new ArrayList<Object>();
-  
-  public static class Recorder implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) throws Exception {
-      recordedIndexes.add(execution.getVariable("index"));
-    }
-  }
-
-  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){
-    }
-  }
-
-  public void testWhile() {
-    int loops = 20;
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("for").initial().behaviour(new For(loops))
-        .transition("loop").to("recorder")
-        .transition("done").to("end")
-      .node("recorder").behaviour(new Recorder())
-        .transition().to("for")
-      .node("end").behaviour(new WaitState())
-    .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-    
-    List<Object> expectedIndexes = new ArrayList<Object>();
-    for (int i=0; i<loops; i++) expectedIndexes.add(i); 
-
-    assertEquals(expectedIndexes, recordedIndexes);
-    assertEquals("end", execution.getNode().getName());
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/PvmClientTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/PvmClientTests.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/PvmClientTests.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,57 +0,0 @@
-/*
- * 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.client;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-/**
- * @author Tom Baeyens
- */
-public class PvmClientTests {
-
-  public static Test suite() {
-    TestSuite suite = new TestSuite("Test for org.jbpm.pvm.client");
-    //$JUnit-BEGIN$
-    suite.addTestSuite(BasicExecutionFlowTest.class);
-    suite.addTestSuite(TransitionAsWaitStateTest.class);
-    suite.addTestSuite(TransitionBasedConcurrencyTest.class);
-    suite.addTestSuite(ScopeStateTest.class);
-    suite.addTestSuite(SubProcessTest.class);
-    suite.addTestSuite(ExecutionStateTest.class);
-    suite.addTestSuite(ExceptionHandlerTest.class);
-    suite.addTestSuite(FunctionalActivityTest.class);
-    suite.addTestSuite(ScopeVariableDeclarationTest.class);
-    suite.addTestSuite(LoopingTest.class);
-    suite.addTestSuite(TransitionEventsTest.class);
-    suite.addTestSuite(ExternalDecisionTest.class);
-    suite.addTestSuite(VariableTest.class);
-    suite.addTestSuite(ScopeVariableTest.class);
-    suite.addTestSuite(EventTest.class);
-    suite.addTestSuite(AutomaticDecisionTest.class);
-    suite.addTestSuite(EventPropagationTest.class);
-    //$JUnit-END$
-    return suite;
-  }
-
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeStateTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeStateTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeStateTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,83 +0,0 @@
-/*
- * 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.client;
-
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.Execution;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- * @author Tom Baeyens
- */
-public class ScopeStateTest extends JbpmTestCase
-{
-
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      assertEquals(Execution.STATE_ACTIVE, execution.getState());
-    }
-  }
-
-  public static class WaitState implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      assertEquals(Execution.STATE_ACTIVE, execution.getState());
-      execution.waitForSignal();
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
-      assertEquals(Execution.STATE_ACTIVE, execution.getState());
-      execution.take(signalName);
-    }
-  }
-
-  public void testInactivationWhenCreatingNestedExecution() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new AutomaticActivity())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .scope()
-        .transition().to("c")
-      .node("c").behaviour(new WaitState())
-    .done();
-  
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    
-    assertEquals(Execution.STATE_CREATED, processInstance.getState());
-    
-    processInstance.begin();
-    Execution scopeExecution = processInstance.getExecutions().iterator().next();
-
-    assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
-    assertEquals(Execution.STATE_ACTIVE, scopeExecution.getState());
-    
-    processInstance.signal(scopeExecution);
-
-    assertEquals(Execution.STATE_ENDED, scopeExecution.getState());
-    assertEquals(Execution.STATE_ACTIVE, processInstance.getState());
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableDeclarationTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableDeclarationTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableDeclarationTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,221 +0,0 @@
-/*
- * 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.client;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.Node;
-import org.jbpm.pvm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ScopeVariableDeclarationTest extends JbpmTestCase
-{
-
-  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) {
-      execution.take(signalName);
-    }
-  }
-  
-  public static class Composite implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      Node child = execution.getNode().getNodes().get(0);
-      execution.execute(child);
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
-    }
-  }
-  
-  public void testProcessInstanceVariableDeclaration() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .variable("flight")
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-
-    assertTrue(processInstance.hasVariable("flight"));
-    assertNull(processInstance.getVariable("flight"));
-  }
-
-  public void testProcessInstanceVariableDeclarationWithInitialValue() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .variable("flight", "B52")
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-
-    assertTrue(processInstance.hasVariable("flight"));
-    assertEquals("B52", processInstance.getVariable("flight"));
-  }
-
-  public void testNestedScopeDeclarations() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .variable("flight", "B52")
-      .compositeNode("outer").behaviour(new Composite())
-        .variable("duration", "22 minutes")
-        .compositeNode("middle").behaviour(new Composite())
-          .variable("altitude", "31000 ft")
-          .compositeNode("inner").behaviour(new Composite())
-            .variable("passengers", "52")
-            .compositeNode("start").initial().behaviour(new WaitState())
-              .variable("fuel", "kerosine")
-            .compositeEnd()
-          .compositeEnd()
-        .compositeEnd()
-      .compositeEnd()
-    .done();
-    
-    Map<String, Object> expectedVariables = new HashMap<String, Object>();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    expectedVariables.put("flight", "B52");
-    assertEquals(expectedVariables, processInstance.getVariables());
-    
-    OpenExecution outerExecution = processInstance.getExecution("outer");
-    expectedVariables.put("duration", "22 minutes");
-    assertEquals(expectedVariables, outerExecution.getVariables());
-
-    OpenExecution middleExecution = outerExecution.getExecution("middle");
-    expectedVariables.put("altitude", "31000 ft");
-    assertEquals(expectedVariables, middleExecution.getVariables());
-
-    OpenExecution innerExecution = middleExecution.getExecution("inner");
-    expectedVariables.put("passengers", "52");
-    assertEquals(expectedVariables, innerExecution.getVariables());
-
-    OpenExecution startExecution = innerExecution.getExecution("start");
-    expectedVariables.put("fuel", "kerosine");
-    assertEquals(expectedVariables, startExecution.getVariables());
-  }
-
-  public void testHiddenVariable() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .variable("flight", "B52")
-      .compositeNode("c").behaviour(new Composite())
-        .variable("flight", "U2")
-        .node("i").initial().behaviour(new WaitState())
-          .variable("flight", "C130")
-      .compositeEnd()
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    OpenExecution executionC = processInstance.getExecution("c");
-    OpenExecution executionI = executionC.getExecution("i");
-    
-    assertEquals("B52", processInstance.getVariable("flight"));
-    assertEquals("U2", executionC.getVariable("flight"));
-    assertEquals("C130", executionI.getVariable("flight"));
-  }
-
-  public void testAutomaticScopeManagement() {
-    /*
-    process 
-     ${flight} = 'B52'
-    +--------------------------------------------------------------------+
-    | outer                                                              |
-    |  ${duration} = '22 minutes'                                        |
-    | +-------------------------------+                                  |  
-    | | left-middle                   |                                  |
-    | |  ${altitude} = '31000 ft'     |                                  |
-    | | +---------------------------+ |   +----------------------------+ |
-    | | | left-inner                | |   | right-middle               | |       
-    | | |  ${passengers}            | |   |  ${customer} = 'coca cola' | |       
-    | | | +-----------------------+ | |   |  +--------------------+    | |
-    | | | | left-start            | -------> | right-inner        |    | |
-    | | | |  ${fuel} = 'kerosine' | | |   |  |  ${date} = 'today' |    | |
-    | | | +-----------------------+ | |   |  +--------------------+    | |
-    | | +---------------------------+ |   +----------------------------+ |
-    +--------------------------------------------------------------------+
-    */
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .variable("flight", "B52")
-      .compositeNode("outer").behaviour(new Composite())
-        .variable("duration", "22 minutes")
-        .compositeNode("left-middle").behaviour(new Composite())
-          .variable("altitude", "31000 ft")
-          .compositeNode("left-inner").behaviour(new Composite())
-            .variable("passengers", "52")
-            .compositeNode("left-start").initial().behaviour(new WaitState())
-              .variable("fuel", "kerosine")
-              .transition().to("right-inner")
-            .compositeEnd()
-          .compositeEnd()
-        .compositeEnd()
-        .compositeNode("right-middle").behaviour(new Composite())
-          .variable("customer", "coca-cola")
-          .compositeNode("right-inner").behaviour(new WaitState())
-            .variable("date", "today")
-          .compositeEnd()
-        .compositeEnd()
-      .compositeEnd()
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    OpenExecution outerExecution = processInstance.getExecution("outer");
-    OpenExecution leftMiddleExecution = outerExecution.getExecution("left-middle");
-    OpenExecution leftInnerExecution = leftMiddleExecution.getExecution("left-inner");
-    OpenExecution leftStartExecution = leftInnerExecution.getExecution("left-start");
-
-    Map<String, Object> expectedVariables = new HashMap<String, Object>();
-    expectedVariables.put("flight", "B52");
-    expectedVariables.put("duration", "22 minutes");
-    expectedVariables.put("altitude", "31000 ft");
-    expectedVariables.put("passengers", "52");
-    expectedVariables.put("fuel", "kerosine");
-    assertEquals(expectedVariables, leftStartExecution.getVariables());
-
-    processInstance.signal(leftStartExecution);
-
-    OpenExecution rightMiddleExecution = outerExecution.getExecution("right-middle");
-    OpenExecution rightInnerExecution = rightMiddleExecution.getExecution("right-inner");
-
-    expectedVariables = new HashMap<String, Object>();
-    expectedVariables.put("flight", "B52");
-    expectedVariables.put("duration", "22 minutes");
-    
-    assertEquals(expectedVariables, outerExecution.getVariables());
-    
-    expectedVariables.put("customer", "coca-cola");
-    assertEquals(expectedVariables, rightMiddleExecution.getVariables());
-
-    expectedVariables.put("date", "today");
-    assertEquals(expectedVariables, rightInnerExecution.getVariables());
-  }
-
-
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/ScopeVariableTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,185 +0,0 @@
-/*
- * 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.client;
-
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- *  
- *    +---+     +--------+     +---+ 
- *    | a |     | b      |     | c |
- *    |   | --> |        | --> |   |  
- *    |   |     | SCOPE! |     |   |
- *    +---+     +--------+     +---+  
- *
- * @author Tom Baeyens
- */
-public class ScopeVariableTest extends JbpmTestCase
-{
-
-  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) {
-      execution.take(signalName);
-    }
-  }
-  
-  public void testOuterscopeLookup() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .scope() // !!!!
-        .transition().to("c")
-      .node("c").behaviour(new WaitState())
-    .done();
-  
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    processInstance.setVariable("destination", "anywhere");
-    
-    processInstance.signal();
-    
-    OpenExecution bScope = processInstance.getExecution("b");
-
-    // check if the global vars are still visible within the scope for b.
-    assertEquals("anywhere", bScope.getVariable("destination"));
-    
-    bScope.createVariable("temp", "23C");
-    assertEquals("23C", bScope.getVariable("temp"));
-    assertNull(processInstance.getVariable("temp"));
-  }
-
-  public void testLocalVariableLookup() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .scope() // !!!!
-        .transition().to("c")
-      .node("c").behaviour(new WaitState())
-    .done();
-  
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-
-    processInstance.signal();
-    OpenExecution bScope = processInstance.getExecution("b");
-
-    bScope.createVariable("temp", "23C");
-    
-    assertEquals("23C", bScope.getVariable("temp"));
-    assertNull(processInstance.getVariable("temp"));
-    
-    processInstance.signal(bScope);
-    
-    assertTrue(bScope.isEnded());
-    assertNull(processInstance.getVariable("temp"));
-  }
-
-  public void testLocalVariableUpdate() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .scope() // !!!!
-        .transition().to("c")
-      .node("c").behaviour(new WaitState())
-    .done();
-  
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-
-    processInstance.signal();
-    OpenExecution bScope = processInstance.getExecution("b");
-
-    bScope.createVariable("temp", "23C");
-    bScope.setVariable("temp", "28C");
-    
-    assertEquals("28C", bScope.getVariable("temp"));
-    
-    processInstance.signal(bScope);
-    
-    assertTrue(bScope.isEnded());
-    assertNull(processInstance.getVariable("temp"));
-  }
-
-  public void testDefaultCreationOnGlobalScope() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .scope() // !!!!
-        .transition().to("c")
-      .node("c").behaviour(new WaitState())
-    .done();
-  
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-
-    processInstance.signal();
-    OpenExecution bScope = processInstance.getExecution("b");
-
-    bScope.setVariable("temp", "28C");
-    assertEquals("28C", bScope.getVariable("temp"));
-    
-    processInstance.signal(bScope);
-    
-    assertTrue(bScope.isEnded());
-    assertEquals("28C", processInstance.getVariable("temp"));
-  }
-
-  public void testVariableUpdatesOnEndedScope() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-        .transition().to("b")
-      .node("b").behaviour(new WaitState())
-        .scope() // !!!!
-        .transition().to("c")
-      .node("c").behaviour(new WaitState())
-    .done();
-  
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-
-    processInstance.signal();
-    OpenExecution bScope = processInstance.getExecution("b");
-
-    bScope.createVariable("temp", "28C");
-    
-    processInstance.signal(bScope);
-    
-    try {
-      bScope.setVariable("temp", "21C");
-      fail("expected exception");
-    } catch (PvmException e) {
-      // OK
-      assertTextPresent("can't update variable 'temp' on execution[b]", e.getMessage());
-    }
-  }
-
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/SubProcessTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/SubProcessTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/SubProcessTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,106 +0,0 @@
-/*
- * 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.client;
-
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- * @author Tom Baeyens
- */
-public class SubProcessTest extends JbpmTestCase
-{
-
-  public static class SubProcess implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    ClientProcessDefinition subProcess;
-    public SubProcess(ClientProcessDefinition subProcess) {
-      this.subProcess = subProcess;
-    }
-    public void execute(ActivityExecution execution) throws Exception {
-      ClientProcessInstance subProcessInstance = execution.beginSubProcessInstance(subProcess);
-      if (!subProcessInstance.isEnded()) {
-        execution.waitForSignal();
-      }
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
-    }
-  }
-  
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-    }
-  }
-  
-  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){
-    }
-  }
-
-  public static class EndState implements Activity {
-    public void execute(ActivityExecution execution) throws Exception {
-      execution.end();
-    }
-  }
-
-  public void testSubProcess() {
-    ClientProcessDefinition subProcess = ProcessFactory.build("sub")
-      .node("sub1").initial().behaviour(new AutomaticActivity())
-        .transition().to("sub2")
-      .node("sub2").behaviour(new WaitState())
-        .transition().to("sub3")
-      .node("sub3").behaviour(new EndState())
-    .done();
-    
-    ClientProcessDefinition superProcess = ProcessFactory.build("super")
-      .node("super1").initial().behaviour(new AutomaticActivity())
-        .transition().to("super2")
-      .node("super2").behaviour(new SubProcess(subProcess))
-        .transition().to("super3")
-      .node("super3").behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance superProcesInstance = superProcess.beginProcessInstance();
-    assertEquals("super2", superProcesInstance.getNode().getName());
-
-    ClientProcessInstance subProcessInstance = (ClientProcessInstance) superProcesInstance.getSubProcessInstance(); 
-    assertNotNull(subProcessInstance);
-    assertEquals("sub2", subProcessInstance.getNode().getName());
-    
-    subProcessInstance.signal();
-    
-    assertEquals("sub3", subProcessInstance.getNode().getName());
-    assertTrue(subProcessInstance.isEnded());
-    
-    assertEquals("super3", superProcesInstance.getNode().getName());
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionAsWaitStateTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionAsWaitStateTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionAsWaitStateTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,81 +0,0 @@
-/*
- * 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.client;
-
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.listener.Condition;
-import org.jbpm.pvm.listener.EventListenerExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/** this test shows how to implement a transition that behaves as a 
- * wait state.
- * 
- * @author Tom Baeyens
- */
-public class TransitionAsWaitStateTest extends JbpmTestCase
-{
-
-  public static class AlwaysTrue implements Condition {
-    private static final long serialVersionUID = 1L;
-    public boolean evaluate(EventListenerExecution execution) {
-      return true;
-    }
-  };
-  
-  public static class AutomaticActivity implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-    }
-  }
-  
-  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){
-    }
-  }
-
-  public void testSmallAmount() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("make loss").initial().behaviour(new AutomaticActivity())
-        .transition("use jbpm").to("make profit")
-          .waitCondition(new AlwaysTrue())
-      .node("make profit").behaviour(new WaitState())
-    .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertNull(execution.getNode());
-    
-    execution.signal();
-    
-    assertEquals("make profit", execution.getNode().getName());
-  }  
-
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionBasedConcurrencyTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionBasedConcurrencyTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionBasedConcurrencyTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,168 +0,0 @@
-package org.jbpm.pvm.client;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.Execution;
-import org.jbpm.pvm.activity.Activity;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.Node;
-import org.jbpm.pvm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.pvm.model.Transition;
-
-/**
- * concurrent execution where synchronization is done by checking if the 
- * number of expected child executions arrived at the join.
- * 
- * @author Tom Baeyens
- */
-public class TransitionBasedConcurrencyTest extends JbpmTestCase
-{
-  
-  public static class Fork implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      Node node = execution.getNode();
-      List<Transition> outgoingTransitions = node.getOutgoingTransitions();
-
-      // for each outgoing transition
-      for (Transition outgoingTransition: outgoingTransitions) {
-        // launch a concurrent path of execution
-        String childExecutionName = outgoingTransition.getName();
-        // creating the execution will cause the execution to become inactive
-        Execution childExecution = execution.createExecution(childExecutionName);
-        execution.take(outgoingTransition, childExecution);
-      }
-    }
-  }
-
-  public static class Join implements Activity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) throws Exception {
-      // end the child execution execution
-      // this will also remove the execution from it's parent
-      execution.end();
-      
-      Node join = execution.getNode();
-      List<OpenExecution> joinedExecutions = findJoinedExecutions(execution, join);
-      
-      if (isComplete(joinedExecutions, join)) {
-        remove(joinedExecutions, execution);
-        OpenExecution processInstance = execution.getProcessInstance();
-        
-        Execution outgoingExecution = null;
-        if ( processInstance.getExecutions()==null
-             || processInstance.getExecutions().isEmpty() 
-           ) {
-          outgoingExecution = processInstance;
-        } else {
-          outgoingExecution = execution.createExecution(processInstance);
-        }
-        
-        execution.move(join, outgoingExecution);
-        Transition transition = join.getDefaultTransition();
-        execution.take(transition, outgoingExecution);
-      }
-    }
-    
-    List<OpenExecution> findJoinedExecutions(OpenExecution execution, Node join) {
-      List<OpenExecution> joinedExecutions = new ArrayList<OpenExecution>();
-      scanRecursive(execution.getProcessInstance(), join, joinedExecutions);
-      return joinedExecutions;
-    }
-
-    void scanRecursive(OpenExecution execution, Node join, List<OpenExecution> joinedExecutions) {
-      // if the execution is positioned in the join
-      if (join.equals(execution.getNode())) {
-        joinedExecutions.add(execution);
-      }
-      Collection<OpenExecution> childExecutions = execution.getExecutions();
-      if (childExecutions!=null) {
-        for (OpenExecution childExecution: childExecutions) {
-          scanRecursive(childExecution, join, joinedExecutions);
-        }
-      }
-    }
-
-    boolean isComplete(List<OpenExecution> joinedExecutions, Node join) {
-      int executionsToJoin = join.getIncomingTransitions().size();
-      return (executionsToJoin==joinedExecutions.size());
-    }
-
-    void remove(List<OpenExecution> joinedExecutions, ActivityExecution execution) {
-      for (OpenExecution joinedExecution: joinedExecutions) {
-        execution.removeExecution(joinedExecution, joinedExecution.getParent());
-      }
-    }
-  }
-
-  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) {
-      execution.take(signalName);
-    }
-  }
-
-  public void testTransitionBasedConcurrency() {
-
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("fork").initial().behaviour(new Fork())
-        .transition("billing").to("bill")
-        .transition("shipping").to("ship")
-      .node("bill").behaviour(new WaitState())
-        .transition().to("join")
-      .node("ship").behaviour(new WaitState())
-        .transition().to("join")
-      .node("join").behaviour(new Join())
-        .transition().to("end")
-      .node("end").behaviour(new WaitState())
-    .done();
-
-    ClientProcessInstance main = processDefinition.beginProcessInstance();
-    
-    assertEquals("fork", main.getNode().getName());
-    assertEquals(Execution.STATE_INACTIVE, main.getState());
-    
-    Execution billing = main.getExecution("billing");
-    assertNotNull(billing);
-    assertEquals("bill", billing.getNodeName());
-    assertFalse(billing.isEnded());
-    
-    Execution shipping = main.getExecution("shipping");
-    
-    assertNotNull(shipping);
-    assertEquals("ship", shipping.getNodeName());
-    assertFalse(shipping.isEnded());
-    assertTrue(main.getExecutions().contains(billing));
-    assertTrue(main.getExecutions().contains(shipping));
-
-    main.signal(billing);
-    
-    assertEquals("fork", main.getNodeName());
-    assertEquals("join", billing.getNodeName());
-    assertTrue(billing.isEnded());
-    assertEquals("ship", shipping.getNodeName());
-    assertFalse(shipping.isEnded());
-    assertTrue(billing.isEnded());
-    assertEquals(Execution.STATE_INACTIVE, main.getState());
-
-    main.signal(shipping);
-    
-    assertEquals(Execution.STATE_ACTIVE, main.getState());
-    assertEquals("end", main.getNodeName());
-    assertEquals("join", billing.getNodeName());
-    assertTrue(billing.isEnded());
-    assertEquals("join", shipping.getNodeName());
-    assertTrue(shipping.isEnded());
-    assertFalse(main.getExecutions().contains(billing));
-    assertFalse(main.getExecutions().contains(shipping));
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionEventsTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionEventsTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/TransitionEventsTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,452 +0,0 @@
-/*
- * 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.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.listener.EventListener;
-import org.jbpm.pvm.listener.EventListenerExecution;
-import org.jbpm.pvm.model.Event;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- * @author Tom Baeyens
- */
-public class TransitionEventsTest extends JbpmTestCase
-{
-  
-  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){
-    }
-  }
-  
-  public class Recorder implements EventListener {
-    private static final long serialVersionUID = 1L;
-    public List<Object> events = new ArrayList<Object>();
-    public void notify(EventListenerExecution execution) {
-      events.add(execution.getEvent()+" on "+execution.getEventSource());
-    }
-  }
-
-
-  public void testCompositeLeave(){
-    Recorder processListener = new Recorder();
-    Recorder outsideListener = new Recorder();
-    Recorder compositeListener = new Recorder();
-    Recorder insideListener = new Recorder();
-
-    /*
-    +--------------+
-    | composite    |
-    |  +--------+  |     +---------+    
-    |  | inside |------->| outside |
-    |  +--------+  |     +---------+    
-    +--------------+
-    */
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
-        .event(Event.NODE_END) 
-          .listener(processListener)
-        .event(Event.NODE_BEGIN) 
-          .listener(processListener)
-        .event(Event.TRANSITION_TAKE) 
-          .listener(processListener)
-        .compositeNode("composite")
-          .event(Event.NODE_END) 
-            .listener(compositeListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(compositeListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(compositeListener)
-            .node("inside").initial().behaviour(new WaitState())
-              .event(Event.NODE_END) 
-                .listener(insideListener)
-              .event(Event.NODE_BEGIN) 
-                .listener(insideListener)
-              .event(Event.TRANSITION_TAKE) 
-                .listener(insideListener)
-              .transition().to("outside")
-          .compositeEnd()
-        .node("outside").behaviour(new WaitState())
-          .event(Event.NODE_END) 
-            .listener(outsideListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(outsideListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(outsideListener)
-    .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals(0, processListener.events.size());
-    assertEquals(0, outsideListener.events.size());
-    assertEquals(0, compositeListener.events.size());
-    assertEquals(0, insideListener.events.size());
-    
-    assertEquals("inside", execution.getNode().getName());
-
-    execution.signal();
-    
-    assertEquals("[event(node-end) on node(inside), " +
-                  "event(node-end) on node(composite), " +
-                  "event(transition-take) on (inside)-->(outside), " +
-                  "event(node-begin) on node(outside)]", 
-                 processListener.events.toString());
-    
-    assertEquals("[event(node-begin) on node(outside)]",
-                 outsideListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(inside), " +
-                  "event(node-end) on node(composite)]",
-                 compositeListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(inside)]",
-                 insideListener.events.toString());
-  }
-
-  public void testCompositeEnter(){
-    Recorder processListener = new Recorder();
-    Recorder outsideListener = new Recorder();
-    Recorder compositeListener = new Recorder();
-    Recorder insideListener = new Recorder();
-
-    /*
-                   +--------------+
-                   | composite    |
-    +---------+    |  +--------+  |
-    | outside |------>| inside |  |
-    +---------+    |  +--------+  |
-                   +--------------+
-    */
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("enter a super state")
-        .event(Event.NODE_END) 
-          .listener(processListener)
-        .event(Event.NODE_BEGIN) 
-          .listener(processListener)
-        .event(Event.TRANSITION_TAKE) 
-          .listener(processListener)
-        .node("outside").initial().behaviour(new WaitState())
-          .event(Event.NODE_END) 
-            .listener(outsideListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(outsideListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(outsideListener)
-          .transition().to("inside")
-        .compositeNode("composite")
-          .event(Event.NODE_END) 
-            .listener(compositeListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(compositeListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(compositeListener)
-          .node("inside").behaviour(new WaitState())
-            .event(Event.NODE_END) 
-              .listener(insideListener)
-            .event(Event.NODE_BEGIN) 
-              .listener(insideListener)
-            .event(Event.TRANSITION_TAKE) 
-              .listener(insideListener)
-        .compositeEnd()
-    .done();
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals(0, processListener.events.size());
-    assertEquals(0, outsideListener.events.size());
-    assertEquals(0, compositeListener.events.size());
-    assertEquals(0, insideListener.events.size());
-
-    execution.signal();
-    
-    assertEquals("[event(node-end) on node(outside), " +
-    		          "event(transition-take) on (outside)-->(inside), " +
-    		          "event(node-begin) on node(composite), " +
-    		          "event(node-begin) on node(inside)]", 
-                 processListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(outside)]",
-                 outsideListener.events.toString());
-    
-    assertEquals("[event(node-begin) on node(composite), " +
-    		           "event(node-begin) on node(inside)]",
-    		         compositeListener.events.toString());
-    
-    assertEquals("[event(node-begin) on node(inside)]",
-                 insideListener.events.toString());
-  }
-
-  public void testSelfTransition(){
-    Recorder processListener = new Recorder();
-    Recorder compositeListener = new Recorder();
-    Recorder insideListener = new Recorder();
-
-    /*
-    +-----------------+
-    | composite       |
-    |  +--------+     |    
-    |  | inside |---+ |
-    |  |        |   | |
-    |  |        |<--+ |
-    |  +--------+     |    
-    +-----------------+
-    */
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
-        .event(Event.NODE_END) 
-          .listener(processListener)
-        .event(Event.NODE_BEGIN) 
-          .listener(processListener)
-        .event(Event.TRANSITION_TAKE) 
-          .listener(processListener)
-        .compositeNode("composite")
-          .event(Event.NODE_END) 
-            .listener(compositeListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(compositeListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(compositeListener)
-          .node("inside").initial().behaviour(new WaitState())
-            .event(Event.NODE_END) 
-              .listener(insideListener)
-            .event(Event.NODE_BEGIN) 
-              .listener(insideListener)
-            .event(Event.TRANSITION_TAKE) 
-              .listener(insideListener)
-            .transition().to("inside")
-        .compositeEnd()
-    .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals(0, processListener.events.size());
-    assertEquals(0, compositeListener.events.size());
-    assertEquals(0, insideListener.events.size());
-    
-    assertEquals("inside", execution.getNode().getName());
-
-    execution.signal();
-    
-    assertEquals("[event(node-end) on node(inside), " +
-                  "event(transition-take) on (inside)-->(inside), " +
-                  "event(node-begin) on node(inside)]", 
-                 processListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(inside), " +
-                 "event(transition-take) on (inside)-->(inside), " +
-                 "event(node-begin) on node(inside)]",
-                 compositeListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(inside), " +
-    		          "event(node-begin) on node(inside)]",
-                 insideListener.events.toString());
-  }
-
-
-  public void testCompositeLeaveInheritedTransition(){
-    Recorder processListener = new Recorder();
-    Recorder outsideListener = new Recorder();
-    Recorder compositeListener = new Recorder();
-    Recorder insideListener = new Recorder();
-
-    /*
-    +--------------+        +---------+ 
-    | composite    |------->| outside |
-    |  +--------+  |        +---------+   
-    |  | inside |  |
-    |  +--------+  |
-    +--------------+
-    */
-    
-    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
-        .event(Event.NODE_END) 
-          .listener(processListener)
-        .event(Event.NODE_BEGIN) 
-          .listener(processListener)
-        .event(Event.TRANSITION_TAKE) 
-          .listener(processListener)
-        .compositeNode("composite")
-          .event(Event.NODE_END) 
-            .listener(compositeListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(compositeListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(compositeListener)
-          .transition().to("outside")
-          .node("inside").initial().behaviour(new WaitState())
-            .event(Event.NODE_END) 
-              .listener(insideListener)
-            .event(Event.NODE_BEGIN) 
-              .listener(insideListener)
-            .event(Event.TRANSITION_TAKE) 
-              .listener(insideListener)
-        .compositeEnd()
-        .node("outside").behaviour(new WaitState())
-          .event(Event.NODE_END) 
-            .listener(outsideListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(outsideListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(outsideListener)
-    .done();
-
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals(0, processListener.events.size());
-    assertEquals(0, outsideListener.events.size());
-    assertEquals(0, compositeListener.events.size());
-    assertEquals(0, insideListener.events.size());
-    
-    assertEquals("inside", execution.getNode().getName());
-
-    execution.signal();
-    
-    assertEquals("[event(node-end) on node(inside), " +
-                  "event(node-end) on node(composite), " +
-                  "event(transition-take) on (composite)-->(outside), " +
-                  "event(node-begin) on node(outside)]", 
-                 processListener.events.toString());
-    
-    assertEquals("[event(node-begin) on node(outside)]",
-                 outsideListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(inside), " +
-                  "event(node-end) on node(composite)]",
-                 compositeListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(inside)]",
-                 insideListener.events.toString());
-  }
-
-  public void testCompositeLeaveInheritedTransitionExtraNesting(){
-    Recorder processListener = new Recorder();
-    Recorder sourceOutsideListener = new Recorder();
-    Recorder sourceMiddleListener = new Recorder();
-    Recorder sourceInsideListener = new Recorder();
-    Recorder destinationOutsideListener = new Recorder();
-    Recorder destinationInsideListener = new Recorder();
-
-    /*
-    +--------------------------+ 
-    | source outside           |
-    |  +--------------------+  |      +--------------------------+ 
-    |  | source middle      |  |      | destination outside      |
-    |  |  +---------------+ |  |      |  +--------------------+  |   
-    |  |  | source inside | |----------->| destination inside |  |
-    |  |  +---------------+ |  |      |  +--------------------+  |
-    |  +--------------------+  |      +--------------------------+
-    +--------------------------+
-    */
-
-    ClientProcessDefinition processDefinition = ProcessFactory.build("leave a super state")
-        .event(Event.NODE_END) 
-          .listener(processListener)
-        .event(Event.NODE_BEGIN) 
-          .listener(processListener)
-        .event(Event.TRANSITION_TAKE) 
-          .listener(processListener)
-        .compositeNode("source outside")
-          .event(Event.NODE_END) 
-            .listener(sourceOutsideListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(sourceOutsideListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(sourceOutsideListener)
-          .compositeNode("source middle")
-            .event(Event.NODE_END) 
-              .listener(sourceMiddleListener)
-            .event(Event.NODE_BEGIN) 
-              .listener(sourceMiddleListener)
-            .event(Event.TRANSITION_TAKE) 
-              .listener(sourceMiddleListener)
-            .transition().to("destination inside")
-            .node("source inside").initial().behaviour(new WaitState())
-              .event(Event.NODE_END) 
-                .listener(sourceInsideListener)
-              .event(Event.NODE_BEGIN) 
-                .listener(sourceInsideListener)
-              .event(Event.TRANSITION_TAKE) 
-                .listener(sourceInsideListener)
-          .compositeEnd()
-        .compositeEnd()
-        .compositeNode("destination outside")
-          .event(Event.NODE_END) 
-            .listener(destinationOutsideListener)
-          .event(Event.NODE_BEGIN) 
-            .listener(destinationOutsideListener)
-          .event(Event.TRANSITION_TAKE) 
-            .listener(destinationOutsideListener)
-          .node("destination inside").behaviour(new WaitState())
-            .event(Event.NODE_END) 
-              .listener(destinationInsideListener)
-            .event(Event.NODE_BEGIN) 
-              .listener(destinationInsideListener)
-            .event(Event.TRANSITION_TAKE) 
-              .listener(destinationInsideListener)
-        .compositeEnd()
-    .done();
-
-    
-    ClientProcessInstance execution = processDefinition.beginProcessInstance();
-
-    assertEquals("source inside", execution.getNode().getName());
-
-    execution.signal();
-    
-    assertEquals("[event(node-end) on node(source inside), " +
-                  "event(node-end) on node(source middle), " +
-                  "event(node-end) on node(source outside), " +
-                  "event(transition-take) on (source middle)-->(destination inside), " +
-                  "event(node-begin) on node(destination outside), " +
-                  "event(node-begin) on node(destination inside)]", 
-                 processListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(source inside), " +
-                  "event(node-end) on node(source middle), " +
-                  "event(node-end) on node(source outside)]", 
-                 sourceOutsideListener.events.toString());
-    
-    assertEquals("[event(node-end) on node(source inside), " +
-                  "event(node-end) on node(source middle)]", 
-                 sourceMiddleListener.events.toString());
-
-    assertEquals("[event(node-end) on node(source inside)]", 
-                 sourceInsideListener.events.toString());
-
-    assertEquals("[event(node-begin) on node(destination outside), " +
-                  "event(node-begin) on node(destination inside)]", 
-                 destinationOutsideListener.events.toString());
-
-    assertEquals("[event(node-begin) on node(destination inside)]", 
-                 destinationInsideListener.events.toString());
-  }
-}

Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/VariableTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/VariableTest.java	2008-07-17 20:14:17 UTC (rev 1674)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/client/VariableTest.java	2008-07-18 14:11:32 UTC (rev 1675)
@@ -1,245 +0,0 @@
-/*
- * 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.client;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- * @author Tom Baeyens
- */
-public class VariableTest extends JbpmTestCase {
-  
-  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){
-    }
-  }
-  
-  public void testSetAndGetVariable() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    processInstance.setVariable("customer", "coca-cola");
-    assertEquals("coca-cola", processInstance.getVariable("customer"));
-    
-    processInstance.setVariable("address", "usa");
-    assertEquals("usa", processInstance.getVariable("address"));
-
-    processInstance.setVariable("size", "big");
-    assertEquals("big", processInstance.getVariable("size"));
-  }
-
-  public void testHasVariable() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    processInstance.setVariable("customer", "coca-cola");
-
-    assertTrue(processInstance.hasVariable("customer"));
-    assertFalse(processInstance.hasVariable("address"));
-  }
-
-  public void testSetVariables() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-
-    Map<String, Object> variables = new HashMap<String, Object>();
-    variables.put("customer", "coca-cola");
-    variables.put("address", "usa");
-    variables.put("size", "big");
-
-    processInstance.setVariables(variables);
-
-    assertEquals("coca-cola", processInstance.getVariable("customer"));
-    assertEquals("usa", processInstance.getVariable("address"));
-    assertEquals("big", processInstance.getVariable("size"));
-  }
-
-  public void testGetVariables() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    processInstance.setVariable("customer", "coca-cola");
-    processInstance.setVariable("address", "usa");
-    processInstance.setVariable("size", "big");
-    
-    Map<String, Object> expectedVariables = new HashMap<String, Object>();
-    expectedVariables.put("customer", "coca-cola");
-    expectedVariables.put("address", "usa");
-    expectedVariables.put("size", "big");
-    assertEquals(expectedVariables, processInstance.getVariables());
-  }
-
-  public void testRemoveVariable() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    processInstance.setVariable("customer", "coca-cola");
-    processInstance.setVariable("address", "usa");
-    processInstance.setVariable("size", "big");
-    
-    Map<String, Object> expectedVariables = new HashMap<String, Object>();
-    expectedVariables.put("customer", "coca-cola");
-    expectedVariables.put("address", "usa");
-    expectedVariables.put("size", "big");
-    
-    assertEquals(expectedVariables, processInstance.getVariables());
-    
-    processInstance.removeVariable("address");
-    expectedVariables.remove("address");
-
-    assertEquals(expectedVariables, processInstance.getVariables());
-    
-    processInstance.removeVariable("customer");
-    expectedVariables.remove("customer");
-
-    assertEquals(expectedVariables, processInstance.getVariables());
-    
-    processInstance.removeVariable("size");
-    expectedVariables.remove("size");
-
-    assertEquals(expectedVariables, processInstance.getVariables());
-  }
-
-  public void testRemoveVariables() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    processInstance.setVariable("customer", "coca-cola");
-    processInstance.setVariable("address", "usa");
-    processInstance.setVariable("size", "big");
-    
-    processInstance.removeVariables();
-    
-    Map<String, Object> expectedVariables = new HashMap<String, Object>();
-    assertEquals(expectedVariables, processInstance.getVariables());
-  }
-
-  public void testGetVariableKeys() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    processInstance.setVariable("customer", "coca-cola");
-    processInstance.setVariable("address", "usa");
-    processInstance.setVariable("size", "big");
-    
-    Set<String> expectedVariableKeys = new HashSet<String>();
-    expectedVariableKeys.add("customer");
-    expectedVariableKeys.add("address");
-    expectedVariableKeys.add("size");
-    assertEquals(expectedVariableKeys, new HashSet<String>(processInstance.getVariableKeys()));
-  }
-
-  public void testGetUnexistingVariable() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    assertNull(processInstance.getVariable("answer to life, the universe and everything"));
-  }
-
-  public static class VariableActivity implements ExternalActivity {
-    private static final long serialVersionUID = 1L;
-    public void execute(ActivityExecution execution) {
-      assertEquals("coca-cola", execution.getVariable("customer"));
-      execution.setVariable("message", "Killroy was here");
-      execution.waitForSignal();
-    }
-    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
-    }
-  }
-
-  public void testInitialiseVariablesBeforeProcessInstanceBegin() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new VariableActivity())
-    .done();
-    
-    // here, the process instance is created first, and only later it is begun
-    ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-    processInstance.setVariable("customer", "coca-cola");
-    processInstance.begin();
-    assertEquals("Killroy was here", processInstance.getVariable("message"));
-  }
-  
-  public void testNullValue() {
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState())
-    .done();
-    
-    ClientProcessInstance processInstance = processDefinition.beginProcessInstance();
-    
-    processInstance.setVariable("niks", null);
-    processInstance.setVariable("nada", null);
-
-    assertTrue(processInstance.hasVariables());
-    assertTrue(processInstance.hasVariable("niks"));
-    assertTrue(processInstance.hasVariable("nada"));
-
-    assertNull(processInstance.getVariable("niks"));
-    assertNull(processInstance.getVariable("nada"));
-    
-    Set<String> expectedKeys = new HashSet<String>();
-    expectedKeys.add("niks");
-    expectedKeys.add("nada");
-    assertEquals(expectedKeys, new HashSet<String>(processInstance.getVariableKeys()));
-    
-    Map<String, Object> expectedVariables = new HashMap<String, Object>();
-    expectedVariables.put("niks", null);
-    expectedVariables.put("nada", null);
-    assertEquals(expectedVariables, new HashMap<String, Object>(processInstance.getVariables()));
-  }
-
-}




More information about the jbpm-commits mailing list