KickJava   Java API By Example, From Geeks To Geeks.

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


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.graph.exe.Token;
10 import org.jbpm.logging.exe.LoggingInstance;
11
12 public class SignalLogTest extends TestCase {
13
14   public void testSignalLog() {
15     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
16       "<process-definition>" +
17       " <start-state>" +
18       " <transition to='s' />" +
19       " </start-state>" +
20       " <state name='s'>" +
21       " <transition to='s' />" +
22       " </state>" +
23       "</process-definition>"
24     );
25     
26     // start a process instance
27
ProcessInstance processInstance = new ProcessInstance(processDefinition);
28     Token token = processInstance.getRootToken();
29     processInstance.signal();
30     
31     // check the transition log (from the start state to the state)
32
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
33     List JavaDoc processLogs = loggingInstance.getLogs(SignalLog.class);
34
35     // check that there is exactly one signal log
36
assertEquals(1, processLogs.size());
37
38     SignalLog signalLog = (SignalLog) processLogs.get(0);
39     assertSame(token, signalLog.getToken());
40     assertNotNull(signalLog.getDate());
41     
42     // now we signal a second time
43
processInstance.signal();
44     // and check if there are exactly 2 signal logs
45
assertEquals(2, loggingInstance.getLogs(SignalLog.class).size());
46   }
47
48   
49 }
50
Popular Tags