SLING-10195 osgi-mock: Dynamic reference filtering does not work when super type is used
refactor all osgi test services out of OsgiServiceUtil to standalone classes in separate package
re-generate all OSGI-INF files from annotations of test service classes
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
index 0640d39..08bbf62 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
@@ -671,7 +671,7 @@
                 for (Reference reference : metadata.getReferences()) {
                     if (reference.getPolicy() == ReferencePolicy.DYNAMIC) {
                         for (String serviceInterface : registration.getClasses()) {
-                            if (StringUtils.equals(serviceInterface, reference.getInterfaceType())) {
+                            if (classEqualsOrSuper(serviceInterface, reference.getInterfaceType())) {
                                 references.add(new ReferenceInfo(existingRegistration, reference));
                             }
                         }
@@ -698,7 +698,7 @@
                 for (Reference reference : metadata.getReferences()) {
                     if (reference.getPolicy() == ReferencePolicy.STATIC && reference.getPolicyOption() == ReferencePolicyOption.GREEDY) {
                         for (String serviceInterface : registration.getClasses()) {
-                            if (StringUtils.equals(serviceInterface, reference.getInterfaceType())) {
+                            if (classEqualsOrSuper(serviceInterface, reference.getInterfaceType())) {
                                 references.add(new ReferenceInfo(existingRegistration, reference));
                             }
                         }
@@ -709,6 +709,24 @@
         return references;
     }
 
+    private static boolean classEqualsOrSuper(String givenClassName, String expectedClassName) {
+        Class<?> givenClass;
+        try {
+            givenClass = Class.forName(givenClassName);
+        }
+        catch (ClassNotFoundException ex) {
+            throw new RuntimeException("Untable to get class for " + givenClassName + ": " + ex.getMessage(), ex);
+        }
+        Class<?> expectedClass;
+        try {
+            expectedClass = Class.forName(expectedClassName);
+        }
+        catch (ClassNotFoundException ex) {
+            throw new RuntimeException("Untable to get class for " + expectedClassName + ": " + ex.getMessage(), ex);
+        }
+        return expectedClass.isAssignableFrom(givenClass);
+    }
+
     static class ServiceInfo {
 
         private final Object serviceInstance;
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
index 79f2a99..a06349e 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
@@ -22,12 +22,12 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.Service3OsgiR6;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1Optional;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface3;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceSuperInterface3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3OsgiR6;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1Optional;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceSuperInterface3;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
index b7e6be5..74ae6ab 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
@@ -22,12 +22,12 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.Service3;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1Optional;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface3;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceSuperInterface3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1Optional;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceSuperInterface3;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
index 80c527d..0a86105 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
@@ -22,13 +22,13 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.Service3StaticGreedy;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.Service3StaticGreedyImpl;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1Optional;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface3;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceSuperInterface3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedy;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedyImpl;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1Optional;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceSuperInterface3;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
index 91469db..06b8e29 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
@@ -25,6 +25,10 @@
 import java.util.Arrays;
 import java.util.Hashtable;
 
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedService;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceFive;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceTen;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service6VolatileMultipleReferences;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -90,19 +94,19 @@
 
     @Test
     public void testVolatileCollectionReference() {
-        OsgiServiceUtilTest.RankedService rankedServiceTen = new OsgiServiceUtilTest.RankedServiceTen();
-        bundleContext.registerService(OsgiServiceUtilTest.RankedService.class.getName(), rankedServiceTen , null);
+        RankedService rankedServiceTen = new RankedServiceTen();
+        bundleContext.registerService(RankedService.class.getName(), rankedServiceTen , null);
         MockOsgi.activate(rankedServiceTen, bundleContext);
 
-        OsgiServiceUtilTest.RankedService rankedServiceFive = new OsgiServiceUtilTest.RankedServiceFive();
-        bundleContext.registerService(OsgiServiceUtilTest.RankedService.class.getName(), rankedServiceFive, null);
+        RankedService rankedServiceFive = new RankedServiceFive();
+        bundleContext.registerService(RankedService.class.getName(), rankedServiceFive, null);
         MockOsgi.activate(rankedServiceFive, bundleContext);
 
-        OsgiServiceUtilTest.Service6VolatileMultipleReferences service6VolatileMultipleReferences = new OsgiServiceUtilTest.Service6VolatileMultipleReferences();
-        bundleContext.registerService(OsgiServiceUtilTest.Service6VolatileMultipleReferences.class.getName(), service6VolatileMultipleReferences, null);
+        Service6VolatileMultipleReferences service6VolatileMultipleReferences = new Service6VolatileMultipleReferences();
+        bundleContext.registerService(Service6VolatileMultipleReferences.class.getName(), service6VolatileMultipleReferences, null);
         MockOsgi.injectServices(service6VolatileMultipleReferences, bundleContext);
 
-        assertEquals("Should get highest when getting one service", rankedServiceTen, bundleContext.getService(bundleContext.getServiceReference(OsgiServiceUtilTest.RankedService.class)));
+        assertEquals("Should get highest when getting one service", rankedServiceTen, bundleContext.getService(bundleContext.getServiceReference(RankedService.class)));
         assertEquals("Should have order from lowest to highest on sorted ranked services", "RankedServiceFive=5RankedServiceTen=10", getSortedRankedServices());
         assertEquals("Should have order from lowest to highest on volatile reference list", "RankedServiceFive=5RankedServiceTen=10", service6VolatileMultipleReferences.getRanks());
     }
@@ -110,7 +114,7 @@
     private String getSortedRankedServices() {
         ServiceReference<?>[] refs = null;
         try {
-            refs = bundleContext.getServiceReferences(OsgiServiceUtilTest.RankedService.class.getName(), null);
+            refs = bundleContext.getServiceReferences(RankedService.class.getName(), null);
         }
         catch (InvalidSyntaxException ise) {
             fail("Unexpected InvalidSyntaxException");
@@ -120,7 +124,7 @@
 
         final StringBuilder sb = new StringBuilder();
         for(ServiceReference<?> ref : refs) {
-            OsgiServiceUtilTest.RankedService rankedService = (OsgiServiceUtilTest.RankedService)bundleContext.getService(ref);
+            RankedService rankedService = (RankedService)bundleContext.getService(ref);
             sb.append(rankedService.getClass().getSimpleName()).append("=").append(rankedService.getRanking());
             bundleContext.ungetService(ref);
         }
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
index b6387b9..e8583c8 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
@@ -30,6 +30,8 @@
 import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.OsgiMetadata;
 import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.Reference;
 import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.ReferenceCardinality;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2;
 import org.junit.Test;
 import org.osgi.framework.Constants;
 
@@ -42,10 +44,7 @@
         assertEquals("org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata", metadata.getPID());
 
         Set<String> serviceInterfaces = metadata.getServiceInterfaces();
-        assertEquals(3, serviceInterfaces.size());
-        assertTrue(serviceInterfaces.contains("org.apache.sling.models.spi.Injector"));
-        assertTrue(serviceInterfaces
-                .contains("org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory"));
+        assertEquals(1, serviceInterfaces.size());
         assertTrue(serviceInterfaces.contains("java.lang.Comparable"));
 
         Map<String, Object> props = metadata.getProperties();
@@ -64,13 +63,13 @@
 
     @Test
     public void testReferences() {
-        OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(OsgiServiceUtilTest.Service3.class);
+        OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(Service3.class);
         List<Reference> references = metadata.getReferences();
         assertEquals(5, references.size());
 
         Reference ref1 = references.get(2);
         assertEquals("reference2", ref1.getName());
-        assertEquals("org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface2", ref1.getInterfaceType());
+        assertEquals(ServiceInterface2.class.getName(), ref1.getInterfaceType());
         assertEquals(ReferenceCardinality.MANDATORY_MULTIPLE, ref1.getCardinality());
         assertEquals("bindReference2", ref1.getBind());
         assertEquals("unbindReference2", ref1.getUnbind());
@@ -78,7 +77,7 @@
 
     @Test
     public void testActivateMethodName() {
-        OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(OsgiServiceUtilTest.Service3.class);
+        OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(Service3.class);
         assertEquals("activate", metadata.getActivateMethodName());
     }
 
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java
index 9405869..feadbad 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java
@@ -22,12 +22,12 @@
 import static org.junit.Assert.assertSame;
 import static org.mockito.Mockito.mock;
 
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.Service2;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.Service3;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface3;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3;
 import org.junit.Rule;
 import org.junit.Test;
 import org.osgi.framework.Constants;
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 3365140..b97541c 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
@@ -25,15 +25,25 @@
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Dictionary;
-import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3OsgiR6;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service4;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service5;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceFactory1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface5;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceSuperInterface3;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -42,15 +52,7 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Modified;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
 
 import com.google.common.collect.ImmutableMap;
 
@@ -240,448 +242,4 @@
                 bundleContext.getServiceReference(ServiceFactory1.class.getName())));
     }
 
-
-    public interface ServiceInterface1 {
-        // no methods
-    }
-
-    public interface ServiceInterface1Optional {
-        // no methods
-    }
-
-    public interface ServiceInterface2 {
-        // no methods
-    }
-
-    public interface ServiceInterface3 extends ServiceSuperInterface3 {
-        // no methods
-    }
-
-    public interface ServiceSuperInterface3 {
-        // no methods
-    }
-
-    @Component(service = ServiceInterface1.class,
-            property = Constants.SERVICE_RANKING + ":Integer=100")
-    public static class Service1 implements ServiceInterface1 {
-        // dummy interface
-    }
-
-    @Component(service = { ServiceInterface2.class, ServiceInterface3.class },
-            property = Constants.SERVICE_RANKING + ":Integer=200")
-    public static class Service2 implements ServiceInterface2, ServiceInterface3 {
-        // dummy interface
-    }
-
-    @Component(reference = { @Reference(name = "reference2", service = ServiceInterface2.class, cardinality = ReferenceCardinality.AT_LEAST_ONE,
-            bind="bindReference2", unbind="unbindReference2") })
-    public static class Service3 {
-
-        @Reference(bind="bindReference1", unbind="unbindReference1")
-        private ServiceInterface1 reference1;
-        @Reference(cardinality = ReferenceCardinality.OPTIONAL, bind="bindReference1Optional", unbind="unbindReference1Optional")
-        private ServiceInterface1Optional reference1Optional;
-
-        private List<ServiceReference> references2 = new ArrayList<>();
-
-        @Reference(name = "reference3", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
-                bind="bindReference3", unbind="unbindReference3")
-        private List<ServiceSuperInterface3> references3 = new ArrayList<>();
-        private List<Map<String, Object>> reference3Configs = new ArrayList<>();
-
-        @Reference(name = "references3Set", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
-                bind="bindReferenceSet3", unbind="unbindReferenceSet3")
-        private Set<ServiceSuperInterface3> references3Set = new HashSet<>();
-
-        private ComponentContext componentContext;
-        private Map<String, Object> config;
-
-        @Activate
-        private void activate(ComponentContext ctx) {
-            this.componentContext = ctx;
-            this.config = MapUtil.toMap(ctx.getProperties());
-        }
-
-        @Deactivate
-        private void deactivate(ComponentContext ctx) {
-            this.componentContext = null;
-        }
-
-        @Modified
-        private void modified(Map<String,Object> newConfig) {
-            this.config = newConfig;
-        }
-
-        public ServiceInterface1 getReference1() {
-            return this.reference1;
-        }
-
-        public ServiceInterface1Optional getReference1Optional() {
-            return this.reference1Optional;
-        }
-
-        public List<ServiceInterface2> getReferences2() {
-            List<ServiceInterface2> services = new ArrayList<>();
-            for (ServiceReference<?> serviceReference : references2) {
-                services.add((ServiceInterface2)componentContext.getBundleContext().getService(serviceReference));
-            }
-            return services;
-        }
-
-        public List<ServiceSuperInterface3> getReferences3() {
-            return this.references3;
-        }
-
-        public List<Map<String, Object>> getReference3Configs() {
-            return this.reference3Configs;
-        }
-
-        public Set<ServiceSuperInterface3> getReferences3Set() {
-            return this.references3Set;
-        }
-
-        public ComponentContext getComponentContext() {
-            return this.componentContext;
-        }
-
-        public Map<String, Object> getConfig() {
-            return config;
-        }
-
-        protected void bindReference1Optional(ServiceInterface1Optional service) {
-            reference1Optional = service;
-        }
-
-        protected void unbindReference1Optional(ServiceInterface1Optional service) {
-            reference1Optional = null;
-        }
-
-        protected void bindReference1(ServiceInterface1 service) {
-            reference1 = service;
-        }
-
-        protected void unbindReference1(ServiceInterface1 service) {
-            reference1 = null;
-        }
-
-        protected void bindReference2(ServiceReference serviceReference) {
-            references2.add(serviceReference);
-        }
-
-        protected void unbindReference2(ServiceReference serviceReference) {
-            references2.remove(serviceReference);
-        }
-
-        protected void bindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
-            references3.add(service);
-            reference3Configs.add(serviceConfig);
-        }
-
-        protected void unbindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
-            references3.remove(service);
-            reference3Configs.remove(serviceConfig);
-        }
-
-        protected void bindReference3Set(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
-            references3Set.add(service);
-        }
-
-        protected void unbindReference3Set(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
-            references3Set.remove(service);
-        }
-
-    }
-
-    public static class Service3OsgiR6 {
-
-        private ServiceInterface1 reference1;
-        private ServiceInterface1Optional reference1Optional;
-        private List<ServiceReference> references2;
-        private List<ServiceSuperInterface3> references3;
-        private List<ServiceSuperInterface3> references3Filtered;
-        private ServiceSuperInterface3 reference3DynamicFiltered;
-        private Set<ServiceSuperInterface3> references3Set;
-        private Collection<ServiceSuperInterface3> references3Collection;
-
-        private ComponentContext componentContext;
-        private Map<String, Object> config;
-
-        @Activate
-        private void activate(ComponentContext ctx) {
-            this.componentContext = ctx;
-            this.config = MapUtil.toMap(ctx.getProperties());
-        }
-
-        @Deactivate
-        private void deactivate(ComponentContext ctx) {
-            this.componentContext = null;
-        }
-
-        @Modified
-        private void modified(Map<String,Object> newConfig) {
-            this.config = newConfig;
-        }
-
-        public ServiceInterface1 getReference1() {
-            return this.reference1;
-        }
-
-        public ServiceInterface1Optional getReference1Optional() {
-            return this.reference1Optional;
-        }
-
-        public List<ServiceInterface2> getReferences2() {
-            List<ServiceInterface2> services = new ArrayList<ServiceInterface2>();
-            for (ServiceReference<?> serviceReference : references2) {
-                services.add((ServiceInterface2)componentContext.getBundleContext().getService(serviceReference));
-            }
-            return services;
-        }
-
-        public List<ServiceSuperInterface3> getReferences3() {
-            return this.references3;
-        }
-
-        public List<ServiceSuperInterface3> getReferences3Filtered() {
-            return this.references3Filtered;
-        }
-
-
-        public ServiceSuperInterface3 getReference3DynamicFiltered() {
-            return this.reference3DynamicFiltered;
-        }
-
-        public Set<ServiceSuperInterface3> getReferences3Set() {
-            return this.references3Set;
-        }
-
-        public Collection<ServiceSuperInterface3> getReferences3Collection() {
-            return this.references3Collection;
-        }
-
-        public ComponentContext getComponentContext() {
-            return this.componentContext;
-        }
-
-        public Map<String, Object> getConfig() {
-            return config;
-        }
-
-    }
-
-    public interface Service3StaticGreedy {
-        ServiceInterface1 getReference1();
-        ServiceInterface1Optional getReference1Optional();
-        List<ServiceInterface2> getReferences2();
-        List<ServiceSuperInterface3> getReferences3();
-        List<Map<String, Object>> getReference3Configs();
-    }
-
-    @Component(service= Service3StaticGreedy.class,
-            reference = { @Reference(name = "reference2", service = ServiceInterface2.class, cardinality = ReferenceCardinality.AT_LEAST_ONE,
-            bind="bindReference2", unbind="unbindReference2") })
-    public static class Service3StaticGreedyImpl implements Service3StaticGreedy {
-
-        @Reference(bind="bindReference1", unbind="unbindReference1")
-        private ServiceInterface1 reference1;
-        @Reference(cardinality = ReferenceCardinality.OPTIONAL, bind="bindReference1Optional", unbind="unbindReference1Optional")
-        private ServiceInterface1Optional reference1Optional;
-
-        private List<ServiceReference> references2 = new ArrayList<ServiceReference>();
-
-        @Reference(name = "reference3", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
-                bind="bindReference3", unbind="unbindReference3")
-        private List<ServiceSuperInterface3> references3 = new ArrayList<ServiceSuperInterface3>();
-        private List<Map<String, Object>> reference3Configs = new ArrayList<Map<String, Object>>();
-
-        private ComponentContext componentContext;
-        private Map<String, Object> config;
-
-        @Activate
-        private void activate(ComponentContext ctx) {
-            this.componentContext = ctx;
-            this.config = MapUtil.toMap(ctx.getProperties());
-        }
-
-        @Deactivate
-        private void deactivate(ComponentContext ctx) {
-            this.componentContext = null;
-        }
-
-        @Modified
-        private void modified(Map<String,Object> newConfig) {
-            this.config = newConfig;
-        }
-
-        @Override
-        public ServiceInterface1 getReference1() {
-            return this.reference1;
-        }
-
-        @Override
-        public ServiceInterface1Optional getReference1Optional() {
-            return this.reference1Optional;
-        }
-
-        @Override
-        public List<ServiceInterface2> getReferences2() {
-            List<ServiceInterface2> services = new ArrayList<ServiceInterface2>();
-            for (ServiceReference<?> serviceReference : references2) {
-                services.add((ServiceInterface2)componentContext.getBundleContext().getService(serviceReference));
-            }
-            return services;
-        }
-
-        @Override
-        public List<ServiceSuperInterface3> getReferences3() {
-            return this.references3;
-        }
-
-        @Override
-        public List<Map<String, Object>> getReference3Configs() {
-            return this.reference3Configs;
-        }
-
-        public ComponentContext getComponentContext() {
-            return this.componentContext;
-        }
-
-        public Map<String, Object> getConfig() {
-            return config;
-        }
-
-        protected void bindReference1Optional(ServiceInterface1Optional service) {
-            reference1Optional = service;
-        }
-
-        protected void unbindReference1Optional(ServiceInterface1Optional service) {
-            reference1Optional = null;
-        }
-
-        protected void bindReference1(ServiceInterface1 service) {
-            reference1 = service;
-        }
-
-        protected void unbindReference1(ServiceInterface1 service) {
-            reference1 = null;
-        }
-
-        protected void bindReference2(ServiceReference serviceReference) {
-            references2.add(serviceReference);
-        }
-
-        protected void unbindReference2(ServiceReference serviceReference) {
-            references2.remove(serviceReference);
-        }
-
-        protected void bindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
-            references3.add(service);
-            reference3Configs.add(serviceConfig);
-        }
-
-        protected void unbindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
-            references3.remove(service);
-            reference3Configs.remove(serviceConfig);
-        }
-
-    }
-
-    @Component(reference = @Reference(service = ServiceInterface1.class, name = "customName", bind = "customBind", unbind = "customUnbind"))
-    public static class Service4 {
-
-        private ServiceInterface1 reference1;
-
-        public ServiceInterface1 getReference1() {
-            return this.reference1;
-        }
-
-        protected void customBind(ServiceInterface1 service) {
-            reference1 = service;
-        }
-
-        protected void customUnbind(ServiceInterface1 service) {
-            reference1 = null;
-        }
-
-    }
-
-    @Component(service = { ServiceInterface5.class })
-    public static class Service5 implements ServiceInterface5 {
-
-        @Override
-        public boolean doRemoteThing() {
-            return false;
-        }
-    }
-
-    public interface ServiceInterface5 {
-
-        boolean doRemoteThing();
-
-    }
-
-    @Component(service = ServiceFactory1.class, servicefactory = true)
-    public static class ServiceFactory1 {
-
-    }
-
-    public interface RankedService {
-        int getRanking();
-    }
-
-    @Component(
-            properties = {
-                    "service.ranking:Integer=5"
-            }
-    )
-    public static class RankedServiceFive implements RankedService {
-
-        private int ranking;
-
-        @Activate
-        public void activate(Map<String, Object> properties) {
-            this.ranking = (Integer) properties.get("service.ranking");
-        }
-
-        @Override
-        public int getRanking() {
-            return ranking;
-        }
-    }
-
-    @Component(
-            properties = {
-                    "service.ranking:Integer=10"
-            }
-    )
-    public static class RankedServiceTen implements RankedService {
-
-        private int ranking;
-
-        @Activate
-        public void activate(Map<String, Object> properties) {
-            this.ranking = (Integer) properties.get("service.ranking");
-        }
-
-        @Override
-        public int getRanking() {
-            return ranking;
-        }
-    }
-
-    @Component(service = Service6VolatileMultipleReferences.class)
-    public static class Service6VolatileMultipleReferences {
-
-        @Reference
-        private volatile List<RankedService> rankedServices;
-
-        public String getRanks() {
-            StringBuilder builder = new StringBuilder();
-            for(RankedService rankedService : rankedServices) {
-                builder.append(rankedService.getClass().getSimpleName()).append("=").append(rankedService.getRanking());
-            }
-            return builder.toString();
-        }
-    }
-
 }
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
index caeba0f..862b305 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
@@ -29,9 +29,9 @@
 import java.util.Set;
 
 import org.apache.sling.testing.mock.osgi.NoScrMetadataException;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface1;
-import org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1;
+import org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -119,14 +119,14 @@
     public void testRegisterInjectActivate() {
         context.registerService(ServiceInterface1.class, mock(ServiceInterface1.class));
         context.registerService(ServiceInterface2.class, mock(ServiceInterface2.class));
-        context.registerInjectActivateService(new OsgiServiceUtilTest.Service3());
+        context.registerInjectActivateService(new Service3());
     }
 
     @Test
     public void testRegisterInjectActivateWithProperties() {
         context.registerService(ServiceInterface1.class, mock(ServiceInterface1.class));
         context.registerService(ServiceInterface2.class, mock(ServiceInterface2.class));
-        OsgiServiceUtilTest.Service3 service = context.registerInjectActivateService(new OsgiServiceUtilTest.Service3(), "prop1", "value3");
+        Service3 service = context.registerInjectActivateService(new Service3(), "prop1", "value3");
         assertEquals("value3", service.getConfig().get("prop1"));
     }
 
@@ -134,7 +134,7 @@
     public void testRegisterInjectActivateWithPropertiesWithNulls() {
         context.registerService(ServiceInterface1.class, mock(ServiceInterface1.class));
         context.registerService(ServiceInterface2.class, mock(ServiceInterface2.class));
-        OsgiServiceUtilTest.Service3 service = context.registerInjectActivateService(new OsgiServiceUtilTest.Service3(),
+        Service3 service = context.registerInjectActivateService(new Service3(),
                 "prop1", "value3",
                 "prop2", null,
                 null, "value4",
@@ -151,13 +151,13 @@
         props.put("prop2", null);
         props.put(null, "value4");
         props.put(null, null);
-        OsgiServiceUtilTest.Service3 service = context.registerInjectActivateService(new OsgiServiceUtilTest.Service3(), props);
+        Service3 service = context.registerInjectActivateService(new Service3(), props);
         assertEquals("value3", service.getConfig().get("prop1"));
     }
 
     @Test(expected=RuntimeException.class)
     public void testRegisterInjectActivate_RefrenceMissing() {
-        context.registerInjectActivateService(new OsgiServiceUtilTest.Service3());
+        context.registerInjectActivateService(new Service3());
     }
 
     @Test(expected=NoScrMetadataException.class)
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedService.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedService.java
new file mode 100644
index 0000000..b56054e
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedService.java
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+public interface RankedService {
+
+    int getRanking();
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedServiceFive.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedServiceFive.java
new file mode 100644
index 0000000..b32856f
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedServiceFive.java
@@ -0,0 +1,43 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import java.util.Map;
+
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.propertytypes.ServiceRanking;
+
+@Component(service = RankedService.class)
+@ServiceRanking(5)
+public class RankedServiceFive implements RankedService {
+
+    private int ranking;
+
+    @Activate
+    public void activate(Map<String, Object> properties) {
+        this.ranking = (Integer) properties.get("service.ranking");
+    }
+
+    @Override
+    public int getRanking() {
+        return ranking;
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedServiceTen.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedServiceTen.java
new file mode 100644
index 0000000..b6e2bcc
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/RankedServiceTen.java
@@ -0,0 +1,43 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import java.util.Map;
+
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.propertytypes.ServiceRanking;
+
+@Component(service = RankedService.class)
+@ServiceRanking(10)
+public class RankedServiceTen implements RankedService {
+
+    private int ranking;
+
+    @Activate
+    public void activate(Map<String, Object> properties) {
+        this.ranking = (Integer) properties.get("service.ranking");
+    }
+
+    @Override
+    public int getRanking() {
+        return ranking;
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service1.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service1.java
new file mode 100644
index 0000000..26d0fa7
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service1.java
@@ -0,0 +1,30 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Component;
+
+@Component(service = ServiceInterface1.class,
+        property = Constants.SERVICE_RANKING + ":Integer=100")
+public class Service1 implements ServiceInterface1 {
+
+    // dummy interface
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service2.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service2.java
new file mode 100644
index 0000000..9be7f6b
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service2.java
@@ -0,0 +1,30 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Component;
+
+@Component(service = { ServiceInterface2.class, ServiceInterface3.class },
+        property = Constants.SERVICE_RANKING + ":Integer=200")
+public class Service2 implements ServiceInterface2, ServiceInterface3 {
+
+    // dummy interface
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3.java
new file mode 100644
index 0000000..d0485be
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3.java
@@ -0,0 +1,162 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.testing.mock.osgi.MapUtil;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
+
+@Component(reference = { @Reference(name = "reference2", service = ServiceInterface2.class, cardinality = ReferenceCardinality.AT_LEAST_ONE,
+        policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY,
+        bind="bindReference2", unbind="unbindReference2") })
+public class Service3 {
+
+    @Reference(bind="bindReference1", unbind="unbindReference1", policy = ReferencePolicy.DYNAMIC)
+    private volatile ServiceInterface1 reference1;
+
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC,
+            bind="bindReference1Optional", unbind="unbindReference1Optional")
+    private volatile ServiceInterface1Optional reference1Optional;
+
+    private List<ServiceReference<ServiceInterface2>> references2 = new ArrayList<>();
+
+    @Reference(name = "reference3", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY,
+            bind="bindReference3", unbind="unbindReference3")
+    private volatile List<ServiceSuperInterface3> references3 = new ArrayList<>();
+    private List<Map<String, Object>> reference3Configs = new ArrayList<>();
+
+    @Reference(name = "references3Set", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE)
+    private List<ServiceSuperInterface3> references3Set = new ArrayList<>();
+    //TODO: private Set<ServiceSuperInterface3> references3Set = new HashSet<>();
+
+    private ComponentContext componentContext;
+    private Map<String, Object> config;
+
+    @Activate
+    private void activate(ComponentContext ctx) {
+        this.componentContext = ctx;
+        this.config = MapUtil.toMap(ctx.getProperties());
+    }
+
+    @Deactivate
+    private void deactivate(ComponentContext ctx) {
+        this.componentContext = null;
+    }
+
+    @Modified
+    private void modified(Map<String,Object> newConfig) {
+        this.config = newConfig;
+    }
+
+    public ServiceInterface1 getReference1() {
+        return this.reference1;
+    }
+
+    public ServiceInterface1Optional getReference1Optional() {
+        return this.reference1Optional;
+    }
+
+    public List<ServiceInterface2> getReferences2() {
+        List<ServiceInterface2> services = new ArrayList<>();
+        for (ServiceReference<?> serviceReference : references2) {
+            services.add((ServiceInterface2)componentContext.getBundleContext().getService(serviceReference));
+        }
+        return services;
+    }
+
+    public List<ServiceSuperInterface3> getReferences3() {
+        return this.references3;
+    }
+
+    public List<Map<String, Object>> getReference3Configs() {
+        return this.reference3Configs;
+    }
+
+    public Set<ServiceSuperInterface3> getReferences3Set() {
+        return new HashSet<>(this.references3Set);
+        //TODO: return this.references3Set;
+    }
+
+    public ComponentContext getComponentContext() {
+        return this.componentContext;
+    }
+
+    public Map<String, Object> getConfig() {
+        return config;
+    }
+
+    void bindReference1Optional(ServiceInterface1Optional service) {
+        reference1Optional = service;
+    }
+
+    void unbindReference1Optional(ServiceInterface1Optional service) {
+        reference1Optional = null;
+    }
+
+    void bindReference1(ServiceInterface1 service) {
+        reference1 = service;
+    }
+
+    void unbindReference1(ServiceInterface1 service) {
+        reference1 = null;
+    }
+
+    void bindReference2(ServiceReference<ServiceInterface2> serviceReference) {
+        references2.add(serviceReference);
+    }
+
+    void unbindReference2(ServiceReference<ServiceInterface2> serviceReference) {
+        references2.remove(serviceReference);
+    }
+
+    void bindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
+        references3.add(service);
+        reference3Configs.add(serviceConfig);
+    }
+
+    void unbindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
+        references3.remove(service);
+        reference3Configs.remove(serviceConfig);
+    }
+
+
+    void bindReference3Set(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
+        references3Set.add(service);
+    }
+
+    void unbindReference3Set(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
+        references3Set.remove(service);
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3OsgiR6.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3OsgiR6.java
new file mode 100644
index 0000000..3b1a397
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3OsgiR6.java
@@ -0,0 +1,139 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.testing.mock.osgi.MapUtil;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
+
+@Component
+public class Service3OsgiR6 {
+
+    @Reference
+    private ServiceInterface1 reference1;
+
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
+    private volatile ServiceInterface1Optional reference1Optional;
+
+    @Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE,
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
+    private volatile List<ServiceReference<ServiceInterface2>> references2 = new ArrayList<>();
+
+    @Reference(service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
+    private volatile List<ServiceSuperInterface3> references3;
+
+    @Reference(service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE, target="(prop1=abc)",
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
+    private volatile List<ServiceSuperInterface3> references3Filtered;
+
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL,
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY,
+            name = "reference3DynamicFiltered")
+    private volatile ServiceSuperInterface3 reference3DynamicFiltered;
+
+    @Reference(service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
+    private volatile List<ServiceSuperInterface3> references3Set;
+    //TODO: private Set<ServiceSuperInterface3> references3Set;
+
+    @Reference(service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
+            policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
+    private volatile Collection<ServiceSuperInterface3> references3Collection;
+
+    private ComponentContext componentContext;
+    private Map<String, Object> config;
+
+    @Activate
+    private void activate(ComponentContext ctx) {
+        this.componentContext = ctx;
+        this.config = MapUtil.toMap(ctx.getProperties());
+    }
+
+    @Deactivate
+    private void deactivate(ComponentContext ctx) {
+        this.componentContext = null;
+    }
+
+    @Modified
+    private void modified(Map<String,Object> newConfig) {
+        this.config = newConfig;
+    }
+
+    public ServiceInterface1 getReference1() {
+        return this.reference1;
+    }
+
+    public ServiceInterface1Optional getReference1Optional() {
+        return this.reference1Optional;
+    }
+
+    public List<ServiceInterface2> getReferences2() {
+        List<ServiceInterface2> services = new ArrayList<ServiceInterface2>();
+        for (ServiceReference<?> serviceReference : references2) {
+            services.add((ServiceInterface2)componentContext.getBundleContext().getService(serviceReference));
+        }
+        return services;
+    }
+
+    public List<ServiceSuperInterface3> getReferences3() {
+        return this.references3;
+    }
+
+    public List<ServiceSuperInterface3> getReferences3Filtered() {
+        return this.references3Filtered;
+    }
+
+    public ServiceSuperInterface3 getReference3DynamicFiltered() {
+        return this.reference3DynamicFiltered;
+    }
+
+    public Set<ServiceSuperInterface3> getReferences3Set() {
+        return new HashSet<>(this.references3Set);
+        //TODO: return this.references3Set;
+    }
+
+    public Collection<ServiceSuperInterface3> getReferences3Collection() {
+        return this.references3Collection;
+    }
+
+    public ComponentContext getComponentContext() {
+        return this.componentContext;
+    }
+
+    public Map<String, Object> getConfig() {
+        return config;
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3StaticGreedy.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3StaticGreedy.java
new file mode 100644
index 0000000..98a6409
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3StaticGreedy.java
@@ -0,0 +1,36 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import java.util.List;
+import java.util.Map;
+
+public interface Service3StaticGreedy {
+
+    ServiceInterface1 getReference1();
+
+    ServiceInterface1Optional getReference1Optional();
+
+    List<ServiceInterface2> getReferences2();
+
+    List<ServiceSuperInterface3> getReferences3();
+
+    List<Map<String, Object>> getReference3Configs();
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3StaticGreedyImpl.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3StaticGreedyImpl.java
new file mode 100644
index 0000000..6ffc02b
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service3StaticGreedyImpl.java
@@ -0,0 +1,149 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.sling.testing.mock.osgi.MapUtil;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
+
+@Component(service= Service3StaticGreedy.class,
+        reference = { @Reference(name = "reference2", service = ServiceInterface2.class, cardinality = ReferenceCardinality.AT_LEAST_ONE,
+        policy = ReferencePolicy.STATIC, policyOption = ReferencePolicyOption.GREEDY,
+        bind="bindReference2", unbind="unbindReference2") })
+public class Service3StaticGreedyImpl implements Service3StaticGreedy {
+
+    @Reference(bind="bindReference1", unbind="unbindReference1",
+            policy = ReferencePolicy.STATIC, policyOption = ReferencePolicyOption.GREEDY)
+    private ServiceInterface1 reference1;
+
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL, bind="bindReference1Optional", unbind="unbindReference1Optional",
+            policy = ReferencePolicy.STATIC, policyOption = ReferencePolicyOption.GREEDY)
+    private ServiceInterface1Optional reference1Optional;
+
+    private List<ServiceReference<ServiceInterface2>> references2 = new ArrayList<>();
+
+    @Reference(name = "reference3", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE,
+            policy = ReferencePolicy.STATIC, policyOption = ReferencePolicyOption.GREEDY,
+            bind="bindReference3", unbind="unbindReference3")
+    private List<ServiceSuperInterface3> references3 = new ArrayList<>();
+    private List<Map<String, Object>> reference3Configs = new ArrayList<>();
+
+    private ComponentContext componentContext;
+    private Map<String, Object> config;
+
+    @Activate
+    private void activate(ComponentContext ctx) {
+        this.componentContext = ctx;
+        this.config = MapUtil.toMap(ctx.getProperties());
+    }
+
+    @Deactivate
+    private void deactivate(ComponentContext ctx) {
+        this.componentContext = null;
+    }
+
+    @Modified
+    private void modified(Map<String,Object> newConfig) {
+        this.config = newConfig;
+    }
+
+    @Override
+    public ServiceInterface1 getReference1() {
+        return this.reference1;
+    }
+
+    @Override
+    public ServiceInterface1Optional getReference1Optional() {
+        return this.reference1Optional;
+    }
+
+    @Override
+    public List<ServiceInterface2> getReferences2() {
+        List<ServiceInterface2> services = new ArrayList<>();
+        for (ServiceReference<?> serviceReference : references2) {
+            services.add((ServiceInterface2)componentContext.getBundleContext().getService(serviceReference));
+        }
+        return services;
+    }
+
+    @Override
+    public List<ServiceSuperInterface3> getReferences3() {
+        return this.references3;
+    }
+
+    @Override
+    public List<Map<String, Object>> getReference3Configs() {
+        return this.reference3Configs;
+    }
+
+    public ComponentContext getComponentContext() {
+        return this.componentContext;
+    }
+
+    public Map<String, Object> getConfig() {
+        return config;
+    }
+
+    protected void bindReference1Optional(ServiceInterface1Optional service) {
+        reference1Optional = service;
+    }
+
+    protected void unbindReference1Optional(ServiceInterface1Optional service) {
+        reference1Optional = null;
+    }
+
+    protected void bindReference1(ServiceInterface1 service) {
+        reference1 = service;
+    }
+
+    protected void unbindReference1(ServiceInterface1 service) {
+        reference1 = null;
+    }
+
+    protected void bindReference2(ServiceReference<ServiceInterface2> serviceReference) {
+        references2.add(serviceReference);
+    }
+
+    protected void unbindReference2(ServiceReference<ServiceInterface2> serviceReference) {
+        references2.remove(serviceReference);
+    }
+
+    protected void bindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
+        references3.add(service);
+        reference3Configs.add(serviceConfig);
+    }
+
+    protected void unbindReference3(ServiceSuperInterface3 service, Map<String, Object> serviceConfig) {
+        references3.remove(service);
+        reference3Configs.remove(serviceConfig);
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service4.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service4.java
new file mode 100644
index 0000000..8f23632
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service4.java
@@ -0,0 +1,41 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(reference = @Reference(service = ServiceInterface1.class, name = "customName", bind = "customBind", unbind = "customUnbind"))
+public class Service4 {
+
+    private ServiceInterface1 reference1;
+
+    public ServiceInterface1 getReference1() {
+        return this.reference1;
+    }
+
+    protected void customBind(ServiceInterface1 service) {
+        reference1 = service;
+    }
+
+    protected void customUnbind(ServiceInterface1 service) {
+        reference1 = null;
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service5.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service5.java
new file mode 100644
index 0000000..238a48e
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service5.java
@@ -0,0 +1,31 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import org.osgi.service.component.annotations.Component;
+
+@Component(service = { ServiceInterface5.class })
+public class Service5 implements ServiceInterface5 {
+
+    @Override
+    public boolean doRemoteThing() {
+        return false;
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service6VolatileMultipleReferences.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service6VolatileMultipleReferences.java
new file mode 100644
index 0000000..2e88c72
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/Service6VolatileMultipleReferences.java
@@ -0,0 +1,40 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import java.util.List;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(service = Service6VolatileMultipleReferences.class)
+public class Service6VolatileMultipleReferences {
+
+    @Reference
+    private volatile List<RankedService> rankedServices;
+
+    public String getRanks() {
+        StringBuilder builder = new StringBuilder();
+        for(RankedService rankedService : rankedServices) {
+            builder.append(rankedService.getClass().getSimpleName()).append("=").append(rankedService.getRanking());
+        }
+        return builder.toString();
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceFactory1.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceFactory1.java
new file mode 100644
index 0000000..1139518
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceFactory1.java
@@ -0,0 +1,26 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+import org.osgi.service.component.annotations.Component;
+
+@Component(service = ServiceFactory1.class, servicefactory = true)
+public class ServiceFactory1 {
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface1.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface1.java
new file mode 100644
index 0000000..e450bb4
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface1.java
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+public interface ServiceInterface1 {
+
+    // no methods
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface1Optional.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface1Optional.java
new file mode 100644
index 0000000..ef34357
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface1Optional.java
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+public interface ServiceInterface1Optional {
+
+    // no methods
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface2.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface2.java
new file mode 100644
index 0000000..dfdee55
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface2.java
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+public interface ServiceInterface2 {
+
+    // no methods
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface3.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface3.java
new file mode 100644
index 0000000..4a69b76
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface3.java
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+public interface ServiceInterface3 extends ServiceSuperInterface3 {
+
+    // no methods
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface5.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface5.java
new file mode 100644
index 0000000..d413887
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceInterface5.java
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+public interface ServiceInterface5 {
+
+    boolean doRemoteThing();
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceSuperInterface3.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceSuperInterface3.java
new file mode 100644
index 0000000..4e2821a
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/sample/osgiserviceutil/ServiceSuperInterface3.java
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.mock.osgi.sample.osgiserviceutil;
+
+public interface ServiceSuperInterface3 {
+
+    // no methods
+
+}
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.xml
deleted file mode 100644
index c8e44f1..0000000
--- a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service1">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service1"/>
-    <service servicefactory="false">
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1"/>
-    </service>
-    <property name="service.ranking" type="Integer" value="100"/>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service1"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service2">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service2"/>
-    <service servicefactory="false">
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface2"/>
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3"/>
-    </service>
-    <property name="service.ranking" type="Integer" value="200"/>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service2"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3" activate="activate" deactivate="deactivate" modified="modified">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3"/>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3"/>
-    <reference name="reference1" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1" cardinality="1..1" policy="dynamic" bind="bindReference1" unbind="unbindReference1"/>
-    <reference name="reference1Optional" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1Optional" cardinality="0..1" policy="dynamic" bind="bindReference1Optional" unbind="unbindReference1Optional"/>
-    <reference name="reference2" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface2" cardinality="1..n" policy="dynamic" bind="bindReference2" unbind="unbindReference2"/>
-    <reference name="reference3" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="dynamic" bind="bindReference3" unbind="unbindReference3"/>
-    <reference name="reference3Set" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="dynamic" field="references3" bind="bindReference3Set" unbind="unbindReference3Set"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3OsgiR6" activate="activate" deactivate="deactivate" modified="modified">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3OsgiR6"/>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3OsgiR6"/>
-    <reference name="reference1" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1" cardinality="1..1" policy="dynamic" field="reference1"/>
-    <reference name="reference1Optional" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1Optional" cardinality="0..1" policy="dynamic" field="reference1Optional"/>
-    <reference name="reference2" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface2" cardinality="1..n" policy="dynamic" field="references2" field-collection-type="reference"/>
-    <reference name="reference3" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="dynamic" field="references3" field-collection-type="service"/>
-    <reference name="references3Filtered" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="dynamic" field="references3Filtered" field-collection-type="service" target="(prop1=abc)"/>
-    <reference name="reference3DynamicFiltered" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..1" policy="dynamic" field="reference3DynamicFiltered" field-collection-type="service"/>
-    <reference name="reference3Set" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="dynamic" field="references3Set" field-collection-type="service"/>
-    <reference name="reference3Collection" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="dynamic" field="references3Collection" field-collection-type="service"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3StaticGreedy" activate="activate" deactivate="deactivate" modified="modified">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3StaticGreedyImpl"/>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service3StaticGreedyImpl"/>
-    <reference name="reference1" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1" cardinality="1..1" policy="static" policy-option="greedy" bind="bindReference1" unbind="unbindReference1"/>
-    <reference name="reference1Optional" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1Optional" cardinality="0..1" policy="dynamic" policy-option="greedy" bind="bindReference1Optional" unbind="unbindReference1Optional"/>
-    <reference name="reference2" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface2" cardinality="1..n" policy="static" policy-option="greedy" bind="bindReference2" unbind="unbindReference2"/>
-    <reference name="reference3" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="static" policy-option="greedy" bind="bindReference3" unbind="unbindReference3"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service4_other_name">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service4"/>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service4"/>
-    <reference name="customName" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface1" cardinality="1..1" policy="static" bind="customBind" unbind="customUnbind"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service5">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service5"/>
-    <service servicefactory="false">
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceInterface5"/>
-    </service>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service5"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceFactory1">
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceFactory1"/>
-    <service servicefactory="true">
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceFactory1"/>
-    </service>
-    <property name="service.pid" value="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$ServiceFactory1"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$RankedServiceFive" activate="activate">
-    <property name="service.ranking" type="Integer" value="5"/>
-    <service>
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$RankedService"/>
-    </service>
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$RankedServiceFive"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$RankedServiceTen" activate="activate">
-    <property name="service.ranking" type="Integer" value="10"/>
-    <service>
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$RankedService"/>
-    </service>
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$RankedServiceTen"/>
-  </scr:component>
-  <scr:component name="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service6VolatileMultipleReferences">
-    <service>
-      <provide interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service6VolatileMultipleReferences"/>
-    </service>
-    <reference name="rankedServices" cardinality="0..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$RankedService" field="rankedServices" field-collection-type="service"/>
-    <implementation class="org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest$Service6VolatileMultipleReferences"/>
-  </scr:component>
-</components>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceFive.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceFive.xml
new file mode 100644
index 0000000..5985c59
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceFive.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceFive" activate="activate">
+  <property name="service.ranking" type="Integer" value="5"/>
+  <service>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedService"/>
+  </service>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceFive"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceTen.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceTen.xml
new file mode 100644
index 0000000..b8257c2
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceTen.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceTen" activate="activate">
+  <property name="service.ranking" type="Integer" value="10"/>
+  <service>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedService"/>
+  </service>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedServiceTen"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service1.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service1.xml
new file mode 100644
index 0000000..2758f75
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service1.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service1">
+  <property name="service.ranking" type="Integer" value="100"/>
+  <service>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1"/>
+  </service>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service1"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service2.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service2.xml
new file mode 100644
index 0000000..8b6370c
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service2.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service2">
+  <property name="service.ranking" type="Integer" value="200"/>
+  <service>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2"/>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3"/>
+  </service>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service2"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3.xml
new file mode 100644
index 0000000..0efef0a
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3" activate="activate" deactivate="deactivate" modified="modified">
+  <reference name="reference1" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1" bind="bindReference1" unbind="unbindReference1" field="reference1"/>
+  <reference name="reference1Optional" cardinality="0..1" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1Optional" bind="bindReference1Optional" unbind="unbindReference1Optional" field="reference1Optional"/>
+  <reference name="reference2" cardinality="1..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2" bind="bindReference2" unbind="unbindReference2" policy-option="greedy"/>
+  <reference name="reference3" cardinality="0..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3" bind="bindReference3" unbind="unbindReference3" policy-option="greedy" field="references3" field-collection-type="service"/>
+  <reference name="references3Set" cardinality="0..n" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3" field="references3Set" field-collection-type="service"/>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3OsgiR6.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3OsgiR6.xml
new file mode 100644
index 0000000..187df0e
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3OsgiR6.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3OsgiR6" activate="activate" deactivate="deactivate" modified="modified">
+  <reference name="reference1" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1" field="reference1"/>
+  <reference name="reference1Optional" cardinality="0..1" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1Optional" field="reference1Optional"/>
+  <reference name="reference3DynamicFiltered" cardinality="0..1" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceSuperInterface3" policy-option="greedy" field="reference3DynamicFiltered"/>
+  <reference name="references2" cardinality="1..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2" policy-option="greedy" field="references2" field-collection-type="reference"/>
+  <reference name="references3" cardinality="0..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3" policy-option="greedy" field="references3" field-collection-type="service"/>
+  <reference name="references3Collection" cardinality="0..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3" policy-option="greedy" field="references3Collection" field-collection-type="service"/>
+  <reference name="references3Filtered" cardinality="0..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3" target="(prop1=abc)" policy-option="greedy" field="references3Filtered" field-collection-type="service"/>
+  <reference name="references3Set" cardinality="0..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3" policy-option="greedy" field="references3Set" field-collection-type="service"/>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3OsgiR6"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedyImpl.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedyImpl.xml
new file mode 100644
index 0000000..ba68488
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedyImpl.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedyImpl" activate="activate" deactivate="deactivate" modified="modified">
+  <service>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedy"/>
+  </service>
+  <reference name="reference1" policy="static" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1" bind="bindReference1" unbind="unbindReference1" policy-option="greedy" field="reference1"/>
+  <reference name="reference1Optional" cardinality="0..1" policy="static" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1Optional" bind="bindReference1Optional" unbind="unbindReference1Optional" policy-option="greedy" field="reference1Optional"/>
+  <reference name="reference2" cardinality="1..n" policy="static" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface2" bind="bindReference2" unbind="unbindReference2" policy-option="greedy"/>
+  <reference name="reference3" cardinality="0..n" policy="static" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface3" bind="bindReference3" unbind="unbindReference3" policy-option="greedy" field="references3" field-collection-type="service"/>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service3StaticGreedyImpl"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service4.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service4.xml
new file mode 100644
index 0000000..9497e60
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service4.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service4">
+  <reference name="customName" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface1" bind="customBind" unbind="customUnbind"/>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service4"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service5.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service5.xml
new file mode 100644
index 0000000..432eaff
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service5.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service5">
+  <service>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceInterface5"/>
+  </service>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service5"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service6VolatileMultipleReferences.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service6VolatileMultipleReferences.xml
new file mode 100644
index 0000000..6f04ffd
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service6VolatileMultipleReferences.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service6VolatileMultipleReferences">
+  <service>
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service6VolatileMultipleReferences"/>
+  </service>
+  <reference name="rankedServices" cardinality="0..n" policy="dynamic" interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.RankedService" field="rankedServices" field-collection-type="service"/>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.Service6VolatileMultipleReferences"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceFactory1.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceFactory1.xml
new file mode 100644
index 0000000..8923fd5
--- /dev/null
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceFactory1.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceFactory1">
+  <service scope="bundle">
+    <provide interface="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceFactory1"/>
+  </service>
+  <implementation class="org.apache.sling.testing.mock.osgi.sample.osgiserviceutil.ServiceFactory1"/>
+</scr:component>
diff --git a/core/src/test/resources/OSGI-INF/serviceComponents.xml b/core/src/test/resources/OSGI-INF/serviceComponents.xml
index db1c94a..3cc116e 100644
--- a/core/src/test/resources/OSGI-INF/serviceComponents.xml
+++ b/core/src/test/resources/OSGI-INF/serviceComponents.xml
@@ -22,8 +22,6 @@
   <scr:component name="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata">
     <implementation class="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata"/>
     <service>
-      <provide interface="org.apache.sling.models.spi.Injector"/>
-      <provide interface="org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory"/>
       <provide interface="java.lang.Comparable"/>
     </service>
     <property name="service.ranking" type="Integer" value="5000"/>