You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:21:10 UTC

[sling-org-apache-sling-testing-osgi-mock] annotated tag org.apache.sling.testing.osgi-mock-2.0.4 created (now 4f0b866)

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

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


      at 4f0b866  (tag)
 tagging 5a8348baf4db8758de0a60d294146a9df537bc40 (commit)
      by Stefan Seifert
      on Fri Jun 10 12:13:23 2016 +0000

- Log -----------------------------------------------------------------
org.apache.sling.testing.osgi-mock-2.0.4
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new e5ba840  SLING-4042 Donate sling-mock, jcr-mock, osgi-mock implementation
     new e1ee5ad  svn:ignore
     new 8d20817  SLING-4042 move all mock projects to mocks/ subdirectory
     new ad838b2  SLING-4042 add missing package-info files
     new 740687d  SLING-4042 make sure dependency injection is continued even if not all injections succeeded, and report root cause of invocation target exceptions
     new 7e5bc2d  SLING-4042 add README files
     new 21a5152  add/update SCM urls
     new 74be83a  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.0.0
     new d794a37  [maven-release-plugin] prepare for next development iteration
     new 0a80e0c  SLING-4090 Define package versions for Sling Mock, JCR Mock, OSGi Mock
     new 59f74f6  SLING-4142 MockOsgi: Activate/Deactivate method does not support different signatures
     new a822c76  SLING-4162 Introduce "OsgiContext" junit rule for OSGi and OsgiContextImpl
     new b30dd56  SLING-4162 fix javadoc
     new c40b2dd  SLING-4163 OSGi Mock: Reference bind/unbind method picking order
     new abe8b21  fix some javadoc copy&paste errors and formatting
     new 7c2b519  SLING-4166 OSGi Mock: Support for "modified" SCR lifecycle method
     new 4d131cd  SLING-4166 update package version
     new 907c7df  SLING-4165 OSGi Mock: Fail-fast when calling methods requiring SCR metadata and this is not present
     new 5538cda  SLING-4201 MockOsgi.activate()/deactivate()/modified() should fail fast if method is declared but can't be found
     new 50112aa  SLING-4202 OSGi Mock: Fail-fast when mandatory references cannot be injected
     new 70f5447  fix some javadoc errors/warnings
     new d7f336c  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.1.0
     new 5022c27  [maven-release-plugin] prepare for next development iteration
     new b910746  rename package-private class ReflectinServiceUtil to OsgiServiceUtil because it does not any longer use reflection to do it's job (no functional change)
     new 68de5d4  SLING-4435 OSGi Mock: Cache reading of OSGi SCR Metadata files
     new dc9866e  SLING-4439 add support for unregistering services and prepare dynamic service reference handling
     new e3e8bb1  SLING-4439 implement dynamic service registration
     new e6baa2c  SLING-4439 implement dynamic service registration
     new a980473  SLING-4439 implement dynamic service registration
     new e828e3d  SLING-4439 implement dynamic service registration - support string array properties in osgi metadata as well - merge properties from osgi metadata with those specified on activation/registration call - support "old-style" scr component metadata file as well (and test this case)
     new 5afcfc6  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.2.0
     new cea3da7  [maven-release-plugin] prepare for next development iteration
     new c389c24  SLING-4472 MockBundleContent.getProperty should return null
     new 4900b9b  Add missing licence headers and ignores for rat
     new 174e654  SLING-4670 : SCR metadata can't be read if components element is missing
     new c1ab86f  SLING-4698 - Set parent.relativePath to empty for all modules
     new ad91a5b  SLING-4718 Support OSGi component name different from implementation class
     new dd63020  SLING-4719 osgi-mock: Add Mock EventAdmin implementation
     new aede0b4  SLING-4720 Add support for "Long" and "Boolean" property types in SCR metadata
     new bd78f8a  SLING-4725 osgi-mock: Make compatible to OSGi 5/6
     new 9a4208d  SLING-4470 introduce separate "logging-mock" project for default log configuration in mock tests, remove compile-dependency on slf4j-simple
     new 61fec88  update dependencies for release
     new 20100ff  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.3.0
     new 1e80946  [maven-release-plugin] prepare for next development iteration
     new 62541d8  update to next development snapshot unit released artifacts are in maven central
     new c5653dd  SLING-4756 - ServiceListener notifications are not filtered
     new cd84d7c  SLING-4756 - ServiceListener notifications are not filtered
     new 88790a8  SLING-4756 - ServiceListener notifications are not filtered
     new 3704cb2  update to released mock versions
     new 0f222f7  SLING-4769 Osgi Mock: Add support for bundle headers
     new 5644c49  SLING-4756 add support for filtering via felix.framework FilterImpl implementation
     new f4513f8  SLING-4771 Osgi Mock: Allow to set mock bundle symbolic name
     new 9b26d4c  OsgiServiceUtil: clarify exception message when no matching references were found
     new 7da1c22  MockBundleTest - cast once in the @BeforeMethod instead of every test
     new 4d21da0  SLING-4780 - Implement MockBundle.getLastModified
     new 9248ced  SLING-4781 - Implement MockBundle.getEntryPaths
     new ed82c56  SLING-4781 - Implement MockBundle.getEntryPaths
     new 456e603  SLING-4813 - Support CGLIB enhanced classes for Mockito based service mocks
     new 8d9a404  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.4.0
     new 1e43ffc  [maven-release-plugin] prepare for next development iteration
     new 2cd752f  Update to Sling Parent 23
     new 5e5797b  Testing: remove superflous sling.java.version=6 as it's the default now
     new 384b81a  Update rat exclude rules
     new a69eb1b  @no-jira : test failed with a timeout on jenkins - tring with 2sec timeout
     new 64dc2d0  SLING-4845 - MockBundleContext is not thread-safe
     new 9260a58  SLING-4845 - MockBundleContext is not thread-safe
     new e283546  set parent version to 24 and add empty relativePath where missing
     new e996493  remove unused LOG variable
     new 45d1dbc  SLING-4901 osgi-mock: Add support for ComponentContext.getUsingBundle()
     new ec78cea  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.5.0
     new b693d17  [maven-release-plugin] prepare for next development iteration
     new 1e64d07  cosmetic: beautify error messages when setup/teardown fails
     new 2b257a4  SLING-5083 osgi-mock: Eliminate compile dependency to org.apache.felix.scr.annotations
     new ee4eeb2  SLING-5089 mock-osgi: Deactivate all services on shutdown
     new 3747fc7  SLING-5089 deactivate services in reverse order
     new 571dcdb  SLING-5090 osgi-mock: Support ServiceFactory
     new 29e4a32  SLING-5088 properly shutdown executor service in MockEventAdmin
     new a80c2f8  SLING-5088 deprecate activate/deactivate methods without bundleContext parameter because there is a small risk for memory leaks
     new 3e81888  cosmetic: fix javadoc errors
     new 07870d2  Update the main reactor to parent 25
     new 5f24bfb  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.6.0
     new b52bba4  [maven-release-plugin] prepare for next development iteration
     new 5bdecdf  SLING-5143 osgi-mock: MockBundleContext is not thread-safe when using iterators
     new 3c17662  SLING-5198 osgi-mock: Add basic ConfigurationAdmin support
     new 4aa8c55  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-1.7.0
     new d38d8c1  [maven-release-plugin] prepare for next development iteration
     new 505f211  SLING-5312 osgi-mock: Eliminate runtime-depenency to Felix SCR annotations
     new 9618e26  SLING-5323 Update to OSGi R6
     new 3f5a172  SLING-5324 osgi-mock: Support OSGi R6 field-based reference bindings
     new bf51720  SLING-5325 osgi-mock: Support target filtering on DS references
     new 5e0ac1d  SLING-5323 no need to update to JDK 1.7, we stick with JDK 1.6.
     new eb580c3  SLING-5327 refactor and unify lifecycle method handling (and fix missing argument variants for modified methods - should support the same as the activate method)
     new db27b68  SLING-5327 osgi-mock: Support OSGi R6 Component propert types for configuration
     new b29a918  SLING-5327 inline the required classes from org.apache.felix.scr
     new 5d2ecfe  SLING-5372 osgi-mock: MockBundleContext.getServices(Class,String) throws NPE when no services found
     new 4e489a6  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-2.0.0
     new 9c07ff3  [maven-release-plugin] prepare for next development iteration
     new b3f468c  SLING-5391 osgi-mock: Switch to osgi.core and osgi.cmpn dependencies
     new 2efd6e6  Switch to parent pom 26
     new 6759271  SLING-5453 implement MockBundleContext.getDataFile
     new 7d50f99  SLING-5453 implement MockBundleContext.getDataFile
     new c79ef61  SLING-5462 - demonstrate the wrong sorting of mock service references
     new 0e10e45  SLING-5462 ensure service references are sorted ascending by service ranking, not descending
     new fe2625e  SLING-5462 switch to comparable implementation from commons.osgi and change wrong assumptions in unit test
     new 09964b1  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-2.0.2
     new a8a4072  [maven-release-plugin] prepare for next development iteration
     new 8a090aa  SLING-5544 osgi-mock: Catch RejectedExecutionException in MockEventAdmin
     new 1c6b586  SLING-5667 MockBundleContext.getServiceReference(...) does not return service reference with highest ranking
     new b251609  [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-2.0.4
     new 5a8348b  [maven-release-plugin] copy for tag org.apache.sling.testing.osgi-mock-2.0.4

The 110 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-testing-osgi-mock] 05/05: [maven-release-plugin] copy for tag org.apache.sling.testing.osgi-mock-2.0.4

