JBoss JBPM SVN: r3555 - jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-26 10:10:04 -0500 (Fri, 26 Dec 2008)
New Revision: 3555
Modified:
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java
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/MessageProcessingTest.java
Log:
load test fine tunings
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java 2008-12-26 14:28:11 UTC (rev 3554)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java 2008-12-26 15:10:04 UTC (rev 3555)
@@ -21,11 +21,8 @@
*/
package org.jbpm.test.load;
-import java.util.Random;
-
import org.hibernate.Session;
import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
import org.jbpm.pvm.internal.job.MessageImpl;
import org.jbpm.pvm.internal.model.CommentImpl;
@@ -35,7 +32,6 @@
public class AddCommentMessage extends MessageImpl<Void> {
private static final long serialVersionUID = 1L;
- static Random random = new Random();
public AddCommentMessage() {
}
Modified: 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-26 14:28:11 UTC (rev 3554)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java 2008-12-26 15:10:04 UTC (rev 3555)
@@ -62,9 +62,13 @@
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) {
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-26 14:28:11 UTC (rev 3554)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java 2008-12-26 15:10:04 UTC (rev 3555)
@@ -47,7 +47,7 @@
private static final Log log = Log.getLog(MessageProcessingTest.class.getName());
static long nbrOfTestMessages = 10000; // nbrOfTestMessages must be dividable by insertGroupSize
- static long insertGroupSize = 10;
+ static long insertGroupSize = 50;
static final long SECOND = 1000;
static final long MINUTE = 60 * SECOND;
@@ -99,14 +99,14 @@
memoryWriter.close();
}
- void logStatus() {
+ 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())+" mem:"+used);
+ log.info(commentsAdded+" msgs in "+formatDuration(start, System.currentTimeMillis()));
}
public void testMessageProcessing() throws Exception {
@@ -166,7 +166,7 @@
assertTrue("message " + i + " is not processed: " + processedMessageNumbers, processedMessageNumbers.contains(i));
}
}
-
+
// helper methods ///////////////////////////////////////////////////////////
public static String formatDuration(long start, long stop) {
15 years, 4 months
JBoss JBPM SVN: r3554 - jbpm4/trunk/hudson/hudson-home.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-26 09:28:11 -0500 (Fri, 26 Dec 2008)
New Revision: 3554
Modified:
jbpm4/trunk/hudson/hudson-home/command-db.sh
jbpm4/trunk/hudson/hudson-home/command-load.sh
jbpm4/trunk/hudson/hudson-home/command.sh
Log:
fixed build script type in -DskiptTests
Modified: jbpm4/trunk/hudson/hudson-home/command-db.sh
===================================================================
--- jbpm4/trunk/hudson/hudson-home/command-db.sh 2008-12-26 14:21:20 UTC (rev 3553)
+++ jbpm4/trunk/hudson/hudson-home/command-db.sh 2008-12-26 14:28:11 UTC (rev 3554)
@@ -16,7 +16,7 @@
#
cd $JBPMDIR
cp profiles.xml.example profiles.xml
-MVN_CMD="mvn $ENVIRONMENT -DskiptTests clean install"
+MVN_CMD="mvn $ENVIRONMENT -DskipTests -Pload clean install"
echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
if [ $MVN_STATUS -ne 0 ]; then
echo maven exit status $MVN_STATUS
Modified: jbpm4/trunk/hudson/hudson-home/command-load.sh
===================================================================
--- jbpm4/trunk/hudson/hudson-home/command-load.sh 2008-12-26 14:21:20 UTC (rev 3553)
+++ jbpm4/trunk/hudson/hudson-home/command-load.sh 2008-12-26 14:28:11 UTC (rev 3554)
@@ -16,7 +16,7 @@
#
cd $JBPMDIR
cp profiles.xml.example profiles.xml
-MVN_CMD="mvn $ENVIRONMENT -DskiptTests -Pload clean install"
+MVN_CMD="mvn $ENVIRONMENT -DskipTests -Pload clean install"
echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
if [ $MVN_STATUS -ne 0 ]; then
echo maven exit status $MVN_STATUS
Modified: jbpm4/trunk/hudson/hudson-home/command.sh
===================================================================
--- jbpm4/trunk/hudson/hudson-home/command.sh 2008-12-26 14:21:20 UTC (rev 3553)
+++ jbpm4/trunk/hudson/hudson-home/command.sh 2008-12-26 14:28:11 UTC (rev 3554)
@@ -16,7 +16,7 @@
#
cd $JBPMDIR
cp profiles.xml.example profiles.xml
-MVN_CMD="mvn $ENVIRONMENT -DskiptTests clean install"
+MVN_CMD="mvn $ENVIRONMENT -DskipTests clean install"
echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
if [ $MVN_STATUS -ne 0 ]; then
echo maven exit status $MVN_STATUS
15 years, 4 months
JBoss JBPM SVN: r3553 - jbpm4/trunk/hudson/hudson-home.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-26 09:21:20 -0500 (Fri, 26 Dec 2008)
New Revision: 3553
Added:
jbpm4/trunk/hudson/hudson-home/command-load.sh
Log:
added hudson load test script
Added: jbpm4/trunk/hudson/hudson-home/command-load.sh
===================================================================
--- jbpm4/trunk/hudson/hudson-home/command-load.sh (rev 0)
+++ jbpm4/trunk/hudson/hudson-home/command-load.sh 2008-12-26 14:21:20 UTC (rev 3553)
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# A script that uses Maven to build the project and
+# execute its test suite against a given target container
+#
+# $Id$
+
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+DISTRODIR=$JBPMDIR/modules/distribution/target
+
+ENVIRONMENT=""
+
+#
+# build the tests
+#
+cd $JBPMDIR
+cp profiles.xml.example profiles.xml
+MVN_CMD="mvn $ENVIRONMENT -DskiptTests -Pload clean install"
+echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
+if [ $MVN_STATUS -ne 0 ]; then
+ echo maven exit status $MVN_STATUS
+ exit 1
+fi
+
+#
+# log dependency tree
+#
+MVN_CMD="mvn -o $ENVIRONMENT dependency:tree"
+echo $MVN_CMD; $MVN_CMD | tee $WORKSPACE/dependency-tree.txt
+
+#
+# execute tests
+#
+cd modules/test-load
+MVN_CMD="mvn -o $ENVIRONMENT -Ddatabase=$DATABASE -DtestFailureIgnore=true test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.log
+cat $WORKSPACE/tests.log | egrep FIXME\|FAILED | sort -u | tee $WORKSPACE/fixme.txt
Property changes on: jbpm4/trunk/hudson/hudson-home/command-load.sh
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years, 4 months
JBoss JBPM SVN: r3552 - jbpm4/trunk/hudson/hudson-home.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-26 09:00:41 -0500 (Fri, 26 Dec 2008)
New Revision: 3552
Added:
jbpm4/trunk/hudson/hudson-home/command-db.sh
Modified:
jbpm4/trunk/hudson/hudson-home/command.sh
Log:
changed workspace dir from jbpm to jbpm4
Added: jbpm4/trunk/hudson/hudson-home/command-db.sh
===================================================================
--- jbpm4/trunk/hudson/hudson-home/command-db.sh (rev 0)
+++ jbpm4/trunk/hudson/hudson-home/command-db.sh 2008-12-26 14:00:41 UTC (rev 3552)
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# A script that uses Maven to build the project and
+# execute its test suite against a given target container
+#
+# $Id$
+
+WORKSPACE=`pwd`
+JBPMDIR=$WORKSPACE/jbpm4
+DISTRODIR=$JBPMDIR/modules/distribution/target
+
+ENVIRONMENT=""
+
+#
+# build the tests
+#
+cd $JBPMDIR
+cp profiles.xml.example profiles.xml
+MVN_CMD="mvn $ENVIRONMENT -DskiptTests clean install"
+echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
+if [ $MVN_STATUS -ne 0 ]; then
+ echo maven exit status $MVN_STATUS
+ exit 1
+fi
+
+#
+# log dependency tree
+#
+MVN_CMD="mvn -o $ENVIRONMENT dependency:tree"
+echo $MVN_CMD; $MVN_CMD | tee $WORKSPACE/dependency-tree.txt
+
+#
+# execute example tests
+#
+cd $JBPMDIR/modules/examples
+MVN_CMD="mvn -o $ENVIRONMENT -Ddatabase=$DATABASE -DtestFailureIgnore=true test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.examples.log
+
+#
+# execute database tests
+#
+cd $JBPMDIR/modules/test-db
+MVN_CMD="mvn -o $ENVIRONMENT -Ddatabase=$DATABASE -DtestFailureIgnore=true test"
+echo $MVN_CMD; $MVN_CMD 2>&1 | tee $WORKSPACE/tests.test-db.log
+
+cat $WORKSPACE/tests.examples.log $WORKSPACE/tests.test-db.log | egrep FIXME\|FAILED | sort -u | tee $WORKSPACE/fixme.txt
Property changes on: jbpm4/trunk/hudson/hudson-home/command-db.sh
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/hudson/hudson-home/command.sh
===================================================================
--- jbpm4/trunk/hudson/hudson-home/command.sh 2008-12-26 13:17:25 UTC (rev 3551)
+++ jbpm4/trunk/hudson/hudson-home/command.sh 2008-12-26 14:00:41 UTC (rev 3552)
@@ -6,7 +6,7 @@
# $Id$
WORKSPACE=`pwd`
-JBPMDIR=$WORKSPACE/jbpm
+JBPMDIR=$WORKSPACE/jbpm4
DISTRODIR=$JBPMDIR/modules/distribution/target
ENVIRONMENT=""
15 years, 4 months
JBoss JBPM SVN: r3551 - in jbpm4/trunk/modules: pvm/src/test/java/org/jbpm/pvm/api/tx and 5 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-26 08:17:25 -0500 (Fri, 26 Dec 2008)
New Revision: 3551
Added:
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java
Removed:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessExecutionDbTest.java
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/tx/BasicTransactionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java
jbpm4/trunk/modules/test-load/pom.xml
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
Log:
test suite cleanup
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -49,20 +49,13 @@
/**
* @author Tom Baeyens
*/
-public class ContinuationTest extends OldDbTestCase
-{
+public class ContinuationTest extends OldDbTestCase {
private static final Log log = Log.getLog(ContinuationTest.class.getName());
static Recorder recorder = new Recorder();
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(ContinuationTest.class);
- }
-
- public void testContinuations()
- {
+ public void testContinuations() {
int nbrOfExecutions = 20;
int testTimeoutMillis = 20000;
int checkInterval = 500;
@@ -71,16 +64,13 @@
Set<Integer> expected = new HashSet<Integer>();
JobExecutor jobExecutor = environmentFactory.get(JobExecutor.class);
- try
- {
+ try {
deployProcess(environmentFactory);
startExecutions(nbrOfExecutions, environmentFactory, expected);
jobExecutor.start();
waitTillNoMoreMessages(jobExecutor, testTimeoutMillis, checkInterval, environmentFactory);
- }
- finally
- {
+ } finally {
jobExecutor.stop(true);
}
@@ -92,28 +82,20 @@
expectedLogs.add("execute(end)");
assertEquals(nbrOfExecutions, recorder.executionEvents.size());
- for (List<String> executionLogs : recorder.executionEvents.values())
- {
+ for (List<String> executionLogs : recorder.executionEvents.values()) {
assertEquals(expectedLogs, executionLogs);
}
}
- public void deployProcess(EnvironmentFactory environmentFactory)
- {
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment) throws Exception
- {
+ public void deployProcess(EnvironmentFactory environmentFactory) {
+ 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();
+ 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);
@@ -122,14 +104,11 @@
});
}
- public void startExecutions(int nbrOfExecutions, EnvironmentFactory environmentFactory, Set<Integer> expected)
- {
- for (int i = 0; i < nbrOfExecutions; i++)
- {
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment) throws Exception
- {
+ public void startExecutions(int nbrOfExecutions, EnvironmentFactory environmentFactory, Set<Integer> expected) {
+ 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();
@@ -140,17 +119,16 @@
}
}
- public void waitTillNoMoreMessages(JobExecutor jobExecutor, int maxWait, int checkInterval, EnvironmentFactory environmentFactory)
- {
+ 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()
- {
+ // 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()
- {
+ public void run() {
log.debug("test " + getName() + " took too long. going to interrupt..." + testThread);
testThread.interrupt();
}
@@ -158,37 +136,28 @@
Timer timer = new Timer();
timer.schedule(interruptTask, maxWait);
- try
- {
+ try {
boolean jobsAvailable = true;
- while (jobsAvailable)
- {
+ 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)
- {
+ } catch (InterruptedException e) {
fail("test execution exceeded treshold of " + maxWait + " milliseconds");
- }
- finally
- {
+ } finally {
timer.cancel();
}
}
- private boolean areJobsAvailable(EnvironmentFactory environmentFactory)
- {
- Integer nbrOfJobsAvailable = (Integer)commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment) throws Exception
- {
+ 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)
- {
+ Number jobs = (Number) session.createQuery("select count(*) from " + JobImpl.class.getName()).uniqueResult();
+ if (jobs != null) {
return jobs.intValue();
}
return 0;
@@ -196,12 +165,9 @@
});
boolean areJobsAvailable = nbrOfJobsAvailable > 0;
- if (areJobsAvailable)
- {
+ if (areJobsAvailable) {
log.debug("there are " + nbrOfJobsAvailable + " jobs currently in the jobImpl table");
- }
- else
- {
+ } else {
log.debug("all jobs are processed");
}
return areJobsAvailable;
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/tx/BasicTransactionTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/tx/BasicTransactionTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -40,30 +40,21 @@
/**
* @author Tom Baeyens
*/
-public class BasicTransactionTest extends OldDbTestCase
-{
+public class BasicTransactionTest extends OldDbTestCase {
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(BasicTransactionTest.class);
- }
+ public void testCommit() {
+ commandService.execute(new Command<Object>() {
- public void testCommit()
- {
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment)
- {
+ public Object execute(Environment environment) {
Session session = environment.get(Session.class);
session.save(new CommentImpl("if i only had the time to write code"));
return null;
}
});
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment)
- {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) {
Session session = environment.get(Session.class);
List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
assertEquals("if i only had the time to write code", comments.get(0).getMessage());
@@ -72,34 +63,27 @@
});
}
- public static class MyOwnRuntimeException extends RuntimeException
- {
+ public static class MyOwnRuntimeException extends RuntimeException {
}
- public void testRollbackRuntimeException()
- {
- try
- {
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment)
- {
+ public void testRollbackRuntimeException() {
+ try {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) {
Session session = environment.get(Session.class);
session.save(new CommentImpl("if i only had the time to write code"));
throw new MyOwnRuntimeException();
}
});
fail("expected exception");
- }
- catch (MyOwnRuntimeException e)
- {
+ } catch (MyOwnRuntimeException e) {
// OK
}
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment)
- {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) {
Session session = environment.get(Session.class);
List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
assertEquals(0, comments.size());
@@ -108,35 +92,28 @@
});
}
- public static class MyOwnCheckedException extends Exception
- {
+ public static class MyOwnCheckedException extends Exception {
}
- public void testRollbackCheckedException()
- {
- try
- {
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment) throws Exception
- {
+ public void testRollbackCheckedException() {
+ try {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
Session session = environment.get(Session.class);
session.save(new CommentImpl("if i only had the time to write code"));
throw new MyOwnCheckedException();
}
});
fail("expected exception");
- }
- catch (JbpmException e)
- {
+ } catch (JbpmException e) {
// OK
assertSame(MyOwnCheckedException.class, e.getCause().getClass());
}
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment)
- {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) {
Session session = environment.get(Session.class);
List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
assertEquals(0, comments.size());
@@ -145,10 +122,9 @@
});
}
- public static class SuccessfulSynchronization implements Synchronization
- {
- public void beforeCompletion()
- {
+ public static class SuccessfulSynchronization implements Synchronization {
+
+ public void beforeCompletion() {
Environment environment = Environment.getCurrent();
Session session = environment.get(Session.class);
StringVariable stringVariable = new StringVariable();
@@ -156,17 +132,14 @@
session.save(stringVariable);
}
- public void afterCompletion(int arg0)
- {
+ public void afterCompletion(int arg0) {
}
}
- public void testSuccessfulSynchronization()
- {
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment) throws Exception
- {
+ public void testSuccessfulSynchronization() {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
Session session = environment.get(Session.class);
session.save(new CommentImpl("if i only had the time to write code"));
Transaction transaction = environment.get(Transaction.class);
@@ -176,10 +149,9 @@
}
});
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment)
- {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) {
Session session = environment.get(Session.class);
List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
assertEquals("if i only had the time to write code", comments.get(0).getMessage());
@@ -190,10 +162,9 @@
});
}
- public static class UnsuccessfulSynchronization implements Synchronization
- {
- public void beforeCompletion()
- {
+ public static class UnsuccessfulSynchronization implements Synchronization {
+
+ public void beforeCompletion() {
Environment environment = Environment.getCurrent();
Session session = environment.get(Session.class);
StringVariable stringVariable = new StringVariable();
@@ -202,19 +173,15 @@
throw new MyOwnRuntimeException();
}
- public void afterCompletion(int arg0)
- {
+ public void afterCompletion(int arg0) {
}
}
- public void testUnsuccessfulSynchronization()
- {
- try
- {
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment) throws Exception
- {
+ public void testUnsuccessfulSynchronization() {
+ try {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
Session session = environment.get(Session.class);
session.save(new CommentImpl("if i only had the time to write code"));
Transaction transaction = environment.get(Transaction.class);
@@ -224,19 +191,17 @@
}
});
fail("expected exception");
- }
- catch (MyOwnRuntimeException e)
- {
+ } catch (MyOwnRuntimeException e) {
// OK
}
- // the exception in the beforeCompletion in the synchronization should have caused
+ // the exception in the beforeCompletion in the synchronization should have
+ // caused
// the previous transaction to rollback
- commandService.execute(new Command<Object>()
- {
- public Object execute(Environment environment)
- {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) {
Session session = environment.get(Session.class);
List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
assertEquals(0, comments.size());
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -24,50 +24,36 @@
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.jbpm.Execution;
import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.pvm.internal.db.type.VariableCustomTypeTest;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.session.DbSession;
import org.jbpm.session.PvmDbSession;
import org.jbpm.test.EnvironmentDbTestCase;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
/**
* @author Tom Baeyens
*/
-public class LanguageExtensionsDbTest extends EnvironmentDbTestCase
-{
+public class LanguageExtensionsDbTest extends EnvironmentDbTestCase {
private static final String ENVIRONMENT_CFG_XML = "org/jbpm/pvm/internal/db/langext/environment.cfg.xml";
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(LanguageExtensionsDbTest.class, ENVIRONMENT_CFG_XML);
- }
-
- public LanguageExtensionsDbTest()
- {
+ public LanguageExtensionsDbTest() {
super(ENVIRONMENT_CFG_XML);
}
/**
- * Defines a simple process: only nodes and transitions. Adds a wait state behaviour. Persists it, reloads and
- * executes the process.
+ * Defines a simple process: only nodes and transitions. Adds a wait state
+ * behaviour. Persists it, reloads and executes the process.
*/
- public void testBehaviour()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testBehaviour() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build("addresses").node().initial().behaviour(
- new AddressActivity("Sesamestreet", 15)).transition().to("a").node("a").behaviour(new AddressActivity("Broadway", 151))
- .transition().to("b").node("b").behaviour(new AddressActivity("Champs Elysee", 23)).transition().to("c").node("c").behaviour(
- new AddressActivity("Downing street", 10)).done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build("addresses").node().initial().behaviour(new AddressActivity("Sesamestreet", 15))
+ .transition().to("a").node("a").behaviour(new AddressActivity("Broadway", 151)).transition().to("b").node("b").behaviour(
+ new AddressActivity("Champs Elysee", 23)).transition().to("c").node("c").behaviour(new AddressActivity("Downing street", 10)).done();
persistenceSession.save(processDefinition);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -34,19 +34,12 @@
* @author Guillaume Porcher
*
*/
-public class ProcessCacheDbTest extends EnvironmentDbTestCase
-{
+public class ProcessCacheDbTest extends EnvironmentDbTestCase {
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(ProcessCacheDbTest.class);
- }
-
/**
* Defines a simple process: only nodes. persists it.
*/
- public void testCacheProcessDefinitionNodes()
- {
+ public void testCacheProcessDefinitionNodes() {
OpenProcessDefinition processDefinition = ProcessFactory.build().node("a").initial().node("b").node("c").done();
PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
@@ -56,7 +49,8 @@
newTransaction(); // ///////////////////////////////////////////////////////
- // only the processDefinition.getDbid() is carried over from the previous transaction
+ // only the processDefinition.getDbid() is carried over from the previous
+ // transaction
pvmDbSession = environment.get(PvmDbSession.class);
processDefinition = pvmDbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
@@ -81,7 +75,8 @@
newTransaction(); // ///////////////////////////////////////////////////////
beginCacheTest(); // /////////////
- // only the processDefinition.getDbid() is carried over from the previous transaction
+ // only the processDefinition.getDbid() is carried over from the previous
+ // transaction
pvmDbSession = environment.get(PvmDbSession.class);
processDefinition = pvmDbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
@@ -109,8 +104,7 @@
/**
* Defines a simple process: only nodes. persists it.
*/
- public void testCacheProcessDefinitionNodeOrder()
- {
+ public void testCacheProcessDefinitionNodeOrder() {
OpenProcessDefinition processDefinition = ProcessFactory.build().node("a").initial().node("b").node("c").done();
DbSession dbSession = environment.get(DbSession.class);
@@ -118,7 +112,8 @@
newTransaction(); // ///////////////////////////////////////////////////////
- // only the processDefinition.getDbid() is carried over from the previous transaction
+ // only the processDefinition.getDbid() is carried over from the previous
+ // transaction
dbSession = environment.get(DbSession.class);
processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
@@ -213,10 +208,9 @@
/**
* Test processDefinition initial node
*/
- public void testCacheProcessDefinitionInitialNode()
- {
+ public void testCacheProcessDefinitionInitialNode() {
ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
- NodeImpl node = (NodeImpl)processDefinition.createNode();
+ NodeImpl node = (NodeImpl) processDefinition.createNode();
node.setName("initial node");
node.setDescription("very important node");
@@ -251,23 +245,22 @@
}
/**
- * Defines a simple process: only nested nodes. persists it, reloads it and tries to access the nested nodes
+ * Defines a simple process: only nested nodes. persists it, reloads it and
+ * tries to access the nested nodes
*/
- public void testCacheProcessDefinitionNestedNodes()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testCacheProcessDefinitionNestedNodes() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build().compositeNode().initial().node("a").node("b").node("c").compositeEnd()
- .done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build().compositeNode().initial().node("a").node("b").node("c").compositeEnd().done();
persistenceSession.save(processDefinition);
newTransaction(); // /////////////////////////////////////////////////////
- persistenceSession = (DbSession)environment.get(DbSession.class);
+ persistenceSession = (DbSession) environment.get(DbSession.class);
- OpenProcessDefinition p = (OpenProcessDefinition)persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+ OpenProcessDefinition p = (OpenProcessDefinition) persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
assertNotSame(processDefinition, p);
@@ -280,9 +273,9 @@
newTransaction(); // /////////////////////////////////////////////////////
beginCacheTest(); // /////////
- persistenceSession = (DbSession)environment.get(DbSession.class);
+ persistenceSession = (DbSession) environment.get(DbSession.class);
- p = (OpenProcessDefinition)persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+ p = (OpenProcessDefinition) persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
assertNotSame(processDefinition, p);
@@ -296,22 +289,22 @@
}
/**
- * Defines a process with nested nodes with nested nodes. persists it, reloads it and tries to access the nested nodes
+ * Defines a process with nested nodes with nested nodes. persists it, reloads
+ * it and tries to access the nested nodes
*/
- public void testCacheProcessDefinitionNestedNestedNodes()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testCacheProcessDefinitionNestedNestedNodes() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build().compositeNode().initial().compositeNode("a").node("aa").node("ab")
- .node("ac").compositeEnd().compositeNode("b").node("ba").node("bb").node("bc").compositeEnd().compositeNode("c").node("ca").node(
- "cb").node("cc").compositeEnd().compositeEnd().done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build().compositeNode().initial().compositeNode("a").node("aa").node("ab").node("ac")
+ .compositeEnd().compositeNode("b").node("ba").node("bb").node("bc").compositeEnd().compositeNode("c").node("ca").node("cb").node("cc")
+ .compositeEnd().compositeEnd().done();
persistenceSession.save(processDefinition);
newTransaction(); // /////////////////////////////////////////////////////
- persistenceSession = (DbSession)environment.get(DbSession.class);
+ persistenceSession = (DbSession) environment.get(DbSession.class);
ClientProcessDefinition p = persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
@@ -346,7 +339,7 @@
newTransaction(); // /////////////////////////////////////////////////////
beginCacheTest(); // //////////
- persistenceSession = (DbSession)environment.get(DbSession.class);
+ persistenceSession = (DbSession) environment.get(DbSession.class);
p = persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
@@ -382,23 +375,22 @@
}
/**
- * Defines a simple process: only nodes and default transitions. persists it, reloads and navigates through the
- * transitions.
+ * Defines a simple process: only nodes and default transitions. persists it,
+ * reloads and navigates through the transitions.
*/
- public void testCacheDefaultTransition()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testCacheDefaultTransition() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build().node().initial().transition().to("a").node("a").transition().to("b")
- .node("b").transition().to("c").node("c").done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build().node().initial().transition().to("a").node("a").transition().to("b").node("b")
+ .transition().to("c").node("c").done();
persistenceSession.save(processDefinition);
newTransaction(); // /////////////////////////////////////////////////////
- DbSession testSession = (DbSession)environment.get(DbSession.class);
+ DbSession testSession = (DbSession) environment.get(DbSession.class);
- OpenProcessDefinition p = (OpenProcessDefinition)testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+ OpenProcessDefinition p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
assertNotSame(processDefinition, p);
@@ -426,9 +418,9 @@
newTransaction(); // /////////////////////////////////////////////////////
beginCacheTest(); // //////////
- testSession = (DbSession)environment.get(DbSession.class);
+ testSession = (DbSession) environment.get(DbSession.class);
- p = (OpenProcessDefinition)testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+ p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
assertNotSame(processDefinition, p);
@@ -457,22 +449,21 @@
}
/**
- * Defines a simple process: only nodes and transitions. persists it, reloads and navigates through the transitions.
+ * Defines a simple process: only nodes and transitions. persists it, reloads
+ * and navigates through the transitions.
*/
- public void testCacheTwoTransitions()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testCacheTwoTransitions() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build().node().initial().transition().to("a").transition().to("b").node("a")
- .node("b").done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build().node().initial().transition().to("a").transition().to("b").node("a").node("b").done();
persistenceSession.save(processDefinition);
newTransaction(); // /////////////////////////////////////////////////////
- DbSession testSession = (DbSession)environment.get(DbSession.class);
+ DbSession testSession = (DbSession) environment.get(DbSession.class);
- OpenProcessDefinition p = (OpenProcessDefinition)testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+ OpenProcessDefinition p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
assertNotSame(processDefinition, p);
@@ -506,10 +497,10 @@
newTransaction(); // /////////////////////////////////////////////////////
- testSession = (DbSession)environment.get(DbSession.class);
+ testSession = (DbSession) environment.get(DbSession.class);
beginCacheTest(); // ///////
- p = (OpenProcessDefinition)testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
+ p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
assertNotNull(p);
assertNotSame(processDefinition, p);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -16,8 +16,6 @@
import java.util.Date;
import java.util.List;
-import junit.framework.Test;
-
import org.jbpm.model.Event;
import org.jbpm.model.Node;
import org.jbpm.model.OpenProcessDefinition;
@@ -29,22 +27,14 @@
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.session.DbSession;
import org.jbpm.test.EnvironmentDbTestCase;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
/**
* @author Charles Souillard
* @author Guillaume Porcher
*/
-public class ProcessDefinitionDbTest extends EnvironmentDbTestCase
-{
+public class ProcessDefinitionDbTest extends EnvironmentDbTestCase {
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(ProcessDefinitionDbTest.class);
- }
-
- public void testProcessDefinitionBasicProperties()
- {
+ public void testProcessDefinitionBasicProperties() {
Date deploymentTime = new Date();
ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
@@ -53,7 +43,7 @@
processDefinition.setVersion(3);
processDefinition.setDeploymentTime(deploymentTime);
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
assertEquals("name", processDefinition.getName());
assertEquals("description", processDefinition.getDescription());
@@ -61,11 +51,10 @@
assertEquals(deploymentTime, processDefinition.getDeploymentTime());
}
- public void testProcessDefinitionNodes()
- {
+ public void testProcessDefinitionNodes() {
OpenProcessDefinition processDefinition = ProcessFactory.build().node("a").initial().node("b").node("c").done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
assertNotNull(processDefinition);
List<Node> nodes = processDefinition.getNodes();
@@ -86,11 +75,10 @@
assertEquals(3, nodes.size());
}
- public void testInitialNode()
- {
+ public void testInitialNode() {
OpenProcessDefinition processDefinition = ProcessFactory.build().node("a").initial().node("b").node("c").done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
Node initial = processDefinition.getInitial();
assertNotNull(initial);
@@ -101,22 +89,21 @@
assertEquals(3, processDefinition.getNodes().size());
}
- public void testProcessDefinitionNestedNodes()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testProcessDefinitionNestedNodes() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build().compositeNode("top").initial().node("a").compositeNode("b").node("b1")
- .node("b2").node("b3").compositeEnd().node("c").compositeEnd().done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build().compositeNode("top").initial().node("a").compositeNode("b").node("b1").node("b2").node(
+ "b3").compositeEnd().node("c").compositeEnd().done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
assertNotNull(processDefinition);
Node initial = processDefinition.getInitial();
assertNotNull(initial);
assertEquals(initial, processDefinition.getNode("top"));
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
List<Node> nodes = processDefinition.getNodes();
assertNotNull(nodes);
@@ -138,7 +125,7 @@
assertEquals("b2", nodes.get(1).getName());
assertEquals("b3", nodes.get(2).getName());
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
Node node = processDefinition.findNode("b2");
assertNotNull(node);
@@ -146,15 +133,13 @@
assertEquals("top", node.getParent().getParent().getName());
}
- public void testDefaultTransition()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testDefaultTransition() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build().node("a").initial().transition().to("a").transition("tob").to("b")
- .transition("toc").to("c").node("b").transition("toa").to("a").transition().to("b").transition("toc").to("c").node("c")
- .transition().to("c").node("d").done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build().node("a").initial().transition().to("a").transition("tob").to("b").transition("toc").to(
+ "c").node("b").transition("toa").to("a").transition().to("b").transition("toc").to("c").node("c").transition().to("c").node("d").done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
assertEquals("a", processDefinition.getNode("a").getDefaultTransition().getDestination().getName());
assertEquals("a", processDefinition.getNode("b").getDefaultTransition().getDestination().getName());
@@ -162,14 +147,12 @@
assertNull(processDefinition.getNode("d").getDefaultTransition());
}
- public void testTwoTransitionsWithoutAName()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
+ public void testTwoTransitionsWithoutAName() {
+ DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessFactory.build().node().initial().transition().to("a").transition().to("b").node("a")
- .node("b").done();
+ OpenProcessDefinition processDefinition = ProcessFactory.build().node().initial().transition().to("a").transition().to("b").node("a").node("b").done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
assertNotNull(processDefinition);
Node node = processDefinition.getInitial();
@@ -200,12 +183,11 @@
assertSame(lb.get(0), l.get(1));
}
- public void testEventsOnProcessDefinition()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().event(Event.PROCESS_BEGIN).listener("one")
- .listener("two").event(Event.PROCESS_END).listener("three").listener("four").node().initial().done();
+ public void testEventsOnProcessDefinition() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().event(Event.PROCESS_BEGIN).listener("one").listener("two").event(
+ Event.PROCESS_END).listener("three").listener("four").node().initial().done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
EventImpl event = processDefinition.getEvent(Event.PROCESS_BEGIN);
List<EventListenerReference> listenerReferences = event.getListenerReferences();
@@ -218,12 +200,11 @@
assertEquals("four", listenerReferences.get(1).getExpression());
}
- public void testEventsOnNode()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().node("a").initial().event(Event.NODE_BEGIN)
- .listener("one").listener("two").event(Event.NODE_END).listener("three").listener("four").done();
+ public void testEventsOnNode() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().node("a").initial().event(Event.NODE_BEGIN).listener("one")
+ .listener("two").event(Event.NODE_END).listener("three").listener("four").done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
EventImpl event = processDefinition.getNode("a").getEvent(Event.NODE_BEGIN);
List<EventListenerReference> listenerReferences = event.getListenerReferences();
@@ -236,12 +217,11 @@
assertEquals("four", listenerReferences.get(1).getExpression());
}
- public void testListenersOnTransition()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().node("a").initial().transition().to("b")
- .listener("one").listener("two").node("b").done();
+ public void testListenersOnTransition() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().node("a").initial().transition().to("b").listener("one").listener(
+ "two").node("b").done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
EventImpl event = processDefinition.getNode("a").getDefaultTransition().getEvent();
List<EventListenerReference> listenerReferences = event.getListenerReferences();
@@ -249,13 +229,12 @@
assertEquals("two", listenerReferences.get(1).getExpression());
}
- public void testExceptionHandlersOnProcessDefinition()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build()
- .exceptionHandler(IllegalArgumentException.class).listener("one").listener("two").exceptionHandlerEnd().exceptionHandler(
- RuntimeException.class).listener("three").listener("four").exceptionHandlerEnd().node().initial().done();
+ public void testExceptionHandlersOnProcessDefinition() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().exceptionHandler(IllegalArgumentException.class).listener("one")
+ .listener("two").exceptionHandlerEnd().exceptionHandler(RuntimeException.class).listener("three").listener("four").exceptionHandlerEnd().node()
+ .initial().done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
List<ExceptionHandlerImpl> exceptionHandlers = processDefinition.getExceptionHandlers();
@@ -270,13 +249,12 @@
assertEquals("four", exceptionHandler.getEventListenerReferences().get(1).getExpression());
}
- public void testExceptionHandlersOnNode()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().node("a").initial().exceptionHandler(
- IllegalArgumentException.class).listener("one").listener("two").exceptionHandlerEnd().exceptionHandler(RuntimeException.class)
- .listener("three").listener("four").exceptionHandlerEnd().done();
+ public void testExceptionHandlersOnNode() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().node("a").initial().exceptionHandler(
+ IllegalArgumentException.class).listener("one").listener("two").exceptionHandlerEnd().exceptionHandler(RuntimeException.class).listener("three")
+ .listener("four").exceptionHandlerEnd().done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
List<ExceptionHandlerImpl> exceptionHandlers = processDefinition.getNode("a").getExceptionHandlers();
@@ -291,47 +269,43 @@
assertEquals("four", exceptionHandler.getEventListenerReferences().get(1).getExpression());
}
- public void testProcessDynamicProperties()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().property("key1", "val1").property("key2",
- "val2").node().initial().done();
+ public void testProcessDynamicProperties() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().property("key1", "val1").property("key2", "val2").node().initial()
+ .done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
assertEquals("val1", processDefinition.getProperty("key1"));
assertEquals("val2", processDefinition.getProperty("key2"));
}
- public void testNodeDynamicProperties()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().node().initial().property("key1", "val1")
- .property("key2", "val2").done();
+ public void testNodeDynamicProperties() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().node().initial().property("key1", "val1").property("key2", "val2")
+ .done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
Node node = processDefinition.getInitial();
assertEquals("val1", node.getProperty("key1"));
assertEquals("val2", node.getProperty("key2"));
}
- public void testTransitionDynamicProperties()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().node("a").initial().transition().to("a")
- .property("key1", "val1").property("key2", "val2").done();
+ public void testTransitionDynamicProperties() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().node("a").initial().transition().to("a").property("key1", "val1")
+ .property("key2", "val2").done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
Transition transition = processDefinition.getInitial().getDefaultTransition();
assertEquals("val1", transition.getProperty("key1"));
assertEquals("val2", transition.getProperty("key2"));
}
- public void testEventDynamicProperties()
- {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)ProcessFactory.build().event(Event.PROCESS_BEGIN).property("key1",
- "val1").property("key2", "val2").node().initial().done();
+ public void testEventDynamicProperties() {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build().event(Event.PROCESS_BEGIN).property("key1", "val1").property(
+ "key2", "val2").node().initial().done();
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // / new transaction ////////////////////////////
+ processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
EventImpl event = processDefinition.getEvent(Event.PROCESS_BEGIN);
assertEquals("val1", event.getProperty("key1"));
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessExecutionDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessExecutionDbTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessExecutionDbTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -1,143 +0,0 @@
-/**
- * Copyright (C) 2007 Bull S. A. S.
- * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
- * This library 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
- * version 2.1 of the License.
- * This library 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
- * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301, USA.
- **/
-package org.jbpm.pvm.internal.db.model;
-
-import junit.framework.Test;
-
-import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.test.EnvironmentDbTestCase;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
-
-/**
- * @author Guillaume Porcher
- *
- */
-public class ProcessExecutionDbTest extends EnvironmentDbTestCase
-{
-
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(ProcessExecutionDbTest.class);
- }
-
- public void testExecutionProperties()
- {
- OpenProcessDefinition processDefinition = new ProcessDefinitionImpl();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class); // new transaction /////////
-
- ExecutionImpl execution = new ExecutionImpl();
- execution.setKey("businessKey");
- execution.setName("main");
- execution.setState("test");
- execution.setPriority(42);
-
- execution = reload(execution, ExecutionImpl.class); // new transaction /////////////////////////
-
- assertNotNull(execution);
-
- assertEquals("businessKey", execution.getKey());
- assertEquals("main", execution.getName());
- assertEquals("test", execution.getState());
- assertEquals(42, execution.getPriority());
- }
- /*
- * TODO finish after refactoring
- *
- * public void testChildExecutions() { ProcessDefinition processDefinition = new ProcessDefinitionImpl();
- *
- * processDefinition = reload(processDefinition); // new transaction /////////
- *
- * ExecutionImpl mainExecution = (ExecutionImpl) processDefinition.beginProcessInstance();
- *
- * mainExecution = reload(mainExecution); // new transaction /////////////////////////
- *
- * mainExecution.createExecution("shipping"); mainExecution.createExecution("billing"); ExecutionImpl talking =
- * mainExecution.createExecution("talking"); talking.createExecution("gossip"); talking.createExecution("bs");
- * talking.createExecution("rubbish");
- *
- * mainExecution = reload(mainExecution); // new transaction /////////////////////////
- *
- * Collection<Execution> executions = mainExecution.getExecutions(); assertNotNull(executions);
- * assertNotNull(mainExecution.getExecution("shipping")); assertNotNull(mainExecution.getExecution("billing"));
- * assertNotNull(mainExecution.getExecution("talking")); assertEquals(3, executions.size());
- *
- * ExecutionImpl talkingExecution = mainExecution.getExecution("talking"); Collection<Execution> talkingExecutions =
- * mainExecution.getExecutions(); assertNotNull(talkingExecutions);
- * assertNotNull(talkingExecution.getExecution("gossip")); assertNotNull(talkingExecution.getExecution("bs"));
- * assertNotNull(talkingExecution.getExecution("rubbish")); assertEquals(3, talkingExecutions.size()); }
- *
- * public void testSimpleProcessVariables() { ProcessDefinition processDefinition = new ProcessDefinitionImpl();
- *
- * processDefinition = reload(processDefinition); // new transaction /////////
- *
- * ExecutionImpl execution = (ExecutionImpl) processDefinition.beginProcessInstance(); execution.setVariable("amount",
- * "$500"); execution.setVariable("size", 66); execution.setVariable("color", "blue");
- *
- * execution = reload(execution); // new transaction /////////////////////////
- *
- * assertEquals("$500", execution.getVariable("amount")); assertEquals(66, execution.getVariable("size"));
- * assertEquals("blue", execution.getVariable("color")); assertEquals(3, execution.getVariableKeys().size()); }
- *
- * public static class Color { }
- *
- * public void testUnpersistableVariable() { ProcessDefinition processDefinition = new ProcessDefinitionImpl();
- *
- * processDefinition = reload(processDefinition); // new transaction /////////
- *
- * ExecutionImpl execution = (ExecutionImpl) processDefinition.beginProcessInstance(); execution.setVariable("color",
- * new Color());
- *
- * try { environment.get(DbSession.class).save(execution); fail("expected exception"); } catch (RuntimeException e) {
- * // OK environment.getTransaction().setRollbackOnly(); } }
- *
- * public void testVariablesQuery() { ProcessDefinition processDefinition = new ProcessDefinitionImpl();
- *
- * processDefinition = reload(processDefinition); // new transaction /////////
- *
- * ExecutionImpl execution = (ExecutionImpl) processDefinition.beginProcessInstance("one");
- * execution.setVariable("amount", 100); environment.get(DbSession.class).save(execution);
- *
- * execution = (ExecutionImpl) processDefinition.beginProcessInstance("two"); execution.setVariable("amount", 200);
- * environment.get(DbSession.class).save(execution);
- *
- * execution = (ExecutionImpl) processDefinition.beginProcessInstance("three"); execution.setVariable("amount", 300);
- * environment.get(DbSession.class).save(execution);
- *
- * execution = (ExecutionImpl) processDefinition.beginProcessInstance("four"); execution.setVariable("amount", 400);
- * environment.get(DbSession.class).save(execution);
- *
- * execution = (ExecutionImpl) processDefinition.beginProcessInstance("hmmm"); execution.setVariable("sambucas", 500);
- * environment.get(DbSession.class).save(execution);
- *
- * newTransaction();
- *
- * Session session = environment.get(Session.class); Query query = session.createQuery( "select lv.processInstance " +
- * "from "+LongVariable.class.getName()+" as lv " + "where lv.key = :variableKey" + " and lv.l > :variableValue" );
- * query.setString("variableKey", "amount"); query.setInteger("variableValue", 250); List executions = query.list();
- *
- * assertNotNull(executions); assertEquals(2, executions.size());
- *
- * Set<String> retrievedExecutionNames = new HashSet<String>();
- * retrievedExecutionNames.add(((ExecutionImpl)executions.get(0)).getKey());
- * retrievedExecutionNames.add(((ExecutionImpl)executions.get(1)).getKey());
- *
- * Set<String> expectedExecutionNames = new HashSet<String>(); expectedExecutionNames.add("three");
- * expectedExecutionNames.add("four");
- *
- * assertEquals(expectedExecutionNames, retrievedExecutionNames); }
- */
-}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -32,10 +32,6 @@
*/
public class SessionFactoryDbTest extends EnvironmentDbTestCase
{
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(SessionFactoryDbTest.class);
- }
public void testSessionFactory()
{
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -64,11 +64,6 @@
public class WireDbTest extends EnvironmentDbTestCase
{
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(WireDbTest.class);
- }
-
public void testCharacterDescriptor()
{
DbSession dbSession = environment.get(DbSession.class);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -37,11 +37,6 @@
public class WireTest extends EnvironmentDbTestCase
{
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(WireTest.class);
- }
-
public void testObjectDescriptor()
{
DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -45,12 +45,6 @@
{
private static final String ENVIRONMENT_CFG_XML = "org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml";
- public static Test suite()
- {
- TestSuite suite = new TestSuite(VariableCustomTypeTest.class);
- return new EnvironmentFactoryTestSetup(suite, ENVIRONMENT_CFG_XML);
- }
-
public VariableCustomTypeTest()
{
super(ENVIRONMENT_CFG_XML);
Modified: jbpm4/trunk/modules/test-load/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-load/pom.xml 2008-12-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/test-load/pom.xml 2008-12-26 13:17:25 UTC (rev 3551)
@@ -61,4 +61,19 @@
</dependencies>
+ <!-- Plugins -->
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/*TestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
</project>
\ No newline at end of file
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -0,0 +1,89 @@
+/*
+ * 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();
+ }
+ }
+
+ 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;
+ }
+ });
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -25,13 +25,8 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
import org.hibernate.Session;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
import org.jbpm.cmd.Command;
import org.jbpm.cmd.CommandService;
import org.jbpm.env.Environment;
@@ -40,29 +35,24 @@
import org.jbpm.model.Comment;
import org.jbpm.pvm.internal.cmd.CompositeCmd;
import org.jbpm.pvm.internal.cmd.SendMessageCmd;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.jobexecutor.FailOnceTestCommand;
import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
import org.jbpm.pvm.internal.model.CommentImpl;
-import org.jbpm.session.MessageSession;
-import org.jbpm.test.DbTestCase;
/**
* @author Tom Baeyens
* @author Guillaume Porcher
*/
-public class MessageProcessingTest extends DbTestCase {
+public class MessageProcessingTest extends JobExecutorTestCase {
private static final Log log = Log.getLog(MessageProcessingTest.class.getName());
+ static long nbrOfTestMessages = 10000; // nbrOfTestMessages must be dividable by insertGroupSize
+ static long insertGroupSize = 10;
+
static final long SECOND = 1000;
static final long MINUTE = 60 * SECOND;
static final long HOUR = 60 * MINUTE;
- static long nbrOfTestMessages = 10000; // nbrOfTestMessages must be dividable by insertGroupSize
- static long insertGroupSize = 10;
-
static boolean measureMemory = true;
static long timeoutMillis = 30 * MINUTE; // 10 minutes
@@ -119,7 +109,7 @@
log.info(commentsAdded+" msgs in "+formatDuration(start, System.currentTimeMillis())+" mem:"+used);
}
- public void testSuccessfulMessageProcessing() {
+ public void testMessageProcessing() throws Exception {
JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
long stop = -1;
@@ -206,75 +196,4 @@
}
return text.toString();
}
-
-
- public static class InsertFailOnceTestMsgCmd implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- int i;
-
- public InsertFailOnceTestMsgCmd(int i) {
- this.i = i;
- }
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
- messageSession.send(commandMessage);
- return null;
- }
- }
-
- void insertFailOnceTestMessages() {
- for (int i = 0; i < nbrOfTestMessages; i++) {
- commandService.execute(new InsertFailOnceTestMsgCmd(i));
- }
- }
-
- private void waitTillNoMoreMessages(JobExecutor jobExecutor) {
-
- // 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, timeoutMillis);
-
- try {
- 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();
- }
-
- } catch (InterruptedException e) {
- fail("test execution exceeded treshold of " + timeoutMillis + " milliseconds");
- } finally {
- timer.cancel();
- }
- }
-
- boolean areJobsAvailable() {
- return commandService.execute(new Command<Boolean>() {
- public Boolean execute(Environment environment) {
- Session session = environment.get(Session.class);
-
- Long jobs = (Long) session.createQuery("select count(*) from "+JobImpl.class.getName()).uniqueResult();
- if (jobs.longValue()>0) {
- log.debug("found "+jobs+" more jobs to process");
- return true;
- }
- return false;
- }
- });
- }
}
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-26 12:28:51 UTC (rev 3550)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ProcessExecutionTest.java 2008-12-26 13:17:25 UTC (rev 3551)
@@ -36,10 +36,9 @@
private static Log log = Log.getLog(ProcessExecutionTest.class.getName());
- static int processes = 2;
- static int threads = 2;
+ static int processes = 500;
+ static int threads = 10;
-
Throwable exception;
public void testExecuteProcesses() throws Exception {
15 years, 4 months
JBoss JBPM SVN: r3550 - in jbpm4/trunk/modules: pvm and 13 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-26 07:28:51 -0500 (Fri, 26 Dec 2008)
New Revision: 3550
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.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/ExclusiveTestCommand.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/FailOnceTestCommand.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/FailingTestCommand.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.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/NormalMessageCommand.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageTest.java
jbpm4/trunk/modules/pvm/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java
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/jbpm.load.hbm.xml
jbpm4/trunk/modules/test-load/src/test/resources/org/
jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/
jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/test/
jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/test/load/
jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/test/load/process.jpdl.xml
Removed:
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java
jbpm4/trunk/modules/pvm/pom.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.job.hbm.xml
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java
jbpm4/trunk/modules/pvm/src/test/resources/hibernate.properties
jbpm4/trunk/modules/pvm/src/test/resources/logging.properties
jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
Log:
split job executor tests in load tests and functional tests
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -51,8 +51,13 @@
Object target = wireContext.create(descriptor, false);
try {
- List<ArgDescriptor> argDescriptors = invokeOperation.getArgDescriptors();
- Object[] args = ObjectDescriptor.getArgs(wireContext, argDescriptors);
+ List<ArgDescriptor> argDescriptors = null;
+ Object[] args = null;
+ if (invokeOperation!=null) {
+ argDescriptors = invokeOperation.getArgDescriptors();
+ args = ObjectDescriptor.getArgs(wireContext, argDescriptors);
+ }
+
Class<?> clazz = target.getClass();
Method method = ReflectUtil.findMethod(clazz, methodName, argDescriptors, args);
if (method==null) {
Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/pvm/pom.xml 2008-12-26 12:28:51 UTC (rev 3550)
@@ -141,6 +141,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
+ <exclude>**/*TestCase.java</exclude>
<exclude>**/ExecutionServiceTest.java</exclude>
<exclude>**/AutomaticDecisionDbTest.java</exclude>
<exclude>**/PersistentExecutionModeTest.java</exclude>
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+
+
+/** container for executing multiple commands in one transaction.
+ *
+ * @author Tom Baeyens
+ */
+public class CompositeCmd implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected List<Command<?>> commands = new ArrayList<Command<?>>();
+
+ public Void execute(Environment environment) throws Exception {
+ for (Command command: commands) {
+ command.execute(environment);
+ }
+ return null;
+ }
+
+ public void addCommand(Command<?> command) {
+ commands.add(command);
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompositeCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Message;
+import org.jbpm.session.MessageSession;
+
+/** sends a given message to the configured message service.
+ *
+ * @author Tom Baeyens
+ */
+public class SendMessageCmd implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Message message;
+
+ public SendMessageCmd(Message message) {
+ this.message = message;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ messageSession.send(message);
+ return null;
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SendMessageCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -17,11 +17,8 @@
protected int dbversion;
/** date until which the command should not be executed
- * this date is set to the current time
- * It should be modified only for timers
- * Warning: if you modify this, be sure to wake the JobExecutor
- * when the jobImpl is supposed to be executed */
- protected Date dueDate = new Date();
+ * for async messages, this dueDate should be set to null. */
+ protected Date dueDate = null;
/** suspended jobs will not execute. */
protected boolean isSuspended;
@@ -44,6 +41,9 @@
/** the time the lock on this jobImpl expires. */
protected Date lockExpirationTime;
+ /** any information that subclasses might use in a specific way. */
+ protected String info;
+
/** stack trace of the exception that occurred during command execution. */
protected String exception;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExceptionHandler.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -62,7 +62,9 @@
// execute this job exception handler object as a command with
// the command service so that this gets done in a separate
// transaction
+ log.debug("starting new transaction for handling job exception");
commandService.execute(this);
+ log.debug("completed transaction for handling job exception");
}
public Object execute(Environment environment) throws Exception {
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.job.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.job.hbm.xml 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.job.hbm.xml 2008-12-26 12:28:51 UTC (rev 3550)
@@ -18,6 +18,7 @@
<property name="isExclusive" column="ISEXCLUSIVE_" />
<property name="lockOwner" column="LOCKOWNER_" />
<property name="lockExpirationTime" column="LOCKEXPTIME_" />
+ <property name="info" column="INFO_" />
<property name="exception" column="EXCEPTION_" type="text" />
<property name="retries" column="RETRIES_" />
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/CommentDbTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -35,14 +35,8 @@
/**
* @author Tom Baeyens
*/
-public class CommentDbTest extends EnvironmentDbTestCase
-{
+public class CommentDbTest extends EnvironmentDbTestCase {
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(CommentDbTest.class);
- }
-
public void testComment()
{
Date now = new Date();
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveMessagesTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.session.MessageSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveMessagesTest extends JobExecutorTestCase {
+
+ static Map<String, Set<Long>> exclusiveThreadIds;
+
+ static int nbrOfTestMessagesPerExecution = 5;
+ static int nbrOfTestExecutions = 5;
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ exclusiveThreadIds = new HashMap<String, Set<Long>>();
+ }
+
+ public void testExclusiveMessageProcessing() {
+ insertExclusiveTestMessages();
+
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ // exclusiveMessageIds maps execution keys to a set of thread ids.
+ // the idea is that for each execution, all the exclusive jobs will
+ // be executed by 1 thread sequentially.
+
+ for (int i = 0; i < nbrOfTestExecutions; i++) {
+ String executionKey = "execution-" + i;
+ Set<Long> threadIds = exclusiveThreadIds.get(executionKey);
+ assertNotNull("no thread id set for " + executionKey + " in: " + exclusiveThreadIds, threadIds);
+ assertEquals("exclusive messages for " + executionKey + " have been executed by multiple threads: " + threadIds, 1, threadIds.size());
+ }
+ return null;
+ }
+ });
+ }
+
+ public static class WaitState 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 void insertExclusiveTestMessages() {
+ commandService.execute(new Command<Object>() {
+ public Object execute(Environment environment) throws Exception {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessFactory.build("excl")
+ .node("wait").initial().behaviour(WaitState.class)
+ .done();
+ processDefinition.setId("excl:1");
+
+ Session session = environment.get(Session.class);
+ session.save(processDefinition);
+ return null;
+ }
+ });
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ for (int i = 0; i < nbrOfTestExecutions; i++) {
+ Execution execution = new StartExecutionCmd("excl:1", null, "execution-" + i).execute(environment);
+
+ for (int j = 0; j < nbrOfTestMessagesPerExecution; j++) {
+ CommandMessage exclusiveTestMessage = ExclusiveTestCommand.createMessage(execution);
+ messageSession.send(exclusiveTestMessage);
+ }
+ }
+ return null;
+ }
+ });
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveMessagesTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java (from rev 3540, jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(ExclusiveTestCommand.class.getName());
+ static Random random = new Random();
+
+ long executionId;
+
+ public ExclusiveTestCommand() {
+ }
+
+ public static CommandMessage createMessage(Execution execution) {
+ CommandMessage commandMessage = new CommandMessage();
+ commandMessage.setExecution((ExecutionImpl) execution);
+ commandMessage.setExclusive(true);
+
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(ExclusiveTestCommand.class);
+ commandDescriptor.addInjection("executionId", new LongDescriptor(execution.getDbid()));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ Long threadId = Thread.currentThread().getId();
+
+ Session session = environment.get(Session.class);
+ ExecutionImpl execution = (ExecutionImpl) session.get(ExecutionImpl.class, executionId);
+
+ String executionKey = execution.getKey();
+
+ // exclusiveMessageIds maps execution keys to a set of thread ids.
+ // the idea is that for each execution, all the exclusive jobs will
+ // be executed by 1 thread sequentially.
+
+ // in the end, each set should contain exactly 1 element
+
+ Set<Long> groupMessages = ExclusiveMessagesTest.exclusiveThreadIds.get(executionKey);
+ if (groupMessages==null) {
+ groupMessages = new HashSet<Long>();
+ ExclusiveMessagesTest.exclusiveThreadIds.put(executionKey, groupMessages);
+ }
+ groupMessages.add(threadId);
+
+ /*
+ // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
+ int workTime = random.nextInt(150);
+ log.debug("executing exclusive message for "+execution+". this is going to take "+workTime+"ms");
+ try {
+ Thread.sleep(workTime);
+ } catch (RuntimeException e) {
+ log.debug("sleeping was interrupted");
+ }
+ */
+
+ return null;
+ }
+
+}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceMessageTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailOnceMessageTest extends JobExecutorTestCase {
+
+ private static final Log log = Log.getLog(FailOnceMessageTest.class.getName());
+
+ static long nbrOfTestMessages = 1;
+
+ static List<Integer> failOnceMessageIds = Collections.synchronizedList(new ArrayList<Integer>());
+
+ public void testFailOnceMessages() {
+ failOnceMessageIds.clear();
+
+ jobExecutor.start();
+ try {
+ insertFailOnceTestMessages();
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ log.debug("stopping job executor");
+ jobExecutor.stop(true);
+ }
+
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ assertTrue("message " + i + " is not failed once: " + failOnceMessageIds, failOnceMessageIds.contains(i));
+ }
+ assertEquals(nbrOfTestMessages, failOnceMessageIds.size());
+
+ log.debug("==== all messages processed, now checking if all messages have arrived exactly once ====");
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ List<Comment> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+
+ for (Comment comment : comments) {
+ log.debug("retrieved message: "+comment.getMessage());
+ Integer messageId = new Integer(comment.getMessage());
+ assertTrue("message " + messageId + " committed twice", failOnceMessageIds.remove(messageId));
+ }
+
+ assertTrue("not all messages made a successful commit: " + failOnceMessageIds, failOnceMessageIds.isEmpty());
+ return null;
+ }
+ });
+ }
+
+ public static class InsertFailOnceTestMsgCmd implements Command<Object> {
+ private static final long serialVersionUID = 1L;
+ int i;
+ public InsertFailOnceTestMsgCmd(int i) {
+ this.i = i;
+ }
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
+ messageSession.send(commandMessage);
+ return null;
+ }
+ }
+
+ void insertFailOnceTestMessages() {
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ commandService.execute(new InsertFailOnceTestMsgCmd(i));
+ }
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceMessageTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java (from rev 3540, jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailOnceTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(FailOnceTestCommand.class.getName());
+
+ int messageId;
+
+ public FailOnceTestCommand() {
+ }
+
+ public static CommandMessage createMessage(int messageId) {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailOnceTestCommand.class);
+ commandDescriptor.addInjection("messageId", new IntegerDescriptor(messageId));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+
+ // this message execution should be rolled back
+ Comment comment = new CommentImpl(Integer.toString(messageId));
+ dbSession.save(comment);
+
+ if (!FailOnceMessageTest.failOnceMessageIds.contains(messageId)) {
+ // registering the failed message in a non-transactional resource
+ // so the messageId will still be added even after the transaction has rolled back
+ log.debug("adding failonce message "+messageId);
+ FailOnceMessageTest.failOnceMessageIds.add(messageId);
+
+ throw new RuntimeException("failing once");
+ }
+
+ try {
+ Thread.sleep(700);
+ } catch (Exception e) {
+ log.error(e.toString());
+ }
+
+ log.debug("message "+messageId+" now succeeds");
+
+ return null;
+ }
+
+}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingMessageTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -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.pvm.internal.jobexecutor;
+
+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.Job;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailingMessageTest extends JobExecutorTestCase {
+
+
+ public void testFailedMessageProcessing() {
+ jobExecutor.start();
+ try {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = FailingTestCommand.createMessage();
+ messageSession.send(commandMessage);
+ return null;
+ }
+ });
+
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
+ assertEquals("there should be one dead job", 1, deadJobs.size());
+
+ Session session = environment.get(Session.class);
+ List commands = session.createQuery("from " + CommentImpl.class.getName()).list();
+ assertTrue("command insertion should have been rolled back", commands.isEmpty());
+ return null;
+ }
+ });
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingMessageTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java (from rev 3540, jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailingTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+
+ // this message execution should be rolled back
+ Comment comment = new CommentImpl("failing update");
+ dbSession.save(comment);
+
+ throw new RuntimeException("ooops");
+ }
+
+ public static CommandMessage createMessage() {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailingTestCommand.class);
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+}
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java (from rev 3540, jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ *
+ * Simple command that will create an exception during execution.
+ * The exception will generate a stacktrace with variable length
+ * (controlled by the length parameter).
+ *
+ * This class is to test the persistence of exception stacktrace in jobs.
+ */
+public class GenerateExceptionTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ int length;
+
+ public GenerateExceptionTestCommand() {
+ }
+
+ public static CommandMessage createMessage(int recursionInitialDepth) {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(GenerateExceptionTestCommand.class);
+ commandDescriptor.addInjection("length", new IntegerDescriptor(recursionInitialDepth));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ StringBuilder stringBuilder = new StringBuilder();
+ while (stringBuilder.length() < length) {
+ stringBuilder.append("This is a long test message. ");
+ }
+ throw new RuntimeException(stringBuilder.toString());
+ }
+
+}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTestCase.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+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.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobExecutorTestCase extends DbTestCase {
+
+ static long timeoutMillis = 20 * 1000; // 10 seconds
+ 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 )";
+
+ 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) {
+
+ // 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, timeoutMillis);
+
+ try {
+ 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();
+ }
+
+ } catch (InterruptedException e) {
+ fail("test execution exceeded treshold of " + timeoutMillis + " milliseconds");
+ } finally {
+ timer.cancel();
+ }
+ }
+
+ 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;
+ }
+ });
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageCommand.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageCommand.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.Random;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+/**
+ * @author Tom Baeyens
+ */
+public class NormalMessageCommand implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+ static Random random = new Random();
+
+ int messageId;
+
+ public NormalMessageCommand() {
+ }
+
+ public NormalMessageCommand(int messageId) {
+ this.messageId = messageId;
+ }
+
+ public static CommandMessage createMessage(int messageId) {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(NormalMessageCommand.class);
+ commandDescriptor.addInjection("messageId", new IntegerDescriptor(messageId));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ CommentImpl comment = new CommentImpl(Integer.toString(messageId));
+ Session session = environment.get(Session.class);
+ session.save(comment);
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.jobexecutor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+import org.jbpm.test.Db;
+
+/**
+ * @author Tom Baeyens
+ */
+public class NormalMessageTest extends JobExecutorTestCase {
+
+ static long nbrOfTestMessages = 5;
+
+ static long timeoutMillis = 30 * 1000; // 30 seconds
+ static long checkInterval = 400;
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Db.clean(processEngine);
+ }
+
+ public void testNormalMessageProcessing() {
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+
+ try {
+ // insert ${nbrOfTestMessages} messages...
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ commandService.execute(new InsertNormalMessageCmd(i));
+ }
+
+ // wait till all messages are processed
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ List<Integer> processedMessageNumbers = commandService.execute(new Command<List<Integer>>() {
+ public List<Integer> execute(Environment environment) {
+ List<Integer> processedMessageNumbers = new ArrayList<Integer>();
+ Session session = environment.get(Session.class);
+ List<Comment> comments = session.createCriteria(CommentImpl.class).list();
+ for (Comment comment: comments) {
+ int processedMessageNumber = Integer.parseInt(comment.getMessage());
+ processedMessageNumbers.add(processedMessageNumber);
+ // make sure the db stays clean
+ session.delete(comment);
+ }
+ return processedMessageNumbers;
+ }
+ });
+
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ assertTrue("message " + i + " is not processed: " + processedMessageNumbers, processedMessageNumbers.contains(i));
+ }
+ }
+
+ public static class InsertNormalMessageCmd implements Command<Object> {
+ private static final long serialVersionUID = 1L;
+ int i;
+ public InsertNormalMessageCmd(int i) {
+ this.i = i;
+ }
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = NormalMessageCommand.createMessage(i);
+ messageSession.send(commandMessage);
+ return null;
+ }
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/NormalMessageTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/test/resources/hibernate.properties
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/hibernate.properties 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/pvm/src/test/resources/hibernate.properties 2008-12-26 12:28:51 UTC (rev 3550)
@@ -7,5 +7,5 @@
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
+# hibernate.format_sql true
+# hibernate.use_sql_comments true
Added: jbpm4/trunk/modules/pvm/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/resources/jbpm.cfg.xml 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,66 @@
+<?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>
+ <check-process />
+ <check-problems />
+ <save />
+ </deployer-manager>
+
+ <process-service />
+ <execution-service />
+ <management-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" />
+ <cache-configuration resource="jbpm.pvm.cache.xml"
+ usage="nonstrict-read-write" />
+ </hibernate-configuration>
+
+ <hibernate-session-factory />
+
+ <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 />
+ <message-session />
+ <timer-session />
+ </environment>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/pvm/src/test/resources/jbpm.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/logging.properties 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/pvm/src/test/resources/logging.properties 2008-12-26 12:28:51 UTC (rev 3550)
@@ -4,7 +4,7 @@
redirect.commons.logging = enabled
-java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.level = ERROR
java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
@@ -14,12 +14,12 @@
# 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.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.cfg.HbmBinder.level=SEVERE
+org.hibernate.level=INFO
org.hibernate.cfg.SettingsFactory.level=SEVERE
# org.hibernate.level=FINE
# org.hibernate.SQL.level=FINEST
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java (from rev 3540, jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/AddCommentMessage.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,55 @@
+/*
+ * 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.Random;
+
+import org.hibernate.Session;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.CommentImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddCommentMessage extends MessageImpl<Void> {
+
+ private static final long serialVersionUID = 1L;
+ static Random random = new Random();
+
+ public AddCommentMessage() {
+ }
+
+ public AddCommentMessage(String message) {
+ this.info = message;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ CommentImpl comment = new CommentImpl(info);
+ Session session = environment.get(Session.class);
+ session.save(comment);
+ session.delete(this);
+ MessageProcessingTest.commentAdded();
+ return null;
+ }
+}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/Automatic.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Automatic {
+
+
+ public void doNothing() {
+ }
+}
Property changes on: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/Automatic.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -1,96 +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.HashSet;
-import java.util.Random;
-import java.util.Set;
-
-import org.hibernate.Session;
-import org.jbpm.Execution;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExclusiveTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(ExclusiveTestCommand.class.getName());
- static Random random = new Random();
-
- long executionId;
-
- public ExclusiveTestCommand() {
- }
-
- public static CommandMessage createMessage(Execution execution) {
- CommandMessage commandMessage = new CommandMessage();
- commandMessage.setExecution((ExecutionImpl) execution);
- commandMessage.setExclusive(true);
-
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(ExclusiveTestCommand.class);
- commandDescriptor.addInjection("executionId", new LongDescriptor(execution.getDbid()));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
- public Object execute(Environment environment) throws Exception {
- Long threadId = Thread.currentThread().getId();
-
- Session session = environment.get(Session.class);
- ExecutionImpl execution = (ExecutionImpl) session.get(ExecutionImpl.class, executionId);
-
- String executionKey = execution.getKey();
-
- // exclusiveMessageIds maps execution keys to a set of thread ids.
- // the idea is that for each execution, all the exclusive jobs will
- // be executed by 1 thread sequentially.
-
- // in the end, each set should contain exactly 1 element
- Set<Long> groupMessages = JobExecutorTest.exclusiveThreadIds.get(executionKey);
- if (groupMessages==null) {
- groupMessages = new HashSet<Long>();
- JobExecutorTest.exclusiveThreadIds.put(executionKey, groupMessages);
- }
- groupMessages.add(threadId);
-
- // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
- int workTime = random.nextInt(150);
- log.debug("executing exclusive message for "+execution+". this is going to take "+workTime+"ms");
- try {
- Thread.sleep(workTime);
- } catch (RuntimeException e) {
- log.debug("sleeping was interrupted");
- }
-
- return null;
- }
-
-}
Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -1,78 +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 org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.model.CommentImpl;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.DbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FailOnceTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(FailOnceTestCommand.class.getName());
-
- int messageId;
-
- public FailOnceTestCommand() {
- }
-
- public static CommandMessage createMessage(int messageId) {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailOnceTestCommand.class);
- commandDescriptor.addInjection("messageId", new IntegerDescriptor(messageId));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
- public Object execute(Environment environment) throws Exception {
- DbSession dbSession = environment.get(DbSession.class);
-
- // this message execution should be rolled back
- Comment comment = new CommentImpl(Integer.toString(messageId));
- dbSession.save(comment);
-
- if (!JobExecutorTest.failOnceMessageIds.contains(messageId)) {
- // registering the failed message in a non-transactional resource
- // so the messageId will still be added even after the transaction has rolled back
- log.debug("adding failonce message "+messageId);
- JobExecutorTest.failOnceMessageIds.add(messageId);
-
- throw new RuntimeException("failing once");
- }
-
- log.debug("message "+messageId+" now succeeds");
-
- return null;
- }
-
-}
Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.load;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.CommentImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.DbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FailingTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(Environment environment) throws Exception {
- DbSession dbSession = environment.get(DbSession.class);
-
- // this message execution should be rolled back
- Comment comment = new CommentImpl("failing update");
- dbSession.save(comment);
-
- throw new RuntimeException("ooops");
- }
-
- public static CommandMessage createMessage() {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailingTestCommand.class);
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
-}
Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -1,66 +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 org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-
-
-/**
- * @author Tom Baeyens
- * @author Guillaume Porcher
- *
- * Simple command that will create an exception during execution.
- * The exception will generate a stacktrace with variable length
- * (controlled by the length parameter).
- *
- * This class is to test the persistence of exception stacktrace in jobs.
- */
-public class GenerateExceptionTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
-
- int length;
-
- public GenerateExceptionTestCommand() {
- }
-
- public static CommandMessage createMessage(int recursionInitialDepth) {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(GenerateExceptionTestCommand.class);
- commandDescriptor.addInjection("length", new IntegerDescriptor(recursionInitialDepth));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
- public Object execute(Environment environment) throws Exception {
- StringBuilder stringBuilder = new StringBuilder();
- while (stringBuilder.length() < length) {
- stringBuilder.append("This is a long test message. ");
- }
- throw new RuntimeException(stringBuilder.toString());
- }
-
-}
Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -1,402 +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.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.hibernate.Session;
-import org.jbpm.Execution;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.cmd.Command;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
-import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
-import org.jbpm.pvm.internal.model.CommentImpl;
-import org.jbpm.session.MessageSession;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Tom Baeyens
- * @author Guillaume Porcher
- */
-public class JobExecutorTest extends DbTestCase {
-
- private static final Log log = Log.getLog(JobExecutorTest.class.getName());
-
- static List<Integer> processedMessageIds;
- static Map<String, Set<Long>> exclusiveThreadIds;
- static List<Integer> failOnceMessageIds;
-
- static int nbrOfTestMessages = 1000;
- static int timeoutMillis = 2 * 60 * 1000; // 10 minutes
- static int checkInterval = 400;
- static int nbrOfTestMessagesPerExecution = 5;
- static int nbrOfTestExecutions = 5;
-
- CommandService commandService;
-
- public void setUp() throws Exception {
- super.setUp();
- processedMessageIds = new ArrayList<Integer>();
- exclusiveThreadIds = new HashMap<String, Set<Long>>();
- failOnceMessageIds = new ArrayList<Integer>();
-
- commandService = processEngine.get(CommandService.class);
- }
-
- public void testSuccessfulMessageProcessing() {
- JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
- jobExecutor.start();
- try {
- insertTestMessages();
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- List<Integer> processedMessageNumbers = commandService.execute(new Command<List<Integer>>() {
- public List<Integer> execute(Environment environment) {
- List<Integer> processedMessageNumbers = new ArrayList<Integer>();
- Session session = environment.get(Session.class);
- List<Comment> comments = session.createCriteria(CommentImpl.class).list();
- for (Comment comment: comments) {
- int processedMessageNumber = Integer.parseInt(comment.getMessage());
- processedMessageNumbers.add(processedMessageNumber);
- // make sure the db stays clean
- session.delete(comment);
- }
- return processedMessageNumbers;
- }
- });
-
- for (int i = 0; i < nbrOfTestMessages; i++) {
- assertTrue("message " + i + " is not processed: " + processedMessageNumbers, processedMessageNumbers.contains(i));
- }
- }
-
- /*
- public void testMessagesPresentUponJobExecutorStartUp() {
-
- insertTestMessages();
-
- JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
- jobExecutor.start();
- try {
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- for (int i = 0; i < nbrOfTestMessages; i++) {
- assertTrue("message " + i + " is not processed", processedMessageIds.contains(i));
- }
- }
-
- public void testExclusiveMessageProcessing() {
- insertExclusiveTestMessages();
-
- JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
- jobExecutor.start();
- try {
-
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- commandService.execute(new Command<Object>() {
-
- public Object execute(Environment environment) throws Exception {
- // exclusiveMessageIds maps execution keys to a set of thread ids.
- // the idea is that for each execution, all the exclusive jobs will
- // be executed by 1 thread sequentially.
-
- for (int i = 0; i < nbrOfTestExecutions; i++) {
- String executionKey = "execution-" + i;
- Set<Long> threadIds = exclusiveThreadIds.get(executionKey);
- assertNotNull("no thread id set for " + executionKey + " in: " + exclusiveThreadIds, threadIds);
- assertEquals("exclusive messages for " + executionKey + " have been executed by multiple threads: " + threadIds, 1, threadIds.size());
- }
- return null;
- }
- });
- }
-
- public void testFailOnceMessages() {
- failOnceMessageIds.clear();
-
- JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
- jobExecutor.start();
- try {
- insertFailOnceTestMessages();
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- for (int i = 0; i < nbrOfTestMessages; i++) {
- assertTrue("message " + i + " is not failed once: " + failOnceMessageIds, failOnceMessageIds.contains(i));
- }
- assertEquals(nbrOfTestMessages, failOnceMessageIds.size());
-
- log.debug("==== all messages processed, now checking if all messages have arrived exactly once ====");
-
- commandService.execute(new Command<Object>() {
-
- public Object execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- List<Comment> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
-
- for (Comment comment : comments) {
- log.debug("retrieved message: "+comment.getMessage());
- Integer messageId = new Integer(comment.getMessage());
- assertTrue("message " + messageId + " committed twice", failOnceMessageIds.remove(messageId));
- }
-
- assertTrue("not all messages made a successful commit: " + failOnceMessageIds, failOnceMessageIds.isEmpty());
- return null;
- }
- });
- }
-
- public void testFailedMessageProcessing() {
- JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
- jobExecutor.start();
- try {
- commandService.execute(new Command<Object>() {
-
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = FailingTestCommand.createMessage();
- messageSession.send(commandMessage);
- return null;
- }
- });
-
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- commandService.execute(new Command<Object>() {
-
- public Object execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
- assertEquals("there should be one dead job", 1, deadJobs.size());
-
- Session session = environment.get(Session.class);
- List commands = session.createQuery("from " + CommentImpl.class.getName()).list();
- assertTrue("command insertion should have been rolled back", commands.isEmpty());
- return null;
- }
- });
- }
-
- public void testExceptionInJob() {
-
- JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
- jobExecutor.start();
- try {
- commandService.execute(new Command<Object>() {
-
- // size of the error message to generate
- // (currently there is a limit of 4000 characters)
- int msgLength = 4100;
-
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = GenerateExceptionTestCommand.createMessage(msgLength);
- messageSession.send(commandMessage);
- return null;
- }
- });
-
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- commandService.execute(new Command<Object>() {
-
- public Object execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
- assertEquals("there should be one dead jobImpl", 1, deadJobs.size());
- return null;
- }
- });
- }
- */
-
- // helper methods ///////////////////////////////////////////////////////////
-
- public static class InsertMessageCmd implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- int i;
-
- public InsertMessageCmd(int i) {
- this.i = i;
- }
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = TestMessageCommand.createMessage(i);
- messageSession.send(commandMessage);
- return null;
- }
- }
-
- void insertTestMessages() {
- for (int i = 0; i < nbrOfTestMessages; i++) {
- commandService.execute(new InsertMessageCmd(i));
- }
- }
-
- public static class WaitState 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);
- }
- }
-
- void insertExclusiveTestMessages() {
- deployJpdlXmlString(
- "<process name='excl'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- for (int i = 0; i < nbrOfTestExecutions; i++) {
- Execution execution =
- new StartExecutionCmd("excl:1", null, "execution-" + i)
- .execute(environment);
-
- for (int j = 0; j < nbrOfTestMessagesPerExecution; j++) {
- CommandMessage exclusiveTestMessage = ExclusiveTestCommand.createMessage(execution);
- messageSession.send(exclusiveTestMessage);
- }
- }
- return null;
- }
- });
- }
-
- public static class InsertFailOnceTestMsgCmd implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- int i;
-
- public InsertFailOnceTestMsgCmd(int i) {
- this.i = i;
- }
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
- messageSession.send(commandMessage);
- return null;
- }
- }
-
- void insertFailOnceTestMessages() {
- for (int i = 0; i < nbrOfTestMessages; i++) {
- commandService.execute(new InsertFailOnceTestMsgCmd(i));
- }
- }
-
- private void waitTillNoMoreMessages(JobExecutor jobExecutor) {
-
- // 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, timeoutMillis);
-
- 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();
- }
-
- } catch (InterruptedException e) {
- fail("test execution exceeded treshold of " + timeoutMillis + " milliseconds");
- } finally {
- timer.cancel();
- }
- }
-
- boolean areJobsAvailable() {
- return commandService.execute(new Command<Boolean>() {
- public Boolean execute(Environment environment) {
- Session session = environment.get(Session.class);
-
- Long jobs = (Long) session.createQuery("select count(*) from "+JobImpl.class.getName()).uniqueResult();
- if (jobs.longValue()>0) {
- log.debug("found more jobs to process");
- return true;
- }
- return false;
- }
- });
- }
-}
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java (from rev 3540, jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/MessageProcessingTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,280 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.hibernate.Session;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+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;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cmd.CompositeCmd;
+import org.jbpm.pvm.internal.cmd.SendMessageCmd;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.FailOnceTestCommand;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class MessageProcessingTest extends DbTestCase {
+
+ private static final Log log = Log.getLog(MessageProcessingTest.class.getName());
+
+ static final long SECOND = 1000;
+ static final long MINUTE = 60 * SECOND;
+ static final long HOUR = 60 * MINUTE;
+
+ static long nbrOfTestMessages = 10000; // nbrOfTestMessages must be dividable by insertGroupSize
+ static long insertGroupSize = 10;
+
+ 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();
+ }
+
+
+ void openMemoryLogFile() throws Exception {
+ memoryWriter = new PrintWriter(new File("target/memory.txt"));
+ }
+
+ void closeMemoryLogFile() {
+ memoryWriter.close();
+ }
+
+ 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())+" mem:"+used);
+ }
+
+ public void testSuccessfulMessageProcessing() {
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+
+ long stop = -1;
+
+ try {
+ int messageIndex = 0;
+ // insert ${nbrOfTestMessages} messages...
+ for (int i = 0; i < nbrOfTestMessages; i+=insertGroupSize) {
+ CompositeCmd compositeCmd = new CompositeCmd();
+ // ...in groups of ${insertGroupSize}
+ for (int j = 0; j <insertGroupSize ; j++) {
+ Message message = new AddCommentMessage(Integer.toString(messageIndex));
+ SendMessageCmd sendMessageCmd = new SendMessageCmd(message);
+ compositeCmd.addCommand(sendMessageCmd);
+
+ messageIndex++;
+ }
+ commandService.execute(compositeCmd);
+
+ log.info("added "+messageIndex+" messages");
+ }
+
+ start = System.currentTimeMillis();
+
+ jobExecutor.start();
+
+ // wait till all messages are processed
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ stop = System.currentTimeMillis();
+
+ jobExecutor.stop(true);
+ }
+
+ log.info("processing "+nbrOfTestMessages+" messages took "+formatDuration(start, stop));
+
+ List<Integer> processedMessageNumbers = commandService.execute(new Command<List<Integer>>() {
+ public List<Integer> execute(Environment environment) {
+ List<Integer> processedMessageNumbers = new ArrayList<Integer>();
+ Session session = environment.get(Session.class);
+ List<Comment> comments = session.createCriteria(CommentImpl.class).list();
+ for (Comment comment: comments) {
+ int processedMessageNumber = Integer.parseInt(comment.getMessage());
+ processedMessageNumbers.add(processedMessageNumber);
+ // make sure the db stays clean
+ session.delete(comment);
+ }
+ return processedMessageNumbers;
+ }
+ });
+
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ assertTrue("message " + i + " is not processed: " + processedMessageNumbers, processedMessageNumbers.contains(i));
+ }
+ }
+
+ // 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();
+ }
+
+
+ public static class InsertFailOnceTestMsgCmd implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ int i;
+
+ public InsertFailOnceTestMsgCmd(int i) {
+ this.i = i;
+ }
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
+ messageSession.send(commandMessage);
+ return null;
+ }
+ }
+
+ void insertFailOnceTestMessages() {
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ commandService.execute(new InsertFailOnceTestMsgCmd(i));
+ }
+ }
+
+ private void waitTillNoMoreMessages(JobExecutor jobExecutor) {
+
+ // 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, timeoutMillis);
+
+ try {
+ 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();
+ }
+
+ } catch (InterruptedException e) {
+ fail("test execution exceeded treshold of " + timeoutMillis + " milliseconds");
+ } finally {
+ timer.cancel();
+ }
+ }
+
+ boolean areJobsAvailable() {
+ return commandService.execute(new Command<Boolean>() {
+ public Boolean execute(Environment environment) {
+ Session session = environment.get(Session.class);
+
+ Long jobs = (Long) session.createQuery("select count(*) from "+JobImpl.class.getName()).uniqueResult();
+ if (jobs.longValue()>0) {
+ log.debug("found "+jobs+" more jobs to process");
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ProcessExecutionTest.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,91 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.log.Log;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessExecutionTest extends DbTestCase {
+
+ private static Log log = Log.getLog(ProcessExecutionTest.class.getName());
+
+ static int processes = 2;
+ static int threads = 2;
+
+
+ Throwable exception;
+
+ public void testExecuteProcesses() throws Exception {
+ deployJpdlResource("org/jbpm/test/load/process.jpdl.xml");
+
+ List<Thread> threadList = new ArrayList<Thread>();
+ for (int i=0; i<threads; i++) {
+ Thread thread = new ProcessExecutor();
+ thread.start();
+ threadList.add(thread);
+ }
+
+ for (Thread thread: threadList) {
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ log.info(e.toString());
+ }
+ if (exception!=null) {
+ break;
+ }
+ }
+
+ if (exception!=null) {
+ throw new Exception("thread threw: "+exception.getMessage(), exception);
+ }
+ }
+
+ public class ProcessExecutor extends Thread {
+ public void run() {
+ try {
+ for (int i=0; i<processes; i++) {
+ executeProcess();
+ }
+ } catch (Throwable t) {
+ exception = t;
+ }
+ }
+ public void executeProcess() {
+ Execution execution = executionService.startExecutionByKey("Process");
+ assertEquals("c", execution.getNodeName());
+ String executionId = execution.getId();
+ execution = executionService.signalExecutionById(executionId);
+ assertTrue(execution.isEnded());
+ }
+ }
+
+
+}
Property changes on: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ProcessExecutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java 2008-12-26 12:28:51 UTC (rev 3550)
@@ -1,79 +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.Random;
-
-import org.hibernate.Session;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.CommentImpl;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-
-/**
- * @author Tom Baeyens
- */
-public class TestMessageCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(TestMessageCommand.class.getName());
- static Random random = new Random();
-
- int messageId;
-
- public TestMessageCommand() {
- }
-
- public TestMessageCommand(int messageId) {
- this.messageId = messageId;
- }
-
- public Object execute(Environment environment) throws Exception {
- String msgText = Integer.toString(messageId);
- CommentImpl comment = new CommentImpl(msgText);
- environment.get(Session.class).save(comment);
-
- /*
- // let's assume that an average job takes between 0 and 150 millis to complete.
- int workTime = random.nextInt(150);
- log.debug("executing test message "+messageId+". this is going to take "+workTime+"ms");
- try {
- Thread.sleep(workTime);
- } catch (RuntimeException e) {
- log.debug("sleeping was interrupted");
- }
- */
-
- return null;
- }
-
- public static CommandMessage createMessage(int i) {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(TestMessageCommand.class);
- commandDescriptor.addInjection("messageId", new IntegerDescriptor(i));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-}
Modified: jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml 2008-12-26 12:28:51 UTC (rev 3550)
@@ -33,6 +33,7 @@
<mapping resource="jbpm.pvm.variable.hbm.xml" />
<mapping resource="jbpm.pvm.job.hbm.xml" />
<mapping resource="jbpm.jpdl.hbm.xml" />
+ <mapping resource="jbpm.load.hbm.xml" />
<cache-configuration resource="jbpm.pvm.cache.xml"
usage="nonstrict-read-write" />
</hibernate-configuration>
Added: jbpm4/trunk/modules/test-load/src/test/resources/jbpm.load.hbm.xml
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/jbpm.load.hbm.xml (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/resources/jbpm.load.hbm.xml 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+
+ <subclass name="org.jbpm.test.load.AddCommentMessage"
+ extends="org.jbpm.pvm.internal.job.MessageImpl"
+ discriminator-value="AddMsg">
+ </subclass>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/test-load/src/test/resources/jbpm.load.hbm.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/logging.properties 2008-12-24 22:03:07 UTC (rev 3549)
+++ jbpm4/trunk/modules/test-load/src/test/resources/logging.properties 2008-12-26 12:28:51 UTC (rev 3550)
@@ -1,11 +1,11 @@
-handlers= java.util.logging.ConsoleHandler
+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
+redirect.commons.logging=enabled
-java.util.logging.ConsoleHandler.level = ERROR
-java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
+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
@@ -14,11 +14,15 @@
# 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.jbpm.level=INFO
+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
+org.jbpm.test.load.level=INFO
+
org.hibernate.cfg.HbmBinder.level=SEVERE
org.hibernate.cfg.SettingsFactory.level=SEVERE
# org.hibernate.level=FINE
Added: jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/test/load/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/test/load/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/test/load/process.jpdl.xml 2008-12-26 12:28:51 UTC (rev 3550)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Process" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="a" />
+ </start>
+
+ <java name="a"
+ class="org.jbpm.test.load.Automatic"
+ method="doNothing">
+ <flow to="b" />
+ </java>
+
+ <java name="b"
+ class="org.jbpm.test.load.Automatic"
+ method="doNothing">
+ <flow to="c" />
+ </java>
+
+ <state name="c">
+ <flow to="d" />
+ </state>
+
+ <java name="d"
+ class="org.jbpm.test.load.Automatic"
+ method="doNothing">
+ <flow to="e" />
+ </java>
+
+ <java name="e"
+ class="org.jbpm.test.load.Automatic"
+ method="doNothing">
+ <flow to="end" />
+ </java>
+
+ <end name="end" />
+
+</process>
Property changes on: jbpm4/trunk/modules/test-load/src/test/resources/org/jbpm/test/load/process.jpdl.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years, 4 months
JBoss JBPM SVN: r3549 - jbpm4/trunk/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2008-12-24 17:03:07 -0500 (Wed, 24 Dec 2008)
New Revision: 3549
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
Log:
add the java task documentation
Modified: 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-24 20:45:37 UTC (rev 3548)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2008-12-24 22:03:07 UTC (rev 3549)
@@ -247,7 +247,149 @@
</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
15 years, 4 months
JBoss JBPM SVN: r3548 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-12-24 15:45:37 -0500 (Wed, 24 Dec 2008)
New Revision: 3548
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
Log:
restrict text type workaround to sybase, because it breaks hsqldb
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2008-12-24 19:58:13 UTC (rev 3547)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2008-12-24 20:45:37 UTC (rev 3548)
@@ -33,10 +33,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
import org.hibernate.type.Type;
import org.hibernate.usertype.UserType;
import org.hibernate.util.EqualsHelper;
import org.hibernate.util.StringHelper;
+import org.jbpm.JbpmContext;
+import org.jbpm.persistence.db.DbPersistenceServiceFactory;
+import org.jbpm.svc.Services;
/**
* @author Alejandro Guizar
@@ -197,9 +201,21 @@
}
public void setNull(PreparedStatement st, int index) throws HibernateException, SQLException {
- st.setCharacterStream(index, null, 0);
+ if (getHibernateDialect().indexOf("Sybase") == -1) {
+ st.setNull(index, sqlType());
+ }
+ else {
+ // JBPM-1818: workaround for SQL state JZ0SL: "Unsupported SQL type" with jConnect
+ st.setCharacterStream(index, null, 0);
+ }
}
+ private String getHibernateDialect() {
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) JbpmContext
+ .getCurrentJbpmContext().getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ return factory.getConfiguration().getProperty(Environment.DIALECT);
+ }
+
public Object replace(Object original, Object target, Object owner) throws HibernateException {
return original;
}
@@ -209,9 +225,13 @@
}
public int[] sqlTypes() {
- return new int[] { Types.CLOB };
+ return new int[] { sqlType() };
}
+ public int sqlType() {
+ return Types.CLOB;
+ }
+
public String nullSafeToString(Object value) throws HibernateException {
return value == null ? null : toString(value);
}
15 years, 4 months
JBoss JBPM SVN: r3547 - in jbpm4/trunk/modules/userguide/src/main/docbook/en: modules and 1 other directory.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2008-12-24 14:58:13 -0500 (Wed, 24 Dec 2008)
New Revision: 3547
Added:
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png
Removed:
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
Log:
completed docs for state sequence, state choice and end events
Deleted: 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/end.state.png (from rev 3546, jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png)
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Modified: 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-24 17:35:28 UTC (rev 3546)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2008-12-24 19:58:13 UTC (rev 3547)
@@ -211,6 +211,10 @@
<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>
@@ -294,6 +298,10 @@
</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>
@@ -359,6 +367,8 @@
</table>
<para>Example:
</para>
+ <para>Same picture as <link linkend="exclusive">above</link>.
+ </para>
<programlisting><process name="Poolcar">
<start>
<flow to="How far?" />
@@ -412,6 +422,8 @@
</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>
@@ -466,6 +478,10 @@
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>
@@ -511,15 +527,49 @@
</section>
<section id="endmultiple">
<title><literal>end</literal> multiple</title>
- <para>A process can have multiple end states. This can be handy to indicate
+ <para>A process can have multiple end events. This can be handy to indicate
different outcomes of a process instance. For example
</para>
- <programlisting></programlisting>
+ <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>TODO
+ <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>
@@ -543,6 +593,41 @@
</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>
15 years, 4 months
JBoss JBPM SVN: r3546 - jbpm4/trunk/modules/userguide/src/main/docbook/en/images.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2008-12-24 12:35:28 -0500 (Wed, 24 Dec 2008)
New Revision: 3546
Added:
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
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.sequence.png
Log:
add the examples process images
Added: 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/concurrency.graphbased.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/end.multiple.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/end.processinstance.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/end.state.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/esb.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/exclusive.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/hql.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/java.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/script.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/sql.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/sql.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: 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/state.choice.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/state.sequence.png
===================================================================
(Binary files differ)
15 years, 4 months