KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > def > VariableDefinitionDbTest


1 package org.jbpm.bpel.data.def;
2
3 import javax.xml.namespace.QName JavaDoc;
4
5 import org.jbpm.bpel.db.AbstractDbTestCase;
6 import org.jbpm.bpel.def.BpelDefinition;
7 import org.jbpm.bpel.def.Scope;
8 import org.jbpm.bpel.wsdl.impl.MessageImpl;
9 import org.jbpm.bpel.wsdl.impl.PropertyAliasImpl;
10 import org.jbpm.bpel.wsdl.impl.PropertyImpl;
11
12 public class VariableDefinitionDbTest extends AbstractDbTestCase {
13   
14   BpelDefinition processDefinition;
15   
16   public void testName() {
17     processDefinition = new BpelDefinition();
18     VariableDefinition variable = new VariableDefinition();
19     variable.setName("aName");
20     processDefinition.getScope().addVariable(variable);
21     
22     processDefinition = saveAndReload(processDefinition);
23     
24     assertEquals( "aName", processDefinition.getScope().getVariable("aName").getName() );
25   }
26   
27   public void testPropertyAlias() {
28     processDefinition = new BpelDefinition();
29     VariableDefinition variable = new VariableDefinition();
30     variable.setName("aName");
31     QName JavaDoc name = new QName JavaDoc("local");
32     SchemaTypeInfo typeInfo = new SchemaTypeInfo(name);
33     PropertyImpl property = new PropertyImpl();
34     property.setQName(name);
35     PropertyAliasImpl alias = new PropertyAliasImpl();
36     alias.setProperty(property);
37     typeInfo.addPropertyAlias(alias);
38     variable.setTypeInfo(typeInfo);
39     processDefinition.getScope().addVariable(variable);
40     
41     processDefinition = saveAndReload(processDefinition);
42     
43     typeInfo = (SchemaTypeInfo) processDefinition.getScope().getVariable("aName").getTypeInfo();
44     assertEquals(1, typeInfo.getPropertyAliases().size());
45     assertEquals(name, typeInfo.getPropertyAlias(name).getProperty().getQName());
46   }
47   
48   public void testSchemaType() {
49     processDefinition = new BpelDefinition();
50     VariableDefinition variable = new VariableDefinition();
51     variable.setName("aName");
52     QName JavaDoc name = new QName JavaDoc("local");
53     SchemaTypeInfo typeInfo = new SchemaTypeInfo(name);
54     variable.setTypeInfo(typeInfo);
55     processDefinition.getScope().addVariable(variable);
56     
57     processDefinition = saveAndReload(processDefinition);
58     
59     typeInfo = (SchemaTypeInfo) processDefinition.getScope().getVariable("aName").getTypeInfo();
60     assertEquals( name, typeInfo.getName() );
61   }
62   
63   public void testElementType() {
64     processDefinition = new BpelDefinition();
65     VariableDefinition variable = new VariableDefinition();
66     variable.setName("aName");
67     QName JavaDoc name = new QName JavaDoc("local");
68     ElementTypeInfo typeInfo = new ElementTypeInfo( name );
69     variable.setTypeInfo(typeInfo);
70     processDefinition.getScope().addVariable(variable);
71     
72     processDefinition = saveAndReload(processDefinition);
73     
74     typeInfo = (ElementTypeInfo) processDefinition.getScope().getVariable("aName").getTypeInfo();
75     assertEquals( name, typeInfo.getName() );
76   }
77   
78   public void testMessageType() {
79     processDefinition = new BpelDefinition();
80     MessageImpl message = new MessageImpl();
81     QName JavaDoc messageName = new QName JavaDoc("aMessage");
82     message.setQName(messageName);
83     MessageTypeInfo typeInfo = new MessageTypeInfo(message);
84     VariableDefinition firstVariable = new VariableDefinition();
85     firstVariable.setName("first");
86     firstVariable.setTypeInfo(typeInfo);
87     VariableDefinition secondVariable = new VariableDefinition();
88     secondVariable.setName("second");
89     secondVariable.setTypeInfo(typeInfo);
90     
91     processDefinition.getScope().addVariable(firstVariable);
92     processDefinition.getScope().addVariable(secondVariable);
93     
94     processDefinition = saveAndReload(processDefinition);
95     
96     Scope def = processDefinition.getScope();
97     firstVariable = def.getVariable("first");
98     secondVariable = def.getVariable("second");
99     assertEquals( firstVariable.getTypeInfo(), secondVariable.getTypeInfo());
100     typeInfo = (MessageTypeInfo) firstVariable.getTypeInfo();
101     assertEquals( messageName, typeInfo.getMessage().getQName() );
102   }
103 }
104
Popular Tags