axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r179010 - in /webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl: CreateSchemaTest.java MessageReuseTest.java
Date Mon, 30 May 2005 03:45:24 GMT
Author: chathura
Date: Sun May 29 20:45:22 2005
New Revision: 179010

URL: http://svn.apache.org/viewcvs?rev=179010&view=rev
Log:
Testcases added to test the Multipart handling and resloving the operations that refer to
the same message

Added:
    webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java
    webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java

Added: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java?rev=179010&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java (added)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java Sun
May 29 20:45:22 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.wsdl;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Iterator;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+
+import org.apache.axis.wsdl.builder.WOMBuilderFactory;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.Schema;
+import org.apache.wsdl.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author chathura@opensource.lk
+ *  
+ */
+public class CreateSchemaTest extends AbstractTestCase {
+
+	private WSDLDescription womDescription;
+
+	private Definition wsdl4jDefinition;
+
+	public CreateSchemaTest(String arg) {
+		super(arg);
+	}
+
+	protected void setUp() throws Exception {
+		InputStream in = new FileInputStream(getTestResourceFile("BookQuote.wsdl"));
+		this.womDescription = WOMBuilderFactory.getBuilder(
+				WOMBuilderFactory.WSDL11).build(in);
+
+		WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+		Document doc = Utils.newDocument(new FileInputStream(getTestResourceFile(
+				"BookQuote.wsdl")));
+		this.wsdl4jDefinition = reader.readWSDL(null, doc);
+	}
+
+	public void testInsertedMultipartType() {
+		WSDLTypes types = womDescription.getTypes();
+		assertNotNull(types);
+		Iterator iterator = types.getExtensibilityElements().iterator();
+		WSDLExtensibilityElement element = null;
+		while (iterator.hasNext()) {
+			element = (WSDLExtensibilityElement) iterator.next();
+			if (ExtensionConstants.SCHEMA.equals(element.getType()))
+				break;
+		}
+		assertNotNull(element);
+		Schema schema = (Schema) element;
+		NodeList childNodes = schema.getElelment().getChildNodes();
+		Element insertedElementForMessageReference = null;
+		for (int i = 0; i < childNodes.getLength(); i++) {
+			Node item = childNodes.item(i);
+			if (item instanceof Element
+					&& "complexType".equals(((Element) item).getTagName())
+					&& "BookQuote_getBookPrice".equals(((Element) item)
+							.getAttribute("name"))) {
+				insertedElementForMessageReference = (Element) item;
+			}
+		}
+
+		assertNotNull(insertedElementForMessageReference);
+
+	}
+
+}
\ No newline at end of file

Added: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java?rev=179010&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java (added)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java Sun
May 29 20:45:22 2005
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.wsdl;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Iterator;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.axis.wsdl.builder.WOMBuilderFactory;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.Schema;
+import org.apache.wsdl.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author chathura@opensource.lk
+ *  
+ */
+public class MessageReuseTest extends AbstractTestCase {
+
+	private WSDLDescription womDescription;
+
+	private Definition wsdl4jDefinition;
+
+	public MessageReuseTest(String arg) {
+		super(arg);
+	}
+
+	protected void setUp() throws Exception {
+
+		InputStream in = new FileInputStream(getTestResourceFile("BookQuote.wsdl"));
+		this.womDescription = WOMBuilderFactory.getBuilder(
+				WOMBuilderFactory.WSDL11).build(in);
+
+		WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+		Document doc = Utils.newDocument(new FileInputStream(getTestResourceFile(
+				"BookQuote.wsdl")));
+		this.wsdl4jDefinition = reader.readWSDL(null, doc);
+
+	}
+
+	public void testMultipartmessageReuse() throws Exception {
+
+		WSDLInterface interface1 = this.womDescription.getInterface(
+				new QName("http://www.Monson-Haefel.com/jwsbook/BookQuote",
+						"BookQuote"));
+		WSDLOperation operation1 = (WSDLOperation) interface1.getAllOperations()
+				.get("getBookPrice");
+		QName element1 = operation1.getInputMessage().getElement();
+		WSDLOperation operation2 = (WSDLOperation)interface1.getAllOperations().get("getBookPriceNonRobust");
+		QName element2 = operation2.getInputMessage().getElement();
+		assertEquals(element1, element2);
+		
+		Iterator iterator = womDescription.getTypes().getExtensibilityElements().iterator();
+		Schema types= null;
+		while(iterator.hasNext()){
+			WSDLExtensibilityElement temp = (WSDLExtensibilityElement)iterator.next();
+			if(ExtensionConstants.SCHEMA.equals(temp.getType())){
+				types = (Schema)temp;
+			}
+		}
+		int numberOfBookQuote_getBookPrice = 0;
+		NodeList childNodes = types.getElelment().getChildNodes();
+		for(int i=0; i< childNodes.getLength(); i++){
+			Node item = childNodes.item(i);
+			if(item instanceof Element){
+				Element temp = (Element)item;
+				if("complexType".equals(temp.getNodeName()) && 
+						"BookQuote_getBookPrice".equals(temp.getAttribute("name"))){
+					numberOfBookQuote_getBookPrice++;
+				}
+				
+			}
+		}
+		assertEquals(numberOfBookQuote_getBookPrice, 1);
+		
+
+	}
+}
\ No newline at end of file



Mime
View raw message