KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > exe > ScopeInstanceDbTest


1 package org.jbpm.bpel.exe;
2 import org.jbpm.context.def.ContextDefinition;
3 import org.jbpm.graph.exe.ProcessInstance;
4 import org.jbpm.graph.exe.Token;
5
6 import org.jbpm.bpel.db.AbstractDbTestCase;
7 import org.jbpm.bpel.def.BpelDefinition;
8 import org.jbpm.bpel.exe.state.EndedState;
9
10 public class ScopeInstanceDbTest extends AbstractDbTestCase {
11   
12   public void testToken() {
13     BpelDefinition processDefinition = new BpelDefinition("definition");
14     processDefinition.addDefinition(new ContextDefinition());
15     graphSession.saveProcessDefinition(processDefinition);
16     ProcessInstance processInstance = new ProcessInstance(processDefinition);
17     Token token = processInstance.getRootToken();
18     ScopeInstance.create(token);
19     
20     processInstance = saveAndReload(processInstance);
21
22     ScopeInstance scope = ScopeInstance.get(processInstance.getRootToken());
23     assertEquals(processInstance.getRootToken(), scope.getToken());
24   }
25   
26   public void testScopeState() {
27     BpelDefinition processDefinition = new BpelDefinition("definition");
28     processDefinition.addDefinition(new ContextDefinition());
29     graphSession.saveProcessDefinition(processDefinition);
30     ProcessInstance processInstance = new ProcessInstance(processDefinition);
31     Token token = processInstance.getRootToken();
32     ScopeInstance.create(token).setState(EndedState.COMPLETED);
33     
34     processInstance = saveAndReload(processInstance);
35
36     ScopeInstance scope = ScopeInstance.get(processInstance.getRootToken());
37     assertEquals(EndedState.COMPLETED, scope.getState());
38   }
39   
40   public void testEventState() {
41     BpelDefinition processDefinition = new BpelDefinition("definition");
42     processDefinition.addDefinition(new ContextDefinition());
43     graphSession.saveProcessDefinition(processDefinition);
44     ProcessInstance processInstance = new ProcessInstance(processDefinition);
45     Token token = processInstance.getRootToken();
46     EventInstance.create(token).setState(EndedState.TERMINATED);
47     
48     processInstance = saveAndReload(processInstance);
49
50     EventInstance event = (EventInstance) ScopeInstance.get(processInstance.getRootToken());
51     assertEquals(EndedState.TERMINATED, event.getState());
52   }
53   
54 }
55
Popular Tags