You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ve...@apache.org on 2008/06/20 20:26:48 UTC

svn commit: r670024 - in /synapse/trunk/java/modules/core/src: main/java/org/apache/synapse/core/axis2/ test/java/org/apache/synapse/core/axis2/ test/resources/org/apache/synapse/core/ test/resources/org/apache/synapse/core/axis2/

Author: veithen
Date: Fri Jun 20 11:26:48 2008
New Revision: 670024

URL: http://svn.apache.org/viewvc?rev=670024&view=rev
Log:
* Make sure that the InputSource objects returned by ResourceMap have their systemId set as Axis2 relies on this. The generated system IDs are of the form "synapse-reg:///<key>". This fixes SYNAPSE-362.
* Added a unit test for WSDL/XSD import resolution with ResourceMap. This is a unit test for the improvement in SYNAPSE-200 and a regression test for issue SYNAPSE-362.

Added:
    synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/
    synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/
    synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.wsdl
    synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.xsd
    synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/root.wsdl
Modified:
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ResourceMap.java
    synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/core/axis2/ProxyServiceTest.java

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ResourceMap.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ResourceMap.java?rev=670024&r1=670023&r2=670024&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ResourceMap.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ResourceMap.java Fri Jun 20 11:26:48 2008
@@ -98,7 +98,11 @@
                     log.error(msg);
                     throw new SynapseException(msg, ex);
                 }
-                return new InputSource(new ByteArrayInputStream(baos.toByteArray()));
+                InputSource inputSource = new InputSource(new ByteArrayInputStream(baos.toByteArray()));
+                // We must set a system ID because Axis2 relies on this (see SYNAPSE-362). Compose a
+                // valid URI with the registry key so that it uniquely identifies the resource.
+                inputSource.setSystemId("synapse-reg:///" + key);
+                return inputSource;
             } else {
                 String msg = "Registry item '" + key + "' for location '" +
                     location + "' is not an OMElement";

Modified: synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/core/axis2/ProxyServiceTest.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/core/axis2/ProxyServiceTest.java?rev=670024&r1=670023&r2=670024&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/core/axis2/ProxyServiceTest.java (original)
+++ synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/core/axis2/ProxyServiceTest.java Fri Jun 20 11:26:48 2008
@@ -29,6 +29,7 @@
 
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.synapse.config.Entry;
 import org.apache.synapse.config.SynapseConfiguration;
 import org.xml.sax.InputSource;
 
@@ -50,4 +51,40 @@
         WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
         wsdlReader.readWSDL(null, new InputSource(new ByteArrayInputStream(baos.toByteArray())));
     }
+    
+    /**
+     * Test a proxy with a WSDL importing another WSDL importing an XSD. The imported WSDL and
+     * XSD documents are resolved using a {@link ResourceMap} (i.e. &lt;resource> elements). The
+     * test checks that the proxy service can be built and produce a WSDL.
+     * This is a test for the feature introduced by SYNAPSE-200 and a regression test
+     * for SYNAPSE-362.
+     */
+    public void testWSDLWithPublishWSDLAndRecursiveImports() throws Exception {
+        SynapseConfiguration synCfg = new SynapseConfiguration();
+        AxisConfiguration axisCfg = new AxisConfiguration();
+        // Add local entries
+        Entry entry = new Entry();
+        entry.setType(Entry.URL_SRC);
+        entry.setSrc(getClass().getResource("root.wsdl"));
+        synCfg.addEntry("root_wsdl", entry);
+        entry = new Entry();
+        entry.setType(Entry.URL_SRC);
+        entry.setSrc(getClass().getResource("imported.xsd"));
+        synCfg.addEntry("imported_xsd", entry);
+        entry = new Entry();
+        entry.setType(Entry.URL_SRC);
+        entry.setSrc(getClass().getResource("imported.wsdl"));
+        synCfg.addEntry("imported_wsdl", entry);
+        // Build the proxy service
+        ProxyService proxyService = new ProxyService("Test");
+        proxyService.setWSDLKey("root_wsdl");
+        ResourceMap resourceMap = new ResourceMap();
+        resourceMap.addResource("imported.wsdl", "imported_wsdl");
+        resourceMap.addResource("imported.xsd", "imported_xsd");
+        proxyService.setResourceMap(resourceMap);
+        AxisService axisService = proxyService.buildAxisService(synCfg, axisCfg);
+        // Serialize the WSDL. Note that we can't parse the WSDL because it will have imports
+        // referring to locations such as "my-matches?xsd=xsd0.xsd".
+        axisService.printWSDL(new ByteArrayOutputStream());
+    }
 }

Added: synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.wsdl
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.wsdl?rev=670024&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.wsdl (added)
+++ synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.wsdl Fri Jun 20 11:26:48 2008
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="Imported"
+                  targetNamespace="http://www.example.com/imported"
+                  xmlns:tns="http://www.example.com/imported"
+                  xmlns:s="http://www.example.com/schema"
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    <wsdl:types>
+        <xsd:schema targetNamespace="http://www.example.com/imported">
+            <xsd:import namespace="http://www.example.com/schema" schemaLocation="imported.xsd"/>
+            <xsd:element name="getTestData">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="test" type="s:SomeType" minOccurs="1" maxOccurs="1"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+            <xsd:element name="getTestDataResponse">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="test" type="s:SomeType" minOccurs="1" maxOccurs="1"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:schema>
+    </wsdl:types>
+    <wsdl:message name="getTestDataRequest">
+        <wsdl:part name="parameters" element="tns:getTestData"/>
+    </wsdl:message>
+    <wsdl:message name="getTestDataResponse">
+        <wsdl:part name="parameters" element="tns:getTestDataResponse"/>
+    </wsdl:message>
+    <wsdl:portType name="Test">
+        <wsdl:operation name="getTestData">
+            <wsdl:input message="tns:getTestDataRequest" name="getTestData"/>
+            <wsdl:output message="tns:getTestDataResponse" name="getTestDataResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+</wsdl:definitions>

Added: synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.xsd
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.xsd?rev=670024&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.xsd (added)
+++ synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/imported.xsd Fri Jun 20 11:26:48 2008
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema targetNamespace="http://www.example.com/schema"
+            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    <xsd:simpleType name="SomeType">
+        <xsd:restriction base="xsd:string">
+            <xsd:maxLength value="64"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+</xsd:schema>

Added: synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/root.wsdl
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/root.wsdl?rev=670024&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/root.wsdl (added)
+++ synapse/trunk/java/modules/core/src/test/resources/org/apache/synapse/core/axis2/root.wsdl Fri Jun 20 11:26:48 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="Test"
+                  targetNamespace="http://www.example.com/"
+                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:tns="http://www.example.com/"
+                  xmlns:imp="http://www.example.com/imported"
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+    <wsdl:import namespace="http://www.example.com/imported" location="imported.wsdl"/>
+    <wsdl:binding name="TestBinding" type="imp:Test">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="getTestData">
+            <soap:operation soapAction="http://www.example.com/imported/getTestData"/>
+            <wsdl:input name="getTestData">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="getTestDataResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="Test">
+        <wsdl:port name="Test" binding="tns:TestBinding">
+            <soap:address location="http://localhost/test"/>
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>