bug333474 Added a new stub class for ComponentContext - it is needed for some unit tests with declarative services
diff --git a/org.eclipse.virgo.teststubs.osgi/src/main/java/org/eclipse/virgo/teststubs/osgi/service/component/StubComponentContext.java b/org.eclipse.virgo.teststubs.osgi/src/main/java/org/eclipse/virgo/teststubs/osgi/service/component/StubComponentContext.java
new file mode 100644
index 0000000..4d52657
--- /dev/null
+++ b/org.eclipse.virgo.teststubs.osgi/src/main/java/org/eclipse/virgo/teststubs/osgi/service/component/StubComponentContext.java
@@ -0,0 +1,70 @@
+
+package org.eclipse.virgo.teststubs.osgi.service.component;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.ComponentInstance;
+
+public class StubComponentContext implements ComponentContext {
+
+ public final String DEFAULT_PROP_KEY = "key";
+
+ public final String DEFAULT_PROP_VALUE = "value";
+
+ private final Dictionary<String, String> props = new Hashtable<String, String>();
+
+ private final BundleContext bundleContext;
+
+ public StubComponentContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ populateDefaultProperties();
+ }
+
+ public Dictionary<String, String> getProperties() {
+ return this.props;
+ }
+
+ private void populateDefaultProperties() {
+ this.props.put(this.DEFAULT_PROP_KEY, this.DEFAULT_PROP_VALUE);
+ }
+
+ public Object locateService(String name) {
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Object locateService(String name, ServiceReference reference) {
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public Object[] locateServices(String name) {
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public BundleContext getBundleContext() {
+ return this.bundleContext;
+ }
+
+ public Bundle getUsingBundle() {
+ return null;
+ }
+
+ public ComponentInstance getComponentInstance() {
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
+ public void enableComponent(String name) {
+ }
+
+ public void disableComponent(String name) {
+ }
+
+ public ServiceReference getServiceReference() {
+ return null;
+ }
+
+}
diff --git a/org.eclipse.virgo.teststubs.osgi/template.mf b/org.eclipse.virgo.teststubs.osgi/template.mf
index 8cc2953..ccb08f6 100644
--- a/org.eclipse.virgo.teststubs.osgi/template.mf
+++ b/org.eclipse.virgo.teststubs.osgi/template.mf
@@ -7,7 +7,8 @@
org.junit.*;version="[4.4.0, 5.0.0)",
org.osgi.framework.*;version="0",
org.osgi.service.cm;version="[1.2.0, 1.3.0)",
- org.osgi.service.event;version="[1.1.0, 1.2.0)"
+ org.osgi.service.event;version="[1.1.0, 1.2.0)",
+ org.osgi.service.component;version="0"
Import-Package:
org.aspectj.lang;version="[1.6.3.RELEASE, 2.0.0)",
org.aspectj.lang.annotation;version="[1.6.3.RELEASE, 2.0.0)",