1 package org.jbpm.bpel.xml; 2 3 import java.util.Map ; 4 5 import javax.xml.namespace.QName ; 6 7 import org.w3c.dom.Element ; 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 18 public class ImportReaderTest extends AbstractReaderTestCase { 19 20 static final String 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 { 31 String 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 (NS_TNS, "schedulingLT"))); 39 } 40 41 public void testImportMessage() throws Exception { 42 String 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 (NS_TNS, "scheduleMessage"))); 50 } 51 52 public void testImportPropertyAlias() throws Exception { 53 String 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 (NS_TNS, "POMessage")); 61 Map propertyAliases = messageTypeInfo.getPropertyAliases(); 62 assertEquals(2, propertyAliases.size()); 63 QName propertyName = new QName (NS_TNS, "orderNumber"); 65 PropertyAlias alias = (PropertyAlias) propertyAliases.get(propertyName); 66 assertEquals(propertyName, alias.getProperty().getQName()); 67 propertyName = new QName (NS_TNS, "invoiceId"); 69 alias = (PropertyAlias) propertyAliases.get(propertyName); 70 assertEquals(propertyName, alias.getProperty().getQName()); 71 } 72 73 private void readImports(String xml) throws Exception { 74 Element bpelElem = parseAsBpelElement(xml); 75 ImportsDefinition imports = process.getImports(); 76 String 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 |