JBoss JBPM SVN: r3565 - in projects/spec/trunk/modules/docs: spec-requirements and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-12-28 14:48:15 -0500 (Sun, 28 Dec 2008)
New Revision: 3565
Added:
projects/spec/trunk/modules/docs/.project
projects/spec/trunk/modules/docs/spec-requirements/.project
Log:
Add eclipse stuff
Added: projects/spec/trunk/modules/docs/.project
===================================================================
--- projects/spec/trunk/modules/docs/.project (rev 0)
+++ projects/spec/trunk/modules/docs/.project 2008-12-28 19:48:15 UTC (rev 3565)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bpm-spec-docs</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: projects/spec/trunk/modules/docs/spec-requirements/.project
===================================================================
--- projects/spec/trunk/modules/docs/spec-requirements/.project (rev 0)
+++ projects/spec/trunk/modules/docs/spec-requirements/.project 2008-12-28 19:48:15 UTC (rev 3565)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bpm-spec-docs-requirements</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
15 years, 4 months
JBoss JBPM SVN: r3564 - projects/spec/trunk/modules/integration.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-12-28 14:46:40 -0500 (Sun, 28 Dec 2008)
New Revision: 3564
Added:
projects/spec/trunk/modules/integration/.project
Log:
Add .project
Added: projects/spec/trunk/modules/integration/.project
===================================================================
--- projects/spec/trunk/modules/integration/.project (rev 0)
+++ projects/spec/trunk/modules/integration/.project 2008-12-28 19:46:40 UTC (rev 3564)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bpm-spec-integration</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
15 years, 4 months
JBoss JBPM SVN: r3563 - projects/spec/trunk.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-12-28 14:44:57 -0500 (Sun, 28 Dec 2008)
New Revision: 3563
Modified:
projects/spec/trunk/pom.xml
Log:
Resore comment layout
Modified: projects/spec/trunk/pom.xml
===================================================================
--- projects/spec/trunk/pom.xml 2008-12-28 18:27:11 UTC (rev 3562)
+++ projects/spec/trunk/pom.xml 2008-12-28 19:44:57 UTC (rev 3563)
@@ -107,9 +107,21 @@
<!-- DistributionManagement -->
<distributionManagement>
<!--
- Add this to your ~/.m2/settings.xml <servers> <server> <id>jbpm.dyndns.org</id> <username>yourname</username>
- <privateKey>/home/yourname/.ssh/id_rsa</privateKey> <passphrase>yourpass</passphrase> </server> <server>
- <id>snapshots.jboss.org</id> <username>yourname</username> <password>yourpass</password> </server> </servers>
+ Add this to your ~/.m2/settings.xml
+
+ <servers>
+ <server>
+ <id>jbpm.dyndns.org</id>
+ <username>yourname</username>
+ <privateKey>/home/yourname/.ssh/id_rsa</privateKey>
+ <passphrase>yourpass</passphrase>
+ </server>
+ <server>
+ <id>snapshots.jboss.org</id>
+ <username>yourname</username>
+ <password>yourpass</password>
+ </server>
+ </servers>
-->
<site>
<id>jbpm.dyndns.org</id>
15 years, 4 months
JBoss JBPM SVN: r3562 - in jbpm4/trunk/modules/test-load/src/test: resources and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-28 13:27:11 -0500 (Sun, 28 Dec 2008)
New Revision: 3562
Added:
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java
Removed:
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java
Modified:
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/Automatic.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ProcessExecutionTest.java
jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
Log:
load testing fine tuning
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/Automatic.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/Automatic.java 2008-12-27 13:44:33 UTC (rev 3561)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/Automatic.java 2008-12-28 18:27:11 UTC (rev 3562)
@@ -26,7 +26,6 @@
*/
public class Automatic {
-
public void doNothing() {
}
}
Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java 2008-12-27 13:44:33 UTC (rev 3561)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java 2008-12-28 18:27:11 UTC (rev 3562)
@@ -1,93 +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.test.load;
-
-import java.util.Date;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.jbpm.cmd.Command;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class JobExecutorTestCase extends DbTestCase {
-
- static long checkInterval = 5000;
-
- static String jobsAvailableQueryText =
- "select count(*) "+
- "from "+JobImpl.class.getName()+" as job "+
- "where ( (job.dueDate is null) or (job.dueDate <= :now) ) "+
- " and ( job.retries > 0 )";
-
- protected CommandService commandService;
- protected JobExecutor jobExecutor;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- commandService = processEngine.get(CommandService.class);
- jobExecutor = processEngine.get(JobExecutor.class);
- }
-
- protected void waitTillNoMoreMessages(JobExecutor jobExecutor) throws Exception {
- boolean jobsAvailable = true;
- while (jobsAvailable) {
- log.debug("going to sleep for " + checkInterval + " millis, waiting for the job executor to process more jobs");
- Thread.sleep(checkInterval);
- jobsAvailable = areJobsAvailable();
- logStatus();
- }
- }
-
- public void logStatus() {
- }
-
- public boolean areJobsAvailable() {
- return commandService.execute(new Command<Boolean>() {
- public Boolean execute(Environment environment) {
- Session session = environment.get(Session.class);
-
- Query query = session.createQuery(jobsAvailableQueryText);
- query.setDate("now", new Date());
-
- Long jobs = (Long) query.uniqueResult();
-
- if (jobs.longValue()>0) {
- log.debug("found "+jobs+" more jobs to process");
- return true;
- }
- log.debug("no more jobs to process");
-
- return false;
- }
- });
- }
-
-}
Added: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/LoadTestCase.java 2008-12-28 18:27:11 UTC (rev 3562)
@@ -0,0 +1,180 @@
+/*
+ * 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.test.load;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Date;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class LoadTestCase extends DbTestCase {
+
+ static final long SECOND = 1000;
+ static final long MINUTE = 60 * SECOND;
+ static final long HOUR = 60 * MINUTE;
+
+ static long checkInterval = 200;
+
+ static String jobsAvailableQueryText =
+ "select count(*) "+
+ "from "+JobImpl.class.getName()+" as job "+
+ "where ( (job.dueDate is null) or (job.dueDate <= :now) ) "+
+ " and ( job.retries > 0 )";
+
+ static boolean measureMemory = true;
+
+ protected CommandService commandService;
+ protected JobExecutor jobExecutor;
+ long startTime = -1;
+ long stopTime = -1;
+ PrintWriter logFileWriter;
+
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ if (measureMemory) {
+ openMemoryLogFile();
+ }
+
+ commandService = processEngine.get(CommandService.class);
+ jobExecutor = processEngine.get(JobExecutor.class);
+ }
+
+ protected void tearDown() throws Exception {
+ if (measureMemory) {
+ closeMemoryLogFile();
+ }
+
+ super.tearDown();
+ }
+
+ public void startMeasuringTime() {
+ if (stopTime==-1) {
+ startTime = System.currentTimeMillis();
+ } else {
+ startTime = startTime + (System.currentTimeMillis() - stopTime);
+ stopTime = -1;
+ }
+ }
+
+ public void stopMeasuringTime() {
+ stopTime = System.currentTimeMillis();
+ }
+
+ protected void openMemoryLogFile() throws Exception {
+ String testClass = ReflectUtil.getUnqualifiedClassName(getClass());
+ logFileWriter = new PrintWriter(new File("target/"+testClass +".txt"));
+ logColumnTitles();
+ }
+
+ protected void logColumnTitles() {
+ logFileWriter.println("Used Memory");
+ }
+
+ protected void closeMemoryLogFile() {
+ logFileWriter.close();
+ }
+
+ protected void logStatus() {
+ logFileWriter.println(getUsedMemory());
+ }
+
+ protected long getUsedMemory() {
+ Runtime runtime = Runtime.getRuntime();
+ long total = runtime.totalMemory();
+ long free = runtime.freeMemory();
+ long used = total - free;
+ return used;
+ }
+
+ protected void waitTillNoMoreMessages(JobExecutor jobExecutor) throws Exception {
+ boolean jobsAvailable = true;
+ while (jobsAvailable) {
+ log.debug("going to sleep for " + checkInterval + " millis, waiting for the job executor to process more jobs");
+ Thread.sleep(checkInterval);
+ jobsAvailable = areJobsAvailable();
+ logStatus();
+ }
+ }
+
+ public boolean areJobsAvailable() {
+ return commandService.execute(new Command<Boolean>() {
+ public Boolean execute(Environment environment) {
+ Session session = environment.get(Session.class);
+
+ Query query = session.createQuery(jobsAvailableQueryText);
+ query.setDate("now", new Date());
+
+ Long jobs = (Long) query.uniqueResult();
+
+ if (jobs.longValue()>0) {
+ log.debug("found "+jobs+" more jobs to process");
+ return true;
+ }
+ log.debug("no more jobs to process");
+
+ return false;
+ }
+ });
+ }
+
+ public String getMeasuredTime() {
+ long stop = stopTime!=-1 ? stopTime : System.currentTimeMillis();
+ long diff = stop - startTime;
+
+ long hours = diff / HOUR;
+ diff = diff - (hours * HOUR);
+
+ long minutes = diff / MINUTE;
+ diff = diff - (minutes * MINUTE);
+
+ long seconds = diff / SECOND;
+
+ StringBuffer text = new StringBuffer();
+ if (hours!=0) {
+ text.append(hours+"h");
+ }
+ text.append(minutes);
+ text.append("'");
+ text.append(seconds);
+ text.append("\"");
+
+ // long millis = diff - (seconds * SECOND);
+ // text.append(","+millis);
+
+ return text.toString();
+ }
+}
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java 2008-12-27 13:44:33 UTC (rev 3561)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java 2008-12-28 18:27:11 UTC (rev 3562)
@@ -21,14 +21,11 @@
*/
package org.jbpm.test.load;
-import java.io.File;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
import org.jbpm.cmd.Command;
-import org.jbpm.cmd.CommandService;
import org.jbpm.env.Environment;
import org.jbpm.job.Message;
import org.jbpm.log.Log;
@@ -42,78 +39,41 @@
* @author Tom Baeyens
* @author Guillaume Porcher
*/
-public class MessageProcessingTest extends JobExecutorTestCase {
+public class MessageProcessingTest extends LoadTestCase {
private static final Log log = Log.getLog(MessageProcessingTest.class.getName());
- static long nbrOfTestMessages = 10000; // nbrOfTestMessages must be dividable by insertGroupSize
- static long insertGroupSize = 50;
+ static long nbrOfTestMessages = 50000; // nbrOfTestMessages must be dividable by insertGroupSize
+ static long insertGroupSize = 100;
- static final long SECOND = 1000;
- static final long MINUTE = 60 * SECOND;
- static final long HOUR = 60 * MINUTE;
-
- static boolean measureMemory = true;
-
- static long timeoutMillis = 30 * MINUTE; // 10 minutes
- static long checkInterval = 5000;
-
- static long start = -1;
static int commentsAdded = 0;
public static synchronized void commentAdded() {
commentsAdded++;
}
- CommandService commandService;
- PrintWriter memoryWriter;
-
public void setUp() throws Exception {
super.setUp();
if ( (nbrOfTestMessages % insertGroupSize) != 0 ) {
fail("nbrOfTestMessages ("+nbrOfTestMessages+") is not dividable by insertGroupSize ("+insertGroupSize+")");
}
-
- if (measureMemory) {
- openMemoryLogFile();
- }
-
- commandService = processEngine.get(CommandService.class);
}
- protected void tearDown() throws Exception {
- if (measureMemory) {
- closeMemoryLogFile();
- }
-
- super.tearDown();
+ protected void logColumnTitles() {
+ logFileWriter.println("Used Memory\tProcessed Messages\tTime");
}
-
- void openMemoryLogFile() throws Exception {
- memoryWriter = new PrintWriter(new File("target/memory.txt"));
- }
-
- void closeMemoryLogFile() {
- memoryWriter.close();
- }
-
public void logStatus() {
- Runtime runtime = Runtime.getRuntime();
- long total = runtime.totalMemory();
- long free = runtime.freeMemory();
- long used = total - free;
- memoryWriter.println(used);
-
- log.info(commentsAdded+" msgs in "+formatDuration(start, System.currentTimeMillis()));
+ String measuredTime = getMeasuredTime();
+ logFileWriter.println(getUsedMemory()+"\t"+commentsAdded+"\t"+measuredTime);
+ logFileWriter.flush();
+ log.info(commentsAdded+" msgs in "+measuredTime);
}
-
+
public void testMessageProcessing() throws Exception {
JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
- long stop = -1;
-
try {
int messageIndex = 0;
// insert ${nbrOfTestMessages} messages...
@@ -132,7 +92,7 @@
log.info("added "+messageIndex+" messages");
}
- start = System.currentTimeMillis();
+ startMeasuringTime();
jobExecutor.start();
@@ -140,12 +100,12 @@
waitTillNoMoreMessages(jobExecutor);
} finally {
- stop = System.currentTimeMillis();
+ stopMeasuringTime();
jobExecutor.stop(true);
}
- log.info("processing "+nbrOfTestMessages+" messages took "+formatDuration(start, stop));
+ log.info("processing "+nbrOfTestMessages+" messages took "+getMeasuredTime());
List<Integer> processedMessageNumbers = commandService.execute(new Command<List<Integer>>() {
public List<Integer> execute(Environment environment) {
@@ -167,33 +127,4 @@
}
}
- // helper methods ///////////////////////////////////////////////////////////
-
- public static String formatDuration(long start, long stop) {
- long diff = stop-start;
-
- long hours = diff / HOUR;
- diff = diff - (hours * HOUR);
-
- long minutes = diff / MINUTE;
- diff = diff - (minutes * MINUTE);
-
- long seconds = diff / SECOND;
- diff = diff - (seconds * SECOND);
-
- StringBuffer text = new StringBuffer();
- if (hours!=0) {
- text.append(hours+" hours, ");
- }
- if (minutes!=0) {
- text.append(minutes+" minutes, ");
- }
- if (seconds!=0) {
- text.append(seconds+" seconds and ");
- }
- if (diff!=0) {
- text.append(diff+" ms");
- }
- return text.toString();
- }
}
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ProcessExecutionTest.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ProcessExecutionTest.java 2008-12-27 13:44:33 UTC (rev 3561)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ProcessExecutionTest.java 2008-12-28 18:27:11 UTC (rev 3562)
@@ -26,24 +26,38 @@
import org.jbpm.Execution;
import org.jbpm.log.Log;
-import org.jbpm.test.DbTestCase;
/**
* @author Tom Baeyens
*/
-public class ProcessExecutionTest extends DbTestCase {
+public class ProcessExecutionTest extends LoadTestCase {
private static Log log = Log.getLog(ProcessExecutionTest.class.getName());
- static int processes = 500;
+ static int processes = 50000;
static int threads = 10;
Throwable exception;
+ int finished;
+ public void logStatus() {
+ String measuredTime = getMeasuredTime();
+ logFileWriter.println(getUsedMemory()+"\t"+finished+"\t"+measuredTime);
+ logFileWriter.flush();
+ log.info(finished+" executions in "+measuredTime);
+ }
+
+ protected void logColumnTitles() {
+ logFileWriter.println("Used Memory\tFinished Executions\tTime");
+ logFileWriter.flush();
+ }
+
public void testExecuteProcesses() throws Exception {
deployJpdlResource("org/jbpm/test/load/process.jpdl.xml");
+ startMeasuringTime();
+
List<Thread> threadList = new ArrayList<Thread>();
for (int i=0; i<threads; i++) {
Thread thread = new ProcessExecutor();
@@ -51,11 +65,15 @@
threadList.add(thread);
}
+
for (Thread thread: threadList) {
- try {
- thread.join();
- } catch (InterruptedException e) {
- log.info(e.toString());
+ while (thread.isAlive()) {
+ try {
+ thread.join(checkInterval);
+ } catch (InterruptedException e) {
+ log.info(e.toString());
+ }
+ logStatus();
}
if (exception!=null) {
break;
@@ -64,6 +82,8 @@
if (exception!=null) {
throw new Exception("thread threw: "+exception.getMessage(), exception);
+ } else {
+ log.info(finished+" executions in "+getMeasuredTime());
}
}
@@ -83,8 +103,11 @@
String executionId = execution.getId();
execution = executionService.signalExecutionById(executionId);
assertTrue(execution.isEnded());
+ processFinished();
}
}
-
+ public synchronized void processFinished() {
+ finished++;
+ }
}
Modified: jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/logging.properties 2008-12-27 13:44:33 UTC (rev 3561)
+++ jbpm4/trunk/modules/test-load/src/test/resources/logging.properties 2008-12-28 18:27:11 UTC (rev 3562)
@@ -15,8 +15,8 @@
# com.xyz.foo.level = SEVERE
org.jbpm.level=INFO
-org.jbpm.pvm.internal.model.level=FINE
-org.jbpm.pvm.internal.model.op.level=FINE
+# org.jbpm.pvm.internal.model.level=FINE
+# org.jbpm.pvm.internal.model.op.level=FINE
# org.jbpm.pvm.internal.tx.level=FINE
# org.jbpm.pvm.internal.wire.level=FINE
# org.jbpm.pvm.internal.util.level=FINE
15 years, 4 months
JBoss JBPM SVN: r3561 - in jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm: api and 4 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-27 08:44:33 -0500 (Sat, 27 Dec 2008)
New Revision: 3561
Added:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/
Removed:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/basicfeatures/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/env/NestedEnvironmentTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/AutomaticActivity.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/ContinuationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/Recorder.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/WaitState.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveMessagesTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceMessageTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingMessageTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTestCase.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageTest.java
Log:
cleaning pvm test suite
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/env/NestedEnvironmentTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/env/NestedEnvironmentTest.java 2008-12-27 13:20:00 UTC (rev 3560)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/env/NestedEnvironmentTest.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -29,8 +29,7 @@
/**
* @author Tom Baeyens
*/
-public class NestedEnvironmentTest extends JbpmTestCase
-{
+public class NestedEnvironmentTest extends JbpmTestCase {
public void testNestedEnvironments() {
EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation)
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/AutomaticActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/AutomaticActivity.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/AutomaticActivity.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.pvm.api.db.continuation;
+package org.jbpm.pvm.continuation;
import org.jbpm.activity.Activity;
import org.jbpm.activity.ActivityExecution;
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/ContinuationTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/ContinuationTest.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -19,56 +19,37 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.pvm.api.db.continuation;
+package org.jbpm.pvm.continuation;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import junit.framework.Test;
-
import org.hibernate.Session;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.cmd.Command;
import org.jbpm.env.Environment;
-import org.jbpm.env.EnvironmentFactory;
import org.jbpm.log.Log;
import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutorTestCase;
import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.session.DbSession;
-import org.jbpm.session.PvmDbSession;
-import org.jbpm.test.OldDbTestCase;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
/**
* @author Tom Baeyens
*/
-public class ContinuationTest extends OldDbTestCase {
+public class ContinuationTest extends JobExecutorTestCase {
- private static final Log log = Log.getLog(ContinuationTest.class.getName());
+ // private static final Log log = Log.getLog(ContinuationTest.class.getName());
static Recorder recorder = new Recorder();
+ int nbrOfExecutions = 1;
+
public void testContinuations() {
- int nbrOfExecutions = 20;
- int testTimeoutMillis = 20000;
- int checkInterval = 500;
- EnvironmentFactory environmentFactory = getEnvironmentFactory();
-
- Set<Integer> expected = new HashSet<Integer>();
- JobExecutor jobExecutor = environmentFactory.get(JobExecutor.class);
try {
- deployProcess(environmentFactory);
- startExecutions(nbrOfExecutions, environmentFactory, expected);
+ deployProcess();
+ startExecutions();
jobExecutor.start();
- waitTillNoMoreMessages(jobExecutor, testTimeoutMillis, checkInterval, environmentFactory);
+ waitTillNoMoreMessages();
} finally {
jobExecutor.stop(true);
@@ -80,96 +61,43 @@
expectedLogs.add("execute(b)");
expectedLogs.add("execute(c)");
expectedLogs.add("execute(end)");
-
+
assertEquals(nbrOfExecutions, recorder.executionEvents.size());
for (List<String> executionLogs : recorder.executionEvents.values()) {
assertEquals(expectedLogs, executionLogs);
}
}
- public void deployProcess(EnvironmentFactory environmentFactory) {
+ public void deployProcess() {
commandService.execute(new Command<Object>() {
-
public Object execute(Environment environment) throws Exception {
- log.debug("building process 'continuations'");
- OpenProcessDefinition processDefinition = ProcessFactory.build("continuations").node("start").initial().behaviour(AutomaticActivity.class)
- .asyncExecute().transition().to("a").node("a").behaviour(AutomaticActivity.class).asyncExecute().transition().to("b").node("b").behaviour(
- AutomaticActivity.class).asyncExecute().transition().to("c").node("c").behaviour(AutomaticActivity.class).asyncExecute().transition()
- .to("end").node("end").behaviour(WaitState.class).done();
-
- log.debug("saving process 'continuations'");
- environment.get(DbSession.class).save(processDefinition);
+ OpenProcessDefinition processDefinition = ProcessFactory.build("continuations")
+ .key("continuations")
+ .node("start").initial().behaviour(AutomaticActivity.class)
+ .asyncExecute()
+ .transition().to("a")
+ .node("a").behaviour(AutomaticActivity.class)
+ .asyncExecute()
+ .transition().to("b")
+ .node("b").behaviour(AutomaticActivity.class)
+ .asyncExecute()
+ .transition().to("c")
+ .node("c").behaviour(AutomaticActivity.class)
+ .asyncExecute()
+ .transition().to("end")
+ .node("end").behaviour(WaitState.class)
+ .done();
+
+ Session session = environment.get(Session.class);
+ session.save(processDefinition);
return null;
}
});
}
- public void startExecutions(int nbrOfExecutions, EnvironmentFactory environmentFactory, Set<Integer> expected) {
+ public void startExecutions() {
for (int i = 0; i < nbrOfExecutions; i++) {
- commandService.execute(new Command<Object>() {
-
- public Object execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- ClientProcessDefinition processDefinition = pvmDbSession.findLatestProcessDefinitionByKey("continuations");
- ClientExecution execution = processDefinition.startProcessInstance();
- pvmDbSession.save(execution);
- return null;
- }
- });
+ executionService.startExecutionByKey("continuations");
}
}
-
- public void waitTillNoMoreMessages(JobExecutor jobExecutor, int maxWait, int checkInterval, EnvironmentFactory environmentFactory) {
-
- // install a timer that will interrupt if it takes too long
- // if that happens, it will lead to an interrupted exception and the test
- // will fail
- TimerTask interruptTask = new TimerTask() {
-
- Thread testThread = Thread.currentThread();
-
- public void run() {
- log.debug("test " + getName() + " took too long. going to interrupt..." + testThread);
- testThread.interrupt();
- }
- };
- Timer timer = new Timer();
- timer.schedule(interruptTask, maxWait);
-
- try {
- boolean jobsAvailable = true;
- while (jobsAvailable) {
- log.debug("going to sleep for " + checkInterval + " millis, waiting for the jobImpl executor to process more jobs");
- Thread.sleep(checkInterval);
- jobsAvailable = areJobsAvailable(environmentFactory);
- }
-
- } catch (InterruptedException e) {
- fail("test execution exceeded treshold of " + maxWait + " milliseconds");
- } finally {
- timer.cancel();
- }
- }
-
- private boolean areJobsAvailable(EnvironmentFactory environmentFactory) {
- Integer nbrOfJobsAvailable = (Integer) commandService.execute(new Command<Object>() {
-
- public Object execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- Number jobs = (Number) session.createQuery("select count(*) from " + JobImpl.class.getName()).uniqueResult();
- if (jobs != null) {
- return jobs.intValue();
- }
- return 0;
- }
- });
-
- boolean areJobsAvailable = nbrOfJobsAvailable > 0;
- if (areJobsAvailable) {
- log.debug("there are " + nbrOfJobsAvailable + " jobs currently in the jobImpl table");
- } else {
- log.debug("all jobs are processed");
- }
- return areJobsAvailable;
- }
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/Recorder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/Recorder.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/Recorder.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.pvm.api.db.continuation;
+package org.jbpm.pvm.continuation;
import java.util.ArrayList;
import java.util.HashMap;
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/WaitState.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/WaitState.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/continuation/WaitState.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.pvm.api.db.continuation;
+package org.jbpm.pvm.continuation;
import java.util.Map;
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveMessagesTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveMessagesTest.java 2008-12-27 13:20:00 UTC (rev 3560)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveMessagesTest.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -60,7 +60,7 @@
jobExecutor.start();
try {
- waitTillNoMoreMessages(jobExecutor);
+ waitTillNoMoreMessages();
} finally {
jobExecutor.stop(true);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceMessageTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceMessageTest.java 2008-12-27 13:20:00 UTC (rev 3560)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceMessageTest.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -52,7 +52,7 @@
jobExecutor.start();
try {
insertFailOnceTestMessages();
- waitTillNoMoreMessages(jobExecutor);
+ waitTillNoMoreMessages();
} finally {
log.debug("stopping job executor");
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingMessageTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingMessageTest.java 2008-12-27 13:20:00 UTC (rev 3560)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingMessageTest.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -54,7 +54,7 @@
}
});
- waitTillNoMoreMessages(jobExecutor);
+ waitTillNoMoreMessages();
} finally {
jobExecutor.stop(true);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTestCase.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTestCase.java 2008-12-27 13:20:00 UTC (rev 3560)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTestCase.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -58,7 +58,7 @@
jobExecutor = processEngine.get(JobExecutor.class);
}
- protected void waitTillNoMoreMessages(JobExecutor jobExecutor) {
+ protected void waitTillNoMoreMessages() {
// install a timer that will interrupt if it takes too long
// if that happens, it will lead to an interrupted exception and the test
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageTest.java 2008-12-27 13:20:00 UTC (rev 3560)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageTest.java 2008-12-27 13:44:33 UTC (rev 3561)
@@ -60,7 +60,7 @@
}
// wait till all messages are processed
- waitTillNoMoreMessages(jobExecutor);
+ waitTillNoMoreMessages();
} finally {
jobExecutor.stop(true);
15 years, 4 months
JBoss JBPM SVN: r3560 - in jbpm4/trunk/modules: test-pojo and 8 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-27 08:20:00 -0500 (Sat, 27 Dec 2008)
New Revision: 3560
Added:
jbpm4/trunk/modules/test-pojo/src/main/
jbpm4/trunk/modules/test-pojo/src/main/java/
jbpm4/trunk/modules/test-pojo/src/main/java/org/
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionAsWaitStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
jbpm4/trunk/modules/test-pojo/src/main/resources/
jbpm4/trunk/modules/test-pojo/src/main/resources/logging.properties
Removed:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/AutomaticDecisionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventPropagationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExceptionHandlerTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExternalDecisionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/FunctionalActivityTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/LoopingTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeStateTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableDeclarationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionEventsTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/VariableTest.java
jbpm4/trunk/modules/test-pojo/src/test/
Modified:
jbpm4/trunk/modules/test-pojo/.classpath
jbpm4/trunk/modules/test-pojo/pom.xml
Log:
fixed test-pojo classpath. moved first pojo tests from pvm to test-pojo module
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/AutomaticDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/AutomaticDecisionTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/AutomaticDecisionTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,109 +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.api.basicfeatures;
-
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-
-/** 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.start();
-
- assertEquals("priority delivery", execution.getNode().getName());
- }
-
- public void testAverageRating() {
- ClientProcessDefinition processDefinition = createCreditProcess();
-
- ClientProcessInstance execution = processDefinition.createProcessInstance();
- execution.setVariable("creditRate", 2);
- execution.start();
-
- assertEquals("bulk delivery", execution.getNode().getName());
- }
-
- public void testBadRating() {
- ClientProcessDefinition processDefinition = createCreditProcess();
-
- ClientProcessInstance execution = processDefinition.createProcessInstance();
- execution.setVariable("creditRate", -7);
- execution.start();
-
- assertEquals("payment upfront", execution.getNode().getName());
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,157 +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.api.basicfeatures;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.pvm.example03.AutomaticActivity;
-import org.jbpm.pvm.example03.WaitState;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/** 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("loan")
- .node("submit loan request").initial().behaviour(automaticActivity)
- .transition().to("evaluate")
- .node("evaluate").behaviour(waitState)
- .transition("approve").to("wire money")
- .transition("reject").to("end")
- .node("wire money").behaviour(automaticActivity)
- .transition().to("archive")
- .node("archive").behaviour(waitState)
- .transition().to("end")
- .node("end").behaviour(waitState)
- .done();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- List<String> expectedEvents = new ArrayList<String>();
-
- expectedEvents.add("execute[submit loan request]");
- expectedEvents.add("execute[evaluate]");
-
- assertEquals("evaluate", execution.getNodeName());
- assertEquals(expectedEvents, recordedEvents);
-
- execution.signal("approve");
-
- expectedEvents.add("signal[evaluate]");
- expectedEvents.add("execute[wire money]");
- expectedEvents.add("execute[archive]");
-
- assertEquals("archive", execution.getNodeName());
- assertEquals(expectedEvents, recordedEvents);
-
- execution.signal();
-
- expectedEvents.add("signal[archive]");
- expectedEvents.add("execute[end]");
-
- assertEquals("end", execution.getNodeName());
- assertEquals(expectedEvents, recordedEvents);
- }
-
- public void testDelayedBegin() {
- List<String> recordedEvents = new ArrayList<String>();
- AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
- WaitState waitState = new WaitState(recordedEvents);
-
- ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
- .node("submit loan request").initial().behaviour(automaticActivity)
- .transition().to("evaluate")
- .node("evaluate").behaviour(waitState)
- .transition("approve").to("wire money")
- .transition("reject").to("end")
- .node("wire money").behaviour(automaticActivity)
- .transition().to("archive")
- .node("archive").behaviour(waitState)
- .transition().to("end")
- .node("end").behaviour(waitState)
- .done();
-
-
- ClientProcessInstance processInstance = processDefinition.createProcessInstance();
-
- // here, inbetween create and start 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.start();
-
- expectedEvents.add("execute[submit loan request]");
- expectedEvents.add("execute[evaluate]");
-
- assertEquals("evaluate", processInstance.getNodeName());
- assertEquals(expectedEvents, recordedEvents);
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventPropagationTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventPropagationTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventPropagationTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,358 +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.api.basicfeatures;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.listener.EventListener;
-import org.jbpm.listener.EventListenerExecution;
-import org.jbpm.model.Event;
-import org.jbpm.model.Node;
-import org.jbpm.model.ObservableElement;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- // 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,266 +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.api.basicfeatures;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.listener.EventListener;
-import org.jbpm.listener.EventListenerExecution;
-import org.jbpm.model.Event;
-import org.jbpm.model.Node;
-import org.jbpm.model.ObservableElement;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/** 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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.startProcessInstance();
-
- 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExceptionHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExceptionHandlerTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExceptionHandlerTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,325 +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.api.basicfeatures;
-
-import java.util.Map;
-
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.listener.EventListener;
-import org.jbpm.listener.EventListenerExecution;
-import org.jbpm.model.Event;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
- try {
- execution.signal();
- fail("expected exception");
- } catch (RuntimeException e) {
- assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
- }
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,197 +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.api.basicfeatures;
-
-import java.util.Map;
-
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/** 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.start();
-
- 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.start();
-
- assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
-
- try {
- processInstance.signal();
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("process-instance is not active: inactive", e.getMessage());
- }
- }
-
- public void testCustomEndState() {
- 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.start();
- processInstance.end("error");
-
- assertEquals("error", processInstance.getState());
-
- try {
- processInstance.signal();
- fail("expected exception");
- } catch (JbpmException 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.start();
-
- try {
- processInstance.end("active");
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("invalid end state: active", e.getMessage());
- }
- try {
- processInstance.end("suspended");
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("invalid end state: suspended", e.getMessage());
- }
- try {
- processInstance.end("created");
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("invalid end state: created", e.getMessage());
- }
- try {
- processInstance.end("async");
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("invalid end state: async", e.getMessage());
- }
- try {
- processInstance.end("inactive");
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("invalid end state: inactive", e.getMessage());
- }
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExternalDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExternalDecisionTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExternalDecisionTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,101 +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.api.basicfeatures;
-
-import junit.framework.TestCase;
-
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.pvm.samples.activities.AutomaticActivity;
-import org.jbpm.pvm.samples.activities.WaitState;
-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();
- ClientExecution execution = processDefinition.startProcessInstance();
-
- execution.signal("good");
-
- assertEquals("priority delivery", execution.getNode().getName());
- }
-
- public void testAverageRating() {
- ClientProcessDefinition processDefinition = createCreditProcess();
- ClientExecution execution = processDefinition.startProcessInstance();
-
- execution.signal("average");
-
- assertEquals("bulk delivery", execution.getNode().getName());
- }
-
- public void testBadRating() {
- ClientProcessDefinition processDefinition = createCreditProcess();
- ClientExecution execution = processDefinition.startProcessInstance();
-
- execution.signal("bad");
-
- assertEquals("payment upfront", execution.getNode().getName());
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/FunctionalActivityTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/FunctionalActivityTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/FunctionalActivityTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,157 +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.api.basicfeatures;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.listener.EventListener;
-import org.jbpm.listener.EventListenerExecution;
-import org.jbpm.model.Node;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-
-/** 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.start();
-
- 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.start();
-
- 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.start();
-
- List<String> expectedEvents = new ArrayList<String>();
- expectedEvents.add("performed automatic activity");
-
- assertEquals(expectedEvents, recordedEvents);
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/LoopingTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/LoopingTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/LoopingTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,104 +0,0 @@
-package org.jbpm.pvm.api.basicfeatures;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeStateTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeStateTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeStateTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,85 +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.api.basicfeatures;
-
-import java.util.Map;
-
-import org.jbpm.Execution;
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @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.start();
- 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableDeclarationTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableDeclarationTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableDeclarationTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,222 +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.api.basicfeatures;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.model.Node;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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>();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
- 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,187 +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.api.basicfeatures;
-
-import java.util.Map;
-
-import org.jbpm.JbpmException;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- *
- * +---+ +--------+ +---+
- * | 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- processInstance.signal();
- OpenExecution bScope = processInstance.getExecution("b");
-
- bScope.createVariable("temp", "28C");
-
- processInstance.signal(bScope);
-
- try {
- bScope.setVariable("temp", "21C");
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("can't update variable 'temp' on execution[b]", e.getMessage());
- }
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,108 +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.api.basicfeatures;
-
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @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 {
- ClientExecution 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();
-
- ClientExecution superProcesInstance = superProcess.startProcessInstance();
- assertEquals("super2", superProcesInstance.getNode().getName());
-
- ClientExecution subProcessInstance = (ClientExecution) 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.api.basicfeatures;
-
-import java.util.Map;
-
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.model.Condition;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/** 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(OpenExecution 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- assertNull(execution.getNode());
-
- execution.signal();
-
- assertEquals("make profit", execution.getNode().getName());
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,177 +0,0 @@
-package org.jbpm.pvm.api.basicfeatures;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.Execution;
-import org.jbpm.activity.Activity;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.model.Node;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.model.Transition;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * 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) {
- OpenExecution processInstance = execution.getProcessInstance();
-
- 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, processInstance);
- execution.take(outgoingTransition, childExecution);
- }
-
- // if this was the first fork
- if (execution.isProcessInstance()) {
- execution.setNode(null);
- }
- }
- }
-
- 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.setState(Execution.STATE_INACTIVE);
- execution.waitForSignal();
-
- Node join = execution.getNode();
- List<OpenExecution> joinedExecutions = findJoinedExecutions(execution, join);
-
- if (isComplete(joinedExecutions, join)) {
- endJoinedExecutions(joinedExecutions, execution);
-
- OpenExecution processInstance = execution.getProcessInstance();
-
- Execution outgoingExecution = null;
- if ( processInstance.getExecutions()==null
- || processInstance.getExecutions().isEmpty()
- ) {
- outgoingExecution = processInstance;
- } else {
- outgoingExecution = execution.createExecution(processInstance);
- }
-
- execution.setNode(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 endJoinedExecutions(List<OpenExecution> joinedExecutions, ActivityExecution execution) {
- for (OpenExecution joinedExecution: joinedExecutions) {
- execution.end(joinedExecution);
- }
- }
- }
-
- 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();
-
- ClientExecution main = processDefinition.startProcessInstance();
-
- assertNull("fork", main.getNode());
- 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);
-
- assertNull(main.getNodeName());
- assertEquals("join", billing.getNodeName());
- assertEquals("ship", shipping.getNodeName());
- assertEquals(Execution.STATE_ACTIVE, shipping.getState());
- assertEquals(Execution.STATE_INACTIVE, billing.getState());
- 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionEventsTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionEventsTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionEventsTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,454 +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.api.basicfeatures;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.listener.EventListener;
-import org.jbpm.listener.EventListenerExecution;
-import org.jbpm.model.Event;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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();
-
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- 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/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/VariableTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/VariableTest.java 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/VariableTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,248 +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.api.basicfeatures;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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.start();
- assertEquals("Killroy was here", processInstance.getVariable("message"));
- }
-
- public void testNullValue() {
- ClientProcessDefinition processDefinition = ProcessFactory.build()
- .node("a").initial().behaviour(new WaitState())
- .done();
-
- ClientExecution processInstance = processDefinition.startProcessInstance();
-
- 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()));
- }
-
-}
Modified: jbpm4/trunk/modules/test-pojo/.classpath
===================================================================
--- jbpm4/trunk/modules/test-pojo/.classpath 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/test-pojo/.classpath 2008-12-27 13:20:00 UTC (rev 3560)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/test-classes"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm4/trunk/modules/test-pojo/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-pojo/pom.xml 2008-12-27 13:00:42 UTC (rev 3559)
+++ jbpm4/trunk/modules/test-pojo/pom.xml 2008-12-27 13:20:00 UTC (rev 3560)
@@ -40,11 +40,27 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
+
+ <!-- TODO remove this once process factory api is complete -->
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-pvm</artifactId>
+ <version>${version}</version>
+ </dependency>
+
</dependencies>
<!-- Plugins -->
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <testSourceDirectory>src/main/java</testSourceDirectory>
+ <classesDirectory>target/classes</classesDirectory>
+ <testClassesDirectory>target/classes</testClassesDirectory>
+ </configuration>
+ </plugin>
</plugins>
</build>
Added: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements Activity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticActivity.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/AutomaticDecisionTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+/** 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.start();
+
+ assertEquals("priority delivery", execution.getNode().getName());
+ }
+
+ public void testAverageRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientProcessInstance execution = processDefinition.createProcessInstance();
+ execution.setVariable("creditRate", 2);
+ execution.start();
+
+ assertEquals("bulk delivery", execution.getNode().getName());
+ }
+
+ public void testBadRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientProcessInstance execution = processDefinition.createProcessInstance();
+ execution.setVariable("creditRate", -7);
+ execution.start();
+
+ assertEquals("payment upfront", execution.getNode().getName());
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,155 @@
+/*
+ * 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.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/** 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("loan")
+ .node("submit loan request").initial().behaviour(automaticActivity)
+ .transition().to("evaluate")
+ .node("evaluate").behaviour(waitState)
+ .transition("approve").to("wire money")
+ .transition("reject").to("end")
+ .node("wire money").behaviour(automaticActivity)
+ .transition().to("archive")
+ .node("archive").behaviour(waitState)
+ .transition().to("end")
+ .node("end").behaviour(waitState)
+ .done();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ List<String> expectedEvents = new ArrayList<String>();
+
+ expectedEvents.add("execute[submit loan request]");
+ expectedEvents.add("execute[evaluate]");
+
+ assertEquals("evaluate", execution.getNodeName());
+ assertEquals(expectedEvents, recordedEvents);
+
+ execution.signal("approve");
+
+ expectedEvents.add("signal[evaluate]");
+ expectedEvents.add("execute[wire money]");
+ expectedEvents.add("execute[archive]");
+
+ assertEquals("archive", execution.getNodeName());
+ assertEquals(expectedEvents, recordedEvents);
+
+ execution.signal();
+
+ expectedEvents.add("signal[archive]");
+ expectedEvents.add("execute[end]");
+
+ assertEquals("end", execution.getNodeName());
+ assertEquals(expectedEvents, recordedEvents);
+ }
+
+ public void testDelayedBegin() {
+ List<String> recordedEvents = new ArrayList<String>();
+ AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
+ WaitState waitState = new WaitState(recordedEvents);
+
+ ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+ .node("submit loan request").initial().behaviour(automaticActivity)
+ .transition().to("evaluate")
+ .node("evaluate").behaviour(waitState)
+ .transition("approve").to("wire money")
+ .transition("reject").to("end")
+ .node("wire money").behaviour(automaticActivity)
+ .transition().to("archive")
+ .node("archive").behaviour(waitState)
+ .transition().to("end")
+ .node("end").behaviour(waitState)
+ .done();
+
+
+ ClientProcessInstance processInstance = processDefinition.createProcessInstance();
+
+ // here, inbetween create and start 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.start();
+
+ expectedEvents.add("execute[submit loan request]");
+ expectedEvents.add("execute[evaluate]");
+
+ assertEquals("evaluate", processInstance.getNodeName());
+ assertEquals(expectedEvents, recordedEvents);
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventPropagationTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventPropagationTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Event;
+import org.jbpm.model.Node;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ // 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());
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Event;
+import org.jbpm.model.Node;
+import org.jbpm.model.ObservableElement;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/** 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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.startProcessInstance();
+
+ 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));
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExceptionHandlerTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (RuntimeException e) {
+ assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
+ }
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,197 @@
+/*
+ * 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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/** 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.start();
+
+ 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.start();
+
+ assertEquals(Execution.STATE_INACTIVE, processInstance.getState());
+
+ try {
+ processInstance.signal();
+ fail("expected exception");
+ } catch (JbpmException e) {
+ // OK
+ assertTextPresent("process-instance is not active: inactive", e.getMessage());
+ }
+ }
+
+ public void testCustomEndState() {
+ 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.start();
+ processInstance.end("error");
+
+ assertEquals("error", processInstance.getState());
+
+ try {
+ processInstance.signal();
+ fail("expected exception");
+ } catch (JbpmException 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.start();
+
+ try {
+ processInstance.end("active");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ // OK
+ assertTextPresent("invalid end state: active", e.getMessage());
+ }
+ try {
+ processInstance.end("suspended");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ // OK
+ assertTextPresent("invalid end state: suspended", e.getMessage());
+ }
+ try {
+ processInstance.end("created");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ // OK
+ assertTextPresent("invalid end state: created", e.getMessage());
+ }
+ try {
+ processInstance.end("async");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ // OK
+ assertTextPresent("invalid end state: async", e.getMessage());
+ }
+ try {
+ processInstance.end("inactive");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ // OK
+ assertTextPresent("invalid end state: inactive", e.getMessage());
+ }
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExternalDecisionTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,98 @@
+/*
+ * 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.test.activities;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+/**
+ * @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();
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ execution.signal("good");
+
+ assertEquals("priority delivery", execution.getNode().getName());
+ }
+
+ public void testAverageRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ execution.signal("average");
+
+ assertEquals("bulk delivery", execution.getNode().getName());
+ }
+
+ public void testBadRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ execution.signal("bad");
+
+ assertEquals("payment upfront", execution.getNode().getName());
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/FunctionalActivityTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,157 @@
+/*
+ * 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.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Node;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+/** 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.start();
+
+ 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.start();
+
+ 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.start();
+
+ List<String> expectedEvents = new ArrayList<String>();
+ expectedEvents.add("performed automatic activity");
+
+ assertEquals(expectedEvents, recordedEvents);
+ }
+
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/LoopingTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,104 @@
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ List<Object> expectedIndexes = new ArrayList<Object>();
+ for (int i=0; i<loops; i++) expectedIndexes.add(i);
+
+ assertEquals(expectedIndexes, recordedIndexes);
+ assertEquals("end", execution.getNode().getName());
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeStateTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @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.start();
+ 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());
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableDeclarationTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,222 @@
+/*
+ * 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.test.activities;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Node;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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>();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+ 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());
+ }
+
+
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ScopeVariableTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.JbpmException;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ *
+ * +---+ +--------+ +---+
+ * | 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ processInstance.signal();
+ OpenExecution bScope = processInstance.getExecution("b");
+
+ bScope.createVariable("temp", "28C");
+
+ processInstance.signal(bScope);
+
+ try {
+ bScope.setVariable("temp", "21C");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ // OK
+ assertTextPresent("can't update variable 'temp' on execution[b]", e.getMessage());
+ }
+ }
+
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @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 {
+ ClientExecution 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();
+
+ ClientExecution superProcesInstance = superProcess.startProcessInstance();
+ assertEquals("super2", superProcesInstance.getNode().getName());
+
+ ClientExecution subProcessInstance = (ClientExecution) superProcesInstance.getSubProcessInstance();
+ assertNotNull(subProcessInstance);
+ assertEquals("sub2", subProcessInstance.getNode().getName());
+
+ subProcessInstance.signal();
+
+ assertEquals("sub3", subProcessInstance.getNode().getName());
+ assertTrue(subProcessInstance.isEnded());
+
+ assertEquals("super3", superProcesInstance.getNode().getName());
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionAsWaitStateTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionAsWaitStateTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionAsWaitStateTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Condition;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/** 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(OpenExecution 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ assertNull(execution.getNode());
+
+ execution.signal();
+
+ assertEquals("make profit", execution.getNode().getName());
+ }
+
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionBasedConcurrencyTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,177 @@
+package org.jbpm.test.activities;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Node;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.model.Transition;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * 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) {
+ OpenExecution processInstance = execution.getProcessInstance();
+
+ 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, processInstance);
+ execution.take(outgoingTransition, childExecution);
+ }
+
+ // if this was the first fork
+ if (execution.isProcessInstance()) {
+ execution.setNode(null);
+ }
+ }
+ }
+
+ 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.setState(Execution.STATE_INACTIVE);
+ execution.waitForSignal();
+
+ Node join = execution.getNode();
+ List<OpenExecution> joinedExecutions = findJoinedExecutions(execution, join);
+
+ if (isComplete(joinedExecutions, join)) {
+ endJoinedExecutions(joinedExecutions, execution);
+
+ OpenExecution processInstance = execution.getProcessInstance();
+
+ Execution outgoingExecution = null;
+ if ( processInstance.getExecutions()==null
+ || processInstance.getExecutions().isEmpty()
+ ) {
+ outgoingExecution = processInstance;
+ } else {
+ outgoingExecution = execution.createExecution(processInstance);
+ }
+
+ execution.setNode(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 endJoinedExecutions(List<OpenExecution> joinedExecutions, ActivityExecution execution) {
+ for (OpenExecution joinedExecution: joinedExecutions) {
+ execution.end(joinedExecution);
+ }
+ }
+ }
+
+ 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();
+
+ ClientExecution main = processDefinition.startProcessInstance();
+
+ assertNull("fork", main.getNode());
+ 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);
+
+ assertNull(main.getNodeName());
+ assertEquals("join", billing.getNodeName());
+ assertEquals("ship", shipping.getNodeName());
+ assertEquals(Execution.STATE_ACTIVE, shipping.getState());
+ assertEquals(Execution.STATE_INACTIVE, billing.getState());
+ 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));
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionEventsTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/TransitionEventsTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -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.test.activities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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();
+
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ 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());
+ }
+}
Copied: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java (from rev 3557, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/VariableTest.java)
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,248 @@
+/*
+ * 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.test.activities;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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.start();
+ assertEquals("Killroy was here", processInstance.getVariable("message"));
+ }
+
+ public void testNullValue() {
+ ClientProcessDefinition processDefinition = ProcessFactory.build()
+ .node("a").initial().behaviour(new WaitState())
+ .done();
+
+ ClientExecution processInstance = processDefinition.startProcessInstance();
+
+ 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()));
+ }
+
+}
Added: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ execution.waitForSignal();
+ }
+
+ public void signal(ActivityExecution execution,
+ String signalName,
+ Map<String, Object> parameters) {
+ }
+}
Property changes on: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/test-pojo/src/main/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/test-pojo/src/main/resources/logging.properties 2008-12-27 13:20:00 UTC (rev 3560)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=INFO
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
15 years, 4 months
JBoss JBPM SVN: r3559 - jbpm4/trunk/modules/test-db/src.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-27 08:00:42 -0500 (Sat, 27 Dec 2008)
New Revision: 3559
Removed:
jbpm4/trunk/modules/test-db/src/test/
Log:
fixed test-db api compile classpath: made it strict
15 years, 4 months
JBoss JBPM SVN: r3558 - in jbpm4/trunk/modules: test-db/src and 16 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-27 07:58:42 -0500 (Sat, 27 Dec 2008)
New Revision: 3558
Added:
jbpm4/trunk/modules/test-db/src/main/
jbpm4/trunk/modules/test-db/src/main/java/
jbpm4/trunk/modules/test-db/src/main/java/org/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
jbpm4/trunk/modules/test-db/src/main/resources/
jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties
jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java
jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-db/src/test/resources/logging.properties
Modified:
jbpm4/trunk/modules/test-db/.classpath
jbpm4/trunk/modules/test-db/pom.xml
jbpm4/trunk/modules/test-pojo/pom.xml
Log:
fixed test-db api compile classpath: made it strict
Modified: jbpm4/trunk/modules/test-db/.classpath
===================================================================
--- jbpm4/trunk/modules/test-db/.classpath 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/.classpath 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/test-classes"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/pom.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -43,15 +43,16 @@
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-jpdl</artifactId>
<version>${version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-task</artifactId>
<version>${version}</version>
+ <scope>test</scope>
</dependency>
-
<!-- TODO remove PVM dependency for compilation (keep it for test)-->
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
@@ -65,6 +66,14 @@
<!-- Plugins -->
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <testSourceDirectory>src/main/java</testSourceDirectory>
+ <classesDirectory>target/classes</classesDirectory>
+ <testClassesDirectory>target/classes</testClassesDirectory>
+ </configuration>
+ </plugin>
</plugins>
</build>
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,96 @@
+/*
+ * 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.test.activities;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveTest extends DbTestCase {
+
+ public void testExclusiveExpression() {
+ deployJpdlXmlString(
+ "<process name='Poolcar'>" +
+ " <start>" +
+ " <flow to='How far?' />" +
+ " </start>" +
+ " <exclusive name='How far?' expr='#{distance}'>" +
+ " <flow name='far' to='Big car' />" +
+ " <flow name='nearby' to='Small car' />" +
+ " </exclusive>" +
+ " <state name='Big car' />" +
+ " <state name='Small car' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("distance", "far");
+ Execution execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Big car", execution.getNodeName());
+
+ variables.put("distance", "nearby");
+ execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Small car", execution.getNodeName());
+ }
+
+ public void testExclusiveWithConditions() {
+ deployJpdlXmlString(
+ "<process name='Poolcar'>" +
+ " <start>" +
+ " <flow to='How far?' />" +
+ " </start>" +
+ " <exclusive name='How far?'>" +
+ " <flow to='Big car'>" +
+ " <condition expr='#{distance > 10}' />" +
+ " </flow>" +
+ " <flow to='Small car'>" +
+ " <condition expr='#{distance >= 3}' />" +
+ " </flow>" +
+ " <flow to='No car' />" +
+ " </exclusive>" +
+ " <state name='Big car' />" +
+ " <state name='Small car' />" +
+ " <state name='No car' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("distance", new Integer(69));
+ Execution execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Big car", execution.getNodeName());
+
+ variables.put("distance", new Integer(6));
+ execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Small car", execution.getNodeName());
+
+ variables.put("distance", new Integer(2));
+ execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("No car", execution.getNodeName());
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,153 @@
+/*
+ * 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.test.activities;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateTest extends DbTestCase {
+
+ public void testWaitStatesSequence() {
+ deployJpdlXmlString(
+ "<process name='ThreeStates'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c'>" +
+ " <flow to='d' />" +
+ " </state>" +
+ " <end name='d' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionById("ThreeStates:1");
+ assertEquals("b", execution.getNodeName());
+
+ String executionId = execution.getId();
+ execution = executionService.signalExecutionById(executionId);
+ assertEquals("c", execution.getNodeName());
+
+ execution = executionService.signalExecutionById(executionId);
+ assertEquals("d", execution.getNodeName());
+ assertTrue(execution.isEnded());
+ }
+
+ public void testExternalDecision() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='ed' />" +
+ " </start>" +
+ " <state name='ed'>" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
+ " </state>" +
+ " <state name='b' />" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("p", "one");
+ assertEquals("ed", execution.getNodeName());
+ execution = executionService.signalExecutionById("p/one", "left");
+ assertEquals("b", execution.getNodeName());
+
+ executionService.startExecutionById("p:1", "two");
+ execution = executionService.signalExecutionById("p/two", "middle");
+ assertEquals("c", execution.getNodeName());
+
+ executionService.startExecutionById("p:1", "three");
+ execution = executionService.signalExecutionById("p/three", "right");
+ assertEquals("d", execution.getNodeName());
+ }
+
+ public void testDefaultSignalWithNamedTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
+ " </state>" +
+ " <state name='b' />" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("p", "one");
+ try {
+ executionService.signalExecutionById("p/one", "left");
+ } catch (JbpmException e) {
+ assertTextPresent("no matching transition or event for default signal in state(a)", e.getMessage());
+ }
+ }
+
+ public void testNamedSignalWithoutMatchingTransition() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
+ " </state>" +
+ " <state name='b' />" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("p", "one");
+ Execution execution = executionService.signalExecutionById("p/one", "up");
+ assertEquals("a", execution.getNodeName());
+ }
+
+ public void testDefaultSignalWithoutTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("p", "one");
+ Execution execution = executionService.signalExecutionById("p/one");
+ assertEquals("a", execution.getNodeName());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,63 @@
+/*
+ * 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.test.cfg;
+
+import org.jbpm.Configuration;
+import org.jbpm.ProcessEngine;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConfigurationTest extends JbpmTestCase {
+
+ public void testDefaultConfiguration() {
+ ProcessEngine processEngine = new Configuration()
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ }
+
+ public void testMinimalConfiguration() {
+ ProcessEngine processEngine = new Configuration()
+ .setXmlString("<jbpm-configuration />")
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ }
+
+ public void testConfigurationServices() {
+ ProcessEngine processEngine = new Configuration()
+ .setXmlString(
+ "<jbpm-configuration>" +
+ " <process-engine>" +
+ " <process-service />" +
+ " <execution-service />" +
+ " <management-service />" +
+ " </process-engine>" +
+ "</jbpm-configuration>"
+ )
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ assertNotNull(processEngine.getProcessService());
+ assertNotNull(processEngine.getExecutionService());
+ assertNotNull(processEngine.getManagementService());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,517 @@
+/*
+ * 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.test.svc;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionServiceTest extends DbTestCase {
+
+ // start new process instance ///////////////////////////////////////////////
+
+ public void testStartNewProcessInstance() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getNodeName());
+ }
+
+ public void testAutoSwitchToNewVersion() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getNodeName());
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("b", execution.getNodeName());
+ }
+
+ public void testStartNewProcessInstanceWithAKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "one");
+
+ assertNotNull(execution);
+ assertEquals("ICL/one", execution.getId());
+ }
+
+ public void testStartNewProcessInstanceWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ Execution execution = executionService.startExecutionByKey("ICL", variables);
+
+ String executionId = execution.getId();
+
+ assertNotNull(execution);
+
+ Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
+ Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+ // signal ///////////////////////////////////////////////////////////////////
+
+ public void testSignalExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ assertEquals("a", execution.getNodeName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("b", execution.getNodeName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("c", execution.getNodeName());
+ }
+
+ public void testSignalExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ assertEquals("a", execution.getNodeName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("b", execution.getNodeName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("c", execution.getNodeName());
+ }
+
+ public void testSignalExecutionWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ execution = executionService.signalExecutionById("ICL/82436", variables);
+
+ assertNotNull(execution);
+ String executionId = execution.getId();
+ assertEquals("b", execution.getNodeName());
+
+ Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
+ Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+
+ /*
+ public void testDefaultSignalWithoutTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByName("p", "one");
+ Execution execution = executionService.signalExecution("p/one");
+ assertEquals("a", execution.getNodeName());
+ }
+
+ public void testStartExecutionById()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ // deploy process with key 'NCLFU' and version 1
+ // then we know that the key for this process will be 'NCLFU:1'
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
+ .version(1)
+ .key("NCLFU")
+ .node("initial").initial()
+ .behaviour(WaitState.class)
+ .done();
+
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // start an execution for the process with the given id
+ Execution execution = executionService.startExecutionById("NCLFU:1");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("initial", execution.getNodeName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertNull(execution.getKey());
+ // if there is no user defined name or key specified in the execution,
+ // the default id generator will create a unique id like this: processDefinitionId/execution.dbid
+ assertEquals("NCLFU:1/", execution.getId().substring(0, 8));
+ // the last part of the execution key should be the dbid.
+ Long.parseLong(execution.getId().substring(8));
+ }
+
+ public void testStartExecutionByIdWithGivenExecutionKey()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ // deploy the same process with a given key and version
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
+ .behaviour(WaitState.class).done();
+
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ Execution execution = executionService.startExecutionById("NCLFU:1", "TheFirstTime");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("initial", execution.getNodeName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertEquals("TheFirstTime", execution.getKey());
+ // if there is a user provided key in the execution, the default
+ // id generator will take that to create the id
+ assertEquals("NCLFU:1/TheFirstTime", execution.getId());
+ }
+
+ public void testStartExecutionByIdWithVariables()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
+ .behaviour(WaitState.class).done();
+
+ processService.deploy(new DeploymentImpl(processDefinition));
+
+ // create the map with variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // provide the variables in the start execution method
+ Execution execution = executionService.startExecutionById("NCLFU:1", variables);
+ String executionId = execution.getId();
+
+ assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+ assertEquals("text", executionService.getVariable(executionId, "b"));
+ }
+
+ public void testStartExecutionInLatest()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // start a nuclear fusion in the latest version of
+ // the process definition with name 'nuclear fusion'
+ Execution execution = executionService.startExecutionByKey("NFU");
+ assertNotNull(execution);
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
+ execution.getId().startsWith("NFU:3/"));
+ }
+
+ public void testStartExecutionInLatestByNameWithVariables()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // create variables that are fed into the process before it starts executing
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // feed the variables in
+ Execution execution = executionService.startExecutionByName("nuclear fusion", variables);
+ String executionId = execution.getId();
+
+ // verify that the variables are actually set
+ assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+ assertEquals("text", executionService.getVariable(executionId, "b"));
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
+ execution.getId().startsWith("NFU:3/"));
+ }
+
+ public void testStartExecutionByNameWithKey()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ Execution execution = executionService.startExecutionByName("nuclear fusion", "TheFirstTime");
+ assertNotNull(execution);
+ assertEquals("TheFirstTime", execution.getKey());
+ assertEquals("NFU:3/TheFirstTime", execution.getId());
+ }
+
+ public void testFindExecution()
+ {
+ // create an arbitrary execution
+ Execution execution = startExecution();
+ // take the id and see if the execution service can still find it back
+ execution = executionService.findExecution(execution.getId());
+ assertNotNull(execution);
+ }
+
+ public void testSetVariable()
+ {
+ Execution execution = startExecution();
+
+ String executionId = execution.getId();
+ // set variable a to value text
+ executionService.setVariable(executionId, "a", "text");
+ // check if we can read that value back
+ assertEquals("text", executionService.getVariable(executionId, "a"));
+
+ // overwrite the value of variable a with another text
+ executionService.setVariable(executionId, "a", "another text");
+ // see if we can read another text back from the variable
+ assertEquals("another text", executionService.getVariable(executionId, "a"));
+ }
+
+ public void testSetVariables()
+ {
+ Execution execution = startExecution();
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // set variables in bulk by providing a map
+ executionService.setVariables(execution.getId(), variables);
+
+ Map<String, Object> expected = new HashMap<String, Object>(variables);
+
+ Set<String> variableNames = new HashSet<String>();
+ variableNames.add("a");
+ variableNames.add("b");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+
+ // now set variables b and c with a map
+ variables = new HashMap<String, Object>();
+ variables.put("b", new Integer(99));
+ variables.put("c", "another text");
+
+ // this should leave a untouched, overwrite b and create c
+ executionService.setVariables(execution.getId(), variables);
+
+ // update the expected map
+ expected.put("b", new Integer(99));
+ expected.put("c", "another text");
+
+ // add c to the variable names that should be collected
+ variableNames.add("c");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+ }
+
+ // helper methods ///////////////////////////////////////////////////////////
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+ * 'publish book'
+ void deployMultipleVersionsOfProcesses()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(
+ WaitState.class).done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("publish book").key("PBO").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+ }
+
+ Execution startExecution()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").node("initial").initial().behaviour(WaitState.class)
+ .done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ return executionService.startExecutionByName("nuclear fusion");
+ }
+
+ */
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,36 @@
+/*
+ * 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.test.svc;
+
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceTest extends DbTestCase {
+
+ public void testGetJobs() {
+ assertEquals(0, managementService.getTimers(0, 10).size());
+ assertEquals(0, managementService.getMessages(0, 10).size());
+ }
+
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,357 @@
+/*
+ * 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.test.svc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessServiceTest extends DbTestCase {
+
+ public void testProcessWithNameOnly() {
+ ProcessDefinition processDefinition = deployJpdlXmlString(
+ "<process name='Insurance claim'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("Insurance_claim", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Insurance_claim:1", processDefinition.getId());
+ }
+
+ public void testProcessWithNameAndKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("ICL");
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("ICL", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("ICL:1", processDefinition.getId());
+ }
+
+ // interface methods ////////////////////////////////////////////////////////
+
+ public void testFindProcessDefinitionKeys() {
+ deployMultipleVersionsOfProcesses();
+
+ List<String> processKeys = processService.findProcessDefinitionKeys();
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("nuclear_fusion");
+ expected.add("publish_book");
+ expected.add("ultimate_seduction");
+
+ assertEquals(expected, processKeys);
+ }
+
+
+ public void testFindProcessByKey() {
+ deployJpdlXmlString(
+ "<process name='Name with spaces'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Name_with_spaces");
+ assertNotNull(processDefinition);
+ assertEquals("Name with spaces", processDefinition.getName());
+ assertEquals("Name_with_spaces", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Name_with_spaces:1", processDefinition.getId());
+ }
+
+ public void testFindProcessDefinitions() {
+ deployMultipleVersionsOfProcesses();
+
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("nuclear_fusion");
+ assertNotNull(processDefinitions);
+
+ assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
+ assertEquals("nuclear fusion", processDefinitions.get(0).getName());
+ assertEquals(3, processDefinitions.get(0).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(1).getName());
+ assertEquals(2, processDefinitions.get(1).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(2).getName());
+ assertEquals(1, processDefinitions.get(2).getVersion());
+ }
+
+ public void testFindLatestProcessDefinition() {
+ deployMultipleVersionsOfProcesses();
+
+ ProcessDefinition retrieved = processService.findLatestProcessDefinitionByKey("nuclear_fusion");
+ assertNotNull(retrieved);
+
+ assertEquals(3, retrieved.getVersion());
+ assertEquals("nuclear fusion", retrieved.getName());
+ assertEquals("nuclear_fusion", retrieved.getKey());
+ }
+
+ public void testFindProcessDefinitionById() {
+ deployJpdlXmlString(
+ "<process name='given' version='33'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ ProcessDefinition processDefinition = processService.findProcessDefinitionById("given:33");
+ assertNotNull(processDefinition);
+ assertEquals("given", processDefinition.getName());
+ assertEquals(33, processDefinition.getVersion());
+ }
+
+ public void testDeleteProcessDefinition() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start />" +
+ "</process>")
+ .deploy();
+
+ // load it
+ processService.deleteProcessDefinition("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().list().size());
+ }
+
+ public void testDeleteProcessDefinitionAndInstances() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>")
+ .deploy();
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ processService.deleteProcessDefinitionAndInstances("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().list().size());
+ assertEquals(0, executionService.createExecutionQuery().list().size());
+ }
+
+ public void testDeleteProcessDefinitionButNotInstances() {
+ deployJpdlXmlString(
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ try {
+ processService.deleteProcessDefinition("deleteme:33");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("still 4 process instances for process definition deleteme:33", e.getMessage());
+ }
+ }
+
+ // various other aspects ////////////////////////////////////////////////////
+
+ public void testAutomaticVersioning() {
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look it up again
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+ assertNotNull(processDefinitions);
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // and check that automatically assigned version starts with 1
+ assertEquals(1, processDefinition.getVersion());
+
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look them up again
+ processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
+ // and check that automatically assigned version starts with 1
+ assertEquals(2, processDefinitions.get(0).getVersion());
+ assertEquals(1, processDefinitions.get(1).getVersion());
+ }
+
+ public void testUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("takethis");
+ assertNotNull(processDefinitions);
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // verify that the user specified version was used
+ // (and not overwritten by an automatically assigned versioning)
+ assertEquals(234, processDefinition.getVersion());
+ }
+
+ public void testDuplicateUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ try {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("process 'takethis:234' already exists", e.getMessage());
+ }
+ }
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+ * 'publish book'
+ */
+ void deployMultipleVersionsOfProcesses()
+ {
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='publish book'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+ }
+
+ public void testMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start>" +
+ " <flow to='end' />" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertEquals("end", execution.getNodeName());
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+
+ public void testMostMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,77 @@
+/*
+ * 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.test.svc;
+
+import java.util.Date;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskServiceTest extends DbTestCase {
+
+ public void testNewTask() {
+ Task task = taskService.newTask();
+ task = taskService.getTask(task.getId());
+ assertNull("expected null, but was " + task, task);
+ }
+
+ public void testGenerateTaskId() {
+ Task task = taskService.newTask();
+ String taskId = task.getId();
+ assertNull("expected null, but was " + taskId, taskId);
+ // save task to generate identifier
+ saveTask(task);
+ assertNotNull("expected non-null task id", task.getId());
+ }
+
+ public void testSaveTask() {
+ Task task = taskService.newTask();
+ saveTask(task);
+ String taskId = task.getId();
+ // task was made persistent
+ task = taskService.getTask(taskId);
+ assertNotNull("expected non-null task", task);
+ // make some change
+ Date dueDate = new Date();
+ task.setDueDate(dueDate);
+ taskService.saveTask(task);
+ // verify change is applied
+ task = taskService.getTask(taskId);
+ assertEquals(dueDate, task.getDueDate());
+ }
+
+ public void testDeleteTask() {
+ Task task = taskService.newTask();
+ taskService.saveTask(task);
+ String taskId = task.getId();
+
+ // task was made persistent
+ assertNotNull("expected non-null task", taskService.getTask(taskId));
+ // delete task and verify it does not exist
+ taskService.deleteTask(taskId);
+ task = taskService.getTask(taskId);
+ assertNull("expected null, but was " + task, task);
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,82 @@
+/*
+ * 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.test.variables;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BasicVariablesTest extends DbTestCase {
+
+ public void testNoVariables() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("var", "one");
+ Set<String> variableNames = executionService.getVariableNames("var/one");
+ assertNotNull(variableNames);
+ assertEquals(0, variableNames.size());
+ }
+
+ public void testThreeVariables() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ Set<String> expectedVariableNames = new HashSet<String>(variables.keySet());
+ Map<String, Object> expectedVariables = new HashMap<String, Object>(variables);
+
+ executionService.startExecutionByKey("var", variables, "one");
+
+ Set<String> variableNames = executionService.getVariableNames("var/one");
+ assertNotNull(variableNames);
+
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables("var/one", variableNames);
+
+ assertEquals(expectedVariables, variables);
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties (from rev 3557, jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,11 @@
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.url jdbc:hsqldb:mem:.
+hibernate.connection.username sa
+hibernate.connection.password
+hibernate.hbm2ddl.auto create-drop
+hibernate.cache.use_second_level_cache true
+hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
+# hibernate.show_sql true
+# hibernate.format_sql true
+# hibernate.use_sql_comments true
Property changes on: jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml (from rev 3557, jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+ <process-engine>
+
+ <deployer-manager>
+ <assign-file-type>
+ <file extension=".jpdl.xml" type="jpdl" />
+ </assign-file-type>
+ <parse-jpdl />
+ <check-process />
+ <check-problems />
+ <save />
+ </deployer-manager>
+
+ <process-service />
+ <execution-service />
+ <management-service />
+ <task-service />
+
+ <command-service>
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <hibernate-configuration>
+ <properties resource="hibernate.properties" />
+ <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+ <mapping resource="jbpm.pvm.wire.hbm.xml" />
+ <mapping resource="jbpm.pvm.definition.hbm.xml" />
+ <mapping resource="jbpm.pvm.execution.hbm.xml" />
+ <mapping resource="jbpm.pvm.variable.hbm.xml" />
+ <mapping resource="jbpm.pvm.job.hbm.xml" />
+ <mapping resource="jbpm.jpdl.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <cache-configuration resource="jbpm.pvm.cache.xml"
+ usage="nonstrict-read-write" />
+ </hibernate-configuration>
+
+ <hibernate-session-factory />
+
+ <script-manager default-expression-language="juel"
+ default-script-language="juel"
+ read-contexts="execution, environment, process-engine"
+ write-context="">
+ <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
+ </script-manager>
+
+ <job-executor auto-start="false" />
+ <job-test-helper />
+
+ <id-generator />
+ <variable-types resource="jbpm.pvm.types.xml" />
+
+ <business-calendar>
+ <monday hours="9:00-12:00 and 12:30-17:00"/>
+ <tuesday hours="9:00-12:00 and 12:30-17:00"/>
+ <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+ <thursday hours="9:00-12:00 and 12:30-17:00"/>
+ <friday hours="9:00-12:00 and 12:30-17:00"/>
+ <holiday period="01/07/2008 - 31/08/2008"/>
+ </business-calendar>
+
+ </process-engine>
+
+ <environment>
+ <hibernate-session />
+ <transaction />
+ <pvm-db-session />
+ <job-db-session />
+ <task-db-session />
+ <message-session />
+ <timer-session />
+ </environment>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/resources/logging.properties (from rev 3557, jbpm4/trunk/modules/test-db/src/test/resources/logging.properties)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=INFO
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -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.test.activities;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jbpm.Execution;
-import org.jbpm.jpdl.ExclusiveHandler;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExclusiveTest extends DbTestCase {
-
- public void testExclusiveExpression() {
- deployJpdlXmlString(
- "<process name='Poolcar'>" +
- " <start>" +
- " <flow to='How far?' />" +
- " </start>" +
- " <exclusive name='How far?' expr='#{distance}'>" +
- " <flow name='far' to='Big car' />" +
- " <flow name='nearby' to='Small car' />" +
- " </exclusive>" +
- " <state name='Big car' />" +
- " <state name='Small car' />" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("distance", "far");
- Execution execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Big car", execution.getNodeName());
-
- variables.put("distance", "nearby");
- execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Small car", execution.getNodeName());
- }
-
- public void testExclusiveWithConditions() {
- deployJpdlXmlString(
- "<process name='Poolcar'>" +
- " <start>" +
- " <flow to='How far?' />" +
- " </start>" +
- " <exclusive name='How far?'>" +
- " <flow to='Big car'>" +
- " <condition expr='#{distance > 10}' />" +
- " </flow>" +
- " <flow to='Small car'>" +
- " <condition expr='#{distance >= 3}' />" +
- " </flow>" +
- " <flow to='No car' />" +
- " </exclusive>" +
- " <state name='Big car' />" +
- " <state name='Small car' />" +
- " <state name='No car' />" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("distance", new Integer(69));
- Execution execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Big car", execution.getNodeName());
-
- variables.put("distance", new Integer(6));
- execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Small car", execution.getNodeName());
-
- variables.put("distance", new Integer(2));
- execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("No car", execution.getNodeName());
- }
-
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,153 +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.test.activities;
-
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class StateTest extends DbTestCase {
-
- public void testWaitStatesSequence() {
- deployJpdlXmlString(
- "<process name='ThreeStates'>" +
- " <start name='a'>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b'>" +
- " <flow to='c' />" +
- " </state>" +
- " <state name='c'>" +
- " <flow to='d' />" +
- " </state>" +
- " <end name='d' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionById("ThreeStates:1");
- assertEquals("b", execution.getNodeName());
-
- String executionId = execution.getId();
- execution = executionService.signalExecutionById(executionId);
- assertEquals("c", execution.getNodeName());
-
- execution = executionService.signalExecutionById(executionId);
- assertEquals("d", execution.getNodeName());
- assertTrue(execution.isEnded());
- }
-
- public void testExternalDecision() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='ed' />" +
- " </start>" +
- " <state name='ed'>" +
- " <flow name='left' to='b' />" +
- " <flow name='middle' to='c' />" +
- " <flow name='right' to='d' />" +
- " </state>" +
- " <state name='b' />" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("p", "one");
- assertEquals("ed", execution.getNodeName());
- execution = executionService.signalExecutionById("p/one", "left");
- assertEquals("b", execution.getNodeName());
-
- executionService.startExecutionById("p:1", "two");
- execution = executionService.signalExecutionById("p/two", "middle");
- assertEquals("c", execution.getNodeName());
-
- executionService.startExecutionById("p:1", "three");
- execution = executionService.signalExecutionById("p/three", "right");
- assertEquals("d", execution.getNodeName());
- }
-
- public void testDefaultSignalWithNamedTransitions() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow name='left' to='b' />" +
- " <flow name='middle' to='c' />" +
- " <flow name='right' to='d' />" +
- " </state>" +
- " <state name='b' />" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("p", "one");
- try {
- executionService.signalExecutionById("p/one", "left");
- } catch (JbpmException e) {
- assertTextPresent("no matching transition or event for default signal in state(a)", e.getMessage());
- }
- }
-
- public void testNamedSignalWithoutMatchingTransition() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow name='left' to='b' />" +
- " <flow name='middle' to='c' />" +
- " <flow name='right' to='d' />" +
- " </state>" +
- " <state name='b' />" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("p", "one");
- Execution execution = executionService.signalExecutionById("p/one", "up");
- assertEquals("a", execution.getNodeName());
- }
-
- public void testDefaultSignalWithoutTransitions() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("p", "one");
- Execution execution = executionService.signalExecutionById("p/one");
- assertEquals("a", execution.getNodeName());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,63 +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.test.cfg;
-
-import org.jbpm.Configuration;
-import org.jbpm.ProcessEngine;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class ConfigurationTest extends JbpmTestCase {
-
- public void testDefaultConfiguration() {
- ProcessEngine processEngine = new Configuration()
- .buildProcessEngine();
- assertNotNull(processEngine);
- }
-
- public void testMinimalConfiguration() {
- ProcessEngine processEngine = new Configuration()
- .setXmlString("<jbpm-configuration />")
- .buildProcessEngine();
- assertNotNull(processEngine);
- }
-
- public void testConfigurationServices() {
- ProcessEngine processEngine = new Configuration()
- .setXmlString(
- "<jbpm-configuration>" +
- " <process-engine>" +
- " <process-service />" +
- " <execution-service />" +
- " <management-service />" +
- " </process-engine>" +
- "</jbpm-configuration>"
- )
- .buildProcessEngine();
- assertNotNull(processEngine);
- assertNotNull(processEngine.getProcessService());
- assertNotNull(processEngine.getExecutionService());
- assertNotNull(processEngine.getManagementService());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,517 +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.test.svc;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.Execution;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExecutionServiceTest extends DbTestCase {
-
- // start new process instance ///////////////////////////////////////////////
-
- public void testStartNewProcessInstance() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL");
-
- assertNotNull(execution);
- assertEquals("a", execution.getNodeName());
- }
-
- public void testAutoSwitchToNewVersion() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL");
-
- assertNotNull(execution);
- assertEquals("a", execution.getNodeName());
-
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b' />" +
- "</process>"
- );
-
- execution = executionService.startExecutionByKey("ICL");
-
- assertNotNull(execution);
- assertEquals("b", execution.getNodeName());
- }
-
- public void testStartNewProcessInstanceWithAKey() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "one");
-
- assertNotNull(execution);
- assertEquals("ICL/one", execution.getId());
- }
-
- public void testStartNewProcessInstanceWithVariables() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Map<String,Object> variables = new HashMap<String,Object>();
- variables.put("customer", "John Doe");
- variables.put("type", "Accident");
- variables.put("amount", new Float(763.74));
-
- Execution execution = executionService.startExecutionByKey("ICL", variables);
-
- String executionId = execution.getId();
-
- assertNotNull(execution);
-
- Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
- Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
- Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
- assertEquals(expectedVariableNames, variableNames);
-
- variables = executionService.getVariables(executionId, variableNames);
- assertEquals(expectedVariables, variables);
- }
-
- // signal ///////////////////////////////////////////////////////////////////
-
- public void testSignalExecutionByKey() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow to='b' />" +
- " </state>" +
- " <state name='b'>" +
- " <flow to='c' />" +
- " </state>" +
- " <state name='c' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "82436");
-
- assertEquals("a", execution.getNodeName());
-
- execution = executionService.signalExecutionByKey("ICL", "82436");
-
- assertEquals("b", execution.getNodeName());
-
- execution = executionService.signalExecutionByKey("ICL", "82436");
-
- assertEquals("c", execution.getNodeName());
- }
-
- public void testSignalExecutionById() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow to='b' />" +
- " </state>" +
- " <state name='b'>" +
- " <flow to='c' />" +
- " </state>" +
- " <state name='c' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "82436");
-
- assertEquals("a", execution.getNodeName());
-
- execution = executionService.signalExecutionById("ICL/82436");
-
- assertEquals("b", execution.getNodeName());
-
- execution = executionService.signalExecutionById("ICL/82436");
-
- assertEquals("c", execution.getNodeName());
- }
-
- public void testSignalExecutionWithVariables() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow to='b' />" +
- " </state>" +
- " <state name='b' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "82436");
-
- Map<String,Object> variables = new HashMap<String,Object>();
- variables.put("customer", "John Doe");
- variables.put("type", "Accident");
- variables.put("amount", new Float(763.74));
-
- execution = executionService.signalExecutionById("ICL/82436", variables);
-
- assertNotNull(execution);
- String executionId = execution.getId();
- assertEquals("b", execution.getNodeName());
-
- Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
- Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
- Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
- assertEquals(expectedVariableNames, variableNames);
-
- variables = executionService.getVariables(executionId, variableNames);
- assertEquals(expectedVariables, variables);
- }
-
-
- /*
- public void testDefaultSignalWithoutTransitions() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- executionService.startExecutionByName("p", "one");
- Execution execution = executionService.signalExecution("p/one");
- assertEquals("a", execution.getNodeName());
- }
-
- public void testStartExecutionById()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // deploy process with key 'NCLFU' and version 1
- // then we know that the key for this process will be 'NCLFU:1'
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
- .version(1)
- .key("NCLFU")
- .node("initial").initial()
- .behaviour(WaitState.class)
- .done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // start an execution for the process with the given id
- Execution execution = executionService.startExecutionById("NCLFU:1");
- assertNotNull(execution);
-
- // checking the state
- assertEquals("initial", execution.getNodeName());
-
- // checking the generated id
- assertNull(execution.getName());
- assertNull(execution.getKey());
- // if there is no user defined name or key specified in the execution,
- // the default id generator will create a unique id like this: processDefinitionId/execution.dbid
- assertEquals("NCLFU:1/", execution.getId().substring(0, 8));
- // the last part of the execution key should be the dbid.
- Long.parseLong(execution.getId().substring(8));
- }
-
- public void testStartExecutionByIdWithGivenExecutionKey()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // deploy the same process with a given key and version
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
- .behaviour(WaitState.class).done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- Execution execution = executionService.startExecutionById("NCLFU:1", "TheFirstTime");
- assertNotNull(execution);
-
- // checking the state
- assertEquals("initial", execution.getNodeName());
-
- // checking the generated id
- assertNull(execution.getName());
- assertEquals("TheFirstTime", execution.getKey());
- // if there is a user provided key in the execution, the default
- // id generator will take that to create the id
- assertEquals("NCLFU:1/TheFirstTime", execution.getId());
- }
-
- public void testStartExecutionByIdWithVariables()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
- .behaviour(WaitState.class).done();
-
- processService.deploy(new DeploymentImpl(processDefinition));
-
- // create the map with variables
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // provide the variables in the start execution method
- Execution execution = executionService.startExecutionById("NCLFU:1", variables);
- String executionId = execution.getId();
-
- assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
- assertEquals("text", executionService.getVariable(executionId, "b"));
- }
-
- public void testStartExecutionInLatest()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // start a nuclear fusion in the latest version of
- // the process definition with name 'nuclear fusion'
- Execution execution = executionService.startExecutionByKey("NFU");
- assertNotNull(execution);
-
- // in the generated id, we can see if the right process definition version was taken
- assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
- execution.getId().startsWith("NFU:3/"));
- }
-
- public void testStartExecutionInLatestByNameWithVariables()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // create variables that are fed into the process before it starts executing
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- // feed the variables in
- Execution execution = executionService.startExecutionByName("nuclear fusion", variables);
- String executionId = execution.getId();
-
- // verify that the variables are actually set
- assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
- assertEquals("text", executionService.getVariable(executionId, "b"));
-
- // in the generated id, we can see if the right process definition version was taken
- assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
- execution.getId().startsWith("NFU:3/"));
- }
-
- public void testStartExecutionByNameWithKey()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- Execution execution = executionService.startExecutionByName("nuclear fusion", "TheFirstTime");
- assertNotNull(execution);
- assertEquals("TheFirstTime", execution.getKey());
- assertEquals("NFU:3/TheFirstTime", execution.getId());
- }
-
- public void testFindExecution()
- {
- // create an arbitrary execution
- Execution execution = startExecution();
- // take the id and see if the execution service can still find it back
- execution = executionService.findExecution(execution.getId());
- assertNotNull(execution);
- }
-
- public void testSetVariable()
- {
- Execution execution = startExecution();
-
- String executionId = execution.getId();
- // set variable a to value text
- executionService.setVariable(executionId, "a", "text");
- // check if we can read that value back
- assertEquals("text", executionService.getVariable(executionId, "a"));
-
- // overwrite the value of variable a with another text
- executionService.setVariable(executionId, "a", "another text");
- // see if we can read another text back from the variable
- assertEquals("another text", executionService.getVariable(executionId, "a"));
- }
-
- public void testSetVariables()
- {
- Execution execution = startExecution();
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- // set variables in bulk by providing a map
- executionService.setVariables(execution.getId(), variables);
-
- Map<String, Object> expected = new HashMap<String, Object>(variables);
-
- Set<String> variableNames = new HashSet<String>();
- variableNames.add("a");
- variableNames.add("b");
-
- // read the variables back and compare
- assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
-
- // now set variables b and c with a map
- variables = new HashMap<String, Object>();
- variables.put("b", new Integer(99));
- variables.put("c", "another text");
-
- // this should leave a untouched, overwrite b and create c
- executionService.setVariables(execution.getId(), variables);
-
- // update the expected map
- expected.put("b", new Integer(99));
- expected.put("c", "another text");
-
- // add c to the variable names that should be collected
- variableNames.add("c");
-
- // read the variables back and compare
- assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
- }
-
- // helper methods ///////////////////////////////////////////////////////////
-
- /**
- * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
- * 'publish book'
- void deployMultipleVersionsOfProcesses()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(
- WaitState.class).done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("publish book").key("PBO").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
- }
-
- Execution startExecution()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").node("initial").initial().behaviour(WaitState.class)
- .done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- return executionService.startExecutionByName("nuclear fusion");
- }
-
- */
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,36 +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.test.svc;
-
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class ManagementServiceTest extends DbTestCase {
-
- public void testGetJobs() {
- assertEquals(0, managementService.getTimers(0, 10).size());
- assertEquals(0, managementService.getMessages(0, 10).size());
- }
-
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,357 +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.test.svc;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.ProcessDefinition;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessServiceTest extends DbTestCase {
-
- public void testProcessWithNameOnly() {
- ProcessDefinition processDefinition = deployJpdlXmlString(
- "<process name='Insurance claim'>" +
- " <start />" +
- "</process>"
- );
-
- assertNotNull(processDefinition);
- assertEquals("Insurance claim", processDefinition.getName());
- assertEquals("Insurance_claim", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("Insurance_claim:1", processDefinition.getId());
- }
-
- public void testProcessWithNameAndKey() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start />" +
- "</process>"
- );
-
- ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("ICL");
-
- assertNotNull(processDefinition);
- assertEquals("Insurance claim", processDefinition.getName());
- assertEquals("ICL", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("ICL:1", processDefinition.getId());
- }
-
- // interface methods ////////////////////////////////////////////////////////
-
- public void testFindProcessDefinitionKeys() {
- deployMultipleVersionsOfProcesses();
-
- List<String> processKeys = processService.findProcessDefinitionKeys();
-
- List<String> expected = new ArrayList<String>();
- expected.add("nuclear_fusion");
- expected.add("publish_book");
- expected.add("ultimate_seduction");
-
- assertEquals(expected, processKeys);
- }
-
-
- public void testFindProcessByKey() {
- deployJpdlXmlString(
- "<process name='Name with spaces'>" +
- " <start />" +
- "</process>"
- );
-
- ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Name_with_spaces");
- assertNotNull(processDefinition);
- assertEquals("Name with spaces", processDefinition.getName());
- assertEquals("Name_with_spaces", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("Name_with_spaces:1", processDefinition.getId());
- }
-
- public void testFindProcessDefinitions() {
- deployMultipleVersionsOfProcesses();
-
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("nuclear_fusion");
- assertNotNull(processDefinitions);
-
- assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
- assertEquals("nuclear fusion", processDefinitions.get(0).getName());
- assertEquals(3, processDefinitions.get(0).getVersion());
-
- assertEquals("nuclear fusion", processDefinitions.get(1).getName());
- assertEquals(2, processDefinitions.get(1).getVersion());
-
- assertEquals("nuclear fusion", processDefinitions.get(2).getName());
- assertEquals(1, processDefinitions.get(2).getVersion());
- }
-
- public void testFindLatestProcessDefinition() {
- deployMultipleVersionsOfProcesses();
-
- ProcessDefinition retrieved = processService.findLatestProcessDefinitionByKey("nuclear_fusion");
- assertNotNull(retrieved);
-
- assertEquals(3, retrieved.getVersion());
- assertEquals("nuclear fusion", retrieved.getName());
- assertEquals("nuclear_fusion", retrieved.getKey());
- }
-
- public void testFindProcessDefinitionById() {
- deployJpdlXmlString(
- "<process name='given' version='33'>" +
- " <start />" +
- "</process>"
- );
-
- // load it
- ProcessDefinition processDefinition = processService.findProcessDefinitionById("given:33");
- assertNotNull(processDefinition);
- assertEquals("given", processDefinition.getName());
- assertEquals(33, processDefinition.getVersion());
- }
-
- public void testDeleteProcessDefinition() {
- processService.createDeployment()
- .addString("xmlstring.jpdl.xml",
- "<process name='deleteme' version='33'>" +
- " <start />" +
- "</process>")
- .deploy();
-
- // load it
- processService.deleteProcessDefinition("deleteme:33");
-
- // check if the db is empty
- assertEquals(0, processService.createProcessDefinitionQuery().list().size());
- }
-
- public void testDeleteProcessDefinitionAndInstances() {
- processService.createDeployment()
- .addString("xmlstring.jpdl.xml",
- "<process name='deleteme' version='33'>" +
- " <start>" +
- " <flow to='w' />" +
- " </start>" +
- " <state name='w' />" +
- "</process>")
- .deploy();
-
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
-
- // delete it all
- processService.deleteProcessDefinitionAndInstances("deleteme:33");
-
- // check if the db is empty
- assertEquals(0, processService.createProcessDefinitionQuery().list().size());
- assertEquals(0, executionService.createExecutionQuery().list().size());
- }
-
- public void testDeleteProcessDefinitionButNotInstances() {
- deployJpdlXmlString(
- "<process name='deleteme' version='33'>" +
- " <start>" +
- " <flow to='w' />" +
- " </start>" +
- " <state name='w' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
-
- // delete it all
- try {
- processService.deleteProcessDefinition("deleteme:33");
- fail("expected exception");
- } catch (JbpmException e) {
- assertTextPresent("still 4 process instances for process definition deleteme:33", e.getMessage());
- }
- }
-
- // various other aspects ////////////////////////////////////////////////////
-
- public void testAutomaticVersioning() {
- deployJpdlXmlString(
- "<process name='versionme'>" +
- " <start />" +
- "</process>"
- );
-
- // look it up again
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("versionme");
- assertNotNull(processDefinitions);
- // verify that there is only one
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- ProcessDefinition processDefinition = processDefinitions.get(0);
- // and check that automatically assigned version starts with 1
- assertEquals(1, processDefinition.getVersion());
-
- deployJpdlXmlString(
- "<process name='versionme'>" +
- " <start />" +
- "</process>"
- );
-
- // look them up again
- processDefinitions = processService.findProcessDefinitionsByKey("versionme");
- // verify that there is only one
- assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
- // and check that automatically assigned version starts with 1
- assertEquals(2, processDefinitions.get(0).getVersion());
- assertEquals(1, processDefinitions.get(1).getVersion());
- }
-
- public void testUserProvidedVersion() {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
-
- // load it
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("takethis");
- assertNotNull(processDefinitions);
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- ProcessDefinition processDefinition = processDefinitions.get(0);
- // verify that the user specified version was used
- // (and not overwritten by an automatically assigned versioning)
- assertEquals(234, processDefinition.getVersion());
- }
-
- public void testDuplicateUserProvidedVersion() {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
-
- try {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
- fail("expected exception");
- } catch (JbpmException e) {
- assertTextPresent("process 'takethis:234' already exists", e.getMessage());
- }
- }
-
- /**
- * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
- * 'publish book'
- */
- void deployMultipleVersionsOfProcesses()
- {
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='publish book'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
- }
-
- public void testMinimalProcess() {
- deployJpdlXmlString(
- "<process name='minimal'>" +
- " <start>" +
- " <flow to='end' />" +
- " </start>" +
- " <end name='end' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("minimal");
-
- assertEquals("end", execution.getNodeName());
- assertTrue(execution.isEnded());
- assertFalse(execution.isActive());
- }
-
- public void testMostMinimalProcess() {
- deployJpdlXmlString(
- "<process name='minimal'>" +
- " <start />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("minimal");
-
- assertTrue(execution.isEnded());
- assertFalse(execution.isActive());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,77 +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.test.svc;
-
-import java.util.Date;
-
-import org.jbpm.task.Task;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskServiceTest extends DbTestCase {
-
- public void testNewTask() {
- Task task = taskService.newTask();
- task = taskService.getTask(task.getId());
- assertNull("expected null, but was " + task, task);
- }
-
- public void testGenerateTaskId() {
- Task task = taskService.newTask();
- String taskId = task.getId();
- assertNull("expected null, but was " + taskId, taskId);
- // save task to generate identifier
- saveTask(task);
- assertNotNull("expected non-null task id", task.getId());
- }
-
- public void testSaveTask() {
- Task task = taskService.newTask();
- saveTask(task);
- String taskId = task.getId();
- // task was made persistent
- task = taskService.getTask(taskId);
- assertNotNull("expected non-null task", task);
- // make some change
- Date dueDate = new Date();
- task.setDueDate(dueDate);
- taskService.saveTask(task);
- // verify change is applied
- task = taskService.getTask(taskId);
- assertEquals(dueDate, task.getDueDate());
- }
-
- public void testDeleteTask() {
- Task task = taskService.newTask();
- taskService.saveTask(task);
- String taskId = task.getId();
-
- // task was made persistent
- assertNotNull("expected non-null task", taskService.getTask(taskId));
- // delete task and verify it does not exist
- taskService.deleteTask(taskId);
- task = taskService.getTask(taskId);
- assertNull("expected null, but was " + task, task);
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,82 +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.test.variables;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class BasicVariablesTest extends DbTestCase {
-
- public void testNoVariables() {
- deployJpdlXmlString(
- "<process name='var'>" +
- " <start name='a'>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b'/>" +
- "</process>"
- );
-
- executionService.startExecutionByKey("var", "one");
- Set<String> variableNames = executionService.getVariableNames("var/one");
- assertNotNull(variableNames);
- assertEquals(0, variableNames.size());
- }
-
- public void testThreeVariables() {
- deployJpdlXmlString(
- "<process name='var'>" +
- " <start name='a'>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b'/>" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("customer", "John Doe");
- variables.put("type", "Accident");
- variables.put("amount", new Float(763.74));
-
- Set<String> expectedVariableNames = new HashSet<String>(variables.keySet());
- Map<String, Object> expectedVariables = new HashMap<String, Object>(variables);
-
- executionService.startExecutionByKey("var", variables, "one");
-
- Set<String> variableNames = executionService.getVariableNames("var/one");
- assertNotNull(variableNames);
-
- assertEquals(expectedVariableNames, variableNames);
-
- variables = executionService.getVariables("var/one", variableNames);
-
- assertEquals(expectedVariables, variables);
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,11 +0,0 @@
-hibernate.dialect org.hibernate.dialect.HSQLDialect
-hibernate.connection.driver_class org.hsqldb.jdbcDriver
-hibernate.connection.url jdbc:hsqldb:mem:.
-hibernate.connection.username sa
-hibernate.connection.password
-hibernate.hbm2ddl.auto create-drop
-hibernate.cache.use_second_level_cache true
-hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
-# hibernate.show_sql true
-# hibernate.format_sql true
-# hibernate.use_sql_comments true
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
-
- <process-engine>
-
- <deployer-manager>
- <assign-file-type>
- <file extension=".jpdl.xml" type="jpdl" />
- </assign-file-type>
- <parse-jpdl />
- <check-process />
- <check-problems />
- <save />
- </deployer-manager>
-
- <process-service />
- <execution-service />
- <management-service />
- <task-service />
-
- <command-service>
- <retry-interceptor />
- <environment-interceptor />
- <standard-transaction-interceptor />
- </command-service>
-
- <hibernate-configuration>
- <properties resource="hibernate.properties" />
- <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
- <mapping resource="jbpm.pvm.wire.hbm.xml" />
- <mapping resource="jbpm.pvm.definition.hbm.xml" />
- <mapping resource="jbpm.pvm.execution.hbm.xml" />
- <mapping resource="jbpm.pvm.variable.hbm.xml" />
- <mapping resource="jbpm.pvm.job.hbm.xml" />
- <mapping resource="jbpm.jpdl.hbm.xml" />
- <mapping resource="jbpm.task.hbm.xml" />
- <cache-configuration resource="jbpm.pvm.cache.xml"
- usage="nonstrict-read-write" />
- </hibernate-configuration>
-
- <hibernate-session-factory />
-
- <script-manager default-expression-language="juel"
- default-script-language="juel"
- read-contexts="execution, environment, process-engine"
- write-context="">
- <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
- </script-manager>
-
- <job-executor auto-start="false" />
- <job-test-helper />
-
- <id-generator />
- <variable-types resource="jbpm.pvm.types.xml" />
-
- <business-calendar>
- <monday hours="9:00-12:00 and 12:30-17:00"/>
- <tuesday hours="9:00-12:00 and 12:30-17:00"/>
- <wednesday hours="9:00-12:00 and 12:30-17:00"/>
- <thursday hours="9:00-12:00 and 12:30-17:00"/>
- <friday hours="9:00-12:00 and 12:30-17:00"/>
- <holiday period="01/07/2008 - 31/08/2008"/>
- </business-calendar>
-
- </process-engine>
-
- <environment>
- <hibernate-session />
- <transaction />
- <pvm-db-session />
- <job-db-session />
- <task-db-session />
- <message-session />
- <timer-session />
- </environment>
-
-</jbpm-configuration>
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/logging.properties 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/resources/logging.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,28 +0,0 @@
-handlers= java.util.logging.ConsoleHandler
-# to add the error triggered file handler
-# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
-
-redirect.commons.logging = enabled
-
-java.util.logging.ConsoleHandler.level = FINEST
-java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
-
-# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
-# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
-# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
-
-# For example, set the com.xyz.foo logger to only log SEVERE messages:
-# com.xyz.foo.level = SEVERE
-
-org.jbpm.level=FINEST
-org.jbpm.pvm.internal.tx.level=FINE
-org.jbpm.pvm.internal.wire.level=FINE
-org.jbpm.pvm.internal.util.level=FINE
-
-org.hibernate.level=INFO
-org.hibernate.cfg.HbmBinder.level=SEVERE
-org.hibernate.cfg.SettingsFactory.level=SEVERE
-org.hibernate.SQL.level=FINEST
-# org.hibernate.type.level=FINEST
-# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
-# org.hibernate.transaction.level=FINEST
Modified: jbpm4/trunk/modules/test-pojo/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-pojo/pom.xml 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-pojo/pom.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -48,50 +48,4 @@
</plugins>
</build>
- <!-- Profiles -->
- <profiles>
-
- <!--
- Name: no-impl
- Descr: The default implementation profile
- -->
- <profile>
- <id>no-impl</id>
- <activation>
- <property>
- <name>!impl</name>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>jbpm-pvm</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
-
- <!--
- Name: impl-ri
- Descr: The RI implementation profile
- -->
- <profile>
- <id>impl-ri</id>
- <activation>
- <property>
- <name>impl</name>
- <value>ri</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jbpm.spec</groupId>
- <artifactId>jbpm-spec-ri</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
-
- </profiles>
-
</project>
\ No newline at end of file
15 years, 4 months
JBoss JBPM SVN: r3557 - in jbpm4/trunk/modules/userguide/src/main/docbook/en: images and 1 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-27 06:30:11 -0500 (Sat, 27 Dec 2008)
New Revision: 3557
Added:
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.gpd.site.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.libraries.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.xml.catalog.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.new.process.file.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.new.process.wizard.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.concurrency.graphbased.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.multiple.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.processinstance.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.state.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.esb.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.exclusive.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.hql.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.java.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.script.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.choice.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.sequence.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.task.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml
Removed:
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/concurrency.graphbased.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.multiple.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.processinstance.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/esb.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/exclusive.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/hql.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/java.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/script.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/sql.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.choice.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.sequence.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Gpd.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Scripting.xml
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
Log:
docs completion
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/concurrency.graphbased.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.multiple.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.processinstance.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/esb.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/exclusive.png
===================================================================
(Binary files differ)
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.gpd.site.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.gpd.site.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.libraries.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.libraries.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.xml.catalog.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.install.xml.catalog.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.new.process.file.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.new.process.file.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.new.process.wizard.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.new.process.wizard.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.open.in.xml.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/gpd.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/hql.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/java.png
===================================================================
(Binary files differ)
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.concurrency.graphbased.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/concurrency.graphbased.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.concurrency.graphbased.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.multiple.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.multiple.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.multiple.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.processinstance.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.processinstance.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.processinstance.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.end.state.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png)
===================================================================
(Binary files differ)
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.esb.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/esb.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.esb.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.exclusive.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/exclusive.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.exclusive.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.hql.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/hql.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.hql.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.java.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/java.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.java.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.script.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/script.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.script.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.choice.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.choice.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.choice.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.sequence.png (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.sequence.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.state.sequence.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.task.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.task.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/script.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/sql.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.choice.png
===================================================================
(Binary files differ)
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.sequence.png
===================================================================
(Binary files differ)
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml 2008-12-26 15:23:55 UTC (rev 3556)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/master.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -3,10 +3,11 @@
<!DOCTYPE book [
<!ENTITY ch01-Introduction SYSTEM "modules/ch01-Introduction.xml">
<!ENTITY ch02-Installation SYSTEM "modules/ch02-Installation.xml">
- <!ENTITY ch03-Services SYSTEM "modules/ch03-Services.xml">
- <!ENTITY ch04-Jpdl SYSTEM "modules/ch04-Jpdl.xml">
- <!ENTITY ch05-Gpd SYSTEM "modules/ch05-Gpd.xml">
- <!ENTITY ch06-Scripting SYSTEM "modules/ch06-Scripting.xml">
+ <!ENTITY ch03-Gpd SYSTEM "modules/ch03-Gpd.xml">
+ <!ENTITY ch04-Services SYSTEM "modules/ch04-Services.xml">
+ <!ENTITY ch05-Jpdl SYSTEM "modules/ch05-Jpdl.xml">
+ <!ENTITY ch06-Variables SYSTEM "modules/ch06-Variables.xml">
+ <!ENTITY ch07-Scripting SYSTEM "modules/ch07-Scripting.xml">
]>
<book lang="en">
@@ -19,9 +20,10 @@
&ch01-Introduction;
&ch02-Installation;
- &ch03-Services;
- &ch04-Jpdl;
- &ch05-Gpd;
- &ch06-Scripting;
+ &ch03-Gpd;
+ &ch04-Services;
+ &ch05-Jpdl;
+ &ch06-Variables;
+ &ch07-Scripting;
</book>
\ No newline at end of file
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2008-12-26 15:23:55 UTC (rev 3556)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -96,6 +96,10 @@
<listitem>Select <literal>Accept</literal> and click <literal>Finish</literal></listitem>
<listitem>Restart eclipse</listitem>
</itemizedlist>
+ <figure id="gpd.install.gpd.site">
+ <title>Adding the GPD local archive site</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.install.gpd.site.png"/></imageobject></mediaobject>
+ </figure>
</section>
<section>
<title>Define the jBPM User Library</title>
@@ -123,8 +127,35 @@
<listitem>Click <literal>Choose</literal> </listitem>
<listitem>Click <literal>OK</literal> twice to close all the open dialogs</listitem>
</itemizedlist>
+ <figure id="gpd.install.libraries">
+ <title>Defining jBPM Libraries</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.install.libraries.png"/></imageobject></mediaobject>
+ </figure>
</section>
+
<section>
+ <title>Adding jPDL 4 schema to the catalog</title>
+ <para>In case you want to edit the process XML sources directly, it is best to specify
+ your schema in the XML catalog. This will give you better code completion while
+ editing the process sources.
+ </para>
+ <itemizedlist>
+ <listitem>Click <literal>Window</literal> --> <literal>Preferences</literal> </listitem>
+ <listitem>Select <literal>XML</literal> --> <literal>XML Catalog</literal></listitem>
+ <listitem>Click 'Add...'</listitem>
+ <listitem>The 'Add XML Catalog Entry' dialog opens</listitem>
+ <listitem>Click the button with the map-icon next to location and select 'File System...'</listitem>
+ <listitem>In the dialog that opens, select file <literal>jpdl.xsd</literal>
+ in the src directory of the jBPM installation root.</listitem>
+ <listitem>Click 'Open' and close all the dialogs</listitem>
+ </itemizedlist>
+ <figure id="gpd.install.xml.catalog">
+ <title>Adding jPDL 4 schema to the Catalog</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.install.xml.catalog.png"/></imageobject></mediaobject>
+ </figure>
+ </section>
+
+ <section>
<title>Importing the Examples</title>
<para>In this section we will import the examples project in the
installation in Eclipse
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml (from rev 3540, jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Gpd.xml)
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml (rev 0)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -0,0 +1,50 @@
+<chapter id="gpd">
+ <title>GPD</title>
+
+ <para>This chapter will explain how to work with the Graphical Process Designer.
+ After installing the GPD and setting up the examples, you'll see that the
+ jPDL process files will get a special icon. Double clicking such a file
+ in the package view will open up the jPDL process in the GPD.
+ </para>
+ <figure id="gpd">
+ <title>The GPD</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.png"/></imageobject></mediaobject>
+ </figure>
+
+ <section id="creatingnewprocessfile">
+ <title>Creating a new process file</title>
+ <para>CRTL+N will open up the wizard selector.
+ </para>
+ <figure id="gpd.new.process.wizard">
+ <title>Select wizard dialog</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.new.process.wizard.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Select jBPM --> jPDL 4 File. Click 'Next >'. Then the
+ 'New jPDL 4 File' wizard opens.
+ </para>
+ <figure id="gpd.new.process.file">
+ <title>Create a new process dialog</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.new.process.file.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Select the parent directory, enter a file name and click 'Finish'. Voila,
+ you've created your first jPDL process file.
+ </para>
+ </section>
+
+ <section id="editingtheprocesssource">
+ <title>Editing the process source</title>
+ <para>To edit the process XML sources directly, select the process file, right click
+ and select 'Open with...' --> 'XML editor'
+ </para>
+ <figure id="gpd.open.in.xml">
+ <title>Open a process file in XML editor</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/gpd.open.in.xml.png"/></imageobject></mediaobject>
+ </figure>
+ <para>After you've done this, eclipse will remember that and the next time
+ you double click it, eclipse will open your process file in the XML Editor
+ automatically. To open up the process file in the GPD, perform the
+ same Open-with-action, but select 'jPDL 4 Editor'
+ </para>
+ </section>
+
+</chapter>
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Gpd.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml 2008-12-26 15:23:55 UTC (rev 3556)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -1,292 +0,0 @@
-<chapter id="services">
- <title>Services</title>
-
- <para>Interacting with jBPM occurs through services.
- The service interfaces can be obtained from the <literal>ProcessEngine</literal>
- which is build from a <literal>Configuration</literal>.
- </para>
-
- <section id="processengine">
- <title>ProcessEngine</title>
-
- <para>A <literal>ProcessEngine</literal> is thread safe and can be stored in a
- static member field or even better in JNDI or some other central location.
- One <literal>ProcessEngine</literal> object can be used by all requests and
- threads in an application. Here's how you can obtain a <literal>ProcessEngine</literal>
- </para>
-
- <programlisting>ProcessEngine processEngine = new Configuration()
- .buildProcessEngine();</programlisting>
-
- <para>The previous code snippet shows how to build a <literal>ProcessEngine</literal>
- from the default configuration file <literal>jbpm.cfg.xml</literal> which is
- expected in the root of the classpath. If you want to specify another
- resource location, use the <literal>setResource</literal> method like this:
- </para>
-
- <programlisting>ProcessEngine processEngine = new Configuration()
- .setResource("my-own-configuration-file.xml")
- .buildProcessEngine();</programlisting>
-
- <para>There are other <literal>setXxxx</literal> methods that allow to specify
- the configuration content as an <literal>InputStream</literal>, an
- <literal>xmlString</literal>, <literal>InputSource</literal>,
- <literal>URL</literal> or <literal>File</literal>.
- </para>
-
- <para>From a <literal>ProcessEngine</literal> the following services
- can be obtained:
- </para>
-
- <programlisting><emphasis role="bold">ProcessService</emphasis> processService = processEngine.getProcessService();
-<emphasis role="bold">ExecutionService</emphasis> executionService = processEngine.getExecutionService();
-<emphasis role="bold">ManagementService</emphasis> managementService = processEngine.getManagementService();
-<emphasis role="bold">TaskService</emphasis> taskService = processEngine.getTaskService();</programlisting>
-
- <para>Process engine objects defined in the configuration can also be retrieved by
- type (<literal>processEngine.get(Class<T>)</literal>)
- or by name (<literal>processEngine.get(String)</literal>)</para>
-
- </section>
-
- <section id="deployingaprocess">
- <title>Deploying a process</title>
- <para>The <literal>ProcessService</literal> groups all methods that access
- the repository of process definitions.
- </para>
- <para>A jPDL process file like e.g. <literal>order.jpdl.xml</literal> that is
- accessible as a resource on the classpath can be deployed programmatically with the
- <literal>ProcessService</literal> like this:
- </para>
- <programlisting>processService.createDeployment()
- .addResource("order.jpdl.xml")
- .deploy();</programlisting>
- <para>Analogue to the <literal>addResource</literal> method above, the source of
- the processes definitions XML can be picked up from a file, url, string,
- input stream, zip or jar archive and a directory.
- </para>
- <para>A deployment works with a set of named resources and can potentially contain
- multiple process descriptions and multiple other artifact types. The jPDL deployer
- will recognise process files based on the <literal>.jpdl.xml</literal>
- extension automatically. For files not adhering to that naming
- convention, the type can be set programmatically to <literal>jpdl</literal>
- with method <literal>setFileType("my-jpdl-process.someotherextension", "jpdl")</literal>
- </para>
- <para>During deployment, an <literal>id</literal> is assigned to the process
- definitions. The <literal>id</literal> will have format
- <literal>{key}:{version}</literal>
- </para>
- <para>If <literal>key</literal> is not provided, it is generated automatically
- based on the name. All non alpha numeric characters in the name will be replaced
- by underscores to generate the key.
- </para>
- <para>The same <literal>name</literal> can only be associated to one
- <literal>key</literal> and vice verca.
- </para>
- <para>If <literal>version</literal> is not provided, a <literal>version</literal>
- will be automatically be assigned. For version
- assignment, the versions of all deployed process definitions with the same name will
- be taken into account. The assigned <literal>version</literal> will be one higher
- then the highest <literal>version</literal> number of deployed process definitions
- with the same <literal>key</literal>. If no process definitions with a similar
- <literal>key</literal> have been deployed, version number 1 is assigned.
- </para>
- <para>In this first example, we'll supply a name and nothing else.</para>
- <programlisting><process name="Insurance claim">
-...
-</process></programlisting>
- <para>Let's assume that this is the first time that this process gets deployed.
- Then it will get the following properties:
- </para>
- <table><title>Process properties without key</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Property</entry>
- <entry>Value</entry>
- <entry>Source</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>Insurance claim</entry>
- <entry>process xml</entry>
- </row>
- <row>
- <entry><literal>key</literal></entry>
- <entry>Insurance_claim</entry>
- <entry>generated</entry>
- </row>
- <row>
- <entry><literal>version</literal></entry>
- <entry>1</entry>
- <entry>generated</entry>
- </row>
- <row>
- <entry><literal>id</literal></entry>
- <entry>Insurance_claim:1</entry>
- <entry>generated</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>And as a second example, we'll show how you can get shorter ids by
- specifying a process key:</para>
- <programlisting><process name="Insurance claim" key="ICL">
-...
-</process></programlisting>
- <para>Then the process definition properties look like this:</para>
- <table><title>Process properties with key</title>
- <tgroup cols="2" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Property</entry>
- <entry>Value</entry>
- <entry>Source</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>Insurance claim</entry>
- <entry>process xml</entry>
- </row>
- <row>
- <entry><literal>key</literal></entry>
- <entry>ICL</entry>
- <entry>process xml</entry>
- </row>
- <row>
- <entry><literal>version</literal></entry>
- <entry>1</entry>
- <entry>generated</entry>
- </row>
- <row>
- <entry><literal>id</literal></entry>
- <entry>ICL:1</entry>
- <entry>generated</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section id="startinganewprocessinstance">
- <title>Starting a new process instance</title>
-
- <section id="inlatest">
- <title>In latest</title>
- <para>Simplest and most common way to start a new process instance for a process
- definition is like this:
- </para>
- <programlisting>executionService.startExecutionByKey("ICL");</programlisting>
- <para>In this case, the service method will first look up the latest version of
- the processes with key <literal>ICL</literal>. Then a new
- process instance is started in that latest process definition.
- </para>
- <para>When a new version of the insurance claim process
- is deployed, all invocations of <literal>startExecutionByKey</literal>
- will automatically switch to the newly deployed version.
- </para>
- </section>
-
- <section id="specificprocessversion">
- <title>Specific process version</title>
- <para>If instead you want to start a new process instance in a very
- specific version, you can use the id of the process definition like this:
- </para>
- <programlisting>executionService.startExecutionById("ICL:1");</programlisting>
- </section>
-
- <section id="withakey">
- <title>With a key</title>
- <para>A new process instance can optionally be given a key. A key is
- a user defined reference to the execution. A key must be unique within the
- scope of all versions of a process definition. Typically it is easy
- to find such a key in the domain of the business process. For example, an
- order id or an insurance claim number.
- </para>
- <programlisting>executionService.startExecutionByKey("ICL", "CL92837");</programlisting>
- <para>The key is used to create the id of the process instance.
- The format used is <literal>{process-key}/{execution-id}</literal>.
- So execution created in the previous code snippet will have id
- <literal>ICL/CL92837</literal>.
- </para>
- <para>If no user defined key is provided, the DB primary key is taken
- as the key. In that case, the id can be retrieved like this:
- <programlisting>Execution execution = executionService.startExecutionByKey("ICL");
-String executionId = execution.getId();</programlisting>
- </para>
- <para>We recommend the use of a user defined keys. Typically in your application
- code, you'll have the key available. By providing a user defined key, you can
- then compose the id of the execution, rather then performing a query based
- on the process variables.
- </para>
- </section>
-
- <section id="withvariables">
- <title>With variables</title>
- <para>A map of named parameter objects can be provided when starting a
- new process instance. These parameters will be set as variables on the process
- instance between creation and start of the process instance.
- </para>
- <programlisting>Map<String,Object> variables = new HashMap<String,Object>();
-variables.put("customer", "John Doe");
-variables.put("type", "Accident");
-variables.put("amount", new Float(763.74));
-
-executionService.startExecutionByKey("ICL", variables);</programlisting>
- </section>
- </section>
-
- <section id="singallingawaitingexecution">
- <title>Signalling a waiting execution</title>
- <para>A process definition describes what must be done in terms of activities.
- Each activity in a process is either to be performed by the process
- system or by an external participant. When an activity is to be performed
- by an external participant, then the execution must wait until the
- external participant notifies the process system that the activity is
- completed. So an execution is either executing or waiting on an external
- participant. Typically, you'll see that the processes are mostly
- waiting for external participants. Especially humans tend to be slow :-)
- The time consumed by the process system between two wait states is
- typically very small.
- </para>
- <para>A <literal>state</literal> is the basic activity that represents
- something has to be done by an external participant and the execution
- must wait until a signal (aka external trigger) is given.
- </para>
- <para>When an execution is in a wait state, it can be given an external trigger
- with one of the signal methods. The recommended way to reference an execution
- is by using the process definition and execution key. In the next code snippet,
- <literal>ICL</literal> refers to the process definition key and <literal>82436</literal>
- refers to the execution key.
- </para>
- <programlisting>executionService.signalExecutionByKey("ICL", "82436");</programlisting>
- <para>Alternatively, the execution that must be signaled can be referenced
- by a unique execution id. In the next snippet, <literal>ICL/82436</literal>
- refers to the executionId.</para>
- <programlisting>executionService.signalExecutionById("ICL/82436");</programlisting>
- <para>Optionally some data can be passed along with a signal: a <literal>signalName</literal>
- and <literal>parameters</literal>. How the signalName gets used depends on
- the execution's current activity. The parameters get stored as process variables.
- </para>
- <programlisting>Map<String,Object> parameters = new HashMap<String,Object>();
-parameters.put("quality", "a+");
-parameters.put("target", "profit");
-
-executionService.signalExecutionById("ICL/82436", "Accept", parameters);</programlisting>
- </section>
-
- <section id="taskservice">
- <title>TaskService</title>
- <para></para>
- </section>
-
- <section id="managementservice">
- <title>ManagementService</title>
- <para></para>
- </section>
-
-</chapter>
\ No newline at end of file
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2008-12-26 15:23:55 UTC (rev 3556)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -1,824 +0,0 @@
-<chapter id="jpdl">
- <title>jPDL</title>
-
- <para>This chapter will explain the jPDL file format for describing
- process definitions. The schemadocs can also serve as a quick reference for this
- information.
- </para>
- <para>An example jPDL process file looks like this:
- </para>
- <programlisting><?xml version="1.0" encoding="UTF-8"?>
-
-<process name="Purchase order" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <flow to="Verify supplier" />
- </start>
-
- <state name="Verify supplier">
- <flow name="Supplier ok" to="Check supplier data" />
- <flow name="Supplier not ok" to="Error" />
- </state>
-
- <exclusive name="Check supplier data">
- <flow name="nok" to="Error" />
- <flow name="ok" to="Completed" />
- </exclusive>
-
- <end name="Completed" />
-
- <end name="Error" />
-
-</process></programlisting>
-
- <section id="process">
- <title><literal>process</literal></title>
- <para>The top level element representing one process definition.
- </para>
- <table><title><literal>process</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>any text</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>name or label of the process used to display to the process
- name in user interactions.
- </entry>
- </row>
- <row>
- <entry><literal>key</literal></entry>
- <entry>alpha numeric characters and underscores</entry>
- <entry>if omitted, the key will be generated based on the name by replacing
- all non-alpha-numeric characters with underscores</entry>
- <entry>optional</entry>
- <entry>identification to distinct different process definitions.
- Multiple versions of a process with the same key can be deployed.
- The key:name combination must remain exactly the same for all
- deployed versions.
- </entry>
- </row>
- <row>
- <entry><literal>version</literal></entry>
- <entry>integer</entry>
- <entry>one higher then highest version number starting with 1 if no other process
- is deployed with the same name/key.
- </entry>
- <entry>optional</entry>
- <entry>version number of this process</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <table><title><literal>process</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>description</literal></entry>
- <entry>0..1</entry>
- <entry>description text</entry>
- </row>
- <row>
- <entry><link linkend="activities">activities</link></entry>
- <entry>1..*</entry>
- <entry>a list of any activity type can be placed here. At least
- one <literal>start</literal> activity must be present.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section id="activities">
- <title>Activities</title>
- <para>(BPMN note: when we mention activities here, we are not only refering to BPMN
- activities, but also to BPMN events and BPMN gateways.)
- </para>
-
- <section id="start">
- <title><literal>start</literal></title>
- <para>Indicates where an execution for this process starts. Typically there is
- exactly one start activity in a process. A process has to have at least one start
- activity. A start activity must have exactly one outgoing flow and that flow
- is taken when a process execution starts.
- </para>
- <table><title><literal>start</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>any text</entry>
- <entry></entry>
- <entry>optional</entry>
- <entry>name of the activity. Since a start activity
- cannot have incoming flows, the name is optional.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>start</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>flow</literal></entry>
- <entry>1</entry>
- <entry>the outgoing flow</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section id="state">
- <title><literal>state</literal></title>
- <para>A wait state. Process execution will wait until an external trigger is
- provided through the API. Apart from the <link linkend="commonactivitycontent">
- common activity content</link>, <literal>state</literal> doesn't have any extra
- attributes or elements.
- </para>
- <section id="statesequence">
- <title><literal>state</literal> sequence</title>
- <para>Let's look at an example which shows states connected with flows
- as a sequence</para>
- <figure id="state.sequence">
- <title>A sequence of states</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/state.sequence.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="StateSequence" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <flow to="a" />
- </start>
-
- <state name="a">
- <flow to="b" />
- </state>
-
- <state name="b">
- <flow to="c" />
- </state>
-
- <state name="c" />
-
-</process></programlisting>
- <para>After you start an execution like this:</para>
- <programlisting>Execution execution = executionService.startExecutionByKey("StateSequence");</programlisting>
- <para>the created process instance will be positioned in
- state <literal>a</literal>. Providing an external trigger can
- be done with the <literal>signalExecution</literal> methods.</para>
- <programlisting>String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId);</programlisting>
- </section>
- <section id="statechoice">
- <title><literal>state</literal> choice</title>
- <para>In this second example with states, we'll show how you can use a
- <literal>state</literal> can be used to feed in an external choice of
- the path to take.
- </para>
- <figure id="state.choice">
- <title>A choice between state</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/state.choice.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <flow to="wait for response" />
- </start>
-
- <state name="wait for response">
- <flow name="accept" to="submit document" />
- <flow name="reject" to="try again" />
- </state>
-
- <state name="submit document" />
-
- <state name="try again" />
-
-</process></programlisting>
- <para>Let's start a new process instance for this process definition:</para>
- <programlisting>Execution execution = executionService.startExecutionByKey("StateSequence");</programlisting>
- <para>Now, the execution is arrived in the <literal>wait for response</literal>.
- The execution will wait there until an external trigger is given. In case
- a <literal>state</literal> has multiple outgoing flows, the signalName given
- in the external trigger will be matched against the name of the outgoing flow
- to take. So when we provide signalName <literal>accept</literal> like this:
- </para>
- <programlisting>executionService.signalExecutionById(executionId, "accept");</programlisting>
- <para>Then the execution will continue over the outgoing flow named
- <literal>accept</literal>. Analogue, when signalName <literal>reject</literal>
- is given in the signalExecutionXxx methods, the execution will continue over
- the outgoing flow named reject.
- </para>
- </section>
- </section>
-
- <section id="java">
- <title><literal>java</literal></title>
- <para>The Java task. A process execution will execute the method of the class that is configured
- in this task.</para>
- <table><title><literal>java</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>class</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- <row>
- <entry><literal>method</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- <row>
- <entry><literal>var</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>java</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>field</literal></entry>
- <entry></entry>
- <entry></entry>
- </row>
- <row>
- <entry><literal>arg</literal></entry>
- <entry></entry>
- <entry></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Consider the following example.</para>
- <figure id="java">
- <title>A java task</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/java.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="Java" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <flow to="invoke java method" />
- </start>
-
- <java name="invoke java method"
- class="org.jbpm.examples.java.JohnDoe"
- method="hello"
- var="answer">
-
- <field name="state"><string value="fine"/></field>
- <field name="session"><env type="org.hibernate.Session"/></field>
-
- <arg><string value="Hi, how are you?"/></arg>
-
- <flow to="wait" />
- </java>
-
- <state name="wait">
-
-</process>
- </programlisting>
- <para>The java task specifies that during its execution an instance of the class <literal>org.jbpm.examples.java.JohnDoe</literal>
- will be instantiated and the method <literal>hello</literal> of this class will be invoked on the resulting object. The variable named
- <literal>answer</literal> will contain the result of the invocation. Let's look at the class <literal>JohnDoe</literal> below.
- </para>
- <programlisting>package org.jbpm.examples.java;
-
-import org.hibernate.Session;
-
-public class JohnDoe {
-
- String state;
- Session session;
-
- public String hello(String msg) {
- if ( (msg.indexOf("how are you?")!=-1)
- && (session.isOpen())
- ) {
- return "I'm "+state+", thank you.";
- }
- return null;
- }
-}
- </programlisting>
- <para>The class above reveals that it contains two fields named <literal>state</literal> and <literal>session</literal>
- and that the method <literal>hello</literal> accepts one argument. During the execution the values specified in the
- <literal>field</literal> and <literal>arg</literal> configuration elements will be used. The expected result of creating
- a process instance is that the process variable <literal>answer</literal> contains the string
- <literal>I'm fine, thank you.</literal>.
- </para>
- </section>
-
- <section id="script">
- <title><literal>script</literal></title>
- </section>
-
- <section id="esb">
- <title><literal>esb</literal></title>
- </section>
-
- <section id="sql">
- <title><literal>sql</literal></title>
- </section>
-
- <section id="hql">
- <title><literal>hql</literal></title>
- </section>
-
- <section id="task">
- <title><literal>task</literal></title>
- </section>
-
- <section id="exclusive">
- <title><literal>exclusive</literal></title>
- <para>Takes one path of many alternatives. Also known as a decision. An exclusive
- activity has multiple outgoing flows and when an execution arrives in an exclusive
- activity, an automatic evaluation will decide which outgoing flow is taken.
- </para>
- <para>An exclusive activity should be configured in one of the three following ways:
- </para>
-
- <section id="exclusiveconditions">
- <title>Exclusive conditions</title>
- <para>An exclusive with conditions on the flows evaluates the condition in each flow.
- The first flow for which the nested condition expression resolves to true or which does
- not have a condition is taken.
- </para>
- <table><title><literal>exclusive.flow.condition</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>expr</literal></entry>
- <entry>expression</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>script that will be evaluated in the specified
- expression language.
- </entry>
- </row>
- <row>
- <entry><literal>lang</literal></entry>
- <entry>expression language</entry>
- <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
- <entry>optional</entry>
- <entry>the language in which <literal>expr</literal> is
- to be evaluated.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Example:
- </para>
- <figure id="exclusive">
- <title>The exclusive gateway</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/exclusive.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="ExclusiveConditions" >
-
- <start>
- <flow to="evaluate document" />
- </start>
-
- <exclusive name="evaluate document">
- <flow to="submit document">
- <emphasis role="bold"><condition expr="#{content=="good"}" /></emphasis>
- </flow>
- <flow to="try again">
- <emphasis role="bold"><condition expr="#{content=="not so good"}" /></emphasis>
- </flow>
- <flow to="give up" />
- </exclusive>
-
- <state name="submit document" />
-
- <state name="try again" />
-
- <state name="give up" />
-
-</process></programlisting>
- </section>
-
- <section id="exclusiveexpression">
- <title>Exclusive expression</title>
- <para>An exclusive expression evaluates to a String representing the name of
- an outgoing flow.
- </para>
- <table><title><literal>exclusive</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>expr</literal></entry>
- <entry>expression</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>script that will be evaluated in the specified
- expression language.
- </entry>
- </row>
- <row>
- <entry><literal>lang</literal></entry>
- <entry>expression language</entry>
- <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
- <entry>optional</entry>
- <entry>the language in which <literal>expr</literal> is
- to be evaluated.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Example:
- </para>
- <para>Same picture as <link linkend="exclusive">above</link>.
- </para>
- <programlisting><process name="Poolcar">
- <start>
- <flow to="How far?" />
- </start>
- <exclusive name="How far?" <emphasis role="bold">expr="#{distance}"</emphasis>>
- <flow name="far" to="Big car" />
- <flow name="nearby" to="Small car" />
- </exclusive>
- <state name="Big car" />
- <state name="Small car" />
-</process></programlisting>
- <para>When you start an new process instance like this
- </para>
- <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
-variables.put("distance", "far");
-Execution execution = executionService.startExecutionByKey("Poolcar", variables);</programlisting>
- <para>then the new execution will go to node <literal>Big car</literal>.</para>
- </section>
-
- <section id="exclusivehandler">
- <title>Exclusive handler</title>
- <para>An exclusive handler is a java class that implements the
- <literal>ExclusiveHandler</literal> interface. The exclusive handler
- will be responsible for selecting the name of the outgoing flow.
- </para>
- <programlisting>public interface ExclusiveHandler {
- String select(OpenExecution execution);
-}</programlisting>
- <para>The handler is specified as a sub element of the exclusive</para>
- <table><title><literal>exclusive.handler</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>class</literal></entry>
- <entry>classname</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>fully qualified classname of the handler implementation class.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Here's an example process of an exclusive using an ExclusiveHandler:</para>
- <para>Same picture as <link linkend="exclusive">above</link>.
- </para>
- <programlisting><process name="ExclusiveHandler">
-
- <start>
- <flow to="evaluate document" />
- </start>
-
- <exclusive name="evaluate document">
- <handler class="org.jbpm.examples.exclusive.handler.ContentEvaluation" />
- <flow name="good" to="submit document" />
- <flow name="bad" to="try again" />
- <flow name="ugly" to="give up" />
- </exclusive>
-
- <state name="submit document" />
-
- <state name="try again" />
-
- <state name="give up" />
-
-</process></programlisting>
- <para>The ContentEvaluation class looks like this</para>
- <programlisting>public class ContentEvaluation implements ExclusiveHandler {
-
- public String select(OpenExecution execution) {
- String content = (String) execution.getVariable("content");
- if (content.equals("you're great")) {
- return "good";
- }
- if (content.equals("you gotta improve")) {
- return "bad";
- }
- return "ugly";
- }
-}</programlisting>
- <para>Now, when we start a process instance and supply value
- <literal>you're great</literal> for variable content, then the
- ContentEvaluation will return String <literal>good</literal> and
- the process instance will arrive in node <literal>Submit document</literal>.
- </para>
- </section>
-
- </section>
-
- <section id="end">
- <title><literal>end</literal></title>
- <para>Ends the execution.
- </para>
- <section id="endprocessinstance">
- <title><literal>end</literal> process instance</title>
- <para>By default, an end activity will end the complete
- process instance. In case multiple concurrent executions
- are still active within the same process instance, all of
- them will be ended.
- </para>
- <figure id="end.processinstance">
- <title>The end event</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/end.processinstance.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="EndProcessInstance" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <flow to="end" />
- </start>
-
- <end name="end" />
-
-</process></programlisting>
- <para>When a new process instance is created, it immediately ends.</para>
- </section>
- <section id="endexecution">
- <title><literal>end</literal> execution</title>
- <para>Only the execution that arrives in the
- end activity will be ended and other concurrent executions
- should be left active. To get this behaviour, set
- attribute <literal>ends="execution"</literal>
- </para>
- <table><title><literal>end</literal> execution attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>ends</literal></entry>
- <entry>{processinstance|execution}</entry>
- <entry>processinstance</entry>
- <entry>optional</entry>
- <entry>specifies if the whole process instance should be ended or
- just the path of execution that arrives in the end activity.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section id="endmultiple">
- <title><literal>end</literal> multiple</title>
- <para>A process can have multiple end events. This can be handy to indicate
- different outcomes of a process instance. For example
- </para>
- <figure id="end.multiple">
- <title>Multiple end events</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/end.multiple.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="EndMultiple" xmlns="http://;jbpm.org/4/jpdl">
-
- <start>
- <flow to="get return code" />
- <start>
-
- <state name="get return code">
- <flow name="200" to="ok"/>
- <flow name="400" to="bad request"/>
- <flow name="500" to="internal server error"/>
- </state>
-
- <end name="ok"/>
- <end name="bad request"/>
- <end name="internal server error"/>
-
-</process>
- </programlisting>
- <para>Now if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the
- following code, the execution would end with the <literal>bad request</literal> end event.</para>
- <programlisting>Execution execution = executionService.startExecutionByKey("EndMultiple");
-String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId, "400");
- </programlisting>
- <para>Likewise, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
- to end with the <literal>ok</literal> or with the <literal>internal server error</literal> end events
- respectively.</para>
- </section>
-
- <section id="endstate">
- <title><literal>end</literal> state</title>
- <para>An execution can also end with different states. It is another way to specify the outcome of a process.
- It is indicated by the <literal>state</literal> attribute of the end event or by the <literal>end-cancel</literal>
- and <literal>end-error</literal> shortcut notations.
- </para>
-
- <table><title><literal>end</literal> execution attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>state</literal></entry>
- <entry>String</entry>
- <entry></entry>
- <entry>optional</entry>
- <entry>the state assigned to the execution.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>Take for example the following process.
- </para>
- <figure id="end.state">
- <title>Different end states</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/end.state.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="EndState" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <flow to="get return code"/>
- </start>
-
- <state name="get return code">
- <flow name="200" to="ok"/>
- <flow name="400" to="bad request" />
- <flow name="500" to="internal server error"/>
- </state>
-
- <end name="ok" state="completed"/>
- <end-cancel name="bad request"/>
- <end-error name="internal server error"/>
-
-</process>
- </programlisting>
- <para>This time, if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the
- following code, the execution would end with the <literal>cancel</literal> state.</para>
- <programlisting>Execution execution = executionService.startExecutionByKey("EndState");
-String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId, "400");
- </programlisting>
- <para>Similarly as above, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
- to end with the <literal>completed</literal> or with the <literal>error</literal> states
- respectively.</para>
-
- </section>
- </section>
-
- <section id="commonactivitycontents">
- <title>Common activity contents</title>
- <para>Unless specified otherwise above, all activities also include this
- content model:
- </para>
- <table><title>Common activity attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>any text</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>name of the activity</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title>Common activity elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>flow</literal></entry>
- <entry>0..*</entry>
- <entry>the outgoing flows</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- </section>
-
-</chapter>
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml (from rev 3540, jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml)
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml (rev 0)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -0,0 +1,292 @@
+<chapter id="services">
+ <title>Services</title>
+
+ <para>Interacting with jBPM occurs through services.
+ The service interfaces can be obtained from the <literal>ProcessEngine</literal>
+ which is build from a <literal>Configuration</literal>.
+ </para>
+
+ <section id="processengine">
+ <title>ProcessEngine</title>
+
+ <para>A <literal>ProcessEngine</literal> is thread safe and can be stored in a
+ static member field or even better in JNDI or some other central location.
+ One <literal>ProcessEngine</literal> object can be used by all requests and
+ threads in an application. Here's how you can obtain a <literal>ProcessEngine</literal>
+ </para>
+
+ <programlisting>ProcessEngine processEngine = new Configuration()
+ .buildProcessEngine();</programlisting>
+
+ <para>The previous code snippet shows how to build a <literal>ProcessEngine</literal>
+ from the default configuration file <literal>jbpm.cfg.xml</literal> which is
+ expected in the root of the classpath. If you want to specify another
+ resource location, use the <literal>setResource</literal> method like this:
+ </para>
+
+ <programlisting>ProcessEngine processEngine = new Configuration()
+ .setResource("my-own-configuration-file.xml")
+ .buildProcessEngine();</programlisting>
+
+ <para>There are other <literal>setXxxx</literal> methods that allow to specify
+ the configuration content as an <literal>InputStream</literal>, an
+ <literal>xmlString</literal>, <literal>InputSource</literal>,
+ <literal>URL</literal> or <literal>File</literal>.
+ </para>
+
+ <para>From a <literal>ProcessEngine</literal> the following services
+ can be obtained:
+ </para>
+
+ <programlisting><emphasis role="bold">ProcessService</emphasis> processService = processEngine.getProcessService();
+<emphasis role="bold">ExecutionService</emphasis> executionService = processEngine.getExecutionService();
+<emphasis role="bold">ManagementService</emphasis> managementService = processEngine.getManagementService();
+<emphasis role="bold">TaskService</emphasis> taskService = processEngine.getTaskService();</programlisting>
+
+ <para>Process engine objects defined in the configuration can also be retrieved by
+ type (<literal>processEngine.get(Class<T>)</literal>)
+ or by name (<literal>processEngine.get(String)</literal>)</para>
+
+ </section>
+
+ <section id="deployingaprocess">
+ <title>Deploying a process</title>
+ <para>The <literal>ProcessService</literal> groups all methods that access
+ the repository of process definitions.
+ </para>
+ <para>A jPDL process file like e.g. <literal>order.jpdl.xml</literal> that is
+ accessible as a resource on the classpath can be deployed programmatically with the
+ <literal>ProcessService</literal> like this:
+ </para>
+ <programlisting>processService.createDeployment()
+ .addResource("order.jpdl.xml")
+ .deploy();</programlisting>
+ <para>Analogue to the <literal>addResource</literal> method above, the source of
+ the processes definitions XML can be picked up from a file, url, string,
+ input stream, zip or jar archive and a directory.
+ </para>
+ <para>A deployment works with a set of named resources and can potentially contain
+ multiple process descriptions and multiple other artifact types. The jPDL deployer
+ will recognise process files based on the <literal>.jpdl.xml</literal>
+ extension automatically. For files not adhering to that naming
+ convention, the type can be set programmatically to <literal>jpdl</literal>
+ with method <literal>setFileType("my-jpdl-process.someotherextension", "jpdl")</literal>
+ </para>
+ <para>During deployment, an <literal>id</literal> is assigned to the process
+ definitions. The <literal>id</literal> will have format
+ <literal>{key}:{version}</literal>
+ </para>
+ <para>If <literal>key</literal> is not provided, it is generated automatically
+ based on the name. All non alpha numeric characters in the name will be replaced
+ by underscores to generate the key.
+ </para>
+ <para>The same <literal>name</literal> can only be associated to one
+ <literal>key</literal> and vice verca.
+ </para>
+ <para>If <literal>version</literal> is not provided, a <literal>version</literal>
+ will be automatically be assigned. For version
+ assignment, the versions of all deployed process definitions with the same name will
+ be taken into account. The assigned <literal>version</literal> will be one higher
+ then the highest <literal>version</literal> number of deployed process definitions
+ with the same <literal>key</literal>. If no process definitions with a similar
+ <literal>key</literal> have been deployed, version number 1 is assigned.
+ </para>
+ <para>In this first example, we'll supply a name and nothing else.</para>
+ <programlisting><process name="Insurance claim">
+...
+</process></programlisting>
+ <para>Let's assume that this is the first time that this process gets deployed.
+ Then it will get the following properties:
+ </para>
+ <table><title>Process properties without key</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Value</entry>
+ <entry>Source</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>Insurance claim</entry>
+ <entry>process xml</entry>
+ </row>
+ <row>
+ <entry><literal>key</literal></entry>
+ <entry>Insurance_claim</entry>
+ <entry>generated</entry>
+ </row>
+ <row>
+ <entry><literal>version</literal></entry>
+ <entry>1</entry>
+ <entry>generated</entry>
+ </row>
+ <row>
+ <entry><literal>id</literal></entry>
+ <entry>Insurance_claim:1</entry>
+ <entry>generated</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>And as a second example, we'll show how you can get shorter ids by
+ specifying a process key:</para>
+ <programlisting><process name="Insurance claim" key="ICL">
+...
+</process></programlisting>
+ <para>Then the process definition properties look like this:</para>
+ <table><title>Process properties with key</title>
+ <tgroup cols="2" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Value</entry>
+ <entry>Source</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>Insurance claim</entry>
+ <entry>process xml</entry>
+ </row>
+ <row>
+ <entry><literal>key</literal></entry>
+ <entry>ICL</entry>
+ <entry>process xml</entry>
+ </row>
+ <row>
+ <entry><literal>version</literal></entry>
+ <entry>1</entry>
+ <entry>generated</entry>
+ </row>
+ <row>
+ <entry><literal>id</literal></entry>
+ <entry>ICL:1</entry>
+ <entry>generated</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section id="startinganewprocessinstance">
+ <title>Starting a new process instance</title>
+
+ <section id="inlatest">
+ <title>In latest</title>
+ <para>Simplest and most common way to start a new process instance for a process
+ definition is like this:
+ </para>
+ <programlisting>executionService.startExecutionByKey("ICL");</programlisting>
+ <para>In this case, the service method will first look up the latest version of
+ the processes with key <literal>ICL</literal>. Then a new
+ process instance is started in that latest process definition.
+ </para>
+ <para>When a new version of the insurance claim process
+ is deployed, all invocations of <literal>startExecutionByKey</literal>
+ will automatically switch to the newly deployed version.
+ </para>
+ </section>
+
+ <section id="specificprocessversion">
+ <title>Specific process version</title>
+ <para>If instead you want to start a new process instance in a very
+ specific version, you can use the id of the process definition like this:
+ </para>
+ <programlisting>executionService.startExecutionById("ICL:1");</programlisting>
+ </section>
+
+ <section id="withakey">
+ <title>With a key</title>
+ <para>A new process instance can optionally be given a key. A key is
+ a user defined reference to the execution. A key must be unique within the
+ scope of all versions of a process definition. Typically it is easy
+ to find such a key in the domain of the business process. For example, an
+ order id or an insurance claim number.
+ </para>
+ <programlisting>executionService.startExecutionByKey("ICL", "CL92837");</programlisting>
+ <para>The key is used to create the id of the process instance.
+ The format used is <literal>{process-key}/{execution-id}</literal>.
+ So execution created in the previous code snippet will have id
+ <literal>ICL/CL92837</literal>.
+ </para>
+ <para>If no user defined key is provided, the DB primary key is taken
+ as the key. In that case, the id can be retrieved like this:
+ <programlisting>Execution execution = executionService.startExecutionByKey("ICL");
+String executionId = execution.getId();</programlisting>
+ </para>
+ <para>We recommend the use of a user defined keys. Typically in your application
+ code, you'll have the key available. By providing a user defined key, you can
+ then compose the id of the execution, rather then performing a query based
+ on the process variables.
+ </para>
+ </section>
+
+ <section id="withvariables">
+ <title>With variables</title>
+ <para>A map of named parameter objects can be provided when starting a
+ new process instance. These parameters will be set as variables on the process
+ instance between creation and start of the process instance.
+ </para>
+ <programlisting>Map<String,Object> variables = new HashMap<String,Object>();
+variables.put("customer", "John Doe");
+variables.put("type", "Accident");
+variables.put("amount", new Float(763.74));
+
+executionService.startExecutionByKey("ICL", variables);</programlisting>
+ </section>
+ </section>
+
+ <section id="singallingawaitingexecution">
+ <title>Signalling a waiting execution</title>
+ <para>A process definition describes what must be done in terms of activities.
+ Each activity in a process is either to be performed by the process
+ system or by an external participant. When an activity is to be performed
+ by an external participant, then the execution must wait until the
+ external participant notifies the process system that the activity is
+ completed. So an execution is either executing or waiting on an external
+ participant. Typically, you'll see that the processes are mostly
+ waiting for external participants. Especially humans tend to be slow :-)
+ The time consumed by the process system between two wait states is
+ typically very small.
+ </para>
+ <para>A <literal>state</literal> is the basic activity that represents
+ something has to be done by an external participant and the execution
+ must wait until a signal (aka external trigger) is given.
+ </para>
+ <para>When an execution is in a wait state, it can be given an external trigger
+ with one of the signal methods. The recommended way to reference an execution
+ is by using the process definition and execution key. In the next code snippet,
+ <literal>ICL</literal> refers to the process definition key and <literal>82436</literal>
+ refers to the execution key.
+ </para>
+ <programlisting>executionService.signalExecutionByKey("ICL", "82436");</programlisting>
+ <para>Alternatively, the execution that must be signaled can be referenced
+ by a unique execution id. In the next snippet, <literal>ICL/82436</literal>
+ refers to the executionId.</para>
+ <programlisting>executionService.signalExecutionById("ICL/82436");</programlisting>
+ <para>Optionally some data can be passed along with a signal: a <literal>signalName</literal>
+ and <literal>parameters</literal>. How the signalName gets used depends on
+ the execution's current activity. The parameters get stored as process variables.
+ </para>
+ <programlisting>Map<String,Object> parameters = new HashMap<String,Object>();
+parameters.put("quality", "a+");
+parameters.put("target", "profit");
+
+executionService.signalExecutionById("ICL/82436", "Accept", parameters);</programlisting>
+ </section>
+
+ <section id="taskservice">
+ <title>TaskService</title>
+ <para></para>
+ </section>
+
+ <section id="managementservice">
+ <title>ManagementService</title>
+ <para></para>
+ </section>
+
+</chapter>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Services.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Gpd.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Gpd.xml 2008-12-26 15:23:55 UTC (rev 3556)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Gpd.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -1,7 +0,0 @@
-<chapter id="gpd">
- <title>GPD</title>
-
- <para>This chapter will explain how to work with the Graphical Process Designer.
- </para>
-
-</chapter>
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml (from rev 3549, jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml)
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -0,0 +1,1252 @@
+<chapter id="jpdl">
+ <title>jPDL</title>
+
+ <para>This chapter will explain the jPDL file format for describing
+ process definitions. The schemadocs can also serve as a quick reference for this
+ information.
+ </para>
+ <para>An example jPDL process file looks like this:
+ </para>
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Purchase order" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="Verify supplier" />
+ </start>
+
+ <state name="Verify supplier">
+ <flow name="Supplier ok" to="Check supplier data" />
+ <flow name="Supplier not ok" to="Error" />
+ </state>
+
+ <exclusive name="Check supplier data">
+ <flow name="nok" to="Error" />
+ <flow name="ok" to="Completed" />
+ </exclusive>
+
+ <end name="Completed" />
+
+ <end name="Error" />
+
+</process></programlisting>
+
+ <section id="process">
+ <title><literal>process</literal></title>
+ <para>The top level element representing one process definition.
+ </para>
+ <table><title><literal>process</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>any text</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>name or label of the process used to display to the process
+ name in user interactions.
+ </entry>
+ </row>
+ <row>
+ <entry><literal>key</literal></entry>
+ <entry>alpha numeric characters and underscores</entry>
+ <entry>if omitted, the key will be generated based on the name by replacing
+ all non-alpha-numeric characters with underscores</entry>
+ <entry>optional</entry>
+ <entry>identification to distinct different process definitions.
+ Multiple versions of a process with the same key can be deployed.
+ The key:name combination must remain exactly the same for all
+ deployed versions.
+ </entry>
+ </row>
+ <row>
+ <entry><literal>version</literal></entry>
+ <entry>integer</entry>
+ <entry>one higher then highest version number starting with 1 if no other process
+ is deployed with the same name/key.
+ </entry>
+ <entry>optional</entry>
+ <entry>version number of this process</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table><title><literal>process</literal> elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>description</literal></entry>
+ <entry>0..1</entry>
+ <entry>description text</entry>
+ </row>
+ <row>
+ <entry><link linkend="activities">activities</link></entry>
+ <entry>1..*</entry>
+ <entry>a list of any activity type can be placed here. At least
+ one <literal>start</literal> activity must be present.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section id="activities">
+ <title>Activities</title>
+ <para>(BPMN note: when we mention activities here, we are not only refering to BPMN
+ activities, but also to BPMN events and BPMN gateways.)
+ </para>
+
+ <section id="start">
+ <title><literal>start</literal></title>
+ <para>Indicates where an execution for this process starts. Typically there is
+ exactly one start activity in a process. A process has to have at least one start
+ activity. A start activity must have exactly one outgoing flow and that flow
+ is taken when a process execution starts.
+ </para>
+ <para>Known limitation: for now, a process can not have more then
+ one <literal>start</literal>.
+ </para>
+ <table><title><literal>start</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>any text</entry>
+ <entry></entry>
+ <entry>optional</entry>
+ <entry>name of the activity. Since a start activity
+ cannot have incoming flows, the name is optional.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>start</literal> elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>flow</literal></entry>
+ <entry>1</entry>
+ <entry>the outgoing flow</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section id="state">
+ <title><literal>state</literal></title>
+ <para>A wait state. Process execution will wait until an external trigger is
+ provided through the API. Apart from the <link linkend="commonactivitycontent">
+ common activity content</link>, <literal>state</literal> doesn't have any extra
+ attributes or elements.
+ </para>
+ <section id="statesequence">
+ <title><literal>state</literal> sequence</title>
+ <para>Let's look at an example which shows states connected with flows
+ as a sequence</para>
+ <figure id="process.state.sequence">
+ <title>A sequence of states</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.state.sequence.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="StateSequence" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="a" />
+ </start>
+
+ <state name="a">
+ <flow to="b" />
+ </state>
+
+ <state name="b">
+ <flow to="c" />
+ </state>
+
+ <state name="c" />
+
+</process></programlisting>
+ <para>After you start an execution like this:</para>
+ <programlisting>Execution execution = executionService.startExecutionByKey("StateSequence");</programlisting>
+ <para>the created process instance will be positioned in
+ state <literal>a</literal>. Providing an external trigger can
+ be done with the <literal>signalExecution</literal> methods.</para>
+ <programlisting>String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId);</programlisting>
+ </section>
+ <section id="statechoice">
+ <title><literal>state</literal> choice</title>
+ <para>In this second example with states, we'll show how you can use a
+ <literal>state</literal> can be used to feed in an external choice of
+ the path to take.
+ </para>
+ <figure id="process.state.choice">
+ <title>A choice between state</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.state.choice.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="wait for response" />
+ </start>
+
+ <state name="wait for response">
+ <flow name="accept" to="submit document" />
+ <flow name="reject" to="try again" />
+ </state>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+</process></programlisting>
+ <para>Let's start a new process instance for this process definition:</para>
+ <programlisting>Execution execution = executionService.startExecutionByKey("StateSequence");</programlisting>
+ <para>Now, the execution is arrived in the <literal>wait for response</literal>.
+ The execution will wait there until an external trigger is given. In case
+ a <literal>state</literal> has multiple outgoing flows, the signalName given
+ in the external trigger will be matched against the name of the outgoing flow
+ to take. So when we provide signalName <literal>accept</literal> like this:
+ </para>
+ <programlisting>executionService.signalExecutionById(executionId, "accept");</programlisting>
+ <para>Then the execution will continue over the outgoing flow named
+ <literal>accept</literal>. Analogue, when signalName <literal>reject</literal>
+ is given in the signalExecutionXxx methods, the execution will continue over
+ the outgoing flow named reject.
+ </para>
+ </section>
+ </section>
+
+ <section id="exclusive">
+ <title><literal>exclusive</literal></title>
+ <para>Takes one path of many alternatives. Also known as a decision. An exclusive
+ activity has multiple outgoing flows and when an execution arrives in an exclusive
+ activity, an automatic evaluation will decide which outgoing flow is taken.
+ </para>
+ <para>An exclusive activity should be configured in one of the three following ways:
+ </para>
+
+ <section id="exclusiveconditions">
+ <title>Exclusive conditions</title>
+ <para>An exclusive with conditions on the flows evaluates the condition in each flow.
+ The first flow for which the nested condition expression resolves to true or which does
+ not have a condition is taken.
+ </para>
+ <table><title><literal>exclusive.flow.condition</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>expr</literal></entry>
+ <entry>expression</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>script that will be evaluated in the specified
+ expression language.
+ </entry>
+ </row>
+ <row>
+ <entry><literal>lang</literal></entry>
+ <entry>expression language</entry>
+ <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
+ <entry>optional</entry>
+ <entry>the language in which <literal>expr</literal> is
+ to be evaluated.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Example:
+ </para>
+ <figure id="process.exclusive.condition">
+ <title>The exclusive conditions example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.exclusive.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="ExclusiveConditions" >
+
+ <start>
+ <flow to="evaluate document" />
+ </start>
+
+ <exclusive name="evaluate document">
+ <flow to="submit document">
+ <emphasis role="bold"><condition expr="#{content=="good"}" /></emphasis>
+ </flow>
+ <flow to="try again">
+ <emphasis role="bold"><condition expr="#{content=="not so good"}" /></emphasis>
+ </flow>
+ <flow to="give up" />
+ </exclusive>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+ <state name="give up" />
+
+</process></programlisting>
+ </section>
+
+ <section id="exclusiveexpression">
+ <title>Exclusive expression</title>
+ <para>An exclusive expression evaluates to a String representing the name of
+ an outgoing flow.
+ </para>
+ <table><title><literal>exclusive</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>expr</literal></entry>
+ <entry>expression</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>script that will be evaluated in the specified
+ expression language.
+ </entry>
+ </row>
+ <row>
+ <entry><literal>lang</literal></entry>
+ <entry>expression language</entry>
+ <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
+ <entry>optional</entry>
+ <entry>the language in which <literal>expr</literal> is
+ to be evaluated.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Example:
+ </para>
+ <figure id="process.exclusive.expression">
+ <title>The exclusive expression example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.exclusive.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="Poolcar">
+ <start>
+ <flow to="How far?" />
+ </start>
+ <exclusive name="How far?" <emphasis role="bold">expr="#{distance}"</emphasis>>
+ <flow name="far" to="Big car" />
+ <flow name="nearby" to="Small car" />
+ </exclusive>
+ <state name="Big car" />
+ <state name="Small car" />
+</process></programlisting>
+ <para>When you start an new process instance like this
+ </para>
+ <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
+variables.put("distance", "far");
+Execution execution = executionService.startExecutionByKey("Poolcar", variables);</programlisting>
+ <para>then the new execution will go to node <literal>Big car</literal>.</para>
+ </section>
+
+ <section id="exclusivehandler">
+ <title>Exclusive handler</title>
+ <para>An exclusive handler is a java class that implements the
+ <literal>ExclusiveHandler</literal> interface. The exclusive handler
+ will be responsible for selecting the name of the outgoing flow.
+ </para>
+ <programlisting>public interface ExclusiveHandler {
+ String select(OpenExecution execution);
+}</programlisting>
+ <para>The handler is specified as a sub element of the exclusive</para>
+ <table><title><literal>exclusive.handler</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>class</literal></entry>
+ <entry>classname</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>fully qualified classname of the handler implementation class.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Here's an example process of an exclusive using an ExclusiveHandler:</para>
+ <figure id="process.exclusive.handler">
+ <title>The exclusive handler example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.exclusive.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="ExclusiveHandler">
+
+ <start>
+ <flow to="evaluate document" />
+ </start>
+
+ <exclusive name="evaluate document">
+ <handler class="org.jbpm.examples.exclusive.handler.ContentEvaluation" />
+ <flow name="good" to="submit document" />
+ <flow name="bad" to="try again" />
+ <flow name="ugly" to="give up" />
+ </exclusive>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+ <state name="give up" />
+
+</process></programlisting>
+ <para>The ContentEvaluation class looks like this</para>
+ <programlisting>public class ContentEvaluation implements ExclusiveHandler {
+
+ public String select(OpenExecution execution) {
+ String content = (String) execution.getVariable("content");
+ if (content.equals("you're great")) {
+ return "good";
+ }
+ if (content.equals("you gotta improve")) {
+ return "bad";
+ }
+ return "ugly";
+ }
+}</programlisting>
+ <para>Now, when we start a process instance and supply value
+ <literal>you're great</literal> for variable content, then the
+ ContentEvaluation will return String <literal>good</literal> and
+ the process instance will arrive in node <literal>Submit document</literal>.
+ </para>
+ </section>
+
+ </section>
+
+ <section id="end">
+ <title><literal>end</literal></title>
+ <para>Ends the execution.
+ </para>
+ <section id="endprocessinstance">
+ <title><literal>end</literal> process instance</title>
+ <para>By default, an end activity will end the complete
+ process instance. In case multiple concurrent executions
+ are still active within the same process instance, all of
+ them will be ended.
+ </para>
+ <figure id="process.end.processinstance">
+ <title>The end event</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.end.processinstance.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="EndProcessInstance" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="end" />
+ </start>
+
+ <end name="end" />
+
+</process></programlisting>
+ <para>When a new process instance is created, it immediately ends.</para>
+ </section>
+ <section id="endexecution">
+ <title><literal>end</literal> execution</title>
+ <para>Only the execution that arrives in the
+ end activity will be ended and other concurrent executions
+ should be left active. To get this behaviour, set
+ attribute <literal>ends="execution"</literal>
+ </para>
+ <table><title><literal>end</literal> execution attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>ends</literal></entry>
+ <entry>{processinstance|execution}</entry>
+ <entry>processinstance</entry>
+ <entry>optional</entry>
+ <entry>specifies if the whole process instance should be ended or
+ just the path of execution that arrives in the end activity.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section id="endmultiple">
+ <title><literal>end</literal> multiple</title>
+ <para>A process can have multiple end events. This can be handy to indicate
+ different outcomes of a process instance. For example
+ </para>
+ <figure id="process.end.multiple">
+ <title>Multiple end events</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.end.multiple.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="EndMultiple" xmlns="http://;jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="get return code" />
+ <start>
+
+ <state name="get return code">
+ <flow name="200" to="ok"/>
+ <flow name="400" to="bad request"/>
+ <flow name="500" to="internal server error"/>
+ </state>
+
+ <end name="ok"/>
+ <end name="bad request"/>
+ <end name="internal server error"/>
+
+</process>
+ </programlisting>
+ <para>Now if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the
+ following code, the execution would end with the <literal>bad request</literal> end event.</para>
+ <programlisting>Execution execution = executionService.startExecutionByKey("EndMultiple");
+String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId, "400");
+ </programlisting>
+ <para>Likewise, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
+ to end with the <literal>ok</literal> or with the <literal>internal server error</literal> end events
+ respectively.</para>
+ </section>
+
+ <section id="endstate">
+ <title><literal>end</literal> state</title>
+ <para>An execution can also end with different states. It is another way to specify the outcome of a process.
+ It is indicated by the <literal>state</literal> attribute of the end event or by the <literal>end-cancel</literal>
+ and <literal>end-error</literal> shortcut notations.
+ </para>
+
+ <table><title><literal>end</literal> execution attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>state</literal></entry>
+ <entry>String</entry>
+ <entry></entry>
+ <entry>optional</entry>
+ <entry>the state assigned to the execution.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>Take for example the following process.
+ </para>
+ <figure id="process.end.state">
+ <title>Different end states</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.end.state.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="EndState" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="get return code"/>
+ </start>
+
+ <state name="get return code">
+ <flow name="200" to="ok"/>
+ <flow name="400" to="bad request" />
+ <flow name="500" to="internal server error"/>
+ </state>
+
+ <end name="ok" state="completed"/>
+ <end-cancel name="bad request"/>
+ <end-error name="internal server error"/>
+
+</process>
+ </programlisting>
+ <para>This time, if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the
+ following code, the execution would end with the <literal>cancel</literal> state.</para>
+ <programlisting>Execution execution = executionService.startExecutionByKey("EndState");
+String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId, "400");
+ </programlisting>
+ <para>Similarly as above, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
+ to end with the <literal>completed</literal> or with the <literal>error</literal> states
+ respectively.</para>
+ </section>
+ </section>
+
+ <section id="java">
+ <title><literal>java</literal></title>
+ <para>The Java task. A process execution will execute the method of the class that is configured
+ in this activity.</para>
+ <table><title><literal>java</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>class</literal></entry>
+ <entry>classname</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>The fully qualified classname.</entry>
+ </row>
+ <row>
+ <entry><literal>method</literal></entry>
+ <entry>methodname</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>The name of the method to invoke</entry>
+ </row>
+ <row>
+ <entry><literal>var</literal></entry>
+ <entry>variablename</entry>
+ <entry></entry>
+ <entry>optional</entry>
+ <entry>The name of the variable in which the return value
+ should be stored.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>java</literal> elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>field</literal></entry>
+ <entry>0..*</entry>
+ <entry>describes a configuration value to inject in a memberfield before
+ the method is invoked.</entry>
+ </row>
+ <row>
+ <entry><literal>arg</literal></entry>
+ <entry>0..*</entry>
+ <entry>method parameters</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Consider the following example.</para>
+ <figure id="process.java">
+ <title>A java task</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.java.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="Java" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="invoke java method" />
+ </start>
+
+ <java name="invoke java method"
+ class="org.jbpm.examples.java.JohnDoe"
+ method="hello"
+ var="answer">
+
+ <field name="state"><string value="fine"/></field>
+ <field name="session"><env type="org.hibernate.Session"/></field>
+
+ <arg><string value="Hi, how are you?"/></arg>
+
+ <flow to="wait" />
+ </java>
+
+ <state name="wait">
+
+</process>
+ </programlisting>
+ <para>The java task specifies that during its execution an instance of the class <literal>org.jbpm.examples.java.JohnDoe</literal>
+ will be instantiated and the method <literal>hello</literal> of this class will be invoked on the resulting object. The variable named
+ <literal>answer</literal> will contain the result of the invocation. Let's look at the class <literal>JohnDoe</literal> below.
+ </para>
+ <programlisting>package org.jbpm.examples.java;
+
+import org.hibernate.Session;
+
+public class JohnDoe {
+
+ String state;
+ Session session;
+
+ public String hello(String msg) {
+ if ( (msg.indexOf("how are you?")!=-1)
+ && (session.isOpen())
+ ) {
+ return "I'm "+state+", thank you.";
+ }
+ return null;
+ }
+}</programlisting>
+ <para>The class above reveals that it contains two fields named <literal>state</literal> and <literal>session</literal>
+ and that the method <literal>hello</literal> accepts one argument. During the execution the values specified in the
+ <literal>field</literal> and <literal>arg</literal> configuration elements will be used. The expected result of creating
+ a process instance is that the process variable <literal>answer</literal> contains the string
+ <literal>I'm fine, thank you.</literal>.
+ </para>
+ </section>
+
+ <section id="task">
+ <title><literal>task</literal></title>
+ <para>Creates a task for a person in the task component. The configuration capabilities
+ of the task activity will be expanded in the next releases.
+ </para>
+ <table><title><literal>task</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>assignee</literal></entry>
+ <entry>text</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>id of the person to which this task must be assigned</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>For example:</para>
+ <figure id="process.task">
+ <title>The task example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.task.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="Task" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="review" />
+ </start>
+
+ <emphasis role="bold"><task name="review"
+ assignee="johndoe"></emphasis>
+
+ <flow to="wait" />
+ <emphasis role="bold"></task></emphasis>
+
+ <state name="wait" />
+
+</process></programlisting>
+ <para>After starting a process like this
+ </para>
+ <programlisting>executionService.startExecutionByKey("Task");</programlisting>
+ <para>The task list for user johndoe can be obtained from the <literal>TaskService</literal>
+ like this</para>
+ <programlisting>taskService.getPersonalTaskList("johndoe", 0, 10);</programlisting>
+ <para>The task list for user 'johndoe' will contain a task named 'review'.</para>
+ </section>
+
+ <section id="script">
+ <title><literal>script</literal></title>
+ <para>A script activity evaluates a script. Scripts can be specified in any language for
+ which there is <ulink url="https://scripting.dev.java.net/">a JSR-223 compliant scripting engine</ulink>.
+ Configuration of scripting engines <link linkend="scripting">is explained below</link>.
+ </para>
+ <para>There are 2 ways of specifying a script:
+ </para>
+ <section id="script.expression">
+ <title><literal>script</literal> expression</title>
+ <para>The script is provided with the <literal>expr</literal> attribute.
+ This is for short expressions that are easier expressed in an attribute
+ then in a text element. If no <literal>lang</literal> is specified,
+ the default-expression-language is used.
+ </para>
+ <table><title><literal>script</literal> expression attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>expr</literal></entry>
+ <entry>text</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>the expression text to evaluate.</entry>
+ </row>
+ <row>
+ <entry><literal>lang</literal></entry>
+ <entry>scripting language name as defined in <xref linkend="scripting"/></entry>
+ <entry>the default <emphasis role="bold">expression</emphasis> language as defined in <xref linkend="scripting"/></entry>
+ <entry>optional</entry>
+ <entry>the language in which the expression is specified.</entry>
+ </row>
+ <row>
+ <entry><literal>var</literal></entry>
+ <entry>variablename</entry>
+ <entry></entry>
+ <entry>optional</entry>
+ <entry>name of the variable in which the return value
+ should be stored.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>In the next example, we'll see how a script activity with an expression and
+ how the result is stored in a variable.
+ </para>
+ <figure id="process.script.expression">
+ <title>The script.expression example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.script.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="ScriptExpression" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="invoke script" />
+ </start>
+
+ <emphasis role="bold"><script name="invoke script"
+ expr="Send packet to #{person.address}"
+ var="text"></emphasis>
+
+ <flow to="wait" />
+ <emphasis role="bold"></script></emphasis>
+
+ <state name="wait"/>
+
+</process></programlisting>
+ <para>This example uses a <literal>Person</literal> class that looks like this.
+ </para>
+ <programlisting>public class Person implements Serializable {
+
+ String address;
+
+ public Person(String address) {
+ this.address = address;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+}</programlisting>
+ <para>When starting a process instance for this process, we supply a person
+ with a given address property as variable <literal>person</literal>.
+ </para>
+ <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
+variables.put("<emphasis role="bold">person</emphasis>", <emphasis role="bold">new Person("Honolulu")</emphasis>);
+
+executionService.startExecutionByKey("ScriptText", variables);</programlisting>
+ <para>After the execution of the script activity, variable <literal>text</literal>
+ will contain 'Send packet to Honolulu'.
+ </para>
+ </section>
+
+ <section id="script.text">
+ <title><literal>script</literal> text</title>
+ <para>The second way of specifying a script is with a <literal>text</literal> element.
+ This is convenient when the script text spans multiple lines.
+ </para>
+ <table><title><literal>script</literal> text attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>lang</literal></entry>
+ <entry>scripting language name as defined in <xref linkend="scripting"/></entry>
+ <entry>the default <emphasis role="bold">scripting</emphasis> language as defined in <xref linkend="scripting"/></entry>
+ <entry>optional</entry>
+ <entry>the language in which the script is specified.</entry>
+ </row>
+ <row>
+ <entry><literal>var</literal></entry>
+ <entry>variablename</entry>
+ <entry></entry>
+ <entry>optional</entry>
+ <entry>name of the variable in which the return value
+ should be stored.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>script</literal> text elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>text</literal></entry>
+ <entry>1</entry>
+ <entry>contains the script text</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>For example</para>
+ <figure id="process.script.text">
+ <title>The script.text example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.script.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="ScriptText" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="invoke script" />
+ </start>
+
+ <emphasis role="bold"><script name="invoke script"
+ var="text">
+ <text>
+ Send packet to #{person.address}
+ </text></emphasis>
+ <flow to="wait" />
+ <emphasis role="bold"></script></emphasis>
+
+ <state name="wait"/>
+
+</process></programlisting>
+ </section>
+ <para>Execution of this process is exactly the same as with the script expression above.
+ </para>
+ </section>
+
+ <section id="esb">
+ <title><literal>esb</literal></title>
+ <para>An <literal>esb</literal> activity sends a message to a service over the ESB.
+ The attributes <literal>category</literal> and <literal>service</literal> identify the
+ service in the esb repository. The message is composed with the
+ <literal>part</literal> elements.
+ </para>
+ <table><title><literal>esb</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>category</literal></entry>
+ <entry>string</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>the esb category where the service is defined.</entry>
+ </row>
+ <row>
+ <entry><literal>service</literal></entry>
+ <entry>string</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>the esb name of the service
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>esb</literal> elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>part</literal></entry>
+ <entry>0..*</entry>
+ <entry>Parts of the message to be sent.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>For example</para>
+ <figure id="process.esb">
+ <title>The esb example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.esb.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="Esb" xmlns="http://jbpm.org/4/jpdl">
+
+ <start >
+ <flow to="invoke esb service" />
+ </start>
+
+ <emphasis role="bold"><esb name="invoke esb service"
+ category="orderProcessing"
+ service="bookSold">
+
+ <part name="bookTitle" expr="#{title}" />
+ <part name="goal">
+ <string value="deliver asap" />
+ </part></emphasis>
+
+ <flow to="wait" />
+ <emphasis role="bold"></esb></emphasis>
+
+ <state name="wait" />
+
+</process></programlisting>
+ <para>When a new process is started, a message will be sent to the esb
+ service <literal>bookSold</literal> in category <literal>orderProcessing</literal>.
+ The message will have 2 parts: one named <literal>bookTitle</literal> containing
+ the title process variable. And one named <literal>goal</literal> which
+ contains the text 'deliver asap'.
+ </para>
+ </section>
+
+ <section id="hql">
+ <title><literal>hql</literal></title>
+ <para>With the<literal>hql</literal> activity, a HQL query can be performed
+ on the database and the result is stored in a process variable.
+ </para>
+ <table><title><literal>hql</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>var</literal></entry>
+ <entry>variablename</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>the name of the variable in which the result is stored.</entry>
+ </row>
+ <row>
+ <entry><literal>unique</literal></entry>
+ <entry>{true, false}</entry>
+ <entry>false</entry>
+ <entry>optional</entry>
+ <entry>a value of true means that the result from the hibernate
+ query should be obtained with method <literal>uniqueResult()</literal>.
+ The default is false and in that case the <literal>list()</literal>
+ method will be used to get the result.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>hql</literal> elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>query</literal></entry>
+ <entry>1</entry>
+ <entry>The HQL query.</entry>
+ </row>
+ <row>
+ <entry><literal>parameter</literal></entry>
+ <entry>0..*</entry>
+ <entry>The query parameters</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>For example:</para>
+ <figure id="process.hql">
+ <title>The hql example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.hql.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="Hql" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="get process names" />
+ </start>
+
+ <emphasis role="bold"><hql name="get process names"
+ var="nodes with o">
+ <query>
+ select node.name
+ from org.jbpm.pvm.internal.model.NodeImpl as node
+ where node.name like :nodeName
+ </query>
+ <parameters>
+ <string name="nodeName" value="%o%" />
+ </parameters></emphasis>
+ <flow to="count nodes" />
+ <emphasis role="bold"></hql>
+
+ <hql name="count nodes"
+ var="nodes"
+ unique="true">
+ <query>
+ select count(*)
+ from org.jbpm.pvm.internal.model.NodeImpl
+ </query></emphasis>
+ <flow to="wait" />
+ <emphasis role="bold"></hql></emphasis>
+
+ <state name="wait"/>
+
+</process></programlisting>
+ </section>
+
+ <section id="sql">
+ <title><literal>sql</literal></title>
+ <para>The <literal>sql</literal> activity is exactly the same as the
+ <link linkend="hql">hql</link> activity, with the only difference that
+ <literal>session.createSQLQuery(...)</literal> is used.
+ </para>
+ </section>
+
+ <section id="commonactivitycontents">
+ <title>Common activity contents</title>
+ <para>Unless specified otherwise above, all activities also include this
+ content model:
+ </para>
+ <table><title>Common activity attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>any text</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>name of the activity</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title>Common activity elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>flow</literal></entry>
+ <entry>0..*</entry>
+ <entry>the outgoing flows</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ </section>
+
+</chapter>
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Scripting.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Scripting.xml 2008-12-26 15:23:55 UTC (rev 3556)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Scripting.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -1,18 +0,0 @@
-<chapter id="scripting">
- <title>Scripting</title>
-
- <para>Scripting in jBPM is based on JSR 223: Scripting for the JavaTM Platform.
- Scripting engines can be configured like this:
- </para>
- <programlisting><script-manager default-expression-language="juel"
- default-script-language="juel"
- read-contexts="execution, environment, process-engine"
- write-context="">
- <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
-</script-manager></programlisting>
- <para>A jPDL process definition can contain scripts and expressions. All
- of the configured scripting engines can be used in each situation. But
- scripts and expressions each have their own default.
- </para>
-
-</chapter>
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml (rev 0)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -0,0 +1,7 @@
+<chapter id="variables">
+ <title>Variables</title>
+
+ <para>TODO
+ </para>
+
+</chapter>
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Variables.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml (from rev 3540, jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Scripting.xml)
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml (rev 0)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml 2008-12-27 11:30:11 UTC (rev 3557)
@@ -0,0 +1,18 @@
+<chapter id="scripting">
+ <title>Scripting</title>
+
+ <para>Scripting in jBPM is based on JSR 223: Scripting for the JavaTM Platform.
+ Scripting engines can be configured like this:
+ </para>
+ <programlisting><script-manager default-expression-language="juel"
+ default-script-language="juel"
+ read-contexts="execution, environment, process-engine"
+ write-context="">
+ <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
+</script-manager></programlisting>
+ <para>A jPDL process definition can contain scripts and expressions. All
+ of the configured scripting engines can be used in each situation. But
+ scripts and expressions each have their own default.
+ </para>
+
+</chapter>
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Scripting.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
15 years, 4 months
JBoss JBPM SVN: r3556 - jbpm4/trunk/modules/test-load/src/test/resources.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-26 10:23:55 -0500 (Fri, 26 Dec 2008)
New Revision: 3556
Modified:
jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
Log:
added hibernate transaction level logging in comment
Modified: jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/logging.properties 2008-12-26 15:10:04 UTC (rev 3555)
+++ jbpm4/trunk/modules/test-load/src/test/resources/logging.properties 2008-12-26 15:23:55 UTC (rev 3556)
@@ -27,6 +27,7 @@
org.hibernate.cfg.SettingsFactory.level=SEVERE
# org.hibernate.level=FINE
# org.hibernate.SQL.level=FINEST
+# org.hibernate.transaction.level=FINEST
# org.hibernate.type.level=FINEST
# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
# org.hibernate.transaction.level=FINEST
15 years, 4 months