1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.wsdl.wsdl11;
18
19 import java.io.InputStream;
20 import javax.wsdl.Definition;
21 import javax.wsdl.factory.WSDLFactory;
22 import javax.wsdl.xml.WSDLReader;
23 import javax.xml.parsers.DocumentBuilder;
24 import javax.xml.parsers.DocumentBuilderFactory;
25 import javax.xml.transform.Source;
26 import javax.xml.transform.Transformer;
27 import javax.xml.transform.TransformerFactory;
28 import javax.xml.transform.dom.DOMResult;
29
30 import org.custommonkey.xmlunit.XMLTestCase;
31 import org.custommonkey.xmlunit.XMLUnit;
32 import org.w3c.dom.Document;
33 import org.xml.sax.InputSource;
34
35 public class Wsdl4jDefinitionTest extends XMLTestCase {
36
37 private Wsdl4jDefinition definition;
38
39 private Transformer transformer;
40
41 protected void setUp() throws Exception {
42 XMLUnit.setIgnoreWhitespace(true);
43 WSDLFactory factory = WSDLFactory.newInstance();
44 WSDLReader reader = factory.newWSDLReader();
45 InputStream is = getClass().getResourceAsStream("complete.wsdl");
46 try {
47 Definition wsdl4jDefinition = reader.readWSDL(null, new InputSource(is));
48 definition = new Wsdl4jDefinition(wsdl4jDefinition);
49 }
50 finally {
51 is.close();
52 }
53 transformer = TransformerFactory.newInstance().newTransformer();
54 }
55
56 public void testGetSource() throws Exception {
57 Source source = definition.getSource();
58 assertNotNull("Source is null", source);
59 DOMResult result = new DOMResult();
60 transformer.transform(source, result);
61 DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
62 documentBuilderFactory.setNamespaceAware(true);
63 DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
64 Document expected = documentBuilder.parse(getClass().getResourceAsStream("complete.wsdl"));
65 assertXMLEqual(expected, (Document) result.getNode());
66 }
67 }