KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > log > ProcessInstanceLogTest


1 package org.jbpm.graph.log;
2
3 import java.util.List JavaDoc;
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 ProcessInstanceLogTest extends TestCase {
12
13   public void testProcessInstanceCreateLog() {
14     ProcessDefinition processDefinition = new ProcessDefinition();
15     ProcessInstance processInstance = new ProcessInstance(processDefinition);
16     LoggingInstance loggingInstance = processInstance.getLoggingInstance();
17     List JavaDoc processInstanceCreateLogs = loggingInstance.getLogs(ProcessInstanceCreateLog.class);
18     assertEquals(1, processInstanceCreateLogs.size());
19     ProcessInstanceCreateLog processInstanceCreateLog = (ProcessInstanceCreateLog) processInstanceCreateLogs.get(0);
20     assertSame(processInstance.getRootToken(), processInstanceCreateLog.getToken());
21   }
22
23   public void testNoRootTokenCreateLog() {
24     // the root token logs are replaced by the process instance logs
25
ProcessDefinition processDefinition = new ProcessDefinition();
26     ProcessInstance processInstance = new ProcessInstance(processDefinition);
27     LoggingInstance loggingInstance = processInstance.getLoggingInstance();
28     assertEquals(0, loggingInstance.getLogs(TokenCreateLog.class).size());
29   }
30
31   public void testProcessInstanceEndLog() {
32     ProcessDefinition processDefinition = new ProcessDefinition();
33     ProcessInstance processInstance = new ProcessInstance(processDefinition);
34     processInstance.end();
35     LoggingInstance loggingInstance = processInstance.getLoggingInstance();
36     List JavaDoc processInstanceEndLogs = loggingInstance.getLogs(ProcessInstanceEndLog.class);
37     assertEquals(1, processInstanceEndLogs.size());
38     ProcessInstanceEndLog processInstanceEndLog = (ProcessInstanceEndLog) processInstanceEndLogs.get(0);
39     assertSame(processInstance.getRootToken(), processInstanceEndLog.getToken());
40   }
41
42   public void testNoRootTokenEndLog() {
43     // the root token logs are replaced by the process instance logs
44
ProcessDefinition processDefinition = new ProcessDefinition();
45     ProcessInstance processInstance = new ProcessInstance(processDefinition);
46     processInstance.getRootToken().end();
47     LoggingInstance loggingInstance = processInstance.getLoggingInstance();
48     assertEquals(0, loggingInstance.getLogs(TokenEndLog.class).size());
49   }
50 }
51
Popular Tags