1 package org.jbpm.bpel.xml; 2 3 import java.util.Map ; 4 5 import javax.wsdl.Message; 6 7 import org.w3c.dom.Element ; 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 21 public class CorrelationsReaderTest extends AbstractReaderTestCase { 22 23 CorrelationSetDefinition initiatedSet; 24 CorrelationSetDefinition followedSet; 25 CorrelationSetDefinition defaultSet; 26 27 public void setUp() throws Exception { 28 super.setUp(); 29 initMessageProperties(); 30 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 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 scope.addCorrelationSet(initiatedSet); 57 scope.addCorrelationSet(followedSet); 58 scope.addCorrelationSet(defaultSet); 59 } 60 61 public void testCorrelationsCount() throws Exception { 62 String xml = 63 "<correlations>" + 64 " <correlation set='initiated' initiate='yes'/> " + 65 " <correlation set='followed' initiate='no'/> " + 66 "</correlations>"; 67 Correlations correlations = readCorrelations( xml ); 68 Map correlationMap = correlations.getCorrelations(); 69 assertEquals( 2, correlationMap.size() ); 70 } 71 72 public void testInitiated() throws Exception { 73 String xml = 74 "<correlations>" + 75 " <correlation set='initiated' initiate='yes'/> " + 76 "</correlations>"; 77 Correlations correlations = readCorrelations( xml ); 78 Map correlationMap = correlations.getCorrelations(); 79 Correlation correlation = (Correlation) correlationMap.get("initiated"); 81 assertEquals( Initiate.YES, correlation.getInitiate() ); 82 } 83 84 public void testFollowed() throws Exception { 85 String xml = 86 "<correlations>" + 87 " <correlation set='followed' initiate='no'/> " + 88 "</correlations>"; 89 Correlations correlations = readCorrelations( xml ); 90 Map correlationMap = correlations.getCorrelations(); 91 Correlation correlation = (Correlation) correlationMap.get("followed"); 93 assertEquals( Initiate.NO, correlation.getInitiate() ); 94 } 95 96 public void testDefault() throws Exception { 97 String xml = 98 "<correlations>" + 99 " <correlation set='default'/> " + 100 "</correlations>"; 101 Correlations correlations = readCorrelations( xml ); 102 Map correlationMap = correlations.getCorrelations(); 103 Correlation correlation = (Correlation) correlationMap.get("default"); 105 assertEquals( Initiate.NO, correlation.getInitiate() ); 106 } 107 108 private Correlations readCorrelations(String xml) throws Exception { 109 Element element = parseAsBpelElement(xml); 110 return reader.readCorrelations(element, scope, messageVariable); 111 } 112 } 113 | Popular Tags |