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

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

commit 3c176625d1ba6d92dedee6a626e57d2592152499
Author: Stefan Seifert <[email protected]>
AuthorDate: Mon Oct 26 17:49:05 2015 +0000

    SLING-5198 osgi-mock: Add basic ConfigurationAdmin support
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1710663 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/testing/mock/osgi/MapUtil.java    |  64 ++++++++-----
 .../sling/testing/mock/osgi/MockBundleContext.java |   7 +-
 .../sling/testing/mock/osgi/MockConfiguration.java | 103 +++++++++++++++++++++
 .../testing/mock/osgi/MockConfigurationAdmin.java  |  62 +++++++++++++
 .../apache/sling/testing/mock/osgi/MockOsgi.java   |  25 ++++-
 .../testing/mock/osgi/MockServiceRegistration.java |  10 +-
 .../mock/osgi/MockConfigurationAdminTest.java      |  80 ++++++++++++++++
 .../mock/osgi/MockServiceReferenceTest.java        |   6 +-
 .../testing/mock/osgi/OsgiMetadataUtilTest.java    |   5 +-
 src/test/resources/OSGI-INF/serviceComponents.xml  |   4 +-
 10 files changed, 322 insertions(+), 44 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
index 8a9e4a8..45d7a31 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.osgi;
 
+import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -25,6 +26,9 @@ import java.util.Hashtable;
 import java.util.Map;
 
 import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.OsgiMetadata;
