diff options
Diffstat (limited to 'java/sca/modules/node-launcher-equinox/src/test')
4 files changed, 57 insertions, 10 deletions
diff --git a/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java new file mode 100644 index 0000000000..11e008619c --- /dev/null +++ b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java @@ -0,0 +1,50 @@ +/* + * 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 hello; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") +@EagerInit +public class HelloWorldClient { + + private HelloWorld hw; + + @Reference + public void setHelloWorld(HelloWorld hw) { + this.hw = hw; + } + + @Init + public void hello() { + // Say hello + System.out.println("Contribution ClassLoader: " + getClass().getClassLoader()); + System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader()); + System.out.println(hw.hello("Equinox")); + } + +} diff --git a/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java index c9a7560b12..e51d3c79d9 100644 --- a/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java +++ b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java @@ -24,7 +24,7 @@ package hello; */ public class HelloWorldImpl implements HelloWorld { public String hello(String name) { - System.out.println("Hello: " + name); + System.out.println("Name: " + name); return "Hello, " + name; } } diff --git a/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java b/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java index 569b82cf4c..b16045a103 100644 --- a/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java +++ b/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java @@ -19,9 +19,6 @@ package org.apache.tuscany.sca.node.equinox.launcher; -import hello.HelloWorld; - -import org.apache.tuscany.sca.node.SCAClient; import org.apache.tuscany.sca.node.SCANode; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -55,10 +52,6 @@ public class NodeLauncherTestCase { public void testLaunch() throws Exception { SCANode node = launcher.createNodeFromClassLoader("HelloWorld.composite", getClass().getClassLoader()); node.start(); - - HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld"); - hw.hello("OSGi"); - node.stop(); } diff --git a/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite b/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite index 9e3299d691..0608e70ca5 100644 --- a/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite +++ b/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite @@ -22,9 +22,13 @@ targetNamespace="http://sample/composite"
xmlns:sc="http://sample/composite"
name="HelloWorld">
-
+
<component name="HelloWorld">
- <implementation.java class="hello.HelloWorldImpl"/>
+ <implementation.java class="hello.HelloWorldImpl" />
+ </component>
+ <component name="HelloWorldClient">
+ <implementation.java class="hello.HelloWorldClient" />
+ <reference name="helloWorld" target="HelloWorld"></reference>
</component>
</composite>
|