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

📄 testbasicprocessdefinition.java

📁 jbpm的demo,带有流程设计
💻 JAVA
字号:
/** * $Source: /home/ws/rz65/CVS-Repository/WorkflowProjects/JBPM-Demo/src/test/testjbpmdemo/testbasic/TestBasicProcessDefinition.java,v $ * $Revision: 1.1 $ * $Date: 2005/03/07 19:00:51 $ * $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.jpdl.xml.JpdlXmlReader;import org.jbpm.jpdl.xml.JpdlXmlWriter;import org.jbpm.logging.def.LoggingDefinition;import java.util.Collection;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.1 $ * @author mailto:harald.meyer@rz.uni-karlsruhe.de */public class TestBasicProcessDefinition extends AbstractBasicTestCase {	/**	 * Builds a test case instance.	 * 	 * @param name	 *            The name of the case.	 */	public TestBasicProcessDefinition(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(TestBasicProcessDefinition.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);			}	private ProcessDefinition setUpProcessDefinition;	/**	 * Check the set-up	 */	public void testSetUp() {		assertNotNull("process definition must not be null.",				setUpProcessDefinition);	}	/**	 * Inspect the process definition.	 */	public void testProcessDefinition() throws Exception {		String mn = "testProcessDefinition";		String s = setUpProcessDefinition.getName();		debug(mn, "getName(): " + s);		assertNotNull("getName() must not return null.", s);		assertTrue("getName() must not return empty string.", s.length() > 0);		s = setUpProcessDefinition.generateNodeName();		debug(mn, "generateNodeName(): " + s);		assertNotNull("generateNodeName() must not return null.", s);		assertTrue("generateNodeName() must not return empty string.", s				.length() > 0);		long l = setUpProcessDefinition.getId();		debug(mn, "getId(): " + l);		GraphElement ge = setUpProcessDefinition.getParent();		debug("getParent(): " + ge);		assertNull("getParent() should return null.", ge);	}	/**	 * Inspect the context definition.	 */	public void testContextDefinition() throws Exception {		String mn = "testContextDefinition";		ContextDefinition cd = setUpProcessDefinition.getContextDefinition();		debug(mn, "context definition: " + cd);		long l = cd.getId();		debug(mn, "getId(): " + l);		String s = cd.getName();		debug(mn, "getName(): " + s);		// assertNotNull("getName must not return null.",s);		ProcessDefinition pd = cd.getProcessDefinition();		debug("underlying process definition: " + pd);		assertNotNull("getProcessDefinition must not return null.", pd);		assertSame("process definition mismatch: ", setUpProcessDefinition, pd);	}	/**	 * Inspect the logging definition.	 */	public void testLoggingDefinition() throws Exception {		String mn = "testLoggingDefinition";		LoggingDefinition ld = setUpProcessDefinition.getLoggingDefinition();		debug(mn, "logging definition: " + ld);		debug(mn, "logging definition should be null." + ld);	}	/**	 * Inspect the actions.	 */	public void testDefinitions() throws Exception {		String mn = "testDefinitions";		Map actions = setUpProcessDefinition.getDefinitions();		debug(mn, "no. of actions: " + actions.size());		Set set = actions.keySet();		Iterator iter = set.iterator();		for (int i = 0; iter.hasNext(); i++) {			Object key = iter.next();			String cKey = key.getClass().getName();			Object value = actions.get(key);			String cValue = value.getClass().getName();			debug(mn, "definition[" + i + "]: " + cKey + " " + key + " => "					+ cValue + " " + value);		}	}	/**	 * Inspect the actions.	 */	public void testActions() throws Exception {		String mn = "testActions";		Map actions = setUpProcessDefinition.getActions();		if (actions == null) {			debug(mn, "actions: null");		} else {			debug(mn, "no. of actions: " + actions.size());			Set set = actions.keySet();			Iterator iter = set.iterator();			for (int i = 0; iter.hasNext(); i++) {				Object key = iter.next();				String cKey = key.getClass().getName();				Object value = actions.get(key);				String cValue = value.getClass().getName();				debug(mn, "action[" + i + "]: " + cKey + " " + key + " => "						+ cValue + " " + value);			}		}	}	/**	 * Inspect the node map.	 */	public void testNodeMap() throws Exception {		String mn = "testNodeMap";		Map nodeMap = setUpProcessDefinition.getNodeMap();		if (nodeMap == null) {			debug(mn, "nodeMap: null");		} else {			debug(mn, "no. of nodeMap: " + nodeMap.size());			Set set = nodeMap.keySet();			Iterator iter = set.iterator();			for (int i = 0; iter.hasNext(); i++) {				Object key = iter.next();				String cKey = key.getClass().getName();				Object value = nodeMap.get(key);				String cValue = value.getClass().getName();				debug(mn, "nodeMap[" + i + "]: " + cKey + " " + key + " => "						+ cValue + " " + value);			}		}	}	/**	 * Inspect the nodes and their attributes.	 */	public void testNodes() throws Exception {		String mn = "testNodes";		List nodes = setUpProcessDefinition.getNodes();		if (nodes == null) {			debug(mn, "nodes: null");		} else {			int n = nodes.size();			debug(mn, "no. of nodes: " + n);			assertEquals("size mismatch.",setUpProcessDefinition.getNodeMap().size(),n);			for (int i = 0; i<n; i++) {				Object item= nodes.get(i);				String cItem = item.getClass().getName();				debug(mn, "nodes[" + i + "]: " + cItem + " " + item);				Node node = (Node) item;				debug(mn,"node isolated: " + node);				Collection coll = node.getArrivingTransitions();				debug(mn,"arriving transitions: " + coll);				coll = node.getLeavingTransitions();				debug(mn,"leaving transitions: " + coll);				Transition transition = node.getDefaultLeavingTransition();				debug(mn,"default leaving transition: " + transition);				GraphElement ge = node.getParent();				debug(mn,"parent: " + ge);				Action action = node.getAction();				debug(mn,"action: " + action);			}		}	}	/**	 * Inspect the node map.	 */	public void testEventMap() throws Exception {		String mn = "testEventMap";		Map eventMap = setUpProcessDefinition.getEventMap();		if (eventMap == null) {			debug(mn, "eventMap: null");		} else {			debug(mn, "no. of eventMap: " + eventMap.size());			Set set = eventMap.keySet();			Iterator iter = set.iterator();			for (int i = 0; iter.hasNext(); i++) {				Object key = iter.next();				String cKey = key.getClass().getName();				Object value = eventMap.get(key);				String cValue = value.getClass().getName();				debug(mn, "eventMap[" + i + "]: " + cKey + " " + key + " => "						+ cValue + " " + value);			}		}	}		/**	 * Test the XML writer result.	 */	public void testXmlWriterResults() {		String mn="testXmlWriterResults";		String s = JpdlXmlWriter.toString(setUpProcessDefinition);		assertNotNull("writer result must not be null.",s);		debug(mn,"writer result length: " + s.length());		debug(mn,"result: " + s);	}}

⌨️ 快捷键说明

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