[jbpm-commits] JBoss JBPM SVN: r5257 - in jbpm3/branches/jbpm-3.2-soa/modules/core: src/test/java/org/jbpm/taskmgmt/exe and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jul 8 05:29:33 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-07-08 05:29:32 -0400 (Wed, 08 Jul 2009)
New Revision: 5257
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
Log:
make TaskTimerExecutionDbTest resistant to stale state exceptions
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml 2009-07-07 20:01:12 UTC (rev 5256)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml 2009-07-08 09:29:32 UTC (rev 5257)
@@ -215,6 +215,29 @@
</build>
</profile>
+ <!--
+ Name: jdk14
+ Desc: dependencies specific to jdk 1.4
+ -->
+ <profile>
+ <id>jdk14</id>
+ <activation>
+ <jdk>1.4</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
<!--
Name: no-database
Descr: Setup the default database
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java 2009-07-07 20:01:12 UTC (rev 5256)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskTimerExecutionDbTest.java 2009-07-08 09:29:32 UTC (rev 5257)
@@ -34,22 +34,16 @@
public class TaskTimerExecutionDbTest extends AbstractDbTestCase {
- static int counter = 0;
-
public static class PlusPlus implements ActionHandler {
-
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext executionContext) throws Exception {
- counter++;
+ Integer count = (Integer) executionContext.getVariable("count");
+ count = new Integer(count != null ? count.intValue() + 1 : 1);
+ executionContext.setVariable("count", count);
}
}
- protected void setUp() throws Exception {
- super.setUp();
- counter = 0;
- }
-
public void testTimerCreation() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ " <start-state>"
@@ -58,7 +52,7 @@
+ " <task-node name='a'>"
+ " <task name='clean ceiling'>"
+ " <timer name='ceiling-timer' duedate='0 seconds'>"
- + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " <action class='" + PlusPlus.class.getName() + "' />"
+ " </timer>"
+ " </task>"
+ " </task-node>"
@@ -87,7 +81,7 @@
+ " <task-node name='a'>"
+ " <task name='clean ceiling'>"
+ " <timer name='ceiling-timer' duedate='0 seconds'>"
- + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " <action class='" + PlusPlus.class.getName() + "' />"
+ " </timer>"
+ " </task>"
+ " <transition to='b' />"
@@ -113,7 +107,9 @@
newTransaction();
- assertEquals(0, getTimerCount());
+ processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
+ assertNull("expected variable 'count' to be null", processInstance.getContextInstance()
+ .getVariable("count"));
}
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
@@ -128,7 +124,7 @@
+ " <task-node name='a'>"
+ " <task name='clean ceiling'>"
+ " <timer name='ceiling-timer' duedate='0 seconds'>"
- + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " <action class='" + PlusPlus.class.getName() + "' />"
+ " </timer>"
+ " </task>"
+ " </task-node>"
@@ -142,12 +138,13 @@
processJobs(5000);
- assertEquals(1, counter);
+ processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
+ assertEquals(new Integer(1), processInstance.getContextInstance()
+ .getVariable("count"));
}
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
}
public void testTaskNodeTimerExecution() {
@@ -157,7 +154,7 @@
+ " </start-state>"
+ " <task-node name='a'>"
+ " <timer name='ceiling-timer' duedate='0 seconds'>"
- + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " <action class='" + PlusPlus.class.getName() + "' />"
+ " </timer>"
+ " <task name='clean ceiling' />"
+ " </task-node>"
@@ -169,10 +166,11 @@
processInstance.signal();
jbpmContext.save(processInstance);
- newTransaction();
+ processJobs(5000);
- processJobs(5000);
- assertEquals(1, counter);
+ processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
+ assertEquals(new Integer(1), processInstance.getContextInstance()
+ .getVariable("count"));
}
finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
@@ -187,7 +185,7 @@
+ " <task-node name='a'>"
+ " <task name='clean ceiling'>"
+ " <timer name='ceiling-timer' duedate='0 seconds' repeat='60 second'>"
- + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " <action class='" + PlusPlus.class.getName() + "' />"
+ " </timer>"
+ " </task>"
+ " </task-node>"
@@ -207,8 +205,10 @@
long originalDueDate = timer.getDueDate().getTime();
timer.execute(jbpmContext);
- assertEquals(1, counter);
+ processInstance = timer.getProcessInstance();
+ assertEquals(new Integer(1), processInstance.getContextInstance().getVariable("count"));
+
// check if the timer has be re-scheduled because of the repeat.
timer = getTimer();
assertNotNull(timer);
@@ -229,7 +229,7 @@
+ " <task-node name='a'>"
+ " <task name='clean ceiling'>"
+ " <timer name='ceiling-timer' duedate='#{baseDate} + 2 days'>"
- + " <action class='org.jbpm.taskmgmt.exe.TaskTimerExecutionDbTest$PlusPlus' />"
+ + " <action class='" + PlusPlus.class.getName() + "' />"
+ " </timer>"
+ " </task>"
+ " </task-node>"
More information about the jbpm-commits
mailing list