Skip to content

Commit 893022a

Browse files
committed
Added more tests
1 parent c425dc8 commit 893022a

File tree

10 files changed

+521
-0
lines changed

10 files changed

+521
-0
lines changed

core/src/main/java/org/springframework/ws/wsdl/wsdl11/DynamicWsdl11Definition.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* @see #setBuildAbstractPart(boolean)
3232
* @see #setBuildConcretePart(boolean)
3333
* @since 1.0.0
34+
* @deprecated as of Spring Web Services 1.5: superseded by {@link org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition}
35+
* and the {@link org.springframework.ws.wsdl.wsdl11.provider} package
3436
*/
3537
public class DynamicWsdl11Definition implements Wsdl11Definition, InitializingBean {
3638

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* Copyright ${YEAR} the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ws.wsdl.wsdl11;
18+
19+
import javax.xml.parsers.DocumentBuilder;
20+
import javax.xml.parsers.DocumentBuilderFactory;
21+
import javax.xml.transform.Transformer;
22+
import javax.xml.transform.TransformerFactory;
23+
import javax.xml.transform.dom.DOMResult;
24+
25+
import org.custommonkey.xmlunit.XMLTestCase;
26+
import org.custommonkey.xmlunit.XMLUnit;
27+
import org.w3c.dom.Document;
28+
29+
import org.springframework.core.io.ClassPathResource;
30+
import org.springframework.core.io.Resource;
31+
import org.springframework.xml.xsd.SimpleXsdSchema;
32+
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
33+
34+
public class DefaultWsdl11DefinitionTest extends XMLTestCase {
35+
36+
private DefaultWsdl11Definition definition;
37+
38+
private Transformer transformer;
39+
40+
private DocumentBuilder documentBuilder;
41+
42+
protected void setUp() throws Exception {
43+
definition = new DefaultWsdl11Definition();
44+
TransformerFactory transformerFactory = TransformerFactory.newInstance();
45+
transformer = transformerFactory.newTransformer();
46+
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
47+
documentBuilderFactory.setNamespaceAware(true);
48+
documentBuilder = documentBuilderFactory.newDocumentBuilder();
49+
XMLUnit.setIgnoreWhitespace(true);
50+
}
51+
52+
public void testSingle() throws Exception {
53+
Resource resource = new ClassPathResource("single.xsd", getClass());
54+
SimpleXsdSchema schema = new SimpleXsdSchema(resource);
55+
schema.afterPropertiesSet();
56+
definition.setSchema(schema);
57+
58+
definition.setTargetNamespace("http://www.springframework.org/spring-ws/single/definitions");
59+
definition.setPortTypeName("Order");
60+
definition.setLocationUri("http://localhost:8080/");
61+
62+
definition.afterPropertiesSet();
63+
64+
DOMResult domResult = new DOMResult();
65+
transformer.transform(definition.getSource(), domResult);
66+
67+
Document result = (Document) domResult.getNode();
68+
Document expected = documentBuilder.parse(getClass().getResourceAsStream("single-inline.wsdl"));
69+
70+
assertXMLEqual("Invalid WSDL built", expected, result);
71+
72+
}
73+
74+
public void testInclude() throws Exception {
75+
ClassPathResource resource = new ClassPathResource("including.xsd", getClass());
76+
CommonsXsdSchemaCollection schemaCollection = new CommonsXsdSchemaCollection(new Resource[]{resource});
77+
schemaCollection.setInline(true);
78+
schemaCollection.afterPropertiesSet();
79+
definition.setSchemaCollection(schemaCollection);
80+
81+
definition.setPortTypeName("Order");
82+
definition.setTargetNamespace("http://www.springframework.org/spring-ws/include/definitions");
83+
definition.setLocationUri("http://localhost:8080/");
84+
definition.afterPropertiesSet();
85+
86+
DOMResult domResult = new DOMResult();
87+
transformer.transform(definition.getSource(), domResult);
88+
89+
Document result = (Document) domResult.getNode();
90+
Document expected = documentBuilder.parse(getClass().getResourceAsStream("include-inline.wsdl"));
91+
assertXMLEqual("Invalid WSDL built", expected, result);
92+
}
93+
94+
public void testImport() throws Exception {
95+
ClassPathResource resource = new ClassPathResource("importing.xsd", getClass());
96+
CommonsXsdSchemaCollection schemaCollection = new CommonsXsdSchemaCollection(new Resource[]{resource});
97+
schemaCollection.setInline(true);
98+
schemaCollection.afterPropertiesSet();
99+
definition.setSchemaCollection(schemaCollection);
100+
101+
definition.setPortTypeName("Order");
102+
definition.setTargetNamespace("http://www.springframework.org/spring-ws/import/definitions");
103+
definition.setLocationUri("http://localhost:8080/");
104+
definition.afterPropertiesSet();
105+
106+
DOMResult domResult = new DOMResult();
107+
transformer.transform(definition.getSource(), domResult);
108+
109+
Document result = (Document) domResult.getNode();
110+
Document expected = documentBuilder.parse(getClass().getResourceAsStream("import-inline.wsdl"));
111+
assertXMLEqual("Invalid WSDL built", expected, result);
112+
}
113+
114+
public void testSoap11And12() throws Exception {
115+
Resource resource = new ClassPathResource("single.xsd", getClass());
116+
SimpleXsdSchema schema = new SimpleXsdSchema(resource);
117+
schema.afterPropertiesSet();
118+
definition.setSchema(schema);
119+
120+
definition.setTargetNamespace("http://www.springframework.org/spring-ws/single/definitions");
121+
definition.setPortTypeName("Order");
122+
definition.setLocationUri("http://localhost:8080/");
123+
definition.setCreateSoap11Binding(true);
124+
definition.setCreateSoap12Binding(true);
125+
126+
definition.afterPropertiesSet();
127+
128+
DOMResult domResult = new DOMResult();
129+
transformer.transform(definition.getSource(), domResult);
130+
131+
Document result = (Document) domResult.getNode();
132+
Document expected = documentBuilder.parse(getClass().getResourceAsStream("soap-11-12.wsdl"));
133+
134+
assertXMLEqual("Invalid WSDL built", expected, result);
135+
136+
}
137+
138+
139+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
3+
xmlns:sch0="http://www.springframework.org/spring-ws/importing/schema"
4+
xmlns:sch1="http://www.springframework.org/spring-ws/imported/schema"
5+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
6+
xmlns:tns="http://www.springframework.org/spring-ws/import/definitions"
7+
targetNamespace="http://www.springframework.org/spring-ws/import/definitions">
8+
9+
<wsdl:types>
10+
<xsd:schema xmlns="http://www.springframework.org/spring-ws/importing/schema"
11+
xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
12+
elementFormDefault="qualified"
13+
targetNamespace="http://www.springframework.org/spring-ws/importing/schema">
14+
<xsd:import namespace="http://www.springframework.org/spring-ws/imported/schema"/>
15+
<xsd:element name="GetOrderRequest">
16+
<xsd:complexType>
17+
<xsd:sequence>
18+
<xsd:element name="child" type="xsd:string"/>
19+
</xsd:sequence>
20+
</xsd:complexType>
21+
</xsd:element>
22+
</xsd:schema>
23+
<xsd:schema xmlns="http://www.springframework.org/spring-ws/imported/schema"
24+
xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
25+
elementFormDefault="qualified"
26+
targetNamespace="http://www.springframework.org/spring-ws/imported/schema">
27+
<xsd:element name="GetOrderResponse">
28+
<xsd:complexType>
29+
<xsd:sequence>
30+
<xsd:element name="child" type="xsd:string"/>
31+
</xsd:sequence>
32+
</xsd:complexType>
33+
</xsd:element>
34+
</xsd:schema>
35+
</wsdl:types>
36+
<wsdl:message name="GetOrderRequest">
37+
<wsdl:part name="GetOrderRequest" element="sch0:GetOrderRequest"/>
38+
</wsdl:message>
39+
<wsdl:message name="GetOrderResponse">
40+
<wsdl:part name="GetOrderResponse" element="sch1:GetOrderResponse"/>
41+
</wsdl:message>
42+
<wsdl:portType name="Order">
43+
<wsdl:operation name="GetOrder">
44+
<wsdl:input message="tns:GetOrderRequest" name="GetOrderRequest"/>
45+
<wsdl:output message="tns:GetOrderResponse" name="GetOrderResponse"/>
46+
</wsdl:operation>
47+
</wsdl:portType>
48+
<wsdl:binding name="OrderSoap11" type="tns:Order">
49+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
50+
<wsdl:operation name="GetOrder">
51+
<soap:operation soapAction=""/>
52+
<wsdl:input name="GetOrderRequest">
53+
<soap:body use="literal"/>
54+
</wsdl:input>
55+
<wsdl:output name="GetOrderResponse">
56+
<soap:body use="literal"/>
57+
</wsdl:output>
58+
</wsdl:operation>
59+
</wsdl:binding>
60+
<wsdl:service name="OrderService">
61+
<wsdl:port binding="tns:OrderSoap11" name="OrderSoap11">
62+
<soap:address location="http://localhost:8080/"/>
63+
</wsdl:port>
64+
</wsdl:service>
65+
</wsdl:definitions>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
targetNamespace="http://www.springframework.org/spring-ws/importing/schema"
4+
xmlns="http://www.springframework.org/spring-ws/importing/schema" elementFormDefault="qualified"
5+
attributeFormDefault="unqualified">
6+
7+
<xsd:import namespace="http://www.springframework.org/spring-ws/imported/schema" schemaLocation="imported.xsd"/>
8+
9+
<xsd:element name="GetOrderRequest">
10+
<xsd:complexType>
11+
<xsd:sequence>
12+
<xsd:element name="child" type="xsd:string"/>
13+
</xsd:sequence>
14+
</xsd:complexType>
15+
</xsd:element>
16+
17+
</xsd:schema>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
3+
xmlns:sch="http://www.springframework.org/spring-ws/include/schema"
4+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
5+
xmlns:tns="http://www.springframework.org/spring-ws/include/definitions"
6+
targetNamespace="http://www.springframework.org/spring-ws/include/definitions">
7+
8+
<wsdl:types>
9+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
10+
targetNamespace="http://www.springframework.org/spring-ws/include/schema"
11+
xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified"
12+
attributeFormDefault="unqualified">
13+
14+
<xsd:element name="GetOrderRequest">
15+
<xsd:complexType>
16+
<xsd:sequence>
17+
<xsd:element name="child" type="xsd:string"/>
18+
</xsd:sequence>
19+
</xsd:complexType>
20+
</xsd:element>
21+
22+
<xsd:element name="GetOrderResponse">
23+
<xsd:complexType>
24+
<xsd:sequence>
25+
<xsd:element name="child" type="xsd:string"/>
26+
</xsd:sequence>
27+
</xsd:complexType>
28+
</xsd:element>
29+
30+
</xsd:schema>
31+
</wsdl:types>
32+
<wsdl:message name="GetOrderResponse">
33+
<wsdl:part name="GetOrderResponse" element="sch:GetOrderResponse"/>
34+
</wsdl:message>
35+
<wsdl:message name="GetOrderRequest">
36+
<wsdl:part name="GetOrderRequest" element="sch:GetOrderRequest"/>
37+
</wsdl:message>
38+
<wsdl:portType name="Order">
39+
<wsdl:operation name="GetOrder">
40+
<wsdl:input message="tns:GetOrderRequest" name="GetOrderRequest"/>
41+
<wsdl:output message="tns:GetOrderResponse" name="GetOrderResponse"/>
42+
</wsdl:operation>
43+
</wsdl:portType>
44+
<wsdl:binding name="OrderSoap11" type="tns:Order">
45+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
46+
<wsdl:operation name="GetOrder">
47+
<soap:operation soapAction=""/>
48+
<wsdl:input name="GetOrderRequest">
49+
<soap:body use="literal"/>
50+
</wsdl:input>
51+
<wsdl:output name="GetOrderResponse">
52+
<soap:body use="literal"/>
53+
</wsdl:output>
54+
</wsdl:operation>
55+
</wsdl:binding>
56+
<wsdl:service name="OrderService">
57+
<wsdl:port binding="tns:OrderSoap11" name="OrderSoap11">
58+
<soap:address location="http://localhost:8080/"/>
59+
</wsdl:port>
60+
</wsdl:service>
61+
</wsdl:definitions>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
targetNamespace="http://www.springframework.org/spring-ws/include/schema"
4+
xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified"
5+
attributeFormDefault="unqualified">
6+
7+
<xsd:element name="GetOrderResponse">
8+
<xsd:complexType>
9+
<xsd:sequence>
10+
<xsd:element name="child" type="xsd:string"/>
11+
</xsd:sequence>
12+
</xsd:complexType>
13+
</xsd:element>
14+
15+
</xsd:schema>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
targetNamespace="http://www.springframework.org/spring-ws/include/schema"
4+
xmlns="http://www.springframework.org/spring-ws/include/schema" elementFormDefault="qualified"
5+
attributeFormDefault="unqualified">
6+
7+
<xsd:include schemaLocation="included.xsd"/>
8+
9+
<xsd:element name="GetOrderRequest">
10+
<xsd:complexType>
11+
<xsd:sequence>
12+
<xsd:element name="child" type="xsd:string"/>
13+
</xsd:sequence>
14+
</xsd:complexType>
15+
</xsd:element>
16+
17+
18+
</xsd:schema>

0 commit comments

Comments
 (0)