KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > context > exe > ContextInstanceDbTest


1 package org.jbpm.context.exe;
2
3 import java.util.*;
4
5 import org.jbpm.context.def.*;
6 import org.jbpm.db.*;
7 import org.jbpm.graph.def.*;
8 import org.jbpm.graph.exe.*;
9
10 public class ContextInstanceDbTest extends AbstractDbTestCase {
11
12   public void testContextInstanceTokenVariableMaps() {
13     ProcessDefinition processDefinition = new ProcessDefinition();
14     processDefinition.addDefinition(new ContextDefinition());
15     graphSession.saveProcessDefinition(processDefinition);
16     
17     ProcessInstance processInstance = new ProcessInstance(processDefinition);
18     Token rootToken = processInstance.getRootToken();
19     Token childToken = new Token(rootToken, "shipping");
20     
21     ContextInstance contextInstance = processInstance.getContextInstance();
22     Map tokenVariableMaps = new HashMap();
23     tokenVariableMaps.put(rootToken, new TokenVariableMap(rootToken, contextInstance));
24     tokenVariableMaps.put(childToken, new TokenVariableMap(childToken, contextInstance));
25     contextInstance.tokenVariableMaps = tokenVariableMaps;
26     
27     processInstance = saveAndReload(processInstance);
28     rootToken = processInstance.getRootToken();
29     childToken = rootToken.getChild("shipping");
30     contextInstance = processInstance.getContextInstance();
31     tokenVariableMaps = contextInstance.tokenVariableMaps;
32     
33     assertEquals(2, tokenVariableMaps.size());
34     assertTrue(tokenVariableMaps.containsKey(rootToken));
35     assertTrue(tokenVariableMaps.containsKey(childToken));
36     TokenVariableMap tokenVariableMap = (TokenVariableMap)tokenVariableMaps.get(rootToken);
37     assertNotNull(tokenVariableMap);
38     tokenVariableMap = (TokenVariableMap)tokenVariableMaps.get(childToken);
39     assertNotNull(tokenVariableMap);
40   }
41 }
42
Popular Tags