This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag 
org.apache.sling.testing.osgi-mock-1.3.0
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit bd78f8a7c3e20bafd999c63803b9b94f7896a137
Author: Stefan Seifert <[email protected]>
AuthorDate: Tue May 19 08:40:54 2015 +0000

    SLING-4725 osgi-mock: Make compatible to OSGi 5/6
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1680202 
13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 20 ++++++++++++
 .../apache/sling/testing/mock/osgi/MockBundle.java | 30 +++++++++++++----
 .../sling/testing/mock/osgi/MockBundleContext.java | 38 +++++++++++++++++++++-
 .../apache/sling/testing/mock/osgi/MockFilter.java |  6 ++++
 .../testing/mock/osgi/MockEventAdminTest.java      |  7 ++--
 5 files changed, 91 insertions(+), 10 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4d2ec30..82988cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,5 +130,25 @@
     
         </plugins>
     </build>
+    
+    <profiles>
+      <profile>
+        <id>osgi-6</id>
+        <dependencies>
+          <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>6.0.0</version>
+            <scope>provided</scope>
+          </dependency>
+          <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>5.0.0</version>
+            <scope>provided</scope>
+          </dependency>
+        </dependencies>
+      </profile>
+    </profiles>
   
 </project>
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
index 6c1f22e..468beaf 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
@@ -18,10 +18,13 @@
  */
 package org.apache.sling.testing.mock.osgi;
 
+import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
+import java.security.cert.X509Certificate;
 import java.util.Dictionary;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Map;
 
 import org.osgi.framework.Bundle;