Posted by ro...@apache.org.
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-2.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit 5a8348baf4db8758de0a60d294146a9df537bc40
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Jun 10 12:13:23 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.testing.osgi-mock-2.0.4
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.osgi-mock-2.0.4@1747696 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-testing-osgi-mock] 01/05: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
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-2.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit a8a4072737443b72494315cbb7040838c9d02549
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Feb 5 22:23:17 2016 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1728747 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 76fb08f..ad787fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-    <version>2.0.2</version>
+    <version>2.0.3-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Testing OSGi Mock</name>
     <description>Mock implementation of selected OSGi APIs.</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.osgi-mock-2.0.2</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.osgi-mock-2.0.2</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.osgi-mock-2.0.2</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/osgi-mock</url>
     </scm>
     
     <dependencies>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-testing-osgi-mock] 03/05: SLING-5667 MockBundleContext.getServiceReference(...) does not return service reference with highest ranking

Posted by ro...@apache.org.
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-2.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit 1c6b58649be856e2b40ca1a7ef4a8a2f2c21775b
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Apr 29 16:54:38 2016 +0000

    SLING-5667 MockBundleContext.getServiceReference(...) does not return service reference with highest ranking
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1741665 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  2 +-
 .../sling/testing/mock/osgi/MockEventAdmin.java    |  5 +-
 .../testing/mock/osgi/MockServiceReference.java    |  3 +-
 .../testing/mock/osgi/MockBundleContextTest.java   | 20 +++----
 .../mock/osgi/MockServiceReferencesSortTest.java   | 70 ++++++++++++++--------
 .../mock/osgi/context/OsgiContextImplTest.java     |  8 ++-
 6 files changed, 67 insertions(+), 41 deletions(-)

