From fd63d9f0d320bf6cace9c47b5fec7a407497a743 Mon Sep 17 00:00:00 2001 From: antelder Date: Sun, 6 Feb 2011 10:01:25 +0000 Subject: Update the getting started contribution to ues the contribution cretaed from the Tuscany contribution-jar Maven archetype git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1067625 13f79535-47bb-0310-9956-ffa450edef68 --- .../getting-started/helloworld-contribution/README | 41 ++++++- .../helloworld-contribution/pom.xml | 131 +++++++++++++-------- .../src/main/java/sample/HelloworldImpl.java | 1 - .../main/resources/META-INF/sca-contribution.xml | 5 +- .../src/main/resources/helloworld.composite | 2 +- .../src/main/resources/helloworldws.composite | 32 ----- .../src/test/java/sample/HelloworldTestCase.java | 40 +++---- 7 files changed, 138 insertions(+), 114 deletions(-) delete mode 100644 sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite (limited to 'sca-java-2.x') diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README index ed0f1d0ce4..34c4b3a788 100644 --- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README +++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README @@ -1,7 +1,36 @@ -The README in the /samples directory provides -general instructions about building and running samples. (where -distribution-unpack-dir is the directory in which you unpacked the tuscany -binary distribution archive). Take a look there first (noting at you read it that this sample -is not a new style sample). +Tuscany - Getting Started - Helloworld Sample +--------------------------------------------- + +This sample demonstrates a simple helloworld style SCA application and how to run that with Tuscany. + +See the README in the top-level samples folder for general information on the Tuscany samples. + +This project creates a jar format SCA contribution which has a deployable SCA composite. The composite +defines a single component named "HelloworldComponent" which implements a Helloworld service which +is implemented by a Java class. A JUnit testcase tests running the composite and invoking the service. + +You can use the contribution built in the Tuscany Shell - at the root of a Tuscany binary distribution +run the following command: + + bin\tuscany.bat samples\getting-started\helloworld-contribution + +You may then call the helloworld service with the shell command: + + invoke HelloworldComponent sayHello "your name" + + +--- + +This sample was created by the Tuscany contribution-jar Maven archetype. You can use that archetype to +create you own SCA contribution projects by running the following maven command: + + mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org + +at the prompt select 1 to choose the contribution-jar archetype and then answer the questions. This project +used the following answers: + + Define value for property 'groupId': : org.apache.tuscany.sca.samples + Define value for property 'artifactId': : helloworld-contribution + Define value for property 'version': 1.0-SNAPSHOT: 2.0-SNAPSHOT + Define value for property 'package': org.apache.tuscany.sca.samples: sample -TODO - finish this \ No newline at end of file diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml index d0f522d96b..5ecc7a8831 100644 --- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml +++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml @@ -1,57 +1,86 @@ - - 4.0.0 - - org.apache.tuscany.sca - tuscany-samples - 2.0-SNAPSHOT - ../../pom.xml - - - jar - sample-helloworld-contribution - Apache Tuscany SCA Samples - Getting Started - helloworld-contribution - - - - org.apache.tuscany.sca - tuscany-base-runtime - 2.0-SNAPSHOT - - - junit - junit - 4.8.1 - test - - - - - ${project.artifactId} - + + 4.0.0 + + org.apache.tuscany.sca.samples + helloworld-contribution + 2.0-SNAPSHOT + jar + + helloworld-contribution + + + 2.0-SNAPSHOT + UTF-8 + + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} + provided + + + + junit + junit + 4.8.1 + test + + + + org.apache.tuscany.sca + tuscany-base-runtime + ${tuscany.version} + test + + + + + + install + helloworld-contribution + + - org.apache.tuscany.maven.plugins - maven-tuscany-plugin - 2.0-SNAPSHOT + org.apache.tuscany.maven.plugins + maven-tuscany-plugin + ${tuscany.version} - - + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + true + true + + + + + + diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java index aa563cbdf3..3b86c10df0 100644 --- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java +++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java @@ -26,7 +26,6 @@ import org.oasisopen.sca.annotation.EagerInit; public class HelloworldImpl implements Helloworld { public String sayHello(String name) { - System.out.println("HelloworldImpl.sayHello " + name); return "Hello " + name; } diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml index 61053aa92e..95c32fb5bf 100644 --- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml +++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -19,8 +19,7 @@ --> - - - + + diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite index 324395c246..e0206cd6e8 100644 --- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite +++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite @@ -20,7 +20,7 @@ + name="helloworld-contribution"> diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite deleted file mode 100644 index abefee7360..0000000000 --- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java index ded7418469..be27aa68ef 100644 --- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java +++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java @@ -18,31 +18,31 @@ */ package sample; -import static org.junit.Assert.assertEquals; +import org.junit.Assert; -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; +import org.apache.tuscany.sca.TuscanyRuntime; import org.junit.Test; +import org.oasisopen.sca.NoSuchServiceException; public class HelloworldTestCase { @Test - public void testSayHello() { - // Start up the Tuscany runtime with this modules as the contribution - Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "target/classes")); - node.start(); - - // This contribution is configured to deploy the helloworld.composite file - // automatically. This defines the HelloworldComponent. Get a local proxy to it - // and call the sayHello service operation. - Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent"); - String response = helloworld.sayHello("Petra"); - System.out.println("Response from helloworld.sayHello(\"Petra\") = " + response); - assertEquals("Hello Petra", response); - - // Stop the Tuscany runtime - node.stop(); - } + public void testSayHello() throws NoSuchServiceException { + // Run the SCA composite in a Tuscany runtime + Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes"); + try { + + // Get the Helloworld service proxy + Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent"); + + // test that it works as expected + Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia")); + + } finally { + // Stop the Tuscany runtime Node + node.stop(); + } + } } -- cgit v1.2.3