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.4.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git
commit c5653ddab2ae90cca2577255fedd8e41c22dd99b Author: Robert Munteanu <[email protected]> AuthorDate: Wed May 27 13:24:29 2015 +0000 SLING-4756 - ServiceListener notifications are not filtered Service registration now sets the mandatory objectClass property git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1682011 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/sling/testing/mock/osgi/MockServiceRegistration.java | 1 + .../apache/sling/testing/mock/osgi/MockServiceReferenceTest.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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 c9c13dd..fafc13b 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 @@ -53,6 +53,7 @@ class MockServiceRegistration implements ServiceRegistration, Comparable<MockSer this.service = service; this.properties = properties != null ? properties : new Hashtable<String,Object>(); this.properties.put(Constants.SERVICE_ID, this.serviceId); + this.properties.put(Constants.OBJECTCLASS, clazzes); this.serviceReference = new MockServiceReference(bundle, this); this.bundleContext = bundleContext; readOsgiMetadata(); 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 c525575..2eb7cc3 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 @@ -18,6 +18,7 @@ */ package org.apache.sling.testing.mock.osgi; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; @@ -63,8 +64,11 @@ public class MockServiceReferenceTest { @Test public void testProperties() { - assertEquals(2, this.serviceReference.getPropertyKeys().length); + assertEquals(3, this.serviceReference.getPropertyKeys().length); assertEquals("value1", this.serviceReference.getProperty("customProp1")); + // mandatory properties set by the container + assertNotNull(this.serviceReference.getProperty(Constants.SERVICE_ID)); + assertArrayEquals((String[]) this.serviceReference.getProperty(Constants.OBJECTCLASS), new String[] { String.class.getName() }); } @Test -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
