KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > exe > VariableInstanceDbTest


1 package org.jbpm.bpel.data.exe;
2
3 import org.jbpm.context.def.ContextDefinition;
4 import org.jbpm.graph.exe.ProcessInstance;
5
6 import org.jbpm.bpel.data.def.SchemaTypeInfo;
7 import org.jbpm.bpel.data.def.VariableDefinition;
8 import org.jbpm.bpel.db.AbstractDbTestCase;
9 import org.jbpm.bpel.def.BpelDefinition;
10
11 /**
12  * @author Alejandro Guízar
13  * @version $Revision: 1.3 $ $Date: 2005/05/07 00:03:42 $
14  */

15 public class VariableInstanceDbTest extends AbstractDbTestCase {
16
17   BpelDefinition processDefinition;
18   ProcessInstance pi;
19   
20   public void setUp() {
21     super.setUp();
22     processDefinition = new BpelDefinition();
23     processDefinition.addDefinition(new ContextDefinition());
24     pi = new ProcessInstance(processDefinition);
25   }
26
27   
28   public void testSimpleDefinition() {
29     VariableDefinition variable = new VariableDefinition();
30     variable.setName("aName");
31     variable.setTypeInfo(new SchemaTypeInfo());
32     processDefinition.getScope().addVariable(variable);
33     graphSession.saveProcessDefinition(processDefinition);
34     variable.createInstance(pi.getRootToken());
35     pi = saveAndReload(pi);
36     
37     assertEquals( VariableDefinition.class, variable.getInstance(pi.getRootToken()).getDefinition().getClass() );
38   }
39   
40   public void testSimpleValue() {
41     VariableDefinition variable = new VariableDefinition();
42     variable.setName("aName");
43     variable.setTypeInfo(new SchemaTypeInfo());
44     processDefinition.getScope().addVariable(variable);
45     graphSession.saveProcessDefinition(processDefinition);
46     variable.createInstance(pi.getRootToken()).setValue( new Integer JavaDoc(1) );
47     pi = saveAndReload(pi);
48     
49     assertEquals( 1, ((Integer JavaDoc) variable.getInstance(pi.getRootToken()).getValue()).intValue() );
50   }
51   
52   /*
53   public void testElementType() {
54     processDefinition = new BpelDefinition();
55     VariableDefinition variable = new VariableDefinition("aName", new QName(null, "local"));
56     processDefinition.getScopeDefinition().addVariable(variable);
57     
58     processDefinition = saveAndReload(processDefinition);
59     
60     assertNotNull( processDefinition.getScopeDefinition().getVariable("aName").getType() );
61   }
62   
63   public void testMessage() {
64     processDefinition = new BpelDefinition();
65     MessageImpl message = new MessageImpl();
66     VariableDefinition firstVariable = new VariableDefinition("first", message);
67     VariableDefinition secondVariable = new VariableDefinition("second", message);
68     processDefinition.getScopeDefinition().addVariable(firstVariable);
69     processDefinition.getScopeDefinition().addVariable(secondVariable);
70     
71     processDefinition = saveAndReload(processDefinition);
72     
73     ScopeDefinition def = processDefinition.getScopeDefinition();
74     firstVariable = ((VariableDefinition) def.getVariable("first"));
75     secondVariable = ((VariableDefinition) def.getVariable("second"));
76     assertNotNull(firstVariable.getMessage());
77     assertEquals( firstVariable.getMessage(), secondVariable.getMessage() );
78   }
79   */

80 }
81
Popular Tags