1 16 17 package org.apache.wsdl; 18 19 import org.apache.axis2.wsdl.WSDLVersionWrapper; 20 import org.apache.axis2.wsdl.builder.WOMBuilderFactory; 21 import org.apache.wsdl.extensions.ExtensionConstants; 22 import org.apache.wsdl.extensions.Schema; 23 import org.w3c.dom.Element ; 24 import org.w3c.dom.Node ; 25 import org.w3c.dom.NodeList ; 26 27 import javax.wsdl.Definition; 28 import java.io.FileInputStream ; 29 import java.io.InputStream ; 30 import java.util.Iterator ; 31 32 36 public class CreateSchemaTest extends AbstractTestCase { 37 38 private WSDLDescription womDescription; 39 40 private Definition wsdl4jDefinition; 41 42 public CreateSchemaTest(String arg) { 43 super(arg); 44 } 45 46 protected void setUp() throws Exception { 47 WSDLVersionWrapper wsdlVersionWrapper = null; 48 if (null == this.womDescription) { 49 InputStream in = new FileInputStream (getTestResourceFile("BookQuote.wsdl")); 50 wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in); 51 this.womDescription = wsdlVersionWrapper.getDescription(); 52 } 53 if (null == wsdl4jDefinition) { 54 this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition(); 55 } 56 } 57 58 public void testInsertedMultipartType() { 59 WSDLTypes types = womDescription.getTypes(); 60 assertNotNull(types); 61 Iterator iterator = types.getExtensibilityElements().iterator(); 62 WSDLExtensibilityElement element = null; 63 while (iterator.hasNext()) { 64 element = (WSDLExtensibilityElement) iterator.next(); 65 if (ExtensionConstants.SCHEMA.equals(element.getType())) 66 break; 67 } 68 assertNotNull(element); 69 Schema schema = (Schema) element; 70 NodeList childNodes = schema.getElelment().getChildNodes(); 71 Element insertedElementForMessageReference = null; 72 for (int i = 0; i < childNodes.getLength(); i++) { 73 Node item = childNodes.item(i); 74 if (item instanceof Element 75 && "complexType".equals(((Element ) item).getTagName()) 76 && "BookQuote_getBookPrice".equals(((Element ) item) 77 .getAttribute("name"))) { 78 insertedElementForMessageReference = (Element ) item; 79 } 80 } 81 82 assertNotNull(insertedElementForMessageReference); 83 84 } 85 86 } | Popular Tags |