1   package org.codehaus.xfire.java.document;
2   
3   import org.codehaus.xfire.SOAPConstants;
4   import org.codehaus.xfire.java.test.TestHttpTransport;
5   import org.codehaus.xfire.plexus.PlexusXFireTest;
6   import org.codehaus.xfire.transport.TransportManager;
7   import org.codehaus.xfire.wsdl.WSDL;
8   import org.dom4j.Document;
9   
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 PlexusXFireTest
17  {
18      public void testBeanService() throws Exception
19      {
20          Document response = 
21              invokeService( "Bean", "/org/codehaus/xfire/java/document/bean11.xml" );
22  
23          addNamespace( "sb", "http://test.java.xfire.codehaus.org");
24          assertValid( "//sb:out", response );
25          assertValid( "//sb:out/sb:howdy[text()=\"howdy\"]", response );
26          assertValid( "//sb:out/sb:bleh[text()=\"bleh\"]", response );
27      }
28      
29      public void testBeanServiceWSDL() throws Exception
30      {
31          TransportManager tm = (TransportManager) lookup( TransportManager.ROLE );
32          tm.register( new TestHttpTransport() );
33          
34          // Test WSDL generation
35          Document doc = getWSDLDocument( "Bean" );
36  
37          addNamespace( "wsdl", WSDL.WSDL11_NS );
38          addNamespace( "wsdlsoap", WSDL.WSDL11_SOAP_NS );
39          addNamespace( "xsd", SOAPConstants.XSD );
40  
41          assertValid( "/wsdl:definitions/wsdl:types", doc );
42          assertValid( "/wsdl:definitions/wsdl:types/xsd:schema", doc );
43          assertValid( "/wsdl:definitions/wsdl:types" +
44                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
45                  "/xsd:complexType", doc );
46          assertValid( "/wsdl:definitions/wsdl:types" +
47                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
48                  "/xsd:complexType", doc );
49          assertValid( "/wsdl:definitions/wsdl:types" +
50                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
51                  "/xsd:complexType[@name=\"SimpleBean\"]", doc );
52          assertValid( "/wsdl:definitions/wsdl:types" +
53                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
54                  "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"bleh\"]", doc );
55          assertValid( "/wsdl:definitions/wsdl:types" +
56                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
57                  "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"howdy\"]", doc );
58          assertValid( "/wsdl:definitions/wsdl:types" +
59                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
60                  "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@type=\"xsd:string\"]", doc );
61  
62          assertValid( "/wsdl:definitions/wsdl:service/wsdl:port/wsdlsoap:address[@location=\"http://localhost/services/Bean\"]", doc );
63      }
64  }