summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/samples/launcher-embedded-jse
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-05-14 14:52:13 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-05-14 14:52:13 +0000
commit93ee28a97432d9448fa793cf47ff71f33186ae3b (patch)
tree58b7493d84417d30423cf938eedb16dc70df8059 /sca-java-2.x/trunk/samples/launcher-embedded-jse
parent7ea174b274f7e92d0ea46dfa8a689d96f0583b42 (diff)
Launch binding-sca and binding-ws based contributions.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@944300 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/samples/launcher-embedded-jse')
-rw-r--r--sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml18
-rw-r--r--sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java45
-rw-r--r--sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java13
3 files changed, 51 insertions, 25 deletions
diff --git a/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml b/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
index 1b67df3b7e..74f613109f 100644
--- a/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
+++ b/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
@@ -54,7 +54,7 @@
<echo>Please use 'ant run-name-of-sample-contribution-to-run' </echo>
</target>
- <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
<java classname="${main.class}"
fork="true"
failonerror="true">
@@ -64,8 +64,22 @@
<include name="tuscany-sca-manifest.jar" />
</fileset>
</classpath>
- <arg value="contribution-binding-ws-calculator"/>
+ <arg value="contribution-binding-sca-calculator"/>
</java>
</target>
+
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-ws-calculator"/>
+ </java>
+ </target>
</project>
diff --git a/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java b/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
index 7249e92f43..79bd8403e6 100644
--- a/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
+++ b/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
@@ -21,8 +21,6 @@ package launcher;
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
-import org.oasisopen.sca.ServiceRuntimeException;
import calculator.CalculatorService;
@@ -31,7 +29,7 @@ import calculator.CalculatorService;
* This client program shows how to create an embedded SCA runtime, start it,
* and locate and invoke a SCA component
*/
-public class SampleJSELauncher {
+public class SampleJSELauncher extends RuntimeIntegration {
public static void main(String[] args) throws Exception {
SampleJSELauncher launcher = new SampleJSELauncher();
@@ -40,34 +38,45 @@ public class SampleJSELauncher {
if (args == null || args.length != 1){
System.out.println("Please provide the name of the sample contribution to run as a parameter");
- System.out.println("Running binding-ws-calculator by default");
- contribution = "contribution-binding-ws-calculator";
+ System.out.println("Running binding-sca-calculator by default");
+ contribution = "contribution-binding-sca-calculator";
} else {
contribution = args[0];
}
- if (contribution.equals("contribution-binding-ws-calculator")){
+ if (contribution.equals("contribution-binding-sca-calculator")){
+ launcher.launchBindingSCACalculator();
+ } else if (contribution.equals("contribution-binding-ws-calculator")){
launcher.launchBindingWSCalculator();
} else {
System.out.println("Sample contribution " + contribution + "not found");
}
-
- }
-
- public Node startNode(Contribution... contributions){
- Node node = NodeFactory.newInstance().createNode(contributions);
- node.start();
- return node;
- }
-
- public void stopNode(Node node){
- node.stop();
}
+
+ /**
+ * The contribution-binding-sca-calculator contribution includes a client component
+ * that calls the CalculatorServiceComponent from an operation marked by @Init.
+ */
+ public void launchBindingSCACalculator(){
+ Node node = startNode(new Contribution("c1", "../contribution-binding-sca-calculator/target/classes"));
+
+ //CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ //double result = calculator.add(3, 2);
+ //System.out.println("3 + 2 = " + result);
+ //if (result != 5.0){
+ // throw new SampleLauncherException();
+ //}
+ stopNode(node);
+ }
+ /*
+ * Using a Tuscany specific mechanism for getting at local service proxies
+ */
public void launchBindingWSCalculator(){
Node node = startNode(new Contribution("c1", "../contribution-binding-ws-calculator/target/classes"));
- CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
// TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
double result = calculator.add(3, 2);
System.out.println("3 + 2 = " + result);
diff --git a/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java b/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
index d0b9dab4d4..6154f9fce3 100644
--- a/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
+++ b/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
@@ -20,15 +20,18 @@ package launcher;
import org.junit.Test;
-
-
/**
- * Test the Calculator composition.
+ * Test sample contributions.
*/
public class LauncherTestCase {
@Test
- public void testSample() throws Exception {
- SampleJSELauncher.main(null);
+ public void testCOntributionBindingSCACalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-sca-calculator"});
}
+
+ @Test
+ public void testCOntributionBindingWSCalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-ws-calculator"});
+ }
}