summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src')
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java1
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml5
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite2
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite32
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java40
5 files changed, 23 insertions, 57 deletions
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 @@
-->
<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:sample="http://sample">
-
- <deployable composite="sample:helloworld"/>
- <deployable composite="sample:helloworldws"/>
+
+ <deployable composite="sample:helloworld-contribution" />
</contribution>
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 @@
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://sample"
- name="helloworld">
+ name="helloworld-contribution">
<component name="HelloworldComponent">
<implementation.java class="sample.HelloworldImpl"/>
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 @@
-<?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://sample"
- name="helloworldws">
-
- <component name="HelloworldWSComponent">
- <implementation.java class="sample.HelloworldImpl"/>
- <service name="Helloworld">
- <binding.ws />
- </service>
- </component>
-
-</composite>
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();
+ }
+ }
}