summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/sca/modules/implementation-osgi/src/test/java/calculator/CalculatorServiceDSImpl.java8
-rw-r--r--java/sca/modules/implementation-osgi/src/test/java/calculator/test/CalculatorOSGiTestCase.java26
-rw-r--r--java/sca/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml2
3 files changed, 25 insertions, 11 deletions
diff --git a/java/sca/modules/implementation-osgi/src/test/java/calculator/CalculatorServiceDSImpl.java b/java/sca/modules/implementation-osgi/src/test/java/calculator/CalculatorServiceDSImpl.java
index 941dad4fb1..a4eb881792 100644
--- a/java/sca/modules/implementation-osgi/src/test/java/calculator/CalculatorServiceDSImpl.java
+++ b/java/sca/modules/implementation-osgi/src/test/java/calculator/CalculatorServiceDSImpl.java
@@ -18,6 +18,8 @@
*/
package calculator;
+import org.osgi.service.component.ComponentContext;
+
import calculator.operations.AddService;
import calculator.operations.DivideService;
import calculator.operations.MultiplyService;
@@ -36,13 +38,13 @@ public class CalculatorServiceDSImpl implements CalculatorService {
super();
}
- /*
protected void activate(ComponentContext context) {
+ System.out.println("Activating " + context);
}
-
+
protected void deactivate(ComponentContext context) {
+ System.out.println("Deactivating " + context);
}
- */
/*
* The following setters can be used for DS injection
diff --git a/java/sca/modules/implementation-osgi/src/test/java/calculator/test/CalculatorOSGiTestCase.java b/java/sca/modules/implementation-osgi/src/test/java/calculator/test/CalculatorOSGiTestCase.java
index ef50c22011..47bc927181 100644
--- a/java/sca/modules/implementation-osgi/src/test/java/calculator/test/CalculatorOSGiTestCase.java
+++ b/java/sca/modules/implementation-osgi/src/test/java/calculator/test/CalculatorOSGiTestCase.java
@@ -60,13 +60,24 @@ public class CalculatorOSGiTestCase {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
Set<URL> bundles = new HashSet<URL>();
- bundles.add(OSGiTestBundles
- .createBundle("target/test-classes/calculator-bundle.jar",
- "calculator/META-INF/MANIFEST.MF",
- new String[] {"OSGI-INF/calculator-component.xml"},
- CalculatorService.class,
- CalculatorServiceImpl.class,
- CalculatorActivator.class));
+
+ URL url =
+ CalculatorOSGiTestCase.class.getClassLoader()
+ .getResource("org/osgi/service/component/ComponentContext.class");
+ if (url != null) {
+ String path = url.getPath();
+ int index = path.lastIndexOf('!');
+ path = path.substring(0, index);
+ url = new URL(path);
+ bundles.add(url);
+ }
+
+ bundles.add(OSGiTestBundles.createBundle("target/test-classes/calculator-bundle.jar",
+ "calculator/META-INF/MANIFEST.MF",
+ new String[] {"OSGI-INF/calculator-component.xml"},
+ CalculatorService.class,
+ CalculatorServiceImpl.class,
+ CalculatorActivator.class));
bundles.add(OSGiTestBundles.createBundle("target/test-classes/operations-bundle.jar",
"calculator/operations/META-INF/MANIFEST.MF",
@@ -87,6 +98,7 @@ public class CalculatorOSGiTestCase {
host = new EquinoxHost(bundles);
BundleContext context = host.start();
for (Bundle b : context.getBundles()) {
+ System.out.println(b.getSymbolicName());
b.start();
}
ServiceReference ref = context.getServiceReference(CalculatorService.class.getName());
diff --git a/java/sca/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml b/java/sca/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml
index 52ac572a25..f02f2503d9 100644
--- a/java/sca/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml
+++ b/java/sca/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml
@@ -18,7 +18,7 @@
* under the License.
-->
<component name="CalculatorComponent" xmlns="http://www.osgi.org/xmlns/scr/v1.0.0">
- <implementation class="calculator.CalculatorServiceImpl" />
+ <implementation class="calculator.CalculatorServiceDSImpl" />
<service>
<provide interface="calculator.CalculatorService" />
</service>