KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > xml > ReplyReaderTest


1 package org.jbpm.bpel.xml;
2
3 import java.util.Collections JavaDoc;
4
5 import javax.wsdl.Output;
6
7 import org.xml.sax.SAXException JavaDoc;
8
9 import com.ibm.wsdl.OutputImpl;
10
11 import org.jbpm.bpel.data.def.MessageTypeInfo;
12 import org.jbpm.bpel.def.Reply;
13 import org.jbpm.bpel.service.def.CorrelationSetDefinition;
14
15 /**
16  * @author Juan Cantú
17  * @version $Revision: 1.8 $ $Date: 2005/06/23 20:45:05 $
18  */

19 public class ReplyReaderTest extends AbstractReaderTestCase {
20   
21   public void setUp() throws Exception JavaDoc {
22     super.setUp();
23     initMessageProperties();
24   }
25   
26   public void testPartnerLink() throws Exception JavaDoc {
27     String JavaDoc xml = "<reply partnerLink='aPartner' operation='o' variable='iv'/>";
28     Reply reply = (Reply) readActivity(xml);
29     assertEquals(pLink, reply.getReplier().getPartnerLink() );
30   }
31
32   public void testPortType() {
33     String JavaDoc xml = "<reply partnerLink='aPartner' portType='tns:mpt' operation='o' variable='iv'" +
34         " xmlns:tns='http://manufacturing.org/wsdl/purchase'/>";
35     try {
36       readActivity(xml);
37     }
38     catch (Exception JavaDoc e) {
39       fail(e.toString());
40     }
41   }
42
43   public void testPortTypeDefault() {
44     String JavaDoc xml = "<reply partnerLink='aPartner' operation='o' variable='iv'/>";
45     try {
46       readActivity(xml);
47     }
48     catch (Exception JavaDoc e) {
49       fail(e.toString());
50     }
51   }
52   
53   public void testPortTypeNotFound() throws SAXException JavaDoc {
54     String JavaDoc xml = "<reply partnerLink='aPartner' portType='invalidPT' operation='o'/>";
55     ProblemCollector collector = new ProblemCollector();
56     reader.setProblemHandler(collector);
57     readActivity(xml);
58     if(!collector.hasErrors()) {
59       fail("invoke parse must fail when portType doesn't match partnerRole's portType");
60     }
61   }
62   
63   public void testOperation() throws Exception JavaDoc {
64     String JavaDoc xml = "<reply partnerLink='aPartner' operation='o' variable='iv'/>";
65     Reply reply = (Reply) readActivity(xml);
66     assertEquals( "o", reply.getReplier().getOperation().getName() );
67   }
68   
69   public void testVariable() throws Exception JavaDoc {
70     MessageTypeInfo typeInfo = (MessageTypeInfo) messageVariable.getTypeInfo();
71     Output output = new OutputImpl();
72     output.setMessage(typeInfo.getMessage());
73     operation.setOutput(output);
74     
75     String JavaDoc xml =
76       "<reply partnerLink='aPartner' operation='o' variable='iv'/>";
77     Reply reply = (Reply) readActivity(xml);
78     assertEquals(messageVariable, reply.getReplier().getVariable() );
79   }
80   
81   public void testCorrelations() throws Exception JavaDoc {
82     CorrelationSetDefinition corr = new CorrelationSetDefinition();
83     corr.setName("corr");
84     corr.setProperties(Collections.EMPTY_SET);
85     scope.addCorrelationSet(corr);
86     
87     String JavaDoc correlationXml =
88       "<reply partnerLink='aPartner' operation='o' variable='iv'>" +
89       " <correlations>" +
90       " <correlation set='corr'/> " +
91       " </correlations>" +
92       "</reply>";
93     
94     Reply reply = (Reply) readActivity(correlationXml);
95     assertNotNull( reply.getReplier().getCorrelations() );
96
97   }
98 }
99
Popular Tags