1   package org.codehaus.xfire.message.document;
2   
3   import org.codehaus.xfire.service.object.DefaultObjectService;
4   import org.codehaus.xfire.soap.Soap11;
5   import org.codehaus.xfire.soap.SoapConstants;
6   import org.codehaus.xfire.test.AbstractXFireTypeTest;
7   import org.dom4j.Document;
8   
9   /***
10   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
11   * @since Feb 21, 2004
12   */
13  public class DocumentServiceTest
14      extends AbstractXFireTypeTest
15  {
16      public void setUp() throws Exception
17      {
18          super.setUp();
19          
20          DefaultObjectService service = (DefaultObjectService) 
21          getServiceBuilder().create(DocumentService.class,
22                                     "Doc",
23                                     "urn:Doc",
24                                     Soap11.getInstance(),
25                                     SoapConstants.STYLE_DOCUMENT,
26                                     SoapConstants.USE_LITERAL);
27      }
28      
29      public void testNoParams() throws Exception
30      {
31          Document response = 
32              invokeService( "Doc", "/org/codehaus/xfire/message/document/document11-1.xml" );
33  
34          addNamespace( "d", "urn:Doc");
35          assertValid( "//d:getString1out", response );
36          assertValid( "//d:getString1out[text()=\"string\"]", response );
37      }
38      
39      public void testOneParam() throws Exception
40      {
41          Document response = 
42              invokeService( "Doc", "/org/codehaus/xfire/message/document/document11-2.xml" );
43  
44          addNamespace( "d", "urn:Doc");
45          assertValid( "//d:getString2out", response );
46          assertValid( "//d:getString2out[text()=\"bleh\"]", response );
47      } 
48      
49      public void testTwoParams() throws Exception
50      {
51          Document response = 
52              invokeService( "Doc", "/org/codehaus/xfire/message/document/document11-3.xml" );
53  
54          addNamespace( "d", "urn:Doc");
55          assertValid( "//d:getString3out", response );
56          assertValid( "//d:getString3out[text()=\"blehbleh2\"]", response );
57      }     
58      /*
59      public void testBeanServiceWSDL() throws Exception
60      {
61          // Test WSDL generation
62          Document doc = getWSDLDocument( "Bean" );
63  
64          addNamespace( "wsdl", WSDL.WSDL11_NS );
65          addNamespace( "wsdlsoap", WSDL.WSDL11_SOAP_NS );
66          addNamespace( "xsd", SOAPConstants.XSD );
67  
68          assertValid( "/wsdl:definitions/wsdl:types", doc );
69          assertValid( "/wsdl:definitions/wsdl:types/xsd:schema", doc );
70          assertValid( "/wsdl:definitions/wsdl:types" +
71                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
72                  "/xsd:complexType", doc );
73          assertValid( "/wsdl:definitions/wsdl:types" +
74                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
75                  "/xsd:complexType", doc );
76          assertValid( "/wsdl:definitions/wsdl:types" +
77                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
78                  "/xsd:complexType[@name=\"SimpleBean\"]", doc );
79          assertValid( "/wsdl:definitions/wsdl:types" +
80                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
81                  "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"bleh\"]", doc );
82          assertValid( "/wsdl:definitions/wsdl:types" +
83                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
84                  "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"howdy\"]", doc );
85          assertValid( "/wsdl:definitions/wsdl:types" +
86                  "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" +
87                  "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@type=\"xsd:string\"]", doc );
88  
89          assertValid( "/wsdl:definitions/wsdl:service/wsdl:port/wsdlsoap:address[@location=\"http://localhost/services/Bean\"]", doc );
90      }*/
91  }