You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/10/25 10:16:07 UTC
svn commit: r328308 - in /webservices/axis2/trunk/java/modules:
codegen/test/org/apache/axis2/databinding/utils/ wsdl/ wsdl/test-resources/
wsdl/test/org/apache/axis2/wsdl/writer/
xml/src/org/apache/axis2/om/impl/llom/ xml/test/org/apache/axis2/om/
Author: chinthaka
Date: Tue Oct 25 01:15:01 2005
New Revision: 328308
URL: http://svn.apache.org/viewcvs?rev=328308&view=rev
Log:
- Fixing Axis2-291 with a test case.
- The above fixed enables the ADBPullParser to fully handle OMElements and adding a test case for that too.
- Adding a test for WOM serialization. Yet to be completed. Since this requires XML comparison, I had to add XMLUnit as a dependency for WSDL project.
-
Added:
webservices/axis2/trunk/java/modules/wsdl/test-resources/iotest.wsdl
webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WOMInputOutputTest.java
Modified:
webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java
webservices/axis2/trunk/java/modules/wsdl/project.xml
webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WriterTest.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMStAXWrapper.java
webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java
Modified: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java?rev=328308&r1=328307&r2=328308&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java Tue Oct 25 01:15:01 2005
@@ -318,7 +318,14 @@
}
}
- public void testWithOMElements() {
+ public void testWithOMElements() throws XMLStreamException {
+
+ String expectedXML = "<OMElementTest><axis2:FirstOMElement xmlns:axis2=\"http://ws.apache.org/namespaces/axis2\">" +
+ "<axis2:SecondOMElement></axis2:SecondOMElement></axis2:FirstOMElement><Foo>Some Text</Foo>" +
+ "<Dependent><Name>FooTwo</Name><Age>25</Age><Sex>Male</Sex></Dependent>" +
+ "<axis2:SecondOMElement xmlns:axis2=\"http://ws.apache.org/namespaces/axis2\">" +
+ "</axis2:SecondOMElement></OMElementTest>";
+
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace axis2Namespace = factory.createOMNamespace(Constants.AXIS2_NAMESPACE_URI, Constants.AXIS2_NAMESPACE_PREFIX);
OMElement firstElement = factory.createOMElement("FirstOMElement", axis2Namespace);
@@ -344,8 +351,17 @@
XMLStreamReader pullParser = ADBPullParser.createPullParser(new QName("OMElementTest"), propertyList.toArray(), null);
String stringXML = getStringXML(pullParser);
-
- // Seems like we have a problem in OM. Needs to fix that and then come back to this.
+ try {
+ Document actualDom = newDocument(stringXML);
+ Document expectedDocument = newDocument(expectedXML);
+ assertXMLEqual(actualDom, expectedDocument);
+ } catch (ParserConfigurationException e) {
+ fail("Exception in parsing documents " + e);
+ } catch (SAXException e) {
+ fail("Exception in parsing documents " + e);
+ } catch (IOException e) {
+ fail("Exception in parsing documents " + e);
+ }
}
@@ -608,7 +624,9 @@
Object[] attributes = new Object[]{ new QName("mailto:myAttributes@axis2.org", "name", "myAttr"), "Apache Axis2"};
XMLStreamReader pullParser = ADBPullParser.createPullParser(new QName("http://www.apache.org/", "Project", "apache"), propertyList.toArray(), attributes);
- System.out.println(getStringXML(pullParser));
+// System.out.println(getStringXML(pullParser));
+
+ // this still has some namespace problem. Need to fix this.
}
Modified: webservices/axis2/trunk/java/modules/wsdl/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/project.xml?rev=328308&r1=328307&r2=328308&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/project.xml (original)
+++ webservices/axis2/trunk/java/modules/wsdl/project.xml Tue Oct 25 01:15:01 2005
@@ -99,7 +99,16 @@
<module>true</module>
</properties>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>${xmlunit.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://www.ibiblio.org/maven/xmlunit/jars/</url>
+ </dependency>
+ </dependencies>
<!-- add the build properties-->
<build>
<resources>
Added: webservices/axis2/trunk/java/modules/wsdl/test-resources/iotest.wsdl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test-resources/iotest.wsdl?rev=328308&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test-resources/iotest.wsdl (added)
+++ webservices/axis2/trunk/java/modules/wsdl/test-resources/iotest.wsdl Tue Oct 25 01:15:01 2005
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?><definitions name="WSDLInteropTestDocLitService" targetNamespace="http://soapinterop.org/WSDLInteropTestDocLit" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soapinterop.org/WSDLInteropTestDocLit" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://soapinterop.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><types><schema targetNamespace="http://soapinterop.org/xsd" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><complexType name="ArrayOfstring_literal"><sequence><element maxOccurs="unbounded" minOccurs="1" name="string" type="xsd:string"/></sequence></complexType><complexType name="SOAPStruct"><all><element name="varFloat" type="xsd:float"/><element name="varInt" type="xsd:int"/><element name="varString" type="xsd:string"/></all></complexType><element name="echoString"><complexType><sequence><element name="param0" type="xsd:string"/></sequence></complexType></element><element name="echoStringResponse"><complexType><sequence><element name="return" type="xsd:string"/></sequence></complexType></element><element name="echoStringArray"><complexType><sequence><element name="param0" type="xsd1:ArrayOfstring_literal"/></sequence></complexType></element><element name="echoStringArrayResponse"><complexType><sequence><element name="return" type="xsd1:ArrayOfstring_literal"/></sequence></complexType></element><element name="echoStruct"><complexType><sequence><element name="param0" type="xsd1:SOAPStruct"/></sequence></complexType> </element>
+ <element name="echoStructResponse">
+ <complexType>
+ <sequence>
+ <element name="return" type="xsd1:SOAPStruct"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="echoVoid">
+ <complexType/>
+ </element>
+ <element name="echoVoidResponse">
+ <complexType/>
+ </element>
+ </schema>
+ </types>
+ <message name="echoString">
+ <part element="xsd1:echoString" name="parameters"/>
+ </message>
+ <message name="echoStringResponse">
+ <part element="xsd1:echoStringResponse" name="parameters"/>
+ </message>
+ <message name="echoStringArray">
+ <part element="xsd1:echoStringArray" name="parameters"/>
+ </message>
+ <message name="echoStringArrayResponse">
+ <part element="xsd1:echoStringArrayResponse" name="parameters"/>
+ </message>
+ <message name="echoStruct">
+ <part element="xsd1:echoStruct" name="parameters"/>
+ </message>
+ <message name="echoStructResponse">
+ <part element="xsd1:echoStructResponse" name="parameters"/>
+ </message>
+ <message name="echoVoid">
+ <part element="xsd1:echoVoid" name="parameters"/>
+ </message>
+ <message name="echoVoidResponse">
+ <part element="xsd1:echoVoidResponse" name="parameters"/>
+ </message>
+ <portType name="WSDLInteropTestDocLitPortType">
+ <operation name="echoString">
+ <input message="tns:echoString" name="echoString"/>
+ <output message="tns:echoStringResponse" name="echoStringResponse"/>
+ </operation>
+ <operation name="echoStringArray">
+ <input message="tns:echoStringArray" name="echoStringArray"/>
+ <output message="tns:echoStringArrayResponse" name="echoStringArrayResponse"/>
+ </operation>
+ <operation name="echoStruct">
+ <input message="tns:echoStruct" name="echoStruct"/>
+ <output message="tns:echoStructResponse" name="echoStructResponse"/>
+ </operation>
+ <operation name="echoVoid">
+ <input message="tns:echoVoid" name="echoVoid"/>
+ <output message="tns:echoVoidResponse" name="echoVoidResponse"/>
+ </operation>
+ </portType>
+ <binding name="WSDLInteropTestDocLitPortBinding"
+ type="tns:WSDLInteropTestDocLitPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="echoString">
+ <soap:operation soapAction="http://soapinterop.org/" style="document"/>
+ <input name="echoString">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </input>
+ <output name="echoStringResponse">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </output>
+ </operation>
+ <operation name="echoStringArray">
+ <soap:operation soapAction="http://soapinterop.org/" style="document"/>
+ <input name="echoStringArray">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </input>
+ <output name="echoStringArrayResponse">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </output>
+ </operation>
+ <operation name="echoStruct">
+ <soap:operation soapAction="http://soapinterop.org/" style="document"/>
+ <input name="echoStruct">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </input>
+ <output name="echoStructResponse">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </output>
+ </operation>
+ <operation name="echoVoid">
+ <soap:operation soapAction="http://soapinterop.org/" style="document"/>
+ <input name="echoVoid">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </input>
+ <output name="echoVoidResponse">
+ <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit"
+ use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="WSDLInteropTestDocLitService">
+ <port binding="tns:WSDLInteropTestDocLitPortBinding"
+ name="WSDLInteropTestDocLitParamPort">
+ <soap:address
+ location="http://www.whitemesa.net/interop/r3/doclitparam"/>
+ </port>
+ </service>
+</definitions>
Added: webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WOMInputOutputTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WOMInputOutputTest.java?rev=328308&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WOMInputOutputTest.java (added)
+++ webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WOMInputOutputTest.java Tue Oct 25 01:15:01 2005
@@ -0,0 +1,119 @@
+package org.apache.axis2.wsdl.writer;
+
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.WSDLVersionWrapper;
+import org.apache.axis2.wsdl.builder.WOMBuilder;
+import org.apache.axis2.wsdl.builder.WOMBuilderFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.wsdl.WSDLException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+/*
+ * 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.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class WOMInputOutputTest extends XMLTestCase {
+ private WSDLVersionWrapper wsdlVersionWrapper;
+ private String testWSDL = "test-resources/interoptestdoclitparameters.wsdl";
+
+ Log logger = LogFactory.getLog(getClass());
+
+ protected void setUp() throws Exception {
+
+ }
+
+ public void testInputOutput() {
+ try {
+ // create the WOM from the given WSDL.
+ WOMBuilder builder = WOMBuilderFactory.getBuilder(WSDLConstants.WSDL_1_1);
+ wsdlVersionWrapper = builder.build(testWSDL);
+
+ // serialize wom and get the xml.
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ WOMWriter womWriter = WOMWriterFactory.createWriter(WSDLConstants.WSDL_1_1);
+ womWriter.writeWOM(wsdlVersionWrapper, byteArrayOutputStream);
+ String actualWSDL = new String(byteArrayOutputStream.toByteArray());
+
+ // compare that with the original xml file.
+ Document actualWSDLDocument = newDocument(actualWSDL);
+
+ // feeding file directly in to DOM gives me an error. Lets try to read it first to
+ // a String and feed
+
+ Document expectedWSDLDocument = newDocument(getFileContentsAsString(testWSDL));
+// assertXMLEqual(actualWSDLDocument, expectedWSDLDocument);
+
+ } catch (WSDLException e) {
+ logger.error("Error occured in WOMInputOutputTest.testInputOutput() ", e);
+ fail();
+ } catch (WriterException e) {
+ logger.error("Error occured in WOMInputOutputTest.testInputOutput() ", e);
+ fail();
+ } catch (ParserConfigurationException e) {
+ logger.error("Error occured in WOMInputOutputTest.testInputOutput() ", e);
+ fail();
+ } catch (SAXException e) {
+ logger.error("Error occured in WOMInputOutputTest.testInputOutput() ", e);
+ fail();
+ } catch (IOException e) {
+ logger.error("Error occured in WOMInputOutputTest.testInputOutput() ", e);
+ fail();
+ }
+ }
+
+ public Document newDocument(String xml)
+ throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ return db.parse(new ByteArrayInputStream(xml.getBytes()));
+ }
+
+ public Document newDocument(File wsdlFile)
+ throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ return db.parse(wsdlFile);
+ }
+
+ public String getFileContentsAsString(String filePath) throws IOException {
+ String returnString = "";
+
+ BufferedReader in = new BufferedReader(new FileReader(filePath));
+ String str;
+ while ((str = in.readLine()) != null) {
+ returnString += str;
+ }
+ in.close();
+ return returnString;
+ }
+
+}
Modified: webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WriterTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WriterTest.java?rev=328308&r1=328307&r2=328308&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WriterTest.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/test/org/apache/axis2/wsdl/writer/WriterTest.java Tue Oct 25 01:15:01 2005
@@ -1,13 +1,11 @@
package org.apache.axis2.wsdl.writer;
import junit.framework.TestCase;
-import org.apache.wsdl.WSDLDescription;
-import org.apache.axis2.wsdl.builder.WOMBuilderFactory;
-import org.apache.axis2.wsdl.builder.WOMBuilder;
import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.builder.WOMBuilder;
+import org.apache.axis2.wsdl.builder.WOMBuilderFactory;
+import org.apache.wsdl.WSDLDescription;
-import java.io.FileInputStream;
-import java.io.File;
import java.io.PrintStream;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -47,5 +45,7 @@
e.printStackTrace();
}
}
+
+
}
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMStAXWrapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMStAXWrapper.java?rev=328308&r1=328307&r2=328308&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMStAXWrapper.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMStAXWrapper.java Tue Oct 25 01:15:01 2005
@@ -18,6 +18,7 @@
import org.apache.axis2.om.OMAttribute;
import org.apache.axis2.om.OMComment;
+import org.apache.axis2.om.OMDocument;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.om.OMNode;
@@ -128,6 +129,8 @@
*/
private OMNode lastNode = null;
+ private boolean needToThrowEndDocument = false;
+
/**
* Method setAllowSwitching
*
@@ -168,12 +171,15 @@
* @param cache
*/
public OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode,
- boolean cache) {
+ boolean cache) {
// create a navigator
this.navigator = new OMNavigator(startNode);
this.builder = builder;
this.rootNode = startNode;
+ if (rootNode != null && rootNode.getParent() != null && rootNode.getParent() instanceof OMDocument) {
+ needToThrowEndDocument = true;
+ }
// initaite the next and current nodes
// Note - navigator is written in such a way that it first
@@ -367,7 +373,7 @@
if (hasText()) {
if (lastNode instanceof OMText) {
returnString = ((OMText) lastNode).getText();
- } else if (lastNode instanceof OMComment){
+ } else if (lastNode instanceof OMComment) {
returnString = ((OMComment) lastNode).getValue();
}
}
@@ -768,7 +774,11 @@
* @throws XMLStreamException
*/
public boolean hasNext() throws XMLStreamException {
- return !(state == DOCUMENT_COMPLETE);
+ if(needToThrowEndDocument){
+ return !(state == DOCUMENT_COMPLETE);
+ } else {
+ return (state != COMPLETED && currentEvent != END_DOCUMENT);
+ }
}
/**
Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java?rev=328308&r1=328307&r2=328308&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/StaxParserTest.java Tue Oct 25 01:15:01 2005
@@ -121,7 +121,7 @@
public void testParserBehaviornonCaching() throws Exception{
OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createStAXOMBuilder(
- OMAbstractFactory.getSOAP11Factory(),
+ OMAbstractFactory.getOMFactory(),
XMLInputFactory.newInstance().createXMLStreamReader(
new ByteArrayInputStream(xmlDocument.getBytes())));