KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.bpel.xml;
2
3 import java.util.Map JavaDoc;
4
5 import javax.xml.namespace.QName JavaDoc;
6
7 import org.w3c.dom.Element JavaDoc;
8
9 import org.jbpm.bpel.data.def.MessageTypeInfo;
10 import org.jbpm.bpel.def.BpelDefinition;
11 import org.jbpm.bpel.def.ImportsDefinition;
12 import org.jbpm.bpel.wsdl.def.PropertyAlias;
13
14 /**
15  * @author Juan Cantu
16  * @version $Revision: 1.9 $ $Date: 2005/06/23 20:45:04 $
17  */

18 public class ImportReaderTest extends AbstractReaderTestCase {
19
20   static final String JavaDoc NS_TNS = "http://manufacturing.org/wsdl/purchase";
21   
22   BpelDefinition process;
23   BpelReader reader;
24   
25   public void setUp() {
26     reader = new BpelReader();
27     process = new BpelDefinition("process");
28   }
29   
30   public void testImportPartnerLinkType() throws Exception JavaDoc {
31     String JavaDoc xml =
32       "<process>" +
33       " <import namespace='http://manufacturing.org/wsdl/purchase' location='partnerLinkTypeSample.wsdl'" +
34       " importType='http://schemas.xmlsoap.org/wsdl/'/>" +
35       " <receive partnerLink='aPartner' operation='o'/>" +
36       "</process>";
37     readImports( xml );
38     assertNotNull(process.getImports().getPartnerLinkType(new QName JavaDoc(NS_TNS, "schedulingLT")));
39   }
40   
41   public void testImportMessage() throws Exception JavaDoc {
42     String JavaDoc xml =
43       "<process>" +
44       " <import namespace='http://manufacturing.org/wsdl/purchase' location='partnerLinkTypeSample.wsdl'" +
45       " importType='http://schemas.xmlsoap.org/wsdl/'/>" +
46       " <receive partnerLink='aPartner' operation='o'/>" +
47       "</process>";
48     readImports( xml );
49     assertNotNull(process.getImports().getMessage(new QName JavaDoc(NS_TNS, "scheduleMessage")));
50   }
51   
52   public void testImportPropertyAlias() throws Exception JavaDoc {
53     String JavaDoc xml =
54       "<process>" +
55       " <import namespace='http://manufacturing.org/wsdl/purchase' location='propertyAliasSample.wsdl'" +
56       " importType='http://schemas.xmlsoap.org/wsdl/'/>" +
57       " <receive partnerLink='aPartner' operation='o'/>" +
58       "</process>";
59     readImports( xml );
60     MessageTypeInfo messageTypeInfo = process.getImports().getMessageTypeInfo(new QName JavaDoc(NS_TNS, "POMessage"));
61     Map JavaDoc propertyAliases = messageTypeInfo.getPropertyAliases();
62     assertEquals(2, propertyAliases.size());
63     // alias for orderNumber property
64
QName JavaDoc propertyName = new QName JavaDoc(NS_TNS, "orderNumber");
65     PropertyAlias alias = (PropertyAlias) propertyAliases.get(propertyName);
66     assertEquals(propertyName, alias.getProperty().getQName());
67     // alias for invoiceId property
68
propertyName = new QName JavaDoc(NS_TNS, "invoiceId");
69     alias = (PropertyAlias) propertyAliases.get(propertyName);
70     assertEquals(propertyName, alias.getProperty().getQName());
71   }
72   
73   private void readImports(String JavaDoc xml) throws Exception JavaDoc {
74     Element JavaDoc bpelElem = parseAsBpelElement(xml);
75     ImportsDefinition imports = process.getImports();
76     String JavaDoc classURI = ImportReaderTest.class.getResource(".").toString();
77     ImportWsdlLocator locator = new ImportWsdlLocator(classURI);
78     reader.readImports(bpelElem, imports, locator);
79     BpelReader.getInstance().registerPropertyAliases(imports);
80   }
81 }
82
Popular Tags