From 3c7c4a749baafcf375f4785a7668d3a25c9063e3 Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 13 Nov 2009 01:42:27 +0000 Subject: Moving 1.x trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835700 13f79535-47bb-0310-9956-ffa450edef68 --- .../trunk/samples/helloworld-ws-service/README | 141 +++++++++++++++++++ .../trunk/samples/helloworld-ws-service/build.xml | 72 ++++++++++ .../helloworld-ws-service.png | Bin 0 -> 6531 bytes .../helloworld-ws-service.svg | 150 +++++++++++++++++++++ .../trunk/samples/helloworld-ws-service/pom.xml | 79 +++++++++++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 +++++ .../src/main/java/helloworld/HelloWorldServer.java | 46 +++++++ .../main/java/helloworld/HelloWorldService.java | 31 +++++ .../sca-deployables/helloworldws.composite | 33 +++++ .../src/main/resources/wsdl/helloworld.wsdl | 79 +++++++++++ .../java/helloworld/HelloWorldServerTestCase.java | 62 +++++++++ 11 files changed, 726 insertions(+) create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/README create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/build.xml create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.png create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.svg create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/pom.xml create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/trunk/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java (limited to 'sca-java-1.x/trunk/samples/helloworld-ws-service') diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/README b/sca-java-1.x/trunk/samples/helloworld-ws-service/README new file mode 100644 index 0000000000..44dc7ab4e8 --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/README @@ -0,0 +1,141 @@ +Hello World Web Service Service Sample +====================================== +This sample demonstrates an SCA service that uses a web service binding. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-service.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service.jar helloworld.HelloWorldServer + +Now the server is started you can use the helloworld-ws-reference sample to +exercise it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +web service binding. + +helloworld-ws-service/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldImpl.java - component implementation + HelloWorldServer.java - starts the SCA Runtime and + deploys the helloworldws + .composite and then waits for the + service to be called via web services + resources/ + wsdl/ + helloworld.wsdl - the service description that describes + the exposed service + helloworldws.composite - the SCA assembly for this sample + test/ + java/ + helloworld/ + HelloWorldServerTestCase.java - JUnit test case + helloworld-ws-service.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant using the +following commands + +cd helloworld-ws-service +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 14-Jan-2008 14:18:47 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService + [java] HelloWorld server started (press enter to shutdown) + +As this point the SCA service is exposed as a web service by a web server +started automatically by the SCA runtime. To stop the server just press +enter. + +To exercise the service run up the helloworld-ws-reference sample. Take a look at +the README in that sample and you will see you need the following commands + +cd helloworld-ws-reference +ant run + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. When using Maven you don't need to run the helloworld- +ws-reference sample as Maven includes a simple ping test to make sure that the +service is available + +cd helloworld-ws-service +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldServerTestCase +14-Jan-2008 14:19:57 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:19:57 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:19:57 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:57 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:57 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +14-Jan-2008 14:19:57 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:58 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:19:58 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:19:58 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:58 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:58 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +14-Jan-2008 14:19:59 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.75 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/build.xml b/sca-java-1.x/trunk/samples/helloworld-ws-service/build.xml new file mode 100644 index 0000000000..46678febc3 --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.png b/sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.png new file mode 100644 index 0000000000..eab29d0bcd Binary files /dev/null and b/sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.png differ diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.svg b/sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.svg new file mode 100644 index 0000000000..61cd93ead9 --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/helloworld-ws-service.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/pom.xml b/sca-java-1.x/trunk/samples/helloworld-ws-service/pom.xml new file mode 100644 index 0000000000..97b8ff27ab --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-service + Apache Tuscany SCA Sample HelloWorld Web Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0de3c70303 --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,33 @@ +/* + * 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.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldImpl implements HelloWorldService { + + public String getGreetings(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..c37bfcda65 --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java @@ -0,0 +1,46 @@ +/* + * 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 java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This server program shows how to create an SCA runtime, and start it which + * activates the helloworld Web service endpoint. + */ +public class HelloWorldServer { + + public static void main(String[] args) { + + SCADomain scaDomain = SCADomain.newInstance("META-INF/sca-deployables/helloworldws.composite"); + + try { + System.out.println("HelloWorld server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + System.out.println("HelloWorld server stopped"); + } + +} diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..7245513b2a --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,31 @@ +/* + * 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.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); +} + diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite new file mode 100644 index 0000000000..d767625ae7 --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..454763410c --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java new file mode 100644 index 0000000000..189332be91 --- /dev/null +++ b/sca-java-1.x/trunk/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java @@ -0,0 +1,62 @@ +/* + * 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 static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests that the helloworld server is available + */ +public class HelloWorldServerTestCase{ + + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + scaDomain = SCADomain.newInstance("META-INF/sca-deployables/helloworldws.composite"); + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @Test + public void testServiceCall() throws IOException { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService"); + assertNotNull(helloWorldService); + + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + } + + @After + public void stopServer() throws Exception { + scaDomain.close(); + } + +} -- cgit v1.2.3