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.graph.exe.Token; 10 import org.jbpm.logging.exe.LoggingInstance; 11 12 public class ProcessLogsTest extends TestCase { 13 14 public void testProcessInstanceStartLog() { 15 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 16 "<process-definition />" 17 ); 18 19 ProcessInstance processInstance = new ProcessInstance(processDefinition); 21 Token token = processInstance.getRootToken(); 22 23 LoggingInstance loggingInstance = processInstance.getLoggingInstance(); 25 List processLogs = loggingInstance.getLogs(ProcessInstanceCreateLog.class); 26 27 assertEquals(1, processLogs.size()); 28 29 ProcessInstanceCreateLog processInstanceCreateLog = (ProcessInstanceCreateLog) processLogs.get(0); 30 assertSame(token, processInstanceCreateLog.getToken()); 31 assertNotNull(processInstanceCreateLog.getDate()); 32 } 33 34 public void testProcessInstanceEndLog() { 35 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 36 "<process-definition>" + 37 " <start-state>" + 38 " <transition to='end' />" + 39 " </start-state>" + 40 " <end-state name='end' />" + 41 "</process-definition>" 42 ); 43 44 ProcessInstance processInstance = new ProcessInstance(processDefinition); 46 Token token = processInstance.getRootToken(); 47 processInstance.signal(); 48 49 LoggingInstance loggingInstance = processInstance.getLoggingInstance(); 51 List processLogs = loggingInstance.getLogs(ProcessInstanceEndLog.class); 52 53 assertEquals(1, processLogs.size()); 54 55 ProcessInstanceEndLog processInstanceEndLog = (ProcessInstanceEndLog) processLogs.get(0); 56 assertSame(token, processInstanceEndLog.getToken()); 57 assertNotNull(processInstanceEndLog.getDate()); 58 } 59 60 } 61 | Popular Tags |