KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > wsdl > impl > OperationImplDbTest


1 package org.jbpm.bpel.wsdl.impl;
2
3 import javax.wsdl.Operation;
4
5 import org.jbpm.bpel.db.AbstractDbTestCase;
6 import org.jbpm.bpel.def.BpelDefinition;
7 import org.jbpm.bpel.service.def.PartnerLinkDefinition;
8 import org.jbpm.bpel.wsdl.def.PartnerLinkType;
9
10 public class OperationImplDbTest extends AbstractDbTestCase {
11   
12   BpelDefinition processDefinition;
13   OperationImpl operation;
14   
15   public void setUp() {
16     super.setUp();
17     processDefinition = new BpelDefinition();
18     PartnerLinkDefinition plinkDefinition = new PartnerLinkDefinition();
19     plinkDefinition.setName("pl");
20     PartnerLinkType plinkType = new PartnerLinkTypeImpl();
21     PartnerLinkTypeImpl.RoleImpl role = new PartnerLinkTypeImpl.RoleImpl();
22     plinkType.setFirstRole(role);
23     PortTypeImpl portType = new PortTypeImpl();
24     role.setPortType(portType);
25     operation = new OperationImpl();
26     portType.addOperation(operation);
27     plinkDefinition.setPartnerLinkType(plinkType);
28     processDefinition.getScope().addPartnerLink(plinkDefinition);
29   }
30   
31   public void testName() {
32     operation.setName("withdrawCash");
33     
34     processDefinition = saveAndReload(processDefinition);
35     
36     assertEquals("withdrawCash", getOperation().getName());
37   }
38
39   public void testInput() {
40     InputImpl input = new InputImpl();
41     input.setName("userSession");
42     MessageImpl message = new MessageImpl();
43     input.setMessage(message);
44     operation.setInput(input);
45     
46     processDefinition = saveAndReload(processDefinition);
47     
48     input = (InputImpl) getOperation().getInput();
49     assertEquals( "userSession", input.getName() );
50     assertNotNull( input.getMessage() );
51   }
52   
53   public void testOutput() {
54     OutputImpl output = new OutputImpl();
55     output.setName("balance");
56     MessageImpl message = new MessageImpl();
57     output.setMessage(message);
58     operation.setOutput(output);
59     
60     processDefinition = saveAndReload(processDefinition);
61     
62     output = (OutputImpl) getOperation().getOutput();
63     assertEquals( "balance", output.getName() );
64     assertNotNull( output.getMessage() );
65   }
66   
67   public void testFault() {
68     FaultImpl fault = new FaultImpl();
69     fault.setName("errorNumber");
70     MessageImpl message = new MessageImpl();
71     fault.setMessage(message);
72     operation.addFault(fault);
73     
74     processDefinition = saveAndReload(processDefinition);
75     
76     fault = (FaultImpl) getOperation().getFault("errorNumber");
77     assertEquals( "errorNumber", fault.getName() );
78     assertNotNull( fault.getMessage() );
79   }
80   
81   private Operation getOperation() {
82     PartnerLinkType plt = processDefinition.getScope().getPartnerLink("pl").getPartnerLinkType();
83     return (Operation) plt.getFirstRole().getPortType().getOperations().get(0);
84   }
85 }
86
Popular Tags