1 package org.codehaus.xfire.message.document;
2
3 import org.codehaus.xfire.service.object.DefaultObjectService;
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 DocumentAutoTypeTest
16 extends AbstractXFireTypeTest
17 {
18 public void setUp() throws Exception
19 {
20 super.setUp();
21
22 DefaultObjectService service = (DefaultObjectService)
23 getServiceBuilder().create(BeanService.class,
24 "Bean",
25 "urn:Bean",
26 Soap11.getInstance(),
27 SoapConstants.STYLE_DOCUMENT,
28 SoapConstants.USE_LITERAL);
29 }
30
31 public void testBeanService() throws Exception
32 {
33 Document response =
34 invokeService( "Bean", "/org/codehaus/xfire/message/document/bean11.xml" );
35
36 addNamespace( "sb", "urn:Bean");
37 addNamespace( "svc", "http://services.xfire.codehaus.org");
38 assertValid( "//sb:getSimpleBeanout", response );
39 assertValid( "//sb:getSimpleBeanout/svc:howdy[text()=\"howdy\"]", response );
40 assertValid( "//sb:getSimpleBeanout/svc:bleh[text()=\"bleh\"]", response );
41 }
42
43 public void testBeanServiceWSDL() throws Exception
44 {
45
46 Document doc = getWSDLDocument( "Bean" );
47 printNode(doc);
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" +
55 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
56 "/xsd:complexType", doc );
57 assertValid( "/wsdl:definitions/wsdl:types" +
58 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
59 "/xsd:complexType", doc );
60 assertValid( "/wsdl:definitions/wsdl:types" +
61 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
62 "/xsd:complexType[@name=\"SimpleBean\"]", doc );
63 assertValid( "/wsdl:definitions/wsdl:types" +
64 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
65 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"bleh\"]", doc );
66 assertValid( "/wsdl:definitions/wsdl:types" +
67 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
68 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"howdy\"]", doc );
69 assertValid( "/wsdl:definitions/wsdl:types" +
70 "/xsd:schema[@targetNamespace='http://services.xfire.codehaus.org']" +
71 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@type=\"xsd:string\"]", doc );
72
73 assertValid( "/wsdl:definitions/wsdl:service/wsdl:port/wsdlsoap:address[@location=\"http://localhost/services/Bean\"]", doc );
74 }
75 }