⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testbasicprocessinstance.java

📁 jbpm的demo,带有流程设计
💻 JAVA
字号:
/** * $Source: /home/ws/rz65/CVS-Repository/WorkflowProjects/JBPM-Demo/src/test/testjbpmdemo/testbasic/TestBasicProcessInstance.java,v $ * $Revision: 1.2 $ * $Date: 2005/03/08 12:20:46 $ * $Author: rz65 $ * * Copyright (c) 2005 Universitaet Karlsruhe (TH) / Rechenzentrum (RZ-UNI-UKA) * * RZ-UNI-KA makes no representations or warranties about the suitability * of this software, either express or implied, including but not limited * to the implied warranties of merchantability, fitness for a particular * purpose, or non-infringement. RZ-UNI-KA shall not be liable for any * damages as a result of using, modifying or distributing this software * or its derivatives. */package testjbpmdemo.testbasic;import testjbpmdemo.testbasic.AbstractBasicTestCase;import junit.framework.Test;import junit.framework.TestSuite;import junit.textui.TestRunner;import org.jbpm.context.def.ContextDefinition;import org.jbpm.graph.def.Action;import org.jbpm.graph.def.GraphElement;import org.jbpm.graph.def.Node;import org.jbpm.graph.def.ProcessDefinition;import org.jbpm.graph.def.Transition;import org.jbpm.graph.exe.ProcessInstance;import org.jbpm.graph.exe.Token;import org.jbpm.jpdl.xml.JpdlXmlReader;import org.jbpm.jpdl.xml.JpdlXmlWriter;import org.jbpm.logging.def.LoggingDefinition;import java.util.Collection;import java.util.Date;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;/** * A test case for the process definition. *  * <p> *  * @version $Revision: 1.2 $ * @author mailto:harald.meyer@rz.uni-karlsruhe.de */public class TestBasicProcessInstance extends AbstractBasicTestCase {	/**	 * Builds a test case instance.	 * 	 * @param name	 *            The name of the case.	 */	public TestBasicProcessInstance(String name) {		super(name);	}	/**	 * The stand-alone run main method.	 * 	 * @param args	 *            The run-time arguments (ignored)	 */	public static void main(String[] args) {		TestRunner.run(suite());	}	/**	 * Creates a test suite from this class.	 * 	 * @return The test suite that covers all test... methods	 */	public static Test suite() {		return new TestSuite(TestBasicProcessInstance.class);	}	protected void setUp() throws Exception {		String mn = "setUp";		String resourceName = getDefaultXMLResourcePath();		debug(mn, "resource name: " + resourceName);		setUpProcessDefinition = JpdlXmlReader.parseFromResource(resourceName);		debug(mn, "process definition: " + setUpProcessDefinition);		setUpProcessInstance = new ProcessInstance(setUpProcessDefinition);		debug(mn, "process instance: " + setUpProcessInstance);	}	private ProcessDefinition setUpProcessDefinition;	private ProcessInstance setUpProcessInstance;	/**	 * Check the set-up	 */	public void testSetUp() {		assertNotNull("process definition must not be null.",				setUpProcessDefinition);		assertNotNull("process instance must not be null.",				setUpProcessInstance);	}	/**	 * Inspect the process instance.	 */	public void testProcessInstance() throws Exception {		String mn = "testProcessInstance";		long id = setUpProcessInstance.getId();		debug(mn,"instance id: " + id);		ProcessDefinition pd = setUpProcessInstance.getProcessDefinition();		debug("underlying process definition: " + pd);		assertNotNull("getProcessDefinition must not return null.", pd);		assertSame("process definition mismatch: ", setUpProcessDefinition, pd);		boolean b = setUpProcessInstance.hasEnded();		debug(mn,"flag: ended=" + b);		assertFalse("end flag must not be raised.",b);		Date dStart = setUpProcessInstance.getStart();		debug(mn,"start date: " + dStart);		assertNotNull("start date must not be null.",dStart);		assertFalse("start date mismatch",dStart.after(new Date()));		Date dEnd = setUpProcessInstance.getEnd();		debug(mn,"end date: " + dEnd);		assertNull("end date must be null.",dEnd);		b = setUpProcessInstance.hasJbpmSession();		debug(mn,"flag: hast JBPM session=" + b);	}	/**	 * Inspect the root token.	 */	public void testRootToken() throws Exception {		String mn = "testRootToken";		Token rootToken = setUpProcessInstance.getRootToken();		debug(mn,"root token: " + rootToken);		ProcessInstance pi = rootToken.getProcessInstance();		debug("underlying process instance: " + pi);		assertNotNull("getProcessInstance must not return null.", pi);		assertSame("process instance mismatch: ", setUpProcessInstance, pi);		long id = rootToken.getId();		debug(mn,"id: " + id);		String s = rootToken.getName();		debug(mn,"token name: " + s);		//assertNotNull("name must not be null.",s);		//assertFalse("name must not be empty.",s.equals(""));		s = rootToken.getFullName();		debug(mn,"token full name: " + s);		assertNotNull("full name must not be null.",s);		assertFalse("full name must not be empty.",s.equals(""));	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -