KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > service > def > ReplierDbTest


1 package org.jbpm.bpel.service.def;
2
3 import javax.wsdl.Operation;
4 import javax.xml.namespace.QName JavaDoc;
5
6 import org.jbpm.bpel.data.def.VariableDefinition;
7 import org.jbpm.bpel.db.AbstractDbTestCase;
8 import org.jbpm.bpel.def.BpelDefinition;
9 import org.jbpm.bpel.def.Reply;
10 import org.jbpm.bpel.wsdl.def.PartnerLinkType;
11 import org.jbpm.bpel.wsdl.impl.OperationImpl;
12 import org.jbpm.bpel.wsdl.impl.PartnerLinkTypeImpl;
13 import org.jbpm.bpel.wsdl.impl.PortTypeImpl;
14
15 public class ReplierDbTest extends AbstractDbTestCase {
16   
17   BpelDefinition processDefinition;
18   Replier replier;
19   
20   public void setUp() {
21     super.setUp();
22     processDefinition = new BpelDefinition();
23     Reply reply = new Reply("child");
24     replier = new Replier();
25     reply.setReplier(replier);
26     processDefinition.addNode(reply);
27   }
28   
29   public void testCorrelations() {
30     replier.setCorrelations(new Correlations());
31     
32     processDefinition = saveAndReload(processDefinition);
33     replier = getReplier();
34     
35     assertNotNull( replier.getCorrelations() );
36   }
37   
38   public void testOperationName() {
39     //prepare operation
40
PartnerLinkDefinition plinkDefinition = new PartnerLinkDefinition();
41     plinkDefinition.setName("pl");
42     PartnerLinkType plinkType = new PartnerLinkTypeImpl();
43     PartnerLinkTypeImpl.RoleImpl role = new PartnerLinkTypeImpl.RoleImpl();
44     plinkType.setFirstRole(role);
45     PortTypeImpl portType = new PortTypeImpl();
46     role.setPortType(portType);
47     Operation operation = new OperationImpl();
48     operation.setName("o");
49     portType.addOperation(operation);
50     plinkDefinition.setPartnerLinkType(plinkType);
51     processDefinition.getScope().addPartnerLink(plinkDefinition);
52     
53     //set operation
54
replier.setOperation(operation);
55     
56     processDefinition = saveAndReload(processDefinition);
57     replier = getReplier();
58
59     assertEquals("o", replier.getOperation().getName());
60   }
61   
62   public void testFaultName() {
63     replier.setFaultName(new QName JavaDoc(null, "calamitousFault"));
64     
65     processDefinition = saveAndReload(processDefinition);
66     replier = getReplier();
67
68     assertNotNull( replier.getFaultName());
69   }
70   
71   public void testPartnerLink() {
72     PartnerLinkDefinition pl = new PartnerLinkDefinition();
73     pl.setName("pl");
74     processDefinition.getScope().addPartnerLink(pl);
75     replier.setPartnerLink(pl);
76     
77     processDefinition = saveAndReload(processDefinition);
78     replier = getReplier();
79
80     assertNotNull( replier.getPartnerLink() );
81   }
82   
83   public void testVariable() {
84     VariableDefinition variable = new VariableDefinition();
85     variable.setName("v");
86     processDefinition.getScope().addVariable(variable);
87     replier.setVariable(variable);
88     
89     processDefinition = saveAndReload(processDefinition);
90
91     assertNotNull( getReplier().getVariable() );
92   }
93   
94   public void testMessageExchange() {
95     replier.setMessageExchange("msgExchng");
96     processDefinition = saveAndReload(processDefinition);
97     replier = getReplier();
98     
99     assertEquals("msgExchng", replier.getMessageExchange() );
100   }
101   
102   private Replier getReplier() {
103     Reply reply = ((Reply) processDefinition.getNode("child"));
104     return reply.getReplier();
105   }
106 }
107
Popular Tags