assertTrue(process.state().startsWith("open.running"));
Thread.sleep (1000);
// start the first two activities and stop it.
Collection c = process.steps();
for (int i = 1; i <= 2; i++) {
WfActivity a = null;
for (Iterator it = c.iterator(); it.hasNext();) {
a = (WfActivity)it.next();
if (a.name().equals ("A1" + i)) {
break;
}
}
if (a.name().equals("A12")) {
Thread.sleep (1000);
a.resume();
}
Thread.sleep (1000);
assertTrue(a.name() + " not closed.completed: " + a.state(),
a.state().startsWith("closed.completed"));
}
assertTrue(!process.state().equals("closed.completed"));
// try to remove the process (should result into an exception)
boolean removeExceptionCaught = false;
try {
//Process p = processDirectory().lookupProcess(null, process.key());
processDirectory().removeProcess(process);
assertTrue(false);
} catch (CannotRemoveException cre) {
removeExceptionCaught = true;
} catch (Exception e) {
e.printStackTrace();
assertTrue("Unexpected exception caugth", false);
}
assertTrue("did not receive CannotRemoveException for a process "
+ "that has not been terminated",
removeExceptionCaught);
// start the last activity and stop it.
for (int i = 3; i <= 3; i++) {
WfActivity a = null;
for (Iterator it = c.iterator(); it.hasNext();) {
a = (WfActivity)it.next();
if (a.name().equals ("A1" + i)) {
break;
}
}
assertTrue(a.state() != null);
boolean exceptionCaught = false;
assertTrue
(a.name() + " not open.not_running.suspended: " + a.state(),
a.state().startsWith("open.not_running.suspended"));
a.resume();
Thread.sleep (1000);
a.resume();
Thread.sleep (1000);
assertTrue(a.name() + " not closed.completed: " + a.state(),
a.state().startsWith("closed.completed"));
}
assertTrue(process + " not closed.completed: " + process.state(),
process.state().startsWith("closed.completed"));
// finally remove the process and retry to access it