diff options
Diffstat (limited to 'sandbox/sebastien/java/shell/itest/endpoints/src/test')
7 files changed, 492 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..c307547f56 --- /dev/null +++ b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,28 @@ +/*
+ * 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 helloworld;
+
+
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..064d615c45 --- /dev/null +++ b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/helloworld/HelloWorldService.java @@ -0,0 +1,28 @@ +/*
+ * 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 helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/EndpointsTestCase.java b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/EndpointsTestCase.java new file mode 100644 index 0000000000..7802848c3b --- /dev/null +++ b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/EndpointsTestCase.java @@ -0,0 +1,110 @@ +/*
+ * 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 test;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.tuscany.sca.http.jetty.JettyServer;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class EndpointsTestCase {
+
+ private static Node node;
+
+ @Test
+ public void testJSONP1() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp />
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent1/HelloWorldService/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP2() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp2"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP3() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="jsonp3"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP4() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="/jsonp4"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp4/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP5() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp5a" uri="/jsonp5b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp5b/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP6() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp6a" uri="jsonp6b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo");
+ }
+
+ @Test
+ public void testWS1() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS />
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent1/HelloWorldService");
+ }
+ @Test
+ public void testWS2() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS2"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent2/HelloWorldService/ws2");
+ }
+ @Test
+ public void testWS3() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="WS3"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent3/HelloWorldService/ws3");
+ }
+ @Test
+ public void testWS4() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="/WS4"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws4");
+ }
+ @Test
+ public void testWS5() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS5a" uri="/WS5b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws5b");
+ }
+ @Test
+ public void testWS6() throws Exception {
+ // <tuscany:binding.ws name="ws6a" uri="ws6b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent6/HelloWorldService/ws6a/ws6b");
+ }
+
+ @BeforeClass
+ public static void init() throws Exception {
+ JettyServer.portDefault = 8085;
+ node = NodeFactory.newInstance().createNode("helloworld.composite").start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java new file mode 100644 index 0000000000..f3b6c15bf1 --- /dev/null +++ b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java @@ -0,0 +1,110 @@ +/*
+ * 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 test;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.tuscany.sca.http.jetty.JettyServer;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class NestedEndpointsTestCase {
+
+ private static Node node;
+
+ @Test
+ public void testJSONP1() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp />
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent1/HelloWorldService/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP2() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp2"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP3() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="jsonp3"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP4() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="/jsonp4"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp4/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP5() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp5a" uri="/jsonp5b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp5b/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP6() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp6a" uri="jsonp6b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo");
+ }
+
+ @Test
+ public void testWS1() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS />
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent1/HelloWorldService");
+ }
+ @Test
+ public void testWS2() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS2"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent2/HelloWorldService/ws2");
+ }
+ @Test
+ public void testWS3() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="WS3"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent3/HelloWorldService/ws3");
+ }
+ @Test
+ public void testWS4() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="/WS4"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws4");
+ }
+ @Test
+ public void testWS5() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS5a" uri="/WS5b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws5b");
+ }
+ @Test
+ public void testWS6() throws Exception {
+ // <tuscany:binding.ws name="ws6a" uri="ws6b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent6/HelloWorldService/ws6a/ws6b");
+ }
+
+ @BeforeClass
+ public static void init() throws Exception {
+ JettyServer.portDefault = 8085;
+ node = NodeFactory.newInstance().createNode("nested.composite").start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/Utils.java b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/Utils.java new file mode 100644 index 0000000000..5107d8f660 --- /dev/null +++ b/sandbox/sebastien/java/shell/itest/endpoints/src/test/java/test/Utils.java @@ -0,0 +1,70 @@ +/*
+ * 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 test;
+
+import java.io.BufferedReader;
+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;
+
+public class Utils {
+
+ public static void invokeJSONPEndpoint(String s) throws MalformedURLException, IOException {
+ URL url = new URL(s);
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ String response = br.readLine();
+ Assert.assertEquals("foo(\"Hello petra\");", response);
+ }
+
+ public static 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());
+ }
+
+ private static 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");
+ }
+
+}
diff --git a/sandbox/sebastien/java/shell/itest/endpoints/src/test/resources/helloworld.composite b/sandbox/sebastien/java/shell/itest/endpoints/src/test/resources/helloworld.composite new file mode 100644 index 0000000000..1f56c3d73b --- /dev/null +++ b/sandbox/sebastien/java/shell/itest/endpoints/src/test/resources/helloworld.composite @@ -0,0 +1,116 @@ +<?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:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="HelloWorldComposite">
+
+ <component name="JSONPComponent1">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp />
+ </service>
+ </component>
+
+ <component name="JSONPComponent2">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp name="jsonp2"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent3">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp uri="jsonp3"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent4">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp uri="/jsonp4"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent5">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp name="jsonp5a" uri="/jsonp5b"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent6">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp name="jsonp6a" uri="jsonp6b"/>
+ </service>
+ </component>
+
+ <component name="RMIComponent6">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.rmi name="rmi6a" uri="rmi6b"/>
+ </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" >
+ <binding.ws name="ws6a" uri="ws6b"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/shell/itest/endpoints/src/test/resources/nested.composite b/sandbox/sebastien/java/shell/itest/endpoints/src/test/resources/nested.composite new file mode 100644 index 0000000000..138020eab0 --- /dev/null +++ b/sandbox/sebastien/java/shell/itest/endpoints/src/test/resources/nested.composite @@ -0,0 +1,30 @@ +<?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:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:itest="http://itest"
+ targetNamespace="http://itest"
+ name="NestedComposite">
+
+ <component name="NestedComponent1">
+ <implementation.composite name="itest:HelloWorldComposite"/>
+ </component>
+
+</composite>
|