[jboss-svn-commits] JBL Code SVN: r25125 - labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 5 15:21:58 EST 2009


Author: kevin.conner at jboss.com
Date: 2009-02-05 15:21:57 -0500 (Thu, 05 Feb 2009)
New Revision: 25125

Removed:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl
Modified:
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
Log:
Fix WSDL generation test: JBESB-2339

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java	2009-02-05 18:03:58 UTC (rev 25124)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java	2009-02-05 20:21:57 UTC (rev 25125)
@@ -25,8 +25,13 @@
 import java.io.InputStream;
 import java.util.List;
 
+import javax.wsdl.Binding;
 import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.factory.WSDLFactory;
+import javax.xml.namespace.QName;
 
 import junit.framework.TestCase;
 
@@ -34,7 +39,6 @@
 import org.jboss.soa.esb.listeners.config.Generator;
 import org.jboss.soa.esb.listeners.config.WebserviceInfo;
 import org.jboss.soa.esb.util.ClassUtil;
-import org.jboss.soa.esb.testutils.StringUtils;
 import org.xml.sax.InputSource;
 
 public class ESBContractGeneratorUnitTest extends TestCase {
@@ -62,14 +66,45 @@
         executeTest("jbossesb_config_08.110.xml") ;
     }
 
+    @SuppressWarnings("unchecked")
     public void testWSAExtensions110() throws Exception {
-        String expectedWsdl = StreamUtils.readStreamString(getClass().getResourceAsStream("jbossesb_config_09.110.expected.wsdl"), "UTF-8");
-        String actualWsdl = executeTest("jbossesb_config_09.110.xml") ;
-
-        assertTrue("WSDL not as expected.", StringUtils.compareXMLContent(expectedWsdl, actualWsdl));
+        final String targetNamespace = "http://soa.jboss.org/FirstServiceESB" ;
+        final String wsawNamespace = "http://www.w3.org/2006/05/addressing/wsdl" ;
+        
+        final Definition def = executeTest("jbossesb_config_09.110.xml") ;
+        assertNotNull("Definition", def) ;
+        
+        final QName portName = new QName(targetNamespace, "SimpleListenerPortType") ;
+        final PortType portType = def.getPortType(portName) ;
+        assertNotNull("Port type", portType) ;
+        
+        final Operation operation = portType.getOperation("SimpleListenerOp", "SimpleListenerReq", "SimpleListenerRes") ;
+        assertNotNull("Operation", operation) ;
+        
+        final QName actionQName = new QName(wsawNamespace, "Action") ;
+        assertNotNull("Input action", operation.getInput().getExtensionAttribute(actionQName)) ;
+        assertNotNull("Output action", operation.getOutput().getExtensionAttribute(actionQName)) ;
+        
+        final QName bindingName = new QName(targetNamespace, "SimpleListenerBinding") ;
+        final Binding binding = def.getBinding(bindingName) ;
+        assertNotNull("Binding", binding) ;
+        
+        final List<ExtensibilityElement> extensions = binding.getExtensibilityElements() ;
+        boolean found = false ;
+        for(ExtensibilityElement extension: extensions)
+        {
+            final QName type = extension.getElementType() ;
+            if (wsawNamespace.equals(type.getNamespaceURI()))
+            {
+                assertEquals("Extension element local name", "UsingAddressing", type.getLocalPart()) ;
+                assertTrue("Required element", extension.getRequired().booleanValue()) ;
+                found = true ;
+            }
+        }
+        assertTrue("Extension found", found) ;
     }
 
