Java Reference
In-Depth Information
21.5.4
Test
To test the engine and its implementation of the workflow model we need to
simulate the enactment of a process. We load the process definitions into the
catalogue and create the actors with the profile required by the process.
The file test.xml contains the XPDL description shown in Figure 21.7. We
use the performActivity() method to simulate a user logging into the system
and first starting and then completing the pending activities.
import javax.xml.parsers.*;
import java.io.File;
import org.w3c.dom.*;
import ProcessDefinition.*;
import WfEngine.*;
import WorkflowModel.*;
public class TestEngine {
public static void main(String[] args) {
// creates the process catalog and the organization
WfEngine.Organization org # new WfEngine.Organization();
WfEngine.Catalog cat # new WfEngine.Catalog();
try {
// open a XPDL description file
DocumentBuilder parser #
DocumentBuilderFactory.newInstance().
newDocumentBuilder();
Document doc # parser.parse( new File("web/test.xml"));
// load the process definitions in the catalog
cat.Add(WfProcessDefinition.loadDefinitions(doc));
// define actors that can interact with WFMS
Actor prof # new Actor("Prof Essor","professor");
Actor student # new Actor("John Learner","student");
// and add them to the organization
org.Add(prof);
org.Add(student);
// get the process manager for the test process
WfProcessMgr mgr # cat.getProcess("Student Test");
// creates the process
WfProcess procInst # mgr.create_process(prof);
prof.addPerformer(procInst);
// start the process
procInst.start();
// loop while the process is open
while (procInst.workflow_state() ##
workflow_stateType.open){
performActivity(prof);
performActivity(student);
}
 
Search WWH ::




Custom Search