1 package org.codehaus.xfire.message.wrapped;
2
3 import org.codehaus.xfire.services.ArrayService;
4 import org.codehaus.xfire.services.BeanService;
5 import org.codehaus.xfire.soap.Soap11;
6 import org.codehaus.xfire.soap.SoapConstants;
7 import org.codehaus.xfire.test.AbstractXFireTypeTest;
8 import org.codehaus.xfire.wsdl.WSDLWriter;
9 import org.dom4j.Document;
10
11 /***
12 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
13 * @since Feb 21, 2004
14 */
15 public class WrappedAutoTypeTest
16 extends AbstractXFireTypeTest
17 {
18 public void setUp() throws Exception
19 {
20 super.setUp();
21 getServiceBuilder().create(BeanService.class);
22
23 getServiceBuilder().create(ArrayService.class,
24 "Array",
25 "urn:Array",
26 Soap11.getInstance(),
27 SoapConstants.STYLE_WRAPPED,
28 SoapConstants.USE_LITERAL);
29 }
30
31 public void testBeanService() throws Exception
32 {
33 Document response =
34 invokeService("BeanService",
35 "/org/codehaus/xfire/message/wrapped/bean11.xml");
36
37 addNamespace( "sb", "http://services.xfire.codehaus.org" );
38 assertValid( "/s:Envelope/s:Body/sb:getSimpleBeanResponse", response );
39 assertValid( "//sb:getSimpleBeanResponse/sb:out", response );
40 assertValid( "//sb:getSimpleBeanResponse/sb:out/sb:howdy[text()=\"howdy\"]", response );
41 assertValid( "//sb:getSimpleBeanResponse/sb:out/sb:bleh[text()=\"bleh\"]", response );
42 }
43
44 public void testBeanServiceWSDL() throws Exception
45 {
46 Document doc = getWSDLDocument("BeanService");
47
48 addNamespace( "wsdl", WSDLWriter.WSDL11_NS );
49 addNamespace( "wsdlsoap", WSDLWriter.WSDL11_SOAP_NS );
50 addNamespace( "xsd", SoapConstants.XSD );
51
52 assertValid( "/wsdl:definitions/wsdl:types", doc );
53 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema", doc );
54 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']", doc );
55 assertValid( "//xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']/xsd:element[@name='getSubmitBean']", doc );
56 assertValid( "//xsd:element[@name='getSubmitBean']/xsd:complexType/xsd:sequence/xsd:element[@name='in1'][@type='xsd:string']", doc );
57 assertValid( "//xsd:element[@name='getSubmitBean']/xsd:complexType/xsd:sequence/xsd:element[@name='in0'][@type='tns:SimpleBean']", doc );
58
59 assertValid( "/wsdl:definitions/wsdl:types" +
60 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
61 "/xsd:complexType", doc );
62 assertValid( "/wsdl:definitions/wsdl:types" +
63 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
64 "/xsd:complexType[@name=\"SimpleBean\"]", doc );
65 assertValid( "/wsdl:definitions/wsdl:types" +
66 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
67 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"bleh\"]", doc );
68 assertValid( "/wsdl:definitions/wsdl:types" +
69 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
70 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"howdy\"]", doc );
71 assertValid( "/wsdl:definitions/wsdl:types" +
72 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
73 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@type=\"xsd:string\"]", doc );
74
75 assertValid( "/wsdl:definitions/wsdl:service/wsdl:port/wsdlsoap:address[@location='http://localhost/services/BeanService']", doc );
76 }
77
78 public void testArrayService() throws Exception
79 {
80 Document response = invokeService("Array",
81 "/org/codehaus/xfire/message/wrapped/SubmitStringArray11.xml");
82
83 addNamespace( "a", "urn:Array");
84 addNamespace( "sb", "http://test.java.xfire.codehaus.org");
85 assertValid( "//a:SubmitStringArrayResponse", response );
86 assertValid( "//a:SubmitStringArrayResponse/a:out[text()='true']", response );
87 }
88
89 public void testArrayServiceWSDL() throws Exception
90 {
91 Document doc = getWSDLDocument("Array");
92
93 addNamespace( "wsdl", WSDLWriter.WSDL11_NS );
94 addNamespace( "wsdlsoap", WSDLWriter.WSDL11_SOAP_NS );
95 addNamespace( "xsd", SoapConstants.XSD );
96
97 assertValid( "/wsdl:definitions/wsdl:types", doc );
98 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema", doc );
99 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='urn:Array']", doc );
100 assertValid( "//xsd:schema[@targetNamespace='urn:Array']/xsd:element[@name='SubmitBeanArray']", doc );
101 assertValid( "//xsd:element[@name='SubmitStringArray']/xsd:complexType/xsd:sequence/xsd:element[@name='in0'][@type='tns:ArrayOfString']", doc );
102 assertValid( "//xsd:element[@name='SubmitBeanArray']/xsd:complexType/xsd:sequence/xsd:element[@name='in0'][@type='ns1:ArrayOfSimpleBean']", doc );
103 }
104 }