Added more tests

This commit is contained in:
Arjen Poutsma
2008-03-08 03:32:13 +00:00
parent c425dc8ba3
commit 893022a028
10 changed files with 521 additions and 0 deletions

View File

@@ -31,6 +31,8 @@ import org.springframework.util.Assert;
* @see #setBuildAbstractPart(boolean)
* @see #setBuildConcretePart(boolean)
* @since 1.0.0
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
*/
public class DynamicWsdl11Definition implements Wsdl11Definition, InitializingBean {

View File

@@ -0,0 +1,139 @@
/*
* Copyright ${YEAR} the original author or authors.
*
* 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.springframework.ws.wsdl.wsdl11;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;
import org.w3c.dom.Document;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
public class DefaultWsdl11DefinitionTest extends XMLTestCase {
private DefaultWsdl11Definition definition;
private Transformer transformer;
private DocumentBuilder documentBuilder;
protected void setUp() throws Exception {
definition = new DefaultWsdl11Definition();
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformer = transformerFactory.newTransformer();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
XMLUnit.setIgnoreWhitespace(true);
}
public void testSingle() throws Exception {
Resource resource = new ClassPathResource("single.xsd", getClass());
SimpleXsdSchema schema = new SimpleXsdSchema(resource);
schema.afterPropertiesSet();
definition.setSchema(schema);
definition.setTargetNamespace("http://www.springframework.org/spring-ws/single/definitions");
definition.setPortTypeName("Order");
definition.setLocationUri("http://localhost:8080/");
definition.afterPropertiesSet();
DOMResult domResult = new DOMResult();
transformer.transform(definition.getSource(), domResult);
Document result = (Document) domResult.getNode();
Document expected = documentBuilder.parse(getClass().getResourceAsStream("single-inline.wsdl"));
assertXMLEqual("Invalid WSDL built", expected, result);
}
public void testInclude() throws Exception {
ClassPathResource resource = new ClassPathResource("including.xsd", getClass());
CommonsXsdSchemaCollection schemaCollection = new CommonsXsdSchemaCollection(new Resource[]{resource});
schemaCollection.setInline(true);
schemaCollection.afterPropertiesSet();
definition.setSchemaCollection(schemaCollection);
definition.setPortTypeName("Order");
definition.setTargetNamespace("http://www.springframework.org/spring-ws/include/definitions");
definition.setLocationUri("http://localhost:8080/");
definition.afterPropertiesSet();
DOMResult domResult = new DOMResult();
transformer.transform(definition.getSource(), domResult);
Document result = (Document) domResult.getNode();
Document expected = documentBuilder.parse(getClass().getResourceAsStream("include-inline.wsdl"));
assertXMLEqual("Invalid WSDL built", expected, result);
}
public void testImport() throws Exception {
ClassPathResource resource = new ClassPathResource("importing.xsd", getClass());
CommonsXsdSchemaCollection schemaCollection = new CommonsXsdSchemaCollection(new Resource[]{resource});
schemaCollection.setInline(true);
schemaCollection.afterPropertiesSet();
definition.setSchemaCollection(schemaCollection);
definition.setPortTypeName("Order");
definition.setTargetNamespace("http://www.springframework.org/spring-ws/import/definitions");
definition.setLocationUri("http://localhost:8080/");
definition.afterPropertiesSet();
DOMResult domResult = new DOMResult();
transformer.transform(definition.getSource(), domResult);
Document result = (Document) domResult.getNode();
Document expected = documentBuilder.parse(getClass().getResourceAsStream("import-inline.wsdl"));
assertXMLEqual("Invalid WSDL built", expected, result);
}
public void testSoap11And12() throws Exception {
Resource resource = new ClassPathResource("single.xsd", getClass());
SimpleXsdSchema schema = new SimpleXsdSchema(resource);
schema.afterPropertiesSet();
definition.setSchema(schema);
definition.setTargetNamespace("http://www.springframework.org/spring-ws/single/definitions");
definition.setPortTypeName("Order");
definition.setLocationUri("http://localhost:8080/");
definition.setCreateSoap11Binding(true);
definition.setCreateSoap12Binding(true);
definition.afterPropertiesSet();
DOMResult domResult = new DOMResult();
transformer.transform(definition.getSource(), domResult);
Document result = (Document) domResult.getNode();
Document expected = documentBuilder.parse(getClass().getResourceAsStream("soap-11-12.wsdl"));
assertXMLEqual("Invalid WSDL built", expected, result);
}
}

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:sch0="http://www.springframework.org/spring-ws/importing/schema"
xmlns:sch1="http://www.springframework.org/spring-ws/imported/schema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.springframework.org/spring-ws/import/definitions"
targetNamespace="http://www.springframework.org/spring-ws/import/definitions">
<wsdl:types>
<xsd:schema xmlns="http://www.springframework.org/spring-ws/importing/schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.springframework.org/spring-ws/importing/schema">
<xsd:import namespace="http://www.springframework.org/spring-ws/imported/schema"/>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns="http://www.springframework.org/spring-ws/imported/schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.springframework.org/spring-ws/imported/schema">
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetOrderRequest">
<wsdl:part name="GetOrderRequest" element="sch0:GetOrderRequest"/>
</wsdl:message>
<wsdl:message name="GetOrderResponse">
<wsdl:part name="GetOrderResponse" element="sch1:GetOrderResponse"/>
</wsdl:message>
<wsdl:portType name="Order">
<wsdl:operation name="GetOrder">
<wsdl:input message="tns:GetOrderRequest" name="GetOrderRequest"/>
<wsdl:output message="tns:GetOrderResponse" name="GetOrderResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OrderSoap11" type="tns:Order">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetOrder">
<soap:operation soapAction=""/>
<wsdl:input name="GetOrderRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetOrderResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OrderService">
<wsdl:port binding="tns:OrderSoap11" name="OrderSoap11">
<soap:address location="http://localhost:8080/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/importing/schema"
xmlns="http://www.springframework.org/spring-ws/importing/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/spring-ws/imported/schema" schemaLocation="imported.xsd"/>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:sch="http://www.springframework.org/spring-ws/include/schema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.springframework.org/spring-ws/include/definitions"
targetNamespace="http://www.springframework.org/spring-ws/include/definitions">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/include/schema"
xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetOrderResponse">
<wsdl:part name="GetOrderResponse" element="sch:GetOrderResponse"/>
</wsdl:message>
<wsdl:message name="GetOrderRequest">
<wsdl:part name="GetOrderRequest" element="sch:GetOrderRequest"/>
</wsdl:message>
<wsdl:portType name="Order">
<wsdl:operation name="GetOrder">
<wsdl:input message="tns:GetOrderRequest" name="GetOrderRequest"/>
<wsdl:output message="tns:GetOrderResponse" name="GetOrderResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OrderSoap11" type="tns:Order">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetOrder">
<soap:operation soapAction=""/>
<wsdl:input name="GetOrderRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetOrderResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OrderService">
<wsdl:port binding="tns:OrderSoap11" name="OrderSoap11">
<soap:address location="http://localhost:8080/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/include/schema"
xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/include/schema"
xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:include schemaLocation="included.xsd"/>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:sch="http://www.springframework.org/spring-ws/single/schema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.springframework.org/spring-ws/single/definitions"
targetNamespace="http://www.springframework.org/spring-ws/single/definitions">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/single/schema"
xmlns="http://www.springframework.org/spring-ws/single/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:simpleType name="customType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetOrderRequest">
<wsdl:part name="GetOrderRequest" element="sch:GetOrderRequest"/>
</wsdl:message>
<wsdl:message name="GetOrderFault">
<wsdl:part name="GetOrderFault" element="sch:GetOrderFault"/>
</wsdl:message>
<wsdl:message name="GetOrderResponse">
<wsdl:part name="GetOrderResponse" element="sch:GetOrderResponse"/>
</wsdl:message>
<wsdl:portType name="Order">
<wsdl:operation name="GetOrder">
<wsdl:input message="tns:GetOrderRequest" name="GetOrderRequest"/>
<wsdl:output message="tns:GetOrderResponse" name="GetOrderResponse"/>
<wsdl:fault message="tns:GetOrderFault" name="GetOrderFault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OrderSoap11" type="tns:Order">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetOrder">
<soap:operation soapAction=""/>
<wsdl:input name="GetOrderRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetOrderResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="GetOrderFault">
<soap:fault name="GetOrderFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OrderService">
<wsdl:port binding="tns:OrderSoap11" name="OrderSoap11">
<soap:address location="http://localhost:8080/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/single/schema"
xmlns="http://www.springframework.org/spring-ws/single/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:simpleType name="customType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:sch="http://www.springframework.org/spring-ws/single/schema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://www.springframework.org/spring-ws/single/definitions"
targetNamespace="http://www.springframework.org/spring-ws/single/definitions">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/spring-ws/single/schema"
xmlns="http://www.springframework.org/spring-ws/single/schema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:simpleType name="customType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:element name="GetOrderRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetOrderFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetOrderRequest">
<wsdl:part name="GetOrderRequest" element="sch:GetOrderRequest"/>
</wsdl:message>
<wsdl:message name="GetOrderFault">
<wsdl:part name="GetOrderFault" element="sch:GetOrderFault"/>
</wsdl:message>
<wsdl:message name="GetOrderResponse">
<wsdl:part name="GetOrderResponse" element="sch:GetOrderResponse"/>
</wsdl:message>
<wsdl:portType name="Order">
<wsdl:operation name="GetOrder">
<wsdl:input message="tns:GetOrderRequest" name="GetOrderRequest"/>
<wsdl:output message="tns:GetOrderResponse" name="GetOrderResponse"/>
<wsdl:fault message="tns:GetOrderFault" name="GetOrderFault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OrderSoap12" type="tns:Order">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetOrder">
<soap12:operation soapAction=""/>
<wsdl:input name="GetOrderRequest">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetOrderResponse">
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="GetOrderFault">
<soap12:fault name="GetOrderFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="OrderSoap11" type="tns:Order">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetOrder">
<soap:operation soapAction=""/>
<wsdl:input name="GetOrderRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="GetOrderResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="GetOrderFault">
<soap:fault name="GetOrderFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OrderService">
<wsdl:port binding="tns:OrderSoap12" name="OrderSoap12">
<soap12:address location="http://localhost:8080/"/>
</wsdl:port>
<wsdl:port binding="tns:OrderSoap11" name="OrderSoap11">
<soap:address location="http://localhost:8080/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>