@@ -70,22 +73,22 @@ class MockBundle implements Bundle {
 
     // --- unsupported operations ---
     @Override
-    public Enumeration<?> findEntries(final String path, final String 
filePattern, final boolean recurse) {
+    public Enumeration<URL> findEntries(final String path, final String 
filePattern, final boolean recurse) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public Enumeration<?> getEntryPaths(final String path) {
+    public Enumeration<String> getEntryPaths(final String path) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public Dictionary<?, ?> getHeaders() {
+    public Dictionary<String, String> getHeaders() {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public Dictionary<?, ?> getHeaders(final String locale) {
+    public Dictionary<String, String> getHeaders(final String locale) {
         throw new UnsupportedOperationException();
     }
 
@@ -110,7 +113,7 @@ class MockBundle implements Bundle {
     }
 
     @Override
-    public Enumeration<?> getResources(final String name) {
+    public Enumeration<URL> getResources(final String name) {
         throw new UnsupportedOperationException();
     }
 
@@ -170,7 +173,7 @@ class MockBundle implements Bundle {
     }
 
     // this is part of org.osgi 4.2.0
-    public Map getSignerCertificates(final int signersType) {
+    public Map<X509Certificate, List<X509Certificate>> 
getSignerCertificates(final int signersType) {
         throw new UnsupportedOperationException();
     }
 
@@ -179,4 +182,19 @@ class MockBundle implements Bundle {
         throw new UnsupportedOperationException();
     }
 
+    // this is part of org.osgi.core 6.0.0
+    public int compareTo(Bundle o) {
+        throw new UnsupportedOperationException();
+    }
+
+    // this is part of org.osgi.core 6.0.0
+    public <A> A adapt(Class<A> type) {
+        throw new UnsupportedOperationException();
+    }
+
+    // this is part of org.osgi.core 6.0.0
+    public File getDataFile(String filename) {
+        throw new UnsupportedOperationException();
+    }
+
 }
diff --git 
a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
index eea03d1..8be9673 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.mock.osgi;
 import java.io.File;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Dictionary;
 import java.util.List;
 import java.util.Set;
@@ -38,10 +39,13 @@ import org.osgi.framework.BundleListener;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
+import com.google.common.collect.ImmutableList;
+
 /**
  * Mock {@link BundleContext} implementation.
  */
@@ -78,6 +82,11 @@ class MockBundleContext implements BundleContext {
         return registerService(clazzes, service, properties);
     }
 
+    // this is part of org.osgi.core 6.0.0
+    public <S> ServiceRegistration registerService(Class<S> clazz, S service, 
Dictionary<String, ?> properties) {
+        return registerService(clazz.getName(), service, properties);
+    }
+
     @SuppressWarnings("unchecked")
     @Override
     public ServiceRegistration registerService(final String[] clazzes, final 
Object service, final Dictionary properties) {
@@ -157,6 +166,11 @@ class MockBundleContext implements BundleContext {
         }
     }
 
+    // this is part of org.osgi.core 6.0.0
+    public ServiceReference getServiceReference(Class clazz) {
+        return getServiceReference(clazz.getName());
+    }
+
     @Override
     public ServiceReference[] getServiceReferences(final String clazz, final 
String filter) {
         Set<ServiceReference> result = new TreeSet<ServiceReference>();
@@ -172,6 +186,11 @@ class MockBundleContext implements BundleContext {
         }
     }
 
+    // this is part of org.osgi.core 6.0.0
+    public Collection<ServiceReference> getServiceReferences(Class clazz, 
String filter) {
+        return 
ImmutableList.<ServiceReference>copyOf(getServiceReferences(clazz.getName(), 
filter));
+    }
+
     @Override
     public ServiceReference[] getAllServiceReferences(final String clazz, 
final String filter) {
         // for now just do the same as getServiceReferences
@@ -180,7 +199,7 @@ class MockBundleContext implements BundleContext {
 
     @Override
     public Object getService(final ServiceReference serviceReference) {
-        return ((MockServiceReference) serviceReference).getService();
+        return ((MockServiceReference)serviceReference).getService();
     }
 
     @Override
@@ -282,4 +301,21 @@ class MockBundleContext implements BundleContext {
         throw new UnsupportedOperationException();
     }
 
+    // this is part of org.osgi.core 6.0.0
+    public Bundle getBundle(String location) {
+        throw new UnsupportedOperationException();
+    }
+
+    // this is part of org.osgi.core 6.0.0
+    public <S> ServiceRegistration registerService(Class<S> clazz, 
ServiceFactory factory, Dictionary<String, ?> properties) {
+        throw new UnsupportedOperationException();
+    }
+
+    // this is part of org.osgi.core 6.0.0
+    /* class org.osgi.framework.ServiceObjects does not exist in older OSGi 
versions
+    public ServiceObjects getServiceObjects(ServiceReference reference) {
+        throw new UnsupportedOperationException();
+    }
+    */
+
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockFilter.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockFilter.java
index b0f585c..d8a3ec1 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockFilter.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockFilter.java
@@ -19,6 +19,7 @@
 package org.apache.sling.testing.mock.osgi;
 
 import java.util.Dictionary;
+import java.util.Map;
 
 import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
@@ -43,4 +44,9 @@ class MockFilter implements Filter {
         return false;
     }
 
+    // this is part of org.osgi.core 6.0.0
+    public boolean matches(Map<String, ?> map) {
+        return false;
+    }
+
 }
diff --git 
a/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java 
b/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
index fa3f675..795c656 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.mock.osgi;
 import static org.junit.Assert.assertEquals;
 
 import java.util.ArrayList;
+import java.util.Dictionary;
 import java.util.List;
 
 import org.apache.commons.lang3.ObjectUtils;
@@ -43,9 +44,9 @@ public class MockEventAdminTest {
     private static final String TOPIC_SAMPLE_ALL = "sample/*";
     private static final String TOPIC_OTHER_3 = "other/topic3";
     
-    private static final Event EVENT_SAMPLE_1 = new Event(TOPIC_SAMPLE_1, 
null);
-    private static final Event EVENT_SAMPLE_2 = new Event(TOPIC_SAMPLE_2, 
null);
-    private static final Event EVENT_OTHER_3 = new Event(TOPIC_OTHER_3, null);
+    private static final Event EVENT_SAMPLE_1 = new Event(TOPIC_SAMPLE_1, 
(Dictionary<String,?>)null);
+    private static final Event EVENT_SAMPLE_2 = new Event(TOPIC_SAMPLE_2, 
(Dictionary<String,?>)null);
+    private static final Event EVENT_OTHER_3 = new Event(TOPIC_OTHER_3, 
(Dictionary<String,?>)null);
     
     @Rule
     public OsgiContext context = new OsgiContext();

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to