KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.bpel.xml;
2
3 import java.util.Map JavaDoc;
4
5 import javax.wsdl.Message;
6
7 import org.w3c.dom.Element JavaDoc;
8
9 import org.jbpm.bpel.data.def.MessageTypeInfo;
10 import org.jbpm.bpel.service.def.Correlation;
11 import org.jbpm.bpel.service.def.CorrelationSetDefinition;
12 import org.jbpm.bpel.service.def.Correlations;
13 import org.jbpm.bpel.service.def.Correlation.Initiate;
14 import org.jbpm.bpel.wsdl.def.PropertyAlias;
15 import org.jbpm.bpel.wsdl.impl.PropertyAliasImpl;
16
17 /**
18  * @author Juan Cantu
19  * @version $Revision: 1.6 $ $Date: 2005/06/16 19:15:35 $
20  */

21 public class CorrelationsReaderTest extends AbstractReaderTestCase {
22   
23   CorrelationSetDefinition initiatedSet;
24   CorrelationSetDefinition followedSet;
25   CorrelationSetDefinition defaultSet;
26   
27   public void setUp() throws Exception JavaDoc {
28     super.setUp();
29     initMessageProperties();
30     // correlation sets
31
initiatedSet = new CorrelationSetDefinition();
32     initiatedSet.setName("initiated");
33     initiatedSet.addProperty(p1);
34     followedSet = new CorrelationSetDefinition();
35     followedSet.setName("followed");
36     followedSet.addProperty(p2);
37     defaultSet = new CorrelationSetDefinition();
38     defaultSet.setName("default");
39     defaultSet.addProperty(p3);
40     // property aliases
41
MessageTypeInfo messageType = (MessageTypeInfo) messageVariable.getTypeInfo();
42     Message message = messageType.getMessage();
43     PropertyAlias alias = new PropertyAliasImpl();
44     alias.setMessage(message);
45     alias.setProperty(p1);
46     messageType.addPropertyAlias(alias);
47     alias = new PropertyAliasImpl();
48     alias.setMessage(message);
49     alias.setProperty(p2);
50     messageType.addPropertyAlias(alias);
51     alias = new PropertyAliasImpl();
52     alias.setMessage(message);
53     alias.setProperty(p3);
54     messageType.addPropertyAlias(alias);
55     // declare sets in scope
56
scope.addCorrelationSet(initiatedSet);
57     scope.addCorrelationSet(followedSet);
58     scope.addCorrelationSet(defaultSet);
59   }
60   
61   public void testCorrelationsCount() throws Exception JavaDoc {
62     String JavaDoc xml =
63       "<correlations>" +
64       " <correlation set='initiated' initiate='yes'/> " +
65       " <correlation set='followed' initiate='no'/> " +
66       "</correlations>";
67     Correlations correlations = readCorrelations( xml );
68     Map JavaDoc correlationMap = correlations.getCorrelations();
69     assertEquals( 2, correlationMap.size() );
70   }
71   
72   public void testInitiated() throws Exception JavaDoc {
73     String JavaDoc xml =
74       "<correlations>" +
75       " <correlation set='initiated' initiate='yes'/> " +
76       "</correlations>";
77     Correlations correlations = readCorrelations( xml );
78     Map JavaDoc correlationMap = correlations.getCorrelations();
79     // initiated correlation
80
Correlation correlation = (Correlation) correlationMap.get("initiated");
81     assertEquals( Initiate.YES, correlation.getInitiate() );
82   }
83
84   public void testFollowed() throws Exception JavaDoc {
85     String JavaDoc xml =
86       "<correlations>" +
87       " <correlation set='followed' initiate='no'/> " +
88       "</correlations>";
89     Correlations correlations = readCorrelations( xml );
90     Map JavaDoc correlationMap = correlations.getCorrelations();
91     // followed correlation
92
Correlation correlation = (Correlation) correlationMap.get("followed");
93     assertEquals( Initiate.NO, correlation.getInitiate() );
94   }
95   
96   public void testDefault() throws Exception JavaDoc {
97     String JavaDoc xml =
98       "<correlations>" +
99       " <correlation set='default'/> " +
100       "</correlations>";
101     Correlations correlations = readCorrelations( xml );
102     Map JavaDoc correlationMap = correlations.getCorrelations();
103     // followed correlation (default)
104
Correlation correlation = (Correlation) correlationMap.get("default");
105     assertEquals( Initiate.NO, correlation.getInitiate() );
106   }
107   
108   private Correlations readCorrelations(String JavaDoc xml) throws Exception JavaDoc {
109     Element JavaDoc element = parseAsBpelElement(xml);
110     return reader.readCorrelations(element, scope, messageVariable);
111   }
112 }
113
Popular Tags