1 package org.jbpm.graph.log; 2 3 import java.util.List ; 4 5 import junit.framework.TestCase; 6 7 import org.jbpm.graph.def.ProcessDefinition; 8 import org.jbpm.graph.exe.ProcessInstance; 9 import org.jbpm.logging.exe.LoggingInstance; 10 11 public class NodeLogTest extends TestCase { 12 13 public void testNodeLogCreation() { 14 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 15 "<process-definition>" + 16 " <start-state>" + 17 " <transition to='s' />" + 18 " </start-state>" + 19 " <state name='s'>" + 20 " <transition to='s' />" + 21 " </state>" + 22 "</process-definition>" 23 ); 24 ProcessInstance processInstance = new ProcessInstance(processDefinition); 26 processInstance.signal(); 27 28 LoggingInstance loggingInstance = processInstance.getLoggingInstance(); 29 assertEquals(0, loggingInstance.getLogs(NodeLog.class).size()); 30 31 processInstance.signal(); 32 33 List nodeLogs = loggingInstance.getLogs(NodeLog.class); 34 assertEquals(1, nodeLogs.size()); 35 NodeLog nodeLog = (NodeLog) nodeLogs.get(0); 36 assertSame(processDefinition.getNode("s"), nodeLog.node); 37 assertNotNull(nodeLog.enter); 38 assertNotNull(nodeLog.leave); 39 assertEquals(nodeLog.leave.getTime()-nodeLog.enter.getTime(), nodeLog.duration); 40 } 41 } 42 | Popular Tags |