From 8c7f53c15bf5b2dc64d96e1bee8b1f8cc632d48a Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 9 Sep 2008 22:24:55 +0000 Subject: Use bundle.getResources to discover services Run the test case within OSGi git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@693637 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/hello/HelloWorldClient.java | 50 ++++++++++++++++++++++ .../src/test/java/hello/HelloWorldImpl.java | 2 +- .../equinox/launcher/NodeLauncherTestCase.java | 7 --- .../src/test/resources/HelloWorld.composite | 8 +++- 4 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java (limited to 'java/sca/modules/node-launcher-equinox/src/test') 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"> - + - + + + + + -- cgit v1.2.3