tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1212386 - in /tuscany/sca-java-2.x/trunk: modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/ modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ testing/itest/ws/endpoints/src/main/resources/...
Date Fri, 09 Dec 2011 13:01:36 GMT
Author: slaws
Date: Fri Dec  9 13:01:35 2011
New Revision: 1212386

URL: http://svn.apache.org/viewvc?rev=1212386&view=rev
Log:
TUSCANY-3993 - Update code to handle relative URIs and add a test case

Added:
    tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite
    tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java
Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
    tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
    tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
    tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java?rev=1212386&r1=1212385&r2=1212386&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
Fri Dec  9 13:01:35 2011
@@ -411,7 +411,10 @@ public class WSDLServiceGenerator {
                              Port.class, WSDLDefinitionGenerator.SOAP_ADDRESS);
                 } catch (WSDLException e) {
                 }
-                String uri = computeActualURI(wsBinding, port);
+                // By this stage the URI should have been copied from the WSDL port and
+                // should have run through the binding URI builder. 
+                //String uri = computeActualURI(wsBinding, port);
+                String uri = wsBinding.getURI();
                 ((SOAPAddress)newExt).setLocationURI(uri);
                 newPort.addExtensibilityElement(newExt);
             } else if (extension instanceof SOAP12Address) {
@@ -421,7 +424,10 @@ public class WSDLServiceGenerator {
                              Port.class, WSDLDefinitionGenerator.SOAP12_ADDRESS);
                 } catch (WSDLException e) {
                 }
-                String uri = computeActualURI(wsBinding, port);
+                // By this stage the URI should have been copied from the WSDL port and
+                // should have run through the binding URI builder. 
+                //String uri = computeActualURI(wsBinding, port);
+                String uri = wsBinding.getURI();
                 ((SOAP12Address)newExt).setLocationURI(uri);
                 newPort.addExtensibilityElement(newExt);
             } else {

Modified: tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java?rev=1212386&r1=1212385&r2=1212386&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
Fri Dec  9 13:01:35 2011
@@ -316,7 +316,11 @@ public class BindingURIBuilderImpl imple
                 }
             } else {
                 if (bindingURI != null) {
-                    uriString = basedURI(baseURI, componentURI.resolve(bindingURI)).toString();
+                    if (bindingURI.toString().startsWith("/")) {
+                        uriString = basedURI(baseURI, componentURI.resolve(bindingURI)).toString();
+                    } else {
+                        uriString = basedURI(baseURI, componentURI.resolve(name + "/" + bindingURI)).toString();
+                    }
                 } else {
                     uriString = basedURI(baseURI, componentURI.resolve(name)).toString();
                 }

Added: tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite?rev=1212386&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite
(added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite
Fri Dec  9 13:01:35 2011
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+			xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+			targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+           name="RelativeURI">
+           
+    <!-- 
+    tests that the relative URI of the binding is appended to the default component/service
URL
+    -->      
+
+    <component name="HelloWorldService">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMService"/>
+	    <service name="HelloWorldOM">
+	        <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+	        <binding.ws uri="helloWorld"
+				wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"/>
+	    </service>		
+    </component>
+
+    <component name="HelloWorldComponent">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+	    <reference name="helloWorldWS">
+	        <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+	        <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
+	                    uri="http://localhost:8085/HelloWorldService/HelloWorldOM/helloWorld"/>
+	    </reference>
+    </component>
+
+    <component name="HelloWorldService1">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMService"/>
+	    <service name="HelloWorldOM">
+	        <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+	        <binding.ws uri="../helloWorld"
+				wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"/>
+	    </service>		
+    </component>
+
+    <component name="HelloWorldComponent1">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+	    <reference name="helloWorldWS">
+	        <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+	        <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
+	                    uri="http://localhost:8085/HelloWorldService1/helloWorld"/>
+	    </reference>
+    </component>
+    
+    <component name="HelloWorldService2">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMService"/>
+	    <service name="HelloWorldOM">
+	        <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+	        <binding.ws uri="../../helloWorld"
+				wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"/>
+	    </service>		
+    </component>
+
+    <component name="HelloWorldComponent2">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+	    <reference name="helloWorldWS">
+	        <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+	        <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
+	                    uri="http://localhost:8085/helloWorld"/>
+	    </reference>
+    </component>    
+
+</composite>

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite?rev=1212386&r1=1212385&r2=1212386&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
Fri Dec  9 13:01:35 2011
@@ -42,7 +42,7 @@
 	    <reference name="helloWorldWS">
 	        <interface.wsdl interface="http://helloworld-om-relative-uri#wsdl.interface(HelloWorld)"
/>
 	        <binding.ws wsdlElement="http://helloworld-om-relative-uri#wsdl.binding(HelloWorldSoapBinding)"
-	                    uri="http://localhost:8085/HelloWorldService/helloWorld/myRelativeURI"/>
+	                    uri="http://localhost:8085/HelloWorldService/HelloWorldOM/myRelativeURI"/>
 	    </reference>
     </component>
 

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl?rev=1212386&r1=1212385&r2=1212386&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
Fri Dec  9 13:01:35 2011
@@ -71,7 +71,7 @@
 
     <wsdl:service name="HelloWorldService">
         <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
-            <wsdlsoap:address location="http://localhost:8085/HelloWorldService/helloWorld/myRelativeURI"/>
+            <wsdlsoap:address location="myRelativeURI"/>
         </wsdl:port>
     </wsdl:service>
 

Modified: tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java?rev=1212386&r1=1212385&r2=1212386&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
Fri Dec  9 13:01:35 2011
@@ -26,20 +26,24 @@ import org.apache.axiom.om.OMAbstractFac
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
 import org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOM;
 import org.apache.tuscany.sca.node.Contribution;
 import org.apache.tuscany.sca.node.Node;
 import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
 
 public abstract class AbstractHelloWorldOMTestCase extends TestCase {
 
-    private Node node;
-    private HelloWorldOM helloWorld;
+    protected Node node;
+    protected HelloWorldOM helloWorld;
 
     @Override
     protected void setUp() throws Exception {
         String contribution = "target/classes";
         node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test",
contribution));
+        // force ws binding on node to use a default of 8085 if an absolute port is not specified
+        ((NodeImpl)node).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8085/");
         node.start();
         helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
     }

Added: tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java?rev=1212386&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java
(added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java
Fri Dec  9 13:01:35 2011
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+
+public class RelativeURITestCase extends AbstractHelloWorldOMTestCase {
+    // super class does it all getting composite based on this class name
+    
+    /**
+     * Test binding.ws uri="../helloWorld"
+     */
+    public void testRelative1() throws Exception {
+        HelloWorldOM helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent1");
+        
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om",
"helloworld");
+        OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+        requestOM.addChild(parmE);
+        parmE.addChild(fac.createOMText("petra"));
+        OMElement responseOM = helloWorld.getGreetings(requestOM);
+        OMElement child = (OMElement)responseOM.getFirstElement();
+        Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+    }
+    
+    /**
+     * Test binding.ws uri="../../helloWorld"
+     */
+    public void testRelative2() throws Exception {
+        HelloWorldOM helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent2");
+        
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om",
"helloworld");
+        OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+        requestOM.addChild(parmE);
+        parmE.addChild(fac.createOMText("petra"));
+        OMElement responseOM = helloWorld.getGreetings(requestOM);
+        OMElement child = (OMElement)responseOM.getFirstElement();
+        Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+    }
+}



Mime
View raw message