Merge pull request #11 from apache/bugfix/SLING-10922

SLING-10922 don't consider DS metadata/CA for plain OSGi service
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
index ed69b3d..3d4a2fc 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
@@ -122,8 +122,7 @@
     @SuppressWarnings("unchecked")
     @Override
     public ServiceRegistration registerService(final String[] clazzes, final Object service, final Dictionary properties) {
-        Dictionary<String, Object> mergedPropertes = MapMergeUtil.propertiesMergeWithOsgiMetadata(service.getClass(), configAdmin, properties);
-        MockServiceRegistration<?> registration = new MockServiceRegistration<>(this.bundle, clazzes, service, mergedPropertes, this);
+        MockServiceRegistration<?> registration = new MockServiceRegistration<>(this.bundle, clazzes, service, properties, this);
         this.registeredServices.add(registration);
         handleRefsUpdateOnRegister(registration, this);
         notifyServiceListeners(ServiceEvent.REGISTERED, registration.getReference());
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
index 5ffdf83..089b9cd 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
@@ -26,6 +26,7 @@
 import java.util.Dictionary;
 import java.util.Map;
 
+import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.OsgiMetadata;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.osgi.framework.BundleContext;
@@ -139,7 +140,7 @@
     }
 
     /**
-     * Simulate OSGi DS dependency injection. Injects direct references and multiple references.
+     * Simulates OSGi DS dependency injection. Injects direct references and multiple references.
      * If a some references could not be injected no error is thrown.
      * @param target Service instance
      * @param bundleContext Bundle context from which services are fetched to inject.
@@ -150,7 +151,7 @@
     }
 
     /**
-     * Simulate OSGi DS dependency injection. Injects direct references and multiple references.
+     * Simulates OSGi DS dependency injection. Injects direct references and multiple references.
      * If a some references could not be injected no error is thrown.
      * @param target Service instance
      * @param bundleContext Bundle context from which services are fetched to inject.
@@ -162,7 +163,7 @@
     }
 
     /**
-     * Simulate OSGi DS dependency injection and activation. Injects direct references and multiple references.
+     * Simulates OSGi DS dependency injection and activation. Injects direct references and multiple references.
      * If a some references could not be injected no error is thrown.
      * This method instantiates the service instance and also supports constructor injection.
      * @param targetClass Component/service class
@@ -175,7 +176,7 @@
     }
 
     /**
-     * Simulate OSGi DS dependency injection and activation. Injects direct references and multiple references.
+     * Simulates OSGi DS dependency injection and activation. Injects direct references and multiple references.
      * If a some references could not be injected no error is thrown.
      * This method instantiates the service instance and also supports constructor injection.
      * @param targetClass Component/service class
@@ -191,7 +192,7 @@
     }
 
     /**
-     * Simulate OSGi DS dependency injection and activation. Injects direct references and multiple references.
+     * Simulates OSGi DS dependency injection and activation. Injects direct references and multiple references.
      * If a some references could not be injected no error is thrown.
      * This method instantiates the service instance and also supports constructor injection.
      * @param targetClass Component/service class
@@ -200,13 +201,94 @@
      * @param <T> Target class type
      * @return Component/service instances with injected services
      */
