From 4ae28cf6a61b90e4bfaed80aac2a8705e24b2e0a Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 15 Sep 2011 13:37:28 +0000 Subject: Add a test case to show that reference/target gets the right ws binding configuration when the target service binding is configured via a WSDL element. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1171094 13f79535-47bb-0310-9956-ffa450edef68 --- .../itest/ws/contribution-reference-target/pom.xml | 137 +++++++++++++++++++++ .../apache/tuscany/sca/binding/ws/HelloWorld.java | 37 ++++++ .../tuscany/sca/binding/ws/HelloWorldImpl.java | 59 +++++++++ .../sca/binding/ws/HelloWorldInternalImpl.java | 60 +++++++++ .../src/main/resources/HelloWorldImplService.wsdl | 131 ++++++++++++++++++++ .../resources/HelloWorldImplService_schema1.xsd | 99 +++++++++++++++ .../resources/HelloWorldImplService_schema2.xsd | 40 ++++++ .../resources/HelloWorldServiceService_schema1.xsd | 86 +++++++++++++ .../main/resources/META-INF/sca-contribution.xml | 23 ++++ .../resources/helloworld-external-service.wsdl | 99 +++++++++++++++ .../src/main/resources/helloworld.composite | 43 +++++++ .../ws/launcher/axis2/ReferenceTargetTestCase.java | 130 +++++++++++++++++++ sca-java-2.x/trunk/testing/itest/ws/pom.xml | 1 + 13 files changed, 945 insertions(+) create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/pom.xml create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldInternalImpl.java create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService.wsdl create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema1.xsd create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema2.xsd create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldServiceService_schema1.xsd create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld-external-service.wsdl create mode 100644 sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld.composite create mode 100644 sca-java-2.x/trunk/testing/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/ReferenceTargetTestCase.java (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/pom.xml b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/pom.xml new file mode 100644 index 0000000000..adadc42870 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/pom.xml @@ -0,0 +1,137 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-ws + 2.0-SNAPSHOT + ../pom.xml + + + itest-ws-contribution-reference-target + Apache Tuscany SCA iTest WS Contribution Reference Target + + + + + org.apache.tuscany.sca + tuscany-base-runtime-pom + pom + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-runtime-axis2 + 2.0-SNAPSHOT + + + + org.mortbay.jetty + jetty + 6.1.19 + + + + + + ${project.artifactId} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-source + generate-sources + + add-test-source + + + + target/jaxws-source + + + + + + + org.codehaus.mojo + jaxws-maven-plugin + 1.10 + + + + javax.jws + jsr181-api + 1.0-MR1 + + + javax.annotation + jsr250-api + 1.0 + + + + + + wsimport2 + process-resources + + wsimport + + + org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface + ${basedir}/target/classes + + helloworld-external-service.wsdl + + ${project.build.directory}/jaxws/stale/.wsimport2StaleFlag + + + + + 2.1 + ${project.build.directory}/jaxws-source + true + true + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java new file mode 100644 index 0000000000..c9c1038ea3 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java @@ -0,0 +1,37 @@ +/* + * 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; + +import javax.jws.WebMethod; + +import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo; +import org.oasisopen.sca.ServiceRuntimeException; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface HelloWorld { + + String getGreetings(String s); + String getGreetingsException(String s) throws ServiceRuntimeException; + Foo getGreetingsComplex(Foo foo); + + @WebMethod(operationName = "GetGreetingsCaps") + String getGreetingsCaps(String s); +} diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java new file mode 100644 index 0000000000..d5aeee0b59 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java @@ -0,0 +1,59 @@ +/* + * 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; + +import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo; +import org.oasisopen.sca.ServiceRuntimeException; +import org.oasisopen.sca.annotation.Reference; + +public class HelloWorldImpl implements HelloWorld { + + @Reference + public HelloWorld helloWorldInternal; + + public String getGreetings(String s) { + System.out.println("Entering SCA HelloWorld.getGreetings: " + s); + String response = helloWorldInternal.getGreetings(s); + System.out.println("Leaving SCA HelloWorld.getGreetings: " + response); + return response; + } + + public String getGreetingsException(String s) throws ServiceRuntimeException { + System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s); + String response = helloWorldInternal.getGreetings(s); + System.out.println("Leaving SCA HelloWorld.getGreetings: " + response); + throw new ServiceRuntimeException(response); + } + + public Foo getGreetingsComplex(Foo foo){ + System.out.println("Entering SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS()); + Foo response = helloWorldInternal.getGreetingsComplex(foo); + System.out.println("Leaving SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS()); + return response; + } + + public String getGreetingsCaps(String s) { + System.out.println("Entering SCA HelloWorld.getGreetingsCaps: " + s); + String response = helloWorldInternal.getGreetingsCaps(s); + System.out.println("Leaving SCA HelloWorld.getGreetingsCaps: " + response); + return response; + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldInternalImpl.java b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldInternalImpl.java new file mode 100644 index 0000000000..c2d5f96afb --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldInternalImpl.java @@ -0,0 +1,60 @@ +/* + * 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; + +import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo; +import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService; +import org.oasisopen.sca.ServiceRuntimeException; +import org.oasisopen.sca.annotation.Reference; + +public class HelloWorldInternalImpl implements HelloWorld { + + @Reference + public HelloWorldService helloWorldExternal; + + public String getGreetings(String s) { + System.out.println("Entering SCA HelloWorldInternal.getGreetings: " + s); + String response = helloWorldExternal.getGreetings(s); + System.out.println("Leaving SCA HelloWorldInternal.getGreetings: " + response); + return response; + } + + public String getGreetingsException(String s) throws ServiceRuntimeException { + System.out.println("Entering SCA HelloWorldInternal.getGreetingsException: " + s); + String response = helloWorldExternal.getGreetings(s); + System.out.println("Leaving SCA HelloWorldInternal.getGreetings: " + response); + throw new ServiceRuntimeException(response); + } + + public Foo getGreetingsComplex(Foo foo){ + System.out.println("Entering SCA HelloWorldInternal.getGreetingsComplex: " + foo.getBars().get(0).getS()); + Foo response = helloWorldExternal.getGreetingsComplex(foo); + System.out.println("Leaving SCA HelloWorldInternal.getGreetingsComplex: " + foo.getBars().get(0).getS()); + return response; + } + + public String getGreetingsCaps(String s) { + System.out.println("Entering SCA HelloWorldInternal.getGreetingsCaps: " + s); + String response = helloWorldExternal.getGreetingsCaps(s); + System.out.println("Leaving SCA HelloWorldInternal.getGreetingsCaps: " + response); + return response; + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService.wsdl b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService.wsdl new file mode 100644 index 0000000000..95c9386133 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService.wsdl @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema1.xsd b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema1.xsd new file mode 100644 index 0000000000..2d8adf3d73 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema1.xsd @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema2.xsd b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema2.xsd new file mode 100644 index 0000000000..d955cc2af4 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldImplService_schema2.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldServiceService_schema1.xsd b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldServiceService_schema1.xsd new file mode 100644 index 0000000000..467eeb90c5 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/HelloWorldServiceService_schema1.xsd @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..350ad6be96 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld-external-service.wsdl b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld-external-service.wsdl new file mode 100644 index 0000000000..c38f629e4f --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld-external-service.wsdl @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld.composite b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..f432d4fc25 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/contribution-reference-target/src/main/resources/helloworld.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/ReferenceTargetTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/ReferenceTargetTestCase.java new file mode 100644 index 0000000000..98b7741ab6 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/ReferenceTargetTestCase.java @@ -0,0 +1,130 @@ +/* + * 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.launcher.axis2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import junit.framework.TestCase; + +import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher; +import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher; +import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar; +import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +public class ReferenceTargetTestCase extends TestCase { + + private Node node; + private HelloWorldServiceLauncher externalService; + private HelloWorldClientLauncher externalClient; + + @Before + public void setUp() throws Exception { + // Start the external service + externalService = new HelloWorldServiceLauncher(); + externalService.createService(); + + // Start the SCA contribution + node = NodeFactory.newInstance().createNode(new Contribution("reference-target", "../contribution-reference-target/target/itest-ws-contribution-reference-target.jar")); + node.start(); + + // start the external client + try { + externalClient = new HelloWorldClientLauncher(); + externalClient.createClient(); + } catch (Exception ex) { + ex.printStackTrace(); + throw ex; + } + } + +/* + @Test + public void testWait() throws Exception { + System.out.println("Press a key"); + System.in.read(); + } +*/ + + @Test + public void testGetGreetings() throws Exception { + assertEquals("Hello Fred", externalClient.getGreetings("Fred")); + } + + @Test + @Ignore + public void testGetGreetingsException() throws Exception { + try { + externalClient.getGreetingsException("Fred"); + } catch (Exception ex) { + return; + } + + fail("expecting exception"); + } + + @Test + public void testGetGreetingsComplex() throws Exception { + Foo f = new Foo(); + Bar b1 = new Bar(); + b1.setS("petra"); + b1.setX(1); + b1.setY(new Integer(2)); + b1.setB(Boolean.TRUE); + Bar b2 = new Bar(); + b2.setS("beate"); + b2.setX(3); + b2.setY(new Integer(4)); + b2.setB(Boolean.FALSE); + f.getBars().add(b1); + f.getBars().add(b2); + + Foo f2 = externalClient.getGreetingsComplex(f); + + assertEquals("petra", f2.getBars().get(0).getS()); + assertEquals(1, f2.getBars().get(0).getX()); + assertEquals(2, f2.getBars().get(0).getY().intValue()); + assertTrue(f2.getBars().get(0).isB()); + assertEquals("simon", f2.getBars().get(2).getS()); + assertEquals(7, f2.getBars().get(2).getX()); + assertEquals(8, f2.getBars().get(2).getY().intValue()); + assertTrue(f2.getBars().get(2).isB().booleanValue()); + } + + @Test + public void testGetGreetingsCaps() throws Exception { + assertEquals("Hello Fred", externalClient.getGreetingsCaps("Fred")); + } + + @After + public void tearDown() throws Exception { + node.stop(); + externalClient.destroyClient(); + externalService.destoryService(); + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/ws/pom.xml b/sca-java-2.x/trunk/testing/itest/ws/pom.xml index 1bd8083c05..54ad4da005 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/pom.xml +++ b/sca-java-2.x/trunk/testing/itest/ws/pom.xml @@ -55,6 +55,7 @@ contribution-doc-lit contribution-doc-lit-wrapped contribution-rpc-lit + contribution-reference-target external-client external-service launcher-axis2 -- cgit v1.2.3