diff --git a/pom.xml b/pom.xml
index ad787fe..d076409 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,7 +59,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.osgi</artifactId>
-            <version>2.2.0</version>
+            <version>2.4.0</version>
             <scope>compile</scope>
         </dependency>
 
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
index d182d1f..86c4eb5 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
@@ -33,6 +33,7 @@ import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.commons.osgi.Order;
 import org.apache.sling.commons.osgi.ServiceUtil;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.event.Event;
@@ -106,13 +107,13 @@ public final class MockEventAdmin implements EventAdmin {
     
     protected void bindEventHandler(EventHandler eventHandler, Map<String, Object> props) {
         synchronized (eventHandlers) {
-            eventHandlers.put(ServiceUtil.getComparableForServiceRanking(props), new EventHandlerItem(eventHandler, props));
+            eventHandlers.put(ServiceUtil.getComparableForServiceRanking(props, Order.DESCENDING), new EventHandlerItem(eventHandler, props));
         }
     }
 
     protected void unbindEventHandler(EventHandler eventHandler, Map<String, Object> props) {
         synchronized (eventHandlers) {
-            eventHandlers.remove(ServiceUtil.getComparableForServiceRanking(props));
+            eventHandlers.remove(ServiceUtil.getComparableForServiceRanking(props, Order.DESCENDING));
         }
     }
     
diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java
index 3d3d9ae..32ebd02 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Map;
 
+import org.apache.sling.commons.osgi.Order;
 import org.apache.sling.commons.osgi.ServiceUtil;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -44,7 +45,7 @@ class MockServiceReference<T> implements ServiceReference<T> {
     
     private Comparable<Object> buildComparable() {
         Map<String,Object> props = MapUtil.toMap(serviceRegistration.getProperties());
-        return ServiceUtil.getComparableForServiceRanking(props);
+        return ServiceUtil.getComparableForServiceRanking(props, Order.DESCENDING);
     }
     
     @Override
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
index c2b18ee..5dba8d6 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
@@ -73,15 +73,15 @@ public class MockBundleContextTest {
     @Test
     public void testServiceRegistration() throws InvalidSyntaxException {
         // prepare test services
-        String[] clazzes2 = new String[] { String.class.getName(), Integer.class.getName() };
-        Object service2 = new Object();
+        String[] clazzes1 = new String[] { String.class.getName(), Integer.class.getName() };
+        Object service1 = new Object();
         Dictionary<String, Object> properties2 = getServiceProperties(null);
-        ServiceRegistration reg2 = bundleContext.registerService(clazzes2, service2, properties2);
+        ServiceRegistration reg1 = bundleContext.registerService(clazzes1, service1, properties2);
 
-        String clazz1 = String.class.getName();
-        Object service1 = new Object();
+        String clazz2 = String.class.getName();
+        Object service2 = new Object();
         Dictionary<String, Object> properties1 = getServiceProperties(null);
-        ServiceRegistration reg1 = bundleContext.registerService(clazz1, service1, properties1);
+        ServiceRegistration reg2 = bundleContext.registerService(clazz2, service2, properties1);
 
         String clazz3 = Integer.class.getName();
         Object service3 = new Object();
@@ -93,7 +93,7 @@ public class MockBundleContextTest {
         assertSame(reg1.getReference(), refString);
 
         ServiceReference<?> refInteger = bundleContext.getServiceReference(Integer.class.getName());
-        assertSame(reg3.getReference(), refInteger);
+        assertSame(reg1.getReference(), refInteger);
 
         ServiceReference<?>[] refsString = bundleContext.getServiceReferences(String.class.getName(), null);
         assertEquals(2, refsString.length);
@@ -106,8 +106,8 @@ public class MockBundleContextTest {
 
         ServiceReference<?>[] refsInteger = bundleContext.getServiceReferences(Integer.class.getName(), null);
         assertEquals(2, refsInteger.length);
-        assertSame(reg3.getReference(), refsInteger[0]);
-        assertSame(reg2.getReference(), refsInteger[1]);
+        assertSame(reg1.getReference(), refsInteger[0]);
+        assertSame(reg3.getReference(), refsInteger[1]);
 
         ServiceReference<?>[] allRefsString = bundleContext.getAllServiceReferences(String.class.getName(), null);
         assertArrayEquals(refsString, allRefsString);
@@ -115,7 +115,7 @@ public class MockBundleContextTest {
         // test get services
         assertSame(service1, bundleContext.getService(refsString[0]));
         assertSame(service2, bundleContext.getService(refsString[1]));
-        assertSame(service3, bundleContext.getService(refInteger));
+        assertSame(service1, bundleContext.getService(refInteger));
 
         // unget does nothing
         bundleContext.ungetService(refsString[0]);
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
index b34add1..e60622b 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
@@ -22,10 +22,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Hashtable;
-import java.util.List;
 
 import org.junit.After;
 import org.junit.Before;
@@ -52,33 +50,61 @@ public class MockServiceReferencesSortTest {
     }
 
     @Test
-    public void testServicesOrder() {
-        assertEquals("12345", getSortedServicesString(bundleContext));
+    public void testAllWithRanking() {
+        registerStringServiceWithRanking("A", 3);
+        registerStringServiceWithRanking("B", 5);
+        registerStringServiceWithRanking("C", 4);
+        registerStringServiceWithRanking("D", 1);
+        registerStringServiceWithRanking("E", 2);
+        
+        assertEquals("BCAED", getSortedServicesString());
+        assertEquals("B", bundleContext.getService(bundleContext.getServiceReference(String.class)));
+    }
+
+    @Test
+    public void testAllWithoutRanking() {
+        registerStringServiceWithoutRanking("A");
+        registerStringServiceWithoutRanking("B");
+        registerStringServiceWithoutRanking("C");
+        registerStringServiceWithoutRanking("D");
+        registerStringServiceWithoutRanking("E");
+        
+        assertEquals("ABCDE", getSortedServicesString());
+        assertEquals("A", bundleContext.getService(bundleContext.getServiceReference(String.class)));
+    }
+
+    @Test
+    public void testMixed() {
+        registerStringServiceWithoutRanking("A");
+        registerStringServiceWithRanking("B", 5);
+        registerStringServiceWithoutRanking("C");
+        registerStringServiceWithRanking("D", 10);
+        registerStringServiceWithoutRanking("E");
+        
+        assertEquals("DBACE", getSortedServicesString());
+        assertEquals("D", bundleContext.getService(bundleContext.getServiceReference(String.class)));
+    }
+
+    private ServiceRegistration<?> registerStringServiceWithoutRanking(String serviceValue) {
+        return bundleContext.registerService(String.class, serviceValue, new Hashtable<String, Object>());
     }
 
-    private static ServiceRegistration<?> registerStringService(BundleContext ctx, int index) {
+    private ServiceRegistration<?> registerStringServiceWithRanking(String serviceValue, int index) {
         final Hashtable<String, Object> props = new Hashtable<String, Object>();
         props.put(Constants.SERVICE_RANKING, new Integer(index));
-        return ctx.registerService(String.class.getName(), String.valueOf(index), props);
+        return bundleContext.registerService(String.class, serviceValue, props);
     }
     
     /** Register services with a specific ranking, sort their references and 
      *  return their concatenated toString() values.
      *  Use to test service references sorting.
      */
-    private static String getSortedServicesString(BundleContext ctx) {
-        final List<ServiceRegistration<?>> toCleanup = new ArrayList<ServiceRegistration<?>>();
-        
-        toCleanup.add(registerStringService(ctx, 3));
-        toCleanup.add(registerStringService(ctx, 5));
-        toCleanup.add(registerStringService(ctx, 4));
-        toCleanup.add(registerStringService(ctx, 1));
-        toCleanup.add(registerStringService(ctx, 2));
-        
-        ServiceReference<?> [] refs = null;
+    private String getSortedServicesString() {
+        ServiceReference<?>[] refs = null;
         try {
-            refs = ctx.getServiceReferences(String.class.getName(), null);
-        } catch(InvalidSyntaxException ise) {
+            refs = bundleContext.getServiceReferences(String.class.getName(), null);
+        }
+        catch(InvalidSyntaxException ise) {
             fail("Unexpected InvalidSyntaxException");
         }
         assertNotNull("Expecting our service references", refs);
@@ -86,12 +112,8 @@ public class MockServiceReferencesSortTest {
         
         final StringBuilder sb = new StringBuilder();
         for(ServiceReference<?> ref : refs) {
-            sb.append(ctx.getService(ref).toString());
-            ctx.ungetService(ref);
-        }
-        
-        for(ServiceRegistration<?> reg : toCleanup) {
-            reg.unregister();
+            sb.append(bundleContext.getService(ref).toString());
+            bundleContext.ungetService(ref);
         }
         
         return sb.toString();
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
index 84513e5..1977258 100644
--- a/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
@@ -87,11 +87,13 @@ public class OsgiContextImplTest {
         context.registerService(Set.class, myService1);
         Set<String> myService2 = new HashSet<String>();
         context.registerService(Set.class, myService2);
+        
+        assertSame(myService1, context.getService(Set.class));
 
-        // expected: descending order because ordering descending by service id
+        // expected: ascending order because ordering ascending by service ID
         Set[] serviceResults = context.getServices(Set.class, null);
-        assertSame(myService1, serviceResults[1]);
-        assertSame(myService2, serviceResults[0]);
+        assertSame(myService1, serviceResults[0]);
+        assertSame(myService2, serviceResults[1]);
     }
 
     @Test

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-testing-osgi-mock] 04/05: [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-2.0.4

Posted by ro...@apache.org.
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-2.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit b2516097ec4428de5c777ac363bdfd9b8bfa8309
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Jun 10 12:13:10 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-2.0.4
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1747695 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index d076409..dcd1300 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-    <version>2.0.3-SNAPSHOT</version>
+    <version>2.0.4</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Testing OSGi Mock</name>
     <description>Mock implementation of selected OSGi APIs.</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/testing/mocks/osgi-mock</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.osgi-mock-2.0.4</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.osgi-mock-2.0.4</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.osgi-mock-2.0.4</url>
     </scm>
     
     <dependencies>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-testing-osgi-mock] 02/05: SLING-5544 osgi-mock: Catch RejectedExecutionException in MockEventAdmin

Posted by ro...@apache.org.
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-2.0.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit 8a090aa2620dc8186afa00a709b9be6147e01531
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Feb 22 23:56:17 2016 +0000

    SLING-5544 osgi-mock: Catch RejectedExecutionException in MockEventAdmin
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1731758 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/testing/mock/osgi/MockEventAdmin.java       | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
index 55628da..d182d1f 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -69,12 +70,18 @@ public final class MockEventAdmin implements EventAdmin {
 
     @Override
     public void postEvent(final Event event) {
-        asyncHandler.execute(new Runnable() {
-            @Override
-            public void run() {
-                distributeEvent(event);
-            }
-        });
+        try {
+            asyncHandler.execute(new Runnable() {
+                @Override
+                public void run() {
+                    distributeEvent(event);
+                }
+            });
+        }
+        catch (RejectedExecutionException ex) {
+            // ignore
+            log.debug("Ignore rejected execution: " + ex.getMessage(), ex);;
+        }
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.