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 {