KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > logging > exe > LogLogTest


1 package org.jbpm.logging.exe;
2
3 import junit.framework.TestCase;
4
5 import org.jbpm.context.def.ContextDefinition;
6 import org.jbpm.context.exe.ContextInstance;
7 import org.jbpm.graph.def.ActionHandler;
8 import org.jbpm.graph.def.ProcessDefinition;
9 import org.jbpm.graph.exe.ExecutionContext;
10 import org.jbpm.graph.exe.ProcessInstance;
11 import org.jbpm.logging.log.MessageLog;
12
13 public class LogLogTest extends TestCase {
14   
15   public static class MessageAction implements ActionHandler {
16     private static final long serialVersionUID = 1L;
17     public void execute(ExecutionContext executionContext) throws Exception JavaDoc {
18       executionContext.getToken().addLog(new MessageLog("hello from inside the message action"));
19       executionContext.getContextInstance().setVariable("number", new Float JavaDoc(3.3));
20     }
21   }
22
23   public void testLoggingTheLogs() {
24     ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
25       "<process-definition>" +
26       " <start-state name='start'>" +
27       " <transition to='fork'/>" +
28       " </start-state>" +
29       " <fork name='fork'>" +
30       " <transition name='a' to='a'>" +
31       " <action class='org.jbpm.logging.exe.LogLogTest$MessageAction' />" +
32       " </transition>" +
33       " <transition name='b' to='b' />" +
34       " </fork>" +
35       " <state name='a' />" +
36       " <end-state name='b' />" +
37       "</process-definition>"
38     );
39     processDefinition.addDefinition(new ContextDefinition());
40     
41     ProcessInstance processInstance = new ProcessInstance(processDefinition);
42     ContextInstance contextInstance = processInstance.getContextInstance();
43     contextInstance.setVariable("number", new Float JavaDoc(5.5));
44     contextInstance.setVariable("text", "one of the few");
45     processInstance.signal();
46     
47     LoggingInstance loggingInstance = processInstance.getLoggingInstance();
48     loggingInstance.logLogs();
49   }
50 }
51
Popular Tags