1 package org.codehaus.xfire.java.wrapped; 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 WrappedAutoTypeTest 16 extends PlexusXFireTest 17 { 18 public void testBeanService() throws Exception 19 { 20 Document response = 21 invokeService("Bean", "/org/codehaus/xfire/java/wrapped/bean11.xml"); 22 23 addNamespace( "root", "urn:Bean"); 24 addNamespace( "sb", "http://test.java.xfire.codehaus.org"); 25 assertValid( "//root:getSimpleBeanResponse", response ); 26 assertValid( "//root:getSimpleBeanResponse/sb:out", response ); 27 assertValid( "//root:getSimpleBeanResponse/sb:out/sb:howdy[text()=\"howdy\"]", response ); 28 assertValid( "//root:getSimpleBeanResponse/sb:out/sb:bleh[text()=\"bleh\"]", response ); 29 } 30 31 public void testBeanServiceWSDL() throws Exception 32 { 33 TransportManager tm = (TransportManager) lookup( TransportManager.ROLE ); 34 tm.register( new TestHttpTransport() ); 35 36 Document doc = getWSDLDocument("Bean"); 37 38 addNamespace( "wsdl", WSDL.WSDL11_NS ); 39 addNamespace( "wsdlsoap", WSDL.WSDL11_SOAP_NS ); 40 addNamespace( "xsd", SOAPConstants.XSD ); 41 42 assertValid( "/wsdl:definitions/wsdl:types", doc ); 43 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema", doc ); 44 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='urn:Bean']", doc ); 45 assertValid( "//xsd:schema[@targetNamespace='urn:Bean']/xsd:element[@name='getSubmitBean']", doc ); 46 assertValid( "//xsd:element[@name='getSubmitBean']/xsd:complexType/xsd:sequence/xsd:element[@name='in1'][@type='xsd:string']", doc ); 47 assertValid( "//xsd:element[@name='getSubmitBean']/xsd:complexType/xsd:sequence/xsd:element[@name='in0'][@type='ns1:SimpleBean']", doc ); 48 49 assertNotNull( doc.getRootElement().getNamespaceForPrefix("ns1") ); 50 51 assertValid( "/wsdl:definitions/wsdl:types" + 52 "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" + 53 "/xsd:complexType", doc ); 54 assertValid( "/wsdl:definitions/wsdl:types" + 55 "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" + 56 "/xsd:complexType[@name=\"SimpleBean\"]", doc ); 57 assertValid( "/wsdl:definitions/wsdl:types" + 58 "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" + 59 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"bleh\"]", doc ); 60 assertValid( "/wsdl:definitions/wsdl:types" + 61 "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" + 62 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@name=\"howdy\"]", doc ); 63 assertValid( "/wsdl:definitions/wsdl:types" + 64 "/xsd:schema[@targetNamespace='http://test.java.xfire.codehaus.org']" + 65 "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element[@type=\"xsd:string\"]", doc ); 66 67 assertValid( "/wsdl:definitions/wsdl:service/wsdl:port/wsdlsoap:address[@location='http://localhost/services/Bean']", doc ); 68 } 69 70 public void testArrayService() throws Exception 71 { 72 Document response = invokeService("Array", 73 "/org/codehaus/xfire/java/wrapped/SubmitStringArray11.xml"); 74 75 addNamespace( "a", "urn:Array"); 76 addNamespace( "sb", "http://test.java.xfire.codehaus.org"); 77 assertValid( "//a:SubmitStringArrayResponse", response ); 78 assertValid( "//a:SubmitStringArrayResponse/a:out[text()='true']", response ); 79 } 80 81 public void testArrayServiceWSDL() throws Exception 82 { 83 TransportManager tm = (TransportManager) lookup( TransportManager.ROLE ); 84 tm.register( new TestHttpTransport() ); 85 86 Document doc = getWSDLDocument("Array"); 87 88 addNamespace( "wsdl", WSDL.WSDL11_NS ); 89 addNamespace( "wsdlsoap", WSDL.WSDL11_SOAP_NS ); 90 addNamespace( "xsd", SOAPConstants.XSD ); 91 92 assertValid( "/wsdl:definitions/wsdl:types", doc ); 93 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema", doc ); 94 assertValid( "/wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='urn:Array']", doc ); 95 assertValid( "//xsd:schema[@targetNamespace='urn:Array']/xsd:element[@name='SubmitBeanArray']", doc ); 96 assertValid( "//xsd:element[@name='SubmitStringArray']/xsd:complexType/xsd:sequence/xsd:element[@name='in0'][@type='tns:ArrayOfString']", doc ); 97 assertValid( "//xsd:element[@name='SubmitBeanArray']/xsd:complexType/xsd:sequence/xsd:element[@name='in0'][@type='tns:ArrayOfSimpleBean']", doc ); 98 } 99 }