-    public static @NotNull <T> T activateInjectServices(@NotNull Class<T> targetClass, @NotNull BundleContext bundleContext,  @NotNull Object @NotNull ... properties) {
+    public static @NotNull <T> T activateInjectServices(@NotNull Class<T> targetClass, @NotNull BundleContext bundleContext, @NotNull Object @NotNull ... properties) {
         return activateInjectServices(targetClass, bundleContext, MapUtil.toMap(properties));
     }
 
     /**
-     * Simulate activation of service instance. Invokes the @Activate annotated method.
-     * @param target Service instance.
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * @param <T> DS Component type
+     * @param component a DS component instance
+     * @param bundleContext Bundle context from which services are fetched to inject and which is used for registering new services
+     */
+    public static final @NotNull <T> void registerInjectActivateService(@NotNull final T component, @NotNull BundleContext bundleContext) {
+        registerInjectActivateService(component, bundleContext, (Map<String,Object>)null);
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * @param <T> DS Component type
+     * @param component a DS component instance
+     * @param bundleContext Bundle context from which services are fetched to inject and which is used for registering new services
+     * @param properties Service properties (optional)
+     */
+    public static final @NotNull <T> void registerInjectActivateService(@NotNull final T component, @NotNull BundleContext bundleContext, @Nullable final Map<String, Object> properties) {
+        Map<String, Object> mergedProperties = propertiesMergeWithOsgiMetadata(component.getClass(), getConfigAdmin(bundleContext), properties);
+        MockOsgi.injectServices(component, bundleContext, mergedProperties);
+        ComponentContext componentContext = newComponentContext(bundleContext, mergedProperties);
+        OsgiServiceUtil.activateDeactivate(component, (MockComponentContext)componentContext, true);
+        OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(component.getClass());
+        if (!metadata.getServiceInterfaces().isEmpty()) {
+            bundleContext.registerService(metadata.getServiceInterfaces().toArray(new String[0]), component, toDictionary(mergedProperties));
+        }
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * @param <T> DS Component type
+     * @param component a DS component instance
+     * @param bundleContext Bundle context from which services are fetched to inject and which is used for registering new services.
+     * @param properties Service properties (optional)
+     */
+    public static final @NotNull <T> void registerInjectActivateService(@NotNull final T component, @NotNull BundleContext bundleContext, @NotNull final Object @NotNull ... properties) {
+        registerInjectActivateService(component, bundleContext, MapUtil.toMap(properties));
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * @param <T> DS component type
+     * @param dsComponentClass DS component class
+     * @param bundleContext Bundle context from which services are fetched to inject and which is used for registering new services
+     * @return Registered component instance
+     */
+    public static final @NotNull <T> T registerInjectActivateService(@NotNull final Class<T> dsComponentClass, @NotNull BundleContext bundleContext) {
+        return registerInjectActivateService(dsComponentClass, bundleContext, (Map<String,Object>)null);
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * @param <T> DS component type
+     * @param dsComponentClass DS component class
+     * @param bundleContext Bundle context from which services are fetched to inject and which is used for registering new services
+     * @param properties component properties (optional)
+     * @return Registered component instance
+     */
+    public static final @NotNull <T> T registerInjectActivateService(@NotNull Class<T> dsComponentClass, @NotNull BundleContext bundleContext, @Nullable final Map<String, Object> properties) {
+        Map<String, Object> mergedProperties = propertiesMergeWithOsgiMetadata(dsComponentClass, getConfigAdmin(bundleContext), properties);
+        ComponentContext componentContext = newComponentContext(bundleContext, mergedProperties);
+        T component = OsgiServiceUtil.activateInjectServices(dsComponentClass, (MockComponentContext)componentContext);
+        OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(dsComponentClass);
+        if (!metadata.getServiceInterfaces().isEmpty()) {
+            bundleContext.registerService( metadata.getServiceInterfaces().toArray(new String[0]), component,  toDictionary(mergedProperties));
+        }
+        return component;
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * @param <T> DS component type
+     * @param dsComponentClass DS component class
+     * @param bundleContext Bundle context from which services are fetched to inject and which is used for registering new services
+     * @param properties component properties (optional)
+     * @return Registered component instance
+     */
+    public static final @NotNull <T> T registerInjectActivateService(@NotNull Class<T> dsComponentClass, @NotNull BundleContext bundleContext, @NotNull final Object @NotNull ... properties) {
+        return registerInjectActivateService(dsComponentClass, bundleContext, MapUtil.toMap(properties));
+    }
+
+    /**
+     * Simulates activation of a DS component instance. Invokes the @Activate annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @return true if activation method was called. False if no activate method is defined.
      */
@@ -215,8 +297,8 @@
     }
 
     /**
-     * Simulate activation of service instance. Invokes the @Activate annotated method.
-     * @param target Service instance.
+     * Simulates activation of a DS component instance. Invokes the @Activate annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if activation method was called. False if no activate method is defined.
@@ -228,8 +310,8 @@
     }
 
     /**
-     * Simulate activation of service instance. Invokes the @Activate annotated method.
-     * @param target Service instance.
+     * Simulates activation of a DS component instance. Invokes the @Activate annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if activation method was called. False if no activate method is defined.
@@ -239,8 +321,8 @@
     }
 
     /**
-     * Simulate activation of service instance. Invokes the @Activate annotated method.
-     * @param target Service instance.
+     * Simulates activation of a DS component instance. Invokes the @Activate annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if activation method was called. False if no activate method is defined.
@@ -250,7 +332,7 @@
     }
 
     /**
-     * Simulate deactivation of service instance. Invokes the @Deactivate annotated method.
+     * Simulates deactivation of a DS component instance. Invokes the @Deactivate annotated method.
      * @param target Service instance.
      * @param bundleContext Bundle context.
      * @return true if deactivation method was called. False if no deactivate method is defined.
@@ -260,8 +342,8 @@
     }
 
     /**
-     * Simulate deactivation of service instance. Invokes the @Deactivate annotated method.
-     * @param target Service instance.
+     * Simulates deactivation of a DS component instance. Invokes the @Deactivate annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if deactivation method was called. False if no deactivate method is defined.
@@ -273,8 +355,8 @@
     }
 
     /**
-     * Simulate activation of service instance. Invokes the @Deactivate annotated method.
-     * @param target Service instance.
+     * Simulates deactivation of a DS component instance. Invokes the @Deactivate annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if deactivation method was called. False if no deactivate method is defined.
@@ -284,8 +366,8 @@
     }
 
     /**
-     * Simulate activation of service instance. Invokes the @Deactivate annotated method.
-     * @param target Service instance.
+     * Simulates deactivation of a DS component instance. Invokes the @Deactivate annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if deactivation method was called. False if no deactivate method is defined.
@@ -295,8 +377,8 @@
     }
 
     /**
-     * Simulate configuration modification of service instance. Invokes the @Modified annotated method.
-     * @param target Service instance.
+     * Simulates configuration modification of a DS component instance. Invokes the @Modified annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if modified method was called. False if no modified method is defined.
@@ -306,8 +388,8 @@
     }
 
     /**
-     * Simulate configuration modification of service instance. Invokes the @Modified annotated method.
-     * @param target Service instance.
+     * Simulates configuration modification of a DS component instance. Invokes the @Modified annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if modified method was called. False if no modified method is defined.
@@ -319,8 +401,8 @@
     }
 
     /**
-     * Simulate configuration modification of service instance. Invokes the @Modified annotated method.
-     * @param target Service instance.
+     * Simulates configuration modification of a DS component instance. Invokes the @Modified annotated method.
+     * @param target DS component instance
      * @param bundleContext Bundle context
      * @param properties Properties
      * @return true if modified method was called. False if no modified method is defined.
@@ -372,7 +454,7 @@
     }
 
     /**
-     * Get configuration admin.
+     * Gets configuration admin.
      * @param bundleContext Bundle context
      * @return Configuration admin or null if not registered.
      */
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
index b288731..1661c85 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
@@ -133,75 +133,73 @@
     }
 
     /**
-     * Injects dependencies, activates and registers a service in the mocked OSGi environment.
-     * @param <T> Service type
-     * @param service Service instance
-     * @return Registered service instance
-     */
-    public final @NotNull <T> T registerInjectActivateService(@NotNull final T service) {
-        return registerInjectActivateService(service, (Map<String,Object>)null);
-    }
-
-    /**
-     * Injects dependencies, activates and registers a service in the mocked OSGi environment.
-     * @param <T> Service type
-     * @param service Service instance
-     * @param properties Service properties (optional)
-     * @return Registered service instance
-     */
-    public final @NotNull <T> T registerInjectActivateService(@NotNull final T service, @Nullable final Map<String, Object> properties) {
-        MockOsgi.injectServices(service, bundleContext(), properties);
-        MockOsgi.activate(service, bundleContext(), properties);
-        registerService(null, service, properties);
-        return service;
-    }
-
-    /**
-     * Injects dependencies, activates and registers a service in the mocked OSGi environment.
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
      * Construction injection for OSGi services is supported.
-     * @param <T> Service type
-     * @param service Service class
-     * @param properties Service properties (optional)
-     * @return Registered service instance
+     * @param <T> DS Component type
+     * @param component a DS component instance
+     * @return the DS component instance
      */
-    public final @NotNull <T> T registerInjectActivateService(@NotNull final T service, @NotNull final Object @NotNull ... properties) {
-        return registerInjectActivateService(service, MapUtil.toMap(properties));
+    public final @NotNull <T> T registerInjectActivateService(@NotNull final T component) {
+        return registerInjectActivateService(component, (Map<String,Object>)null);
     }
 
     /**
-     * Injects dependencies, activates and registers a service in the mocked OSGi environment.
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * Constructor injection for DS components is supported.
+     * @param <T> DS Component type
+     * @param component a DS component instance
+     * @param properties component properties (optional)
+     * @return the DS component instance
+     */
+    public final @NotNull <T> T registerInjectActivateService(@NotNull final T component, @Nullable final Map<String, Object> properties) {
+        MockOsgi.registerInjectActivateService(component, bundleContext(), properties);
+        return component;
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * Constructor injection for DS components is supported.
+     * @param <T> DS Component type
+     * @param component a DS component instance
+     * @param properties component properties (optional)
+     * @return the DS component instance
+     */
+    public final @NotNull <T> T registerInjectActivateService(@NotNull final T component, @NotNull final Object @NotNull ... properties) {
+        return registerInjectActivateService(component, MapUtil.toMap(properties));
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * Constructor injection for DS components is supported.
+     * @param <T> DS Component type
+     * @param componentClass a DS component class
+     * @return the DS component instance
+     */
+    public final @NotNull <T> T registerInjectActivateService(@NotNull final Class<T> componentClass) {
+        return registerInjectActivateService(componentClass, (Map<String,Object>)null);
+    }
+
+    /**
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
      * Construction injection for OSGi services is supported.
-     * @param <T> Service type
-     * @param serviceClass Service class
-     * @return Registered service instance
+     * @param <T> DS Component type
+     * @param componentClass a DS component class
+     * @param properties component properties (optional)
+     * @return the DS component instance
      */
-    public final @NotNull <T> T registerInjectActivateService(@NotNull final Class<T> serviceClass) {
-        return registerInjectActivateService(serviceClass, (Map<String,Object>)null);
+    public final @NotNull <T> T registerInjectActivateService(@NotNull Class<T> componentClass, @Nullable final Map<String, Object> properties) {
+        return MockOsgi.registerInjectActivateService(componentClass, bundleContext(), properties);
     }
 
     /**
-     * Injects dependencies, activates and registers a service in the mocked OSGi environment.
-     * Construction injection for OSGi services is supported.
-     * @param <T> Service type
-     * @param serviceClass Service class
-     * @param properties Service properties (optional)
-     * @return Registered service instance
+     * Injects dependencies, activates and registers a DS component in the mocked OSGi environment.
+     * @param <T> DS Component type
+     * @param componentClass a DS component class
+     * @param properties component properties (optional)
+     * @return the DS component instance
      */
-    public final @NotNull <T> T registerInjectActivateService(@NotNull Class<T> serviceClass, @Nullable final Map<String, Object> properties) {
-        T service = MockOsgi.activateInjectServices(serviceClass, bundleContext(), properties);
-        registerService(null, service, properties);
-        return service;
-    }
-
-    /**
-     * Injects dependencies, activates and registers a service in the mocked OSGi environment.
-     * @param <T> Service type
-     * @param serviceClass Service instance
-     * @param properties Service properties (optional)
-     * @return Registered service instance
-     */
-    public final @NotNull <T> T registerInjectActivateService(@NotNull Class<T> serviceClass, @NotNull final Object @NotNull ... properties) {
-        return registerInjectActivateService(serviceClass, MapUtil.toMap(properties));
+    public final @NotNull <T> T registerInjectActivateService(@NotNull Class<T> componentClass, @NotNull final Object @NotNull ... properties) {
+        return registerInjectActivateService(componentClass, MapUtil.toMap(properties));
     }
 
     /**
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java
index e7aaecb..da170a4 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/package-info.java
@@ -19,5 +19,5 @@
 /**
  * OSGi context implementation for unit tests.
  */
-@org.osgi.annotation.versioning.Version("1.3.0")
+@org.osgi.annotation.versioning.Version("1.4.0")
 package org.apache.sling.testing.mock.osgi.context;
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java
index 13357ce..b6ba265 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Mock implementation of selected OSGi APIs.
  */
-@org.osgi.annotation.versioning.Version("3.5.0")
+@org.osgi.annotation.versioning.Version("3.6.0")
 package org.apache.sling.testing.mock.osgi;
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedySelfReferenceTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedySelfReferenceTest.java
index e72fad0..06ea7ea 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedySelfReferenceTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedySelfReferenceTest.java
@@ -47,22 +47,16 @@
 
     @Test
     public void testSelfReferenceWithTargetFilter() throws InvalidSyntaxException {
-        ServiceInterface3 defaultImpl = MockOsgi.activateInjectServices(ServiceInterface3Impl.class, bundleContext);
-        bundleContext.registerService(ServiceInterface3.class.getName(), defaultImpl, null);
-
-        ServiceInterface3 selfReferencingImpl = MockOsgi.activateInjectServices(ServiceInterface3ImplSelfReferencing.class, bundleContext);
-        bundleContext.registerService(ServiceInterface3.class.getName(), selfReferencingImpl, null);
+        MockOsgi.registerInjectActivateService(ServiceInterface3Impl.class, bundleContext);
+        MockOsgi.registerInjectActivateService(ServiceInterface3ImplSelfReferencing.class, bundleContext);
 
         assertNotNull(getDefaultImplFromReference());
     }
 
     @Test
     public void testSelfReferenceWithTargetFilterReverse() throws InvalidSyntaxException {
-        ServiceInterface3 selfReferencingImpl = MockOsgi.activateInjectServices(ServiceInterface3ImplSelfReferencing.class, bundleContext);
-        bundleContext.registerService(ServiceInterface3.class.getName(), selfReferencingImpl, null);
-
-        ServiceInterface3 defaultImpl = MockOsgi.activateInjectServices(ServiceInterface3Impl.class, bundleContext);
-        bundleContext.registerService(ServiceInterface3.class.getName(), defaultImpl, null);
+        MockOsgi.registerInjectActivateService(ServiceInterface3ImplSelfReferencing.class, bundleContext);
+        MockOsgi.registerInjectActivateService(ServiceInterface3Impl.class, bundleContext);
 
         assertNotNull(getDefaultImplFromReference());
     }
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
index b938754..23d8a55 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
@@ -26,7 +26,6 @@
 import java.util.Dictionary;
 import java.util.Hashtable;
 
-import org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.ServiceWithMetadata;
 import org.junit.Before;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
@@ -71,15 +70,4 @@
         assertArrayEquals((String[]) this.serviceReference.getProperty(Constants.OBJECTCLASS), new String[] { String.class.getName() });
     }
 
-    @Test
-    public void testWithOsgiMetadata() {
-        ServiceWithMetadata serviceWithMetadata = new OsgiMetadataUtilTest.ServiceWithMetadata();
-        bundleContext.registerService((String) null, serviceWithMetadata, null);
-        ServiceReference reference = this.bundleContext.getServiceReference(Comparable.class.getName());
-
-        assertEquals(5000, reference.getProperty(Constants.SERVICE_RANKING));
-        assertEquals("The Apache Software Foundation", reference.getProperty(Constants.SERVICE_VENDOR));
-        assertEquals("org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata", reference.getProperty(Constants.SERVICE_PID));
-    }
-
 }
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
index 0acdfd8..3e428ce 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
@@ -50,7 +50,6 @@
 import org.mockito.Mockito;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 
@@ -100,7 +99,6 @@
 
         List<Map<String, Object>> reference3Configs = service3.getReference3Configs();
         assertEquals(1, reference3Configs.size());
-        assertEquals(200, reference3Configs.get(0).get(Constants.SERVICE_RANKING));
 
         Set<ServiceSuperInterface3> references3Set = service3.getReferences3Set();
         assertEquals(1, references3Set.size());