Posted on 2010-03-11 00:06
断点 阅读(303)
评论(0) 编辑 收藏 所属分类:
JBPM4
package org.jbpm.helloworld;
import junit.framework.TestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
public class HelloWorldTest extends TestCase {
public void testHelloWorldProcess() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("helloWorld.xml");
/* 从这里可以看出,是对流程定义的XML进行解析*/
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
assertSame(processDefinition.getStartState(), token.getNode());
token.signal();
assertSame(processDefinition.getNode("s"), token.getNode());
token.signal();
assertSame(processDefinition.getNode("end"), token.getNode());
}
流程定义文件:helloWorld.xml
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="Helloworld">
<start-state>
<transition to='s' />
</start-state>
<state name='s'>
<transition to='end' />
</state>
<end-state name='end' />
</process-definition>