summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-12-09 13:01:35 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-12-09 13:01:35 +0000
commit6e3edd75f039d70b32d9fc3e8da063880d7a10f7 (patch)
treeca256bdacef5ad46d71120131f90f4ef60fc116f
parentc85543051b2de8c971619c21f7ccc9b5c4f73985 (diff)
TUSCANY-3993 - Update code to handle relative URIs and add a test case
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1212386 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java10
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java6
-rw-r--r--sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite83
-rw-r--r--sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite2
-rw-r--r--sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl2
-rw-r--r--sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java8
-rw-r--r--sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java63
7 files changed, 167 insertions, 7 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
index c6f1db4a3e..e131ea83b0 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
@@ -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 {
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
index 114dd45f8c..eff1e9f083 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
@@ -316,7 +316,11 @@ public class BindingURIBuilderImpl implements CompositeBuilder {
}
} 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();
}
diff --git a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite
new file mode 100644
index 0000000000..898d2b0699
--- /dev/null
+++ b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/RelativeURI.composite
@@ -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>
diff --git a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
index 1ea7ab5a36..80ae124c23 100644
--- a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
+++ b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
@@ -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>
diff --git a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
index fe68755c47..cd63064b59 100644
--- a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
+++ b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
@@ -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>
diff --git a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
index bad94bbbc3..1f8e4b3622 100644
--- a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
+++ b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
@@ -26,20 +26,24 @@ import org.apache.axiom.om.OMAbstractFactory;
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");
}
diff --git a/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java
new file mode 100644
index 0000000000..108aa1ce70
--- /dev/null
+++ b/sca-java-2.x/trunk/testing/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/RelativeURITestCase.java
@@ -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());
+ }
+}