-    private String executeTest(final String resourceName) throws Exception {
+    private Definition executeTest(final String resourceName) throws Exception {
         final InputStream is = ClassUtil.getResourceAsStream(resourceName, getClass()) ;
         final byte[] configBytes = StreamUtils.readStream(is) ;
         ByteArrayOutputStream listenerXml = new ByteArrayOutputStream();
@@ -85,7 +120,7 @@
         Definition def = WSDLFactory.newInstance().newWSDLReader().readWSDL("file://tmp.wsdl", inputSource);
         assertNotNull("Failed to generate wsdl file" , def);
 
-        return wsdl;
+        return def;
     }
 
 }

Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl	2009-02-05 18:03:58 UTC (rev 25124)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl	2009-02-05 20:21:57 UTC (rev 25125)
@@ -1,98 +0,0 @@
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.jboss.org/sayHi"
-                  xmlns:ns2="http://www.jboss.org/sayHi" xmlns:ns3="http://www.jboss.org/sayHi"
-                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soa.jboss.org/FirstServiceESB"
-                  targetNamespace="http://soa.jboss.org/FirstServiceESB">
-    <wsdl:types>
-        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://www.jboss.org/sayHi"
-                   elementFormDefault="qualified" targetNamespace="http://www.jboss.org/sayHi" version="1.0">
-            <xs:element name="sayHi" type="x1:sayHi"/>
-            <xs:complexType name="sayHi">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="arg0" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://www.jboss.org/sayHi"
-                   elementFormDefault="qualified" targetNamespace="http://www.jboss.org/sayHi" version="1.0">
-            <xs:element name="sayHiReponse" type="x1:sayHiReponse"/>
-            <xs:complexType name="sayHiReponse">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="arg0" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://www.jboss.org/sayHi"
-                   elementFormDefault="qualified" targetNamespace="http://www.jboss.org/sayHi" version="1.0">
-            <xs:element name="sayFault" type="x1:fault"/>
-            <xs:complexType name="fault">
-                <xs:sequence>
-                    <xs:element name="code" type="xs:string"/>
-                    <xs:element name="faultString" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:element name="sayFault2" type="x1:fault2"/>
-            <xs:complexType name="fault2">
-                <xs:sequence>
-                    <xs:element name="code" type="xs:int"/>
-                    <xs:element name="descrption" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-
-        </xs:schema>
-    </wsdl:types>
-    <wsdl:message name="SimpleListenerFault2">
-        <wsdl:part element="ns1:sayFault" name="fault2">
-        </wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="SimpleListenerFault1">
-        <wsdl:part element="ns1:sayFault" name="fault1">
-        </wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="SimpleListenerReq">
-        <wsdl:part element="ns1:sayHi" name="in">
-        </wsdl:part>
-    </wsdl:message>
-    <wsdl:message name="SimpleListenerRes">
-        <wsdl:part element="ns1:sayHiReponse" name="out">
-        </wsdl:part>
-    </wsdl:message>
-    <wsdl:portType name="SimpleListenerPortType">
-        <wsdl:operation name="SimpleListenerOp">
-            <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="tns:SimpleListenerReq"
-                        name="SimpleListenerReq" wsaw:Action="http://soa.jboss.org/FirstServiceESB/SimpleListenerOp">
-            </wsdl:input>
-            <wsdl:output xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="tns:SimpleListenerRes"
-                         name="SimpleListenerRes"
-                         wsaw:Action="http://soa.jboss.org/FirstServiceESB/SimpleListenerOpResp">
-            </wsdl:output>
-            <wsdl:fault message="tns:SimpleListenerFault1" name="fault1">
-            </wsdl:fault>
-            <wsdl:fault message="tns:SimpleListenerFault2" name="fault2">
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:portType>
-    <wsdl:binding name="SimpleListenerBinding" type="tns:SimpleListenerPortType">
-        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
-        <wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsdl:required="true"/>
-        <wsdl:operation name="SimpleListenerOp">
-            <soap:operation soapAction="http://soa.jboss.org/FirstServiceESB/SimpleListenerOpResp"/>
-            <wsdl:input name="SimpleListenerReq">
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output name="SimpleListenerRes">
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="fault1">
-                <soap:fault name="fault1" use="literal"/>
-            </wsdl:fault>
-            <wsdl:fault name="fault2">
-                <soap:fault name="fault2" use="literal"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:service name="SimpleListenerService">
-        <wsdl:port binding="tns:SimpleListenerBinding" name="SimpleListenerPortType">
-            <soap:address location="http://change_this_URI//FirstServiceESB/SimpleListener"/>
-        </wsdl:port>
-    </wsdl:service>
-</wsdl:definitions>




More information about the jboss-svn-commits mailing list