KickJava   Java API By Example, From Geeks To Geeks.

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


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