* Test deadline execution in combination with suspension of
* activities and/or the process.
* @exception Exception if an error occurs
*/
public void timeoutSuspend() throws Exception {
ProcessMgr mgr = defDir.processMgr("SystemTest", "suspendStartMan");
WfProcess proc = mgr.createProcess(requester);
String procKey = proc.key();
proc.start();
assertTrue(stateReached(proc, "closed.completed"));
ProcessData data = proc.processContext();
String path = (String)data.get("TransitionPath");
assertTrue(path,
path.equals("PATH:start:t1:t2:end"));
procDir.removeProcess(proc);
mgr = defDir.processMgr("SystemTest", "suspendEndMan");
proc = mgr.createProcess(requester);
procKey = proc.key();
proc.start();
assertTrue(stateReached(proc, "closed.completed"));
data = proc.processContext();
path = (String)data.get("TransitionPath");
assertTrue(path,
path.equals("PATH:start:a1:t1:a2:t2:end"));
procDir.removeProcess(proc);
// One test case with two variants:
// 1. activity is suspended: (deadline is triggered after resume)
mgr = defDir.processMgr("SystemTest", "suspendAbsolute");
proc = mgr.createProcess(requester);
procKey = proc.key();
proc.start();
Activity act = null;
Iterator i = proc.steps().iterator();
while (i.hasNext()) {
act = (Activity)i.next();
if (act.name().equals("A1")) {
break;
}
}
assertTrue(act.state(), stateReached(act, "open.running"));
Thread.sleep(1000); // allow some time to invoke first tool
act.suspend();
data = proc.processContext();
path = (String)data.get("TransitionPath");
assertTrue(path, path.equals("PATH:start:a1"));
assertTrue(act.state(),
stateReached(act, "open.not_running.suspended"));
Thread.sleep(15000);
Date timestampRes = new Date();
act.resume();
assertTrue(act.state(),
stateReached(act, "closed.completed.abandoned"));
assertTrue(stateReached(proc, "closed.completed"));
data = proc.processContext();
path = (String)data.get("TransitionPath");
Date timestampTo = (Date)data.get("timestamp_to");
assertTrue(path,
path.equals("PATH:start:a1:t1:end"));
assertTrue( timestampTo + ":" + timestampRes,
timestampTo.after(timestampRes) );
procDir.removeProcess(proc);
// 2. whole process is suspended: (deadline is triggered before resume
// but cannot be started until process is resumed)
proc = mgr.createProcess(requester);
procKey = proc.key();
proc.start();
act = null;
i = proc.steps().iterator();
while (i.hasNext()) {