summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-08-14 12:19:32 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-08-14 12:19:32 +0000
commit5cb022f9ae588bc213d0ed1e69a3a1ae84f99a33 (patch)
treeccff8275c2fc7ebf08691d3f55e2dca030f51bb0
parent64bf5f7f93ec101f5dff31e7d3806a19aa18e9cd (diff)
Add tests for WS endpoints
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@804182 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/itest/endpoints/src/test/java/test/EndpointsTestCase.java72
-rw-r--r--java/sca/itest/endpoints/src/test/resources/helloworld.composite35
2 files changed, 102 insertions, 5 deletions
diff --git a/java/sca/itest/endpoints/src/test/java/test/EndpointsTestCase.java b/java/sca/itest/endpoints/src/test/java/test/EndpointsTestCase.java
index 82723085d0..7739a4b335 100644
--- a/java/sca/itest/endpoints/src/test/java/test/EndpointsTestCase.java
+++ b/java/sca/itest/endpoints/src/test/java/test/EndpointsTestCase.java
@@ -23,6 +23,14 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
import junit.framework.Assert;
@@ -45,27 +53,58 @@ public class EndpointsTestCase {
@Test
public void testJSONP2() throws MalformedURLException, IOException {
// <tuscany:binding.jsonp name="jsonp2"/>
- invokeJSONPEndpoint("http://IBM-B4ADCA311EA:8085/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo");
+ invokeJSONPEndpoint("http://localhost:8085/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo");
}
@Test
public void testJSONP3() throws MalformedURLException, IOException {
// <tuscany:binding.jsonp uri="jsonp3"/>
- invokeJSONPEndpoint("http://IBM-B4ADCA311EA:8085/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo");
+ invokeJSONPEndpoint("http://localhost:8085/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo");
}
@Test
public void testJSONP4() throws MalformedURLException, IOException {
// <tuscany:binding.jsonp uri="/jsonp4"/>
- invokeJSONPEndpoint("http://IBM-B4ADCA311EA:8085/jsonp4/sayHello?name=petra&callback=foo");
+ invokeJSONPEndpoint("http://localhost:8085/jsonp4/sayHello?name=petra&callback=foo");
}
@Test
public void testJSONP5() throws MalformedURLException, IOException {
// <tuscany:binding.jsonp name="jsonp5a" uri="/jsonp5b"/>
- invokeJSONPEndpoint("http://IBM-B4ADCA311EA:8085/jsonp5b/sayHello?name=petra&callback=foo");
+ invokeJSONPEndpoint("http://localhost:8085/jsonp5b/sayHello?name=petra&callback=foo");
}
@Test
public void testJSONP6() throws MalformedURLException, IOException {
// <tuscany:binding.jsonp name="jsonp6a" uri="jsonp6b"/>
- invokeJSONPEndpoint("http://IBM-B4ADCA311EA:8085/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo");
+ invokeJSONPEndpoint("http://localhost:8085/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo");
+ }
+
+ @Test
+ public void testWS1() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS />
+ invokeWSEndpoint("http://localhost:8085/WSComponent1/HelloWorldService");
+ }
+ @Test
+ public void testWS2() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS2"/>
+ invokeWSEndpoint("http://localhost:8085/WSComponent2/HelloWorldService/ws2");
+ }
+ @Test
+ public void testWS3() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="WS3"/>
+ invokeWSEndpoint("http://localhost:8085/WSComponent3/HelloWorldService/ws3");
+ }
+ @Test
+ public void testWS4() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="/WS4"/>
+ invokeWSEndpoint("http://localhost:8085/ws4");
+ }
+ @Test
+ public void testWS5() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS5a" uri="/WS5b"/>
+ invokeWSEndpoint("http://localhost:8085/ws5b");
+ }
+ @Test
+ public void testWS6() throws Exception {
+ // <tuscany:binding.ws name="ws6a" uri="ws6b"/>
+ invokeWSEndpoint("http://localhost:8085/WSComponent6/HelloWorldService/ws6a/ws6b");
}
private void invokeJSONPEndpoint(String s) throws MalformedURLException, IOException {
@@ -75,6 +114,29 @@ public class EndpointsTestCase {
Assert.assertEquals("foo(\"Hello petra\");", response);
}
+ public void invokeWSEndpoint(String endpoint) throws Exception {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL(endpoint + "?wsdl");
+ Assert.assertNotNull(definition);
+ Service service = (Service)definition.getServices().values().iterator().next();
+ Port port = (Port)service.getPorts().values().iterator().next();
+
+ Assert.assertEquals(new URL(endpoint).getPath(), new URL(getEndpoint(port)).getPath());
+ }
+
+ protected String getEndpoint(Port port) {
+ List<?> wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
@BeforeClass
public static void init() throws Exception {
JettyServer.portDefault = 8085;
diff --git a/java/sca/itest/endpoints/src/test/resources/helloworld.composite b/java/sca/itest/endpoints/src/test/resources/helloworld.composite
index a533e0cfaf..081804b34e 100644
--- a/java/sca/itest/endpoints/src/test/resources/helloworld.composite
+++ b/java/sca/itest/endpoints/src/test/resources/helloworld.composite
@@ -71,6 +71,41 @@
</service>
</component>
+ <component name="WSComponent1">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws />
+ </service>
+ </component>
+
+ <component name="WSComponent2">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws name="ws2"/>
+ </service>
+ </component>
+
+ <component name="WSComponent3">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws uri="ws3"/>
+ </service>
+ </component>
+
+ <component name="WSComponent4">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws uri="/ws4"/>
+ </service>
+ </component>
+
+ <component name="WSComponent5">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws name="ws5a" uri="/ws5b"/>
+ </service>
+ </component>
+
<component name="WSComponent6">
<implementation.java class="helloworld.HelloWorldImpl"/>
<service name="HelloWorldService" >