+import org.osgi.framework.Constants;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
 
 /**
  * Map util methods.
@@ -51,35 +55,51 @@ final class MapUtil {
         return map;
     }
 
-    public static Dictionary<String, Object> 
propertiesMergeWithOsgiMetadata(Object target, Dictionary<String, Object> 
properties) {
-        Dictionary<String, Object> mergedProperties = new Hashtable<String, 
Object>();
-        
-        OsgiMetadata metadata = 
OsgiMetadataUtil.getMetadata(target.getClass());
-        if (metadata != null && metadata.getProperties() != null) {
-            for (Map.Entry<String, Object> entry : 
metadata.getProperties().entrySet()) {
-                mergedProperties.put(entry.getKey(), entry.getValue());
-            }
-        }
-        
-        if (properties != null) {
-            Enumeration<String> keys = properties.keys();
-            while (keys.hasMoreElements()) {
-                String key = keys.nextElement();
-                mergedProperties.put(key, properties.get(key));
-            }
-        }
-        
-        return mergedProperties;
+    public static Dictionary<String, Object> 
propertiesMergeWithOsgiMetadata(Object target, 
+            ConfigurationAdmin configAdmin, 
+            Dictionary<String, Object> properties) {
+        return toDictionary(propertiesMergeWithOsgiMetadata(target, 
configAdmin, toMap(properties)));
     }
     
-    public static Map<String, Object> propertiesMergeWithOsgiMetadata(Object 
target, Map<String, Object> properties) {
+    /**
+     * Merge service properties from three sources (with this precedence):
+     * 1. Properties defined in calling unit test code
+     * 2. Properties from ConfigurationAdmin
+     * 3. Properties from OSGi SCR metadata
+     * @param target Target service
+     * @param configAdmin Configuration admin or null if none is registered
+     * @param properties Properties from unit test code or null if none where 
passed
+     * @return Merged properties
+     */
+    @SuppressWarnings("unchecked")
+    public static Map<String, Object> propertiesMergeWithOsgiMetadata(Object 
target,
+            ConfigurationAdmin configAdmin,
+            Map<String, Object> properties) {
         Map<String, Object> mergedProperties = new HashMap<String, Object>();
         
         OsgiMetadata metadata = 
OsgiMetadataUtil.getMetadata(target.getClass());
-        if (metadata != null && metadata.getProperties() != null) {
-            mergedProperties.putAll(metadata.getProperties());
+        if (metadata != null) {
+            Map<String,Object> metadataProperties = metadata.getProperties();
+            if (metadataProperties != null) {
+                mergedProperties.putAll(metadataProperties);
+
+                // merge with configuration from config admin
+                if (configAdmin != null) {
+                    Object pid = metadataProperties.get(Constants.SERVICE_PID);
+                    if (pid != null) {
+                        try {
+                            Configuration config = 
configAdmin.getConfiguration(pid.toString());
+                            
mergedProperties.putAll(toMap(config.getProperties()));
+                        }
+                        catch (IOException ex) {
+                            throw new RuntimeException("Unable to read config 
for pid " + pid, ex);
+                        }
+                    }
+                }
+            }
         }
         
+        // merge with properties from calling unit test code
         if (properties != null) {
             mergedProperties.putAll(properties);
         }
diff --git 
a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
index 5342e7f..786fad7 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
@@ -49,6 +49,7 @@ import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationAdmin;
 
 import com.google.common.collect.ImmutableList;
 
@@ -61,9 +62,13 @@ class MockBundleContext implements BundleContext {
     private final SortedSet<MockServiceRegistration> registeredServices = new 
ConcurrentSkipListSet<MockServiceRegistration>();
     private final Map<ServiceListener, Filter> serviceListeners = new 
ConcurrentHashMap<ServiceListener, Filter>();
     private final Queue<BundleListener> bundleListeners = new 
ConcurrentLinkedQueue<BundleListener>();
+    private final ConfigurationAdmin configAdmin = new 
MockConfigurationAdmin();
 
     public MockBundleContext() {
         this.bundle = new MockBundle(this);
+        
+        // register configuration admin by default
+        registerService(ConfigurationAdmin.class.getName(), configAdmin, null);
     }
 
     @Override
@@ -100,7 +105,7 @@ class MockBundleContext implements BundleContext {
     @SuppressWarnings("unchecked")
     @Override
     public ServiceRegistration registerService(final String[] clazzes, final 
Object service, final Dictionary properties) {
-        Dictionary<String, Object> mergedPropertes = 
MapUtil.propertiesMergeWithOsgiMetadata(service, properties);
+        Dictionary<String, Object> mergedPropertes = 
MapUtil.propertiesMergeWithOsgiMetadata(service, configAdmin, properties);
         MockServiceRegistration registration = new 
MockServiceRegistration(this.bundle, clazzes, service, mergedPropertes, this);
         handleRefsUpdateOnRegister(registration);
         this.registeredServices.add(registration);
diff --git 
a/src/main/java/org/apache/sling/testing/mock/osgi/MockConfiguration.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockConfiguration.java
new file mode 100644
index 0000000..4959cb6
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockConfiguration.java
@@ -0,0 +1,103 @@
+/*
+ * 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;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.Constants;
+import org.osgi.service.cm.Configuration;
+
+/**
+ * Mock implementation of {@link Configuration}.
+ */
+class MockConfiguration implements Configuration {
+    
+    private final String pid;
+    private Dictionary<String, Object> props;
+    
+    /**
+     * @param pid PID
+     */
+    public MockConfiguration(String pid) {
+        this.pid = pid;
+        props = newConfig(pid);
+    }
+
+    @Override
+    public String getPid() {
+        return pid;
+    }
+
+    @Override
+    public Dictionary getProperties() {
+        // return copy of dictionary
+        return new Hashtable<String,Object>(MapUtil.toMap(props));
+    }
+
+    @Override
+    public void update() {
+        // the updating of services already registered in mock-osgi is 
currently not supported.
+        // still allow calling this method to allow usage of {@link 
update(Dictionary)}, but it works
+        // only if applied bevore registering a service in mock-osgi.
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void update(Dictionary properties) {
+        this.props = new Hashtable<String, Object>(MapUtil.toMap(properties));;
+        this.props.put(Constants.SERVICE_PID, pid);
+        this.update();
+    }
+
+    @Override
+    public void delete() {
+        // just clear the props map
+        props = newConfig(pid);
+    }
+    
+    @Override
+    public String toString() {
+        return props.toString();
+    }
+
+    private static Dictionary<String,Object> newConfig(String pid) {
+        Dictionary<String, Object> config = new Hashtable<String, Object>();
+        config.put(Constants.SERVICE_PID, pid);
+        return config;
+    }
+
+    // --- unsupported operations ---
+    
+    @Override
+    public void setBundleLocation(String bundleLocation) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String getBundleLocation() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String getFactoryPid() {
+        throw new UnsupportedOperationException();
+    }
+
+}
diff --git 
a/src/main/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdmin.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdmin.java
new file mode 100644
index 0000000..f195c1c
--- /dev/null
+++ 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdmin.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.osgi;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * Mock implementation of {@link ConfigurationAdmin}.
+ */
+class MockConfigurationAdmin implements ConfigurationAdmin {
+    
+    private ConcurrentMap<String, Configuration> configs = new 
ConcurrentHashMap<String, Configuration>();
+
+    @Override
+    public Configuration getConfiguration(String pid) {
+        configs.putIfAbsent(pid, new MockConfiguration(pid));
+        return configs.get(pid);
+    }
+
+    // --- unsupported operations ---
+
+    @Override
+    public Configuration getConfiguration(String pid, String location) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Configuration createFactoryConfiguration(String factoryPid) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Configuration createFactoryConfiguration(String factoryPid, String 
location) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Configuration[] listConfigurations(String filter) {
+        throw new UnsupportedOperationException();
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
index af48885..a189fda 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
@@ -27,6 +27,8 @@ import java.util.Map;
 
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.log.LogService;
 
@@ -157,7 +159,7 @@ public final class MockOsgi {
      */
     @Deprecated
     public static boolean activate(Object target, Dictionary<String, Object> 
properties) {
-        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, properties);
+        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, null, properties);
         ComponentContext componentContext = 
newComponentContext(mergedProperties);
         return OsgiServiceUtil.activateDeactivate(target, componentContext, 
true);
     }
@@ -183,7 +185,7 @@ public final class MockOsgi {
      * @return true if activation method was called. False if no activate 
method is defined.
      */
     public static boolean activate(Object target, BundleContext bundleContext, 
Dictionary<String, Object> properties) {
-        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, properties);
+        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, getConfigAdmin(bundleContext), 
properties);
         ComponentContext componentContext = newComponentContext(bundleContext, 
mergedProperties);
         return OsgiServiceUtil.activateDeactivate(target, componentContext, 
true);
     }
@@ -231,7 +233,7 @@ public final class MockOsgi {
      */
     @Deprecated
     public static boolean deactivate(Object target, Dictionary<String, Object> 
properties) {
-        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, properties);
+        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, null, properties);
         ComponentContext componentContext = 
newComponentContext(mergedProperties);
         return OsgiServiceUtil.activateDeactivate(target, componentContext, 
false);
     }
@@ -257,7 +259,7 @@ public final class MockOsgi {
      * @return true if deactivation method was called. False if no deactivate 
method is defined.
      */
     public static boolean deactivate(Object target, BundleContext 
bundleContext, Dictionary<String, Object> properties) {
-        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, properties);
+        Dictionary<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, getConfigAdmin(bundleContext), 
properties);
         ComponentContext componentContext = newComponentContext(bundleContext, 
mergedProperties);
         return OsgiServiceUtil.activateDeactivate(target, componentContext, 
false);
     }
@@ -292,7 +294,7 @@ public final class MockOsgi {
      * @return true if modified method was called. False if no modified method 
is defined.
      */
     public static boolean modified(Object target, BundleContext bundleContext, 
Map<String, Object> properties) {
-        Map<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, properties);
+        Map<String, Object> mergedProperties = 
propertiesMergeWithOsgiMetadata(target, getConfigAdmin(bundleContext), 
properties);
         return OsgiServiceUtil.modified(target, bundleContext, 
mergedProperties);
     }
     
@@ -304,4 +306,17 @@ public final class MockOsgi {
         ((MockBundleContext)bundleContext).shutdown();
     }
     
+    /**
+     * Get configuration admin.
+     * @param bundleContext Bundle context
+     * @return Configuration admin or null if not registered.
+     */
+    private static ConfigurationAdmin getConfigAdmin(BundleContext 
bundleContext) {
+        ServiceReference ref = 
bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
+        if (ref != null) {
+            return (ConfigurationAdmin)bundleContext.getService(ref);
+        }
+        return null;
+    }
+    
 }
diff --git 
a/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
index 488cfa7..8ef25a4 100644
--- 
a/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
+++ 
b/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
@@ -21,7 +21,6 @@ package org.apache.sling.testing.mock.osgi;
 import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.lang3.StringUtils;
@@ -124,8 +123,7 @@ class MockServiceRegistration implements 
ServiceRegistration, Comparable<MockSer
     }
 
     /**
-     * Try to read OSGI-metadata from /OSGI-INF and read all implemented
-     * interfaces and service properties
+     * Try to read OSGI-metadata from /OSGI-INF and read all implemented 
interfaces
      */
     private void readOsgiMetadata() {
         Class<?> serviceClass = service.getClass();
@@ -136,12 +134,6 @@ class MockServiceRegistration implements 
ServiceRegistration, Comparable<MockSer
 
         // add service interfaces from OSGi metadata
         clazzes.addAll(metadata.getServiceInterfaces());
-
-        // add properties from OSGi metadata
-        Map<String, Object> props = metadata.getProperties();
-        for (Map.Entry<String, Object> entry : props.entrySet()) {
-            properties.put(entry.getKey(), entry.getValue());
-        }
     }
 
     @Override
diff --git 
a/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
 
b/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
new file mode 100644
index 0000000..ded699f
--- /dev/null
+++ 
b/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import 
org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.ServiceWithMetadata;
+import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import com.google.common.collect.ImmutableMap;
+
+public class MockConfigurationAdminTest {
+    
+    private static final String[] TEST_ADAPTABLES = new String[] {
+        "adaptable1",
+        "adaptable2"
+    };
+
+    @Rule
+    public OsgiContext context = new OsgiContext();
+
+    @Test
+    public void testGetConfigurationString() throws IOException {
+        ConfigurationAdmin configAdmin = 
context.getService(ConfigurationAdmin.class);
+        
+        Configuration config = 
configAdmin.getConfiguration("org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata");
+        Dictionary<String, Object> configProps = new Hashtable<String, 
Object>();
+        configProps.put(Constants.SERVICE_RANKING, 3000);
+        configProps.put("adaptables", TEST_ADAPTABLES);
+        configProps.put("prop2", 2);
+        config.update(configProps);
+        
+        context.registerInjectActivateService(new ServiceWithMetadata(), 
ImmutableMap.<String, Object>builder()
+                .put(Constants.SERVICE_RANKING, 4000)
+                .put("prop1", 1)
+                .build());
+        
+        ServiceReference reference = 
context.bundleContext().getServiceReference(Comparable.class.getName());
+
+        // values passed over when registering service has highest precedence
+        assertEquals(4000, reference.getProperty(Constants.SERVICE_RANKING));
+        assertEquals(1, reference.getProperty("prop1"));
+
+        // values set in config admin has 2ndmost highest precedence
+        assertArrayEquals(TEST_ADAPTABLES, 
(String[])reference.getProperty("adaptables"));
+        assertEquals(2, reference.getProperty("prop2"));
+
+        // values set in OSGi SCR metadata
+        assertEquals("The Apache Software Foundation", 
reference.getProperty(Constants.SERVICE_VENDOR));
+        
assertEquals("org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata",
 reference.getProperty(Constants.SERVICE_PID));
+    }
+
+}
diff --git 
a/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
 
b/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
index 2eb7cc3..b938754 100644
--- 
a/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
+++ 
b/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
@@ -77,9 +77,9 @@ public class MockServiceReferenceTest {
         bundleContext.registerService((String) null, serviceWithMetadata, 
null);
         ServiceReference reference = 
this.bundleContext.getServiceReference(Comparable.class.getName());
 
-        assertEquals(5000, reference.getProperty("service.ranking"));
-        assertEquals("The Apache Software Foundation", 
reference.getProperty("service.vendor"));
-        
assertEquals("org.apache.sling.models.impl.injectors.OSGiServiceInjector", 
reference.getProperty("service.pid"));
+        assertEquals(5000, reference.getProperty(Constants.SERVICE_RANKING));
+        assertEquals("The Apache Software Foundation", 
reference.getProperty(Constants.SERVICE_VENDOR));
+        
assertEquals("org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata",
 reference.getProperty(Constants.SERVICE_PID));
     }
 
 }
diff --git 
a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java 
b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
index 6663f81..050d951 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
@@ -31,6 +31,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.OsgiMetadata;
 import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.Reference;
 import org.junit.Test;
+import org.osgi.framework.Constants;
 
 public class OsgiMetadataUtilTest {
 
@@ -48,8 +49,8 @@ public class OsgiMetadataUtilTest {
         Map<String, Object> props = metadata.getProperties();
         assertEquals(4, props.size());
         assertEquals(5000, props.get("service.ranking"));
-        assertEquals("The Apache Software Foundation", 
props.get("service.vendor"));
-        
assertEquals("org.apache.sling.models.impl.injectors.OSGiServiceInjector", 
props.get("service.pid"));
+        assertEquals("The Apache Software Foundation", 
props.get(Constants.SERVICE_VENDOR));
+        
assertEquals("org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata",
 props.get(Constants.SERVICE_PID));
         assertArrayEquals(new String[] { 
"org.apache.sling.api.resource.Resource", 
"org.apache.sling.api.resource.ResourceResolver" },
                 (String[])props.get("adaptables"));
     }
diff --git a/src/test/resources/OSGI-INF/serviceComponents.xml 
b/src/test/resources/OSGI-INF/serviceComponents.xml
index 14840ed..882de1c 100644
--- a/src/test/resources/OSGI-INF/serviceComponents.xml
+++ b/src/test/resources/OSGI-INF/serviceComponents.xml
@@ -19,7 +19,7 @@
 -->
 <!-- This file follows the old SCR convention using a fixed name 
"serviceComponents.xml" -->
 <components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0";>
-  <scr:component 
name="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata"
 activate="activate">
+  <scr:component 
name="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata">
     <implementation 
class="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata"/>
     <service servicefactory="false">
       <provide interface="org.apache.sling.models.spi.Injector"/>
@@ -28,7 +28,7 @@
     </service>
     <property name="service.ranking" type="Integer" value="5000"/>
     <property name="service.vendor" value="The Apache Software Foundation"/>
-    <property name="service.pid" 
value="org.apache.sling.models.impl.injectors.OSGiServiceInjector"/>
+    <property name="service.pid" 
value="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata"/>
     <property name="adaptables">
        org.apache.sling.api.resource.Resource
        org.apache.sling.api.resource.ResourceResolver

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

Reply via email to