incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r608914 [2/2] - in /incubator/sling/whiteboard/fmeschbe/resource/osgi/commons: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sling/ src/main/java/org/apache/sling/osgi/ src/main/java/...
Date Fri, 04 Jan 2008 16:41:10 GMT
Added: incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockComponentContext.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockComponentContext.java?rev=608914&view=auto
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockComponentContext.java
(added)
+++ incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockComponentContext.java
Fri Jan  4 08:41:06 2008
@@ -0,0 +1,79 @@
+/*
+ * 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 org.apache.sling.osgi.commons.mock;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.osgi.commons.AdapterFactory;
+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 MockComponentContext implements ComponentContext {
+
+    private Map<ServiceReference, AdapterFactory> services = new HashMap<ServiceReference,
AdapterFactory>();
+
+    public Object locateService(String name, ServiceReference reference) {
+        AdapterFactory af = services.get(reference);
+        if (af == null) {
+            af = new MockAdapterFactory();
+            services.put(reference, af);
+        }
+        return af;
+    }
+
+    public void disableComponent(String name) {
+    }
+
+    public void enableComponent(String name) {
+    }
+
+    public BundleContext getBundleContext() {
+        return null;
+    }
+
+    public ComponentInstance getComponentInstance() {
+        return null;
+    }
+
+    public Dictionary<?, ?> getProperties() {
+        return null;
+    }
+
+    public ServiceReference getServiceReference() {
+        return null;
+    }
+
+    public Bundle getUsingBundle() {
+        return null;
+    }
+
+    public Object locateService(String name) {
+        return null;
+    }
+
+    public Object[] locateServices(String name) {
+        return null;
+    }
+
+}

Propchange: incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockComponentContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockServiceReference.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockServiceReference.java?rev=608914&view=auto
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockServiceReference.java
(added)
+++ incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockServiceReference.java
Fri Jan  4 08:41:06 2008
@@ -0,0 +1,62 @@
+/*
+ * 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 org.apache.sling.osgi.commons.mock;
+
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+public class MockServiceReference implements ServiceReference {
+
+    private Bundle bundle;
+    private Dictionary<String, Object> props;
+
+    public MockServiceReference(Bundle bundle) {
+        this.bundle = bundle;
+        this.props = new Hashtable<String, Object>();
+    }
+
+    public Bundle getBundle() {
+        return bundle;
+    }
+
+    public void setProperty(String key, Object value) {
+        props.put(key, value);
+    }
+
+    public Object getProperty(String key) {
+        return props.get(key);
+    }
+
+    public String[] getPropertyKeys() {
+        return Collections.list(props.keys()).toArray(new String[props.size()]);
+    }
+
+    public Bundle[] getUsingBundles() {
+        return null;
+    }
+
+    public boolean isAssignableTo(Bundle bundle, String className) {
+        return false;
+    }
+
+}

Propchange: incubator/sling/whiteboard/fmeschbe/resource/osgi/commons/src/test/java/org/apache/sling/osgi/commons/mock/MockServiceReference.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message