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:20:59 UTC

[sling-org-apache-sling-testing-osgi-mock] annotated tag org.apache.sling.testing.osgi-mock-2.0.2 created (now 0313d8c)

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


      at 0313d8c  (tag)
 tagging b151c485e8a5ba4e811ec28088a42b5b4384cdc9 (commit)
      by Stefan Seifert
      on Fri Feb 5 22:23:13 2016 +0000

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

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 b151c48  [maven-release-plugin] copy for tag org.apache.sling.testing.osgi-mock-2.0.2

The 106 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] 10/10: [maven-release-plugin] copy for tag org.apache.sling.testing.osgi-mock-2.0.2

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

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

    [maven-release-plugin] copy for tag org.apache.sling.testing.osgi-mock-2.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.osgi-mock-2.0.2@1728746 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] 08/10: SLING-5462 switch to comparable implementation from commons.osgi and change wrong assumptions in unit test

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

commit fe2625ed84bbaf65ae4a8a8e9841e821a03e3c3c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Jan 28 17:16:40 2016 +0000

    SLING-5462 switch to comparable implementation from commons.osgi and change wrong assumptions in unit test
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1727409 13f79535-47bb-0310-9956-ffa450edef68
---
 .../testing/mock/osgi/MockServiceReference.java    | 28 +++++++++++-----------
 .../testing/mock/osgi/MockBundleContextTest.java   | 10 ++++----
 .../mock/osgi/context/OsgiContextImplTest.java     |  5 ++--
 3 files changed, 22 insertions(+), 21 deletions(-)

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 dfe84c6..3d3d9ae 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
@@ -20,7 +20,9 @@ package org.apache.sling.testing.mock.osgi;
 
 import java.util.Collections;
 import java.util.Dictionary;
+import java.util.Map;
 
+import org.apache.sling.commons.osgi.ServiceUtil;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -32,12 +34,19 @@ class MockServiceReference<T> implements ServiceReference<T> {
 
     private final Bundle bundle;
     private final MockServiceRegistration<T> serviceRegistration;
+    private volatile Comparable<Object> comparable;
 
     public MockServiceReference(final Bundle bundle, final MockServiceRegistration<T> serviceRegistration) {
         this.bundle = bundle;
         this.serviceRegistration = serviceRegistration;
+        this.comparable = buildComparable();
     }
-
+    
+    private Comparable<Object> buildComparable() {
+        Map<String,Object> props = MapUtil.toMap(serviceRegistration.getProperties());
+        return ServiceUtil.getComparableForServiceRanking(props);
+    }
+    
     @Override
     public Bundle getBundle() {
         return this.bundle;
@@ -50,6 +59,7 @@ class MockServiceReference<T> implements ServiceReference<T> {
      */
     public void setProperty(final String key, final Object value) {
         this.serviceRegistration.getProperties().put(key, value);
+        this.comparable = buildComparable();
     }
 
     @Override
@@ -65,7 +75,7 @@ class MockServiceReference<T> implements ServiceReference<T> {
 
     @Override
     public int hashCode() {
-        return ((Long) getServiceId()).hashCode();
+        return comparable.hashCode();
     }
 
     @Override
@@ -73,7 +83,7 @@ class MockServiceReference<T> implements ServiceReference<T> {
         if (!(obj instanceof MockServiceReference)) {
             return false;
         }
-        return ((Long) getServiceId()).equals(((MockServiceReference) obj).getServiceId());
+        return comparable.equals(((MockServiceReference)obj).comparable);
     }
 
     @Override
@@ -81,17 +91,7 @@ class MockServiceReference<T> implements ServiceReference<T> {
         if (!(obj instanceof MockServiceReference)) {
             return 0;
         }
-        // sort by ascending by service ranking, and secondary ascending by service id
-        Integer serviceRanking = getServiceRanking();
-        Integer otherServiceRanking = ((MockServiceReference)obj).getServiceRanking();
-        int serviceRankingCompare = serviceRanking.compareTo(otherServiceRanking);
-        if (serviceRankingCompare == 0) {
-            Long serviceId = getServiceId();
-            Long otherServiceId = ((MockServiceReference)obj).getServiceId();
-            return serviceId.compareTo(otherServiceId);
-        } else {
-            return serviceRankingCompare;
-        }
+        return comparable.compareTo(((MockServiceReference)obj).comparable);
     }
 
     long getServiceId() {
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 9fc5dc8..c2b18ee 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,16 +73,16 @@ public class MockBundleContextTest {
     @Test
     public void testServiceRegistration() throws InvalidSyntaxException {
         // prepare test services
-        String clazz1 = String.class.getName();
-        Object service1 = new Object();
-        Dictionary<String, Object> properties1 = getServiceProperties(null);
-        ServiceRegistration reg1 = bundleContext.registerService(clazz1, service1, properties1);
-
         String[] clazzes2 = new String[] { String.class.getName(), Integer.class.getName() };
         Object service2 = new Object();
         Dictionary<String, Object> properties2 = getServiceProperties(null);
         ServiceRegistration reg2 = bundleContext.registerService(clazzes2, service2, properties2);
 
+        String clazz1 = String.class.getName();
+        Object service1 = new Object();
+        Dictionary<String, Object> properties1 = getServiceProperties(null);
+        ServiceRegistration reg1 = bundleContext.registerService(clazz1, service1, properties1);
+
         String clazz3 = Integer.class.getName();
         Object service3 = new Object();
         Dictionary<String, Object> properties3 = getServiceProperties(-100L);
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 59990d5..84513e5 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
@@ -88,9 +88,10 @@ public class OsgiContextImplTest {
         Set<String> myService2 = new HashSet<String>();
         context.registerService(Set.class, myService2);
 
+        // expected: descending order because ordering descending by service id
         Set[] serviceResults = context.getServices(Set.class, null);
-        assertSame(myService1, serviceResults[0]);
-        assertSame(myService2, serviceResults[1]);
+        assertSame(myService1, serviceResults[1]);
+        assertSame(myService2, serviceResults[0]);
     }
 
     @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] 03/10: Switch to parent pom 26

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

commit 2efd6e6564405464e1a182a55f7d1dc71dad3ae9
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Jan 3 14:07:46 2016 +0000

    Switch to parent pom 26
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1722720 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 380911e..0a77138 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>25</version>
+        <version>26</version>
         <relativePath />
     </parent>
 

-- 
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/10: SLING-5453 implement MockBundleContext.getDataFile

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

commit 67592714f548c8ab2bc702af54dd7b889047a524
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Jan 25 22:27:17 2016 +0000

    SLING-5453 implement MockBundleContext.getDataFile
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1726704 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  8 ++++-
 .../sling/testing/mock/osgi/MockBundleContext.java | 34 ++++++++++++++++++----
 .../testing/mock/osgi/MockBundleContextTest.java   | 20 ++++++++++++-
 3 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0a77138..81baf92 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,7 +90,13 @@
             <version>3.0.1</version>
             <scope>compile</scope>
         </dependency>
-    
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+            <scope>compile</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
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 3c0ad53..827ef43 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
@@ -19,6 +19,7 @@
 package org.apache.sling.testing.mock.osgi;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Collection;
 import java.util.Dictionary;
@@ -32,6 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ConcurrentSkipListSet;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.felix.framework.FilterImpl;
 import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.Reference;
@@ -53,6 +55,7 @@ import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.io.Files;
 
 /**
  * Mock {@link BundleContext} implementation.
@@ -64,6 +67,7 @@ class MockBundleContext implements BundleContext {
     private final Map<ServiceListener, Filter> serviceListeners = new ConcurrentHashMap<ServiceListener, Filter>();
     private final Queue<BundleListener> bundleListeners = new ConcurrentLinkedQueue<BundleListener>();
     private final ConfigurationAdmin configAdmin = new MockConfigurationAdmin();
+    private File dataFileBaseDir;
 
     public MockBundleContext() {
         this.bundle = new MockBundle(this);
@@ -323,6 +327,24 @@ class MockBundleContext implements BundleContext {
         return null;
     }
     
+    @Override
+    public File getDataFile(final String path) {
+        if (path == null) {
+            throw new IllegalArgumentException("Invalid path: " + path);
+        }
+        synchronized (this) {
+            if (dataFileBaseDir == null) {
+                dataFileBaseDir = Files.createTempDir();
+            }
+        }
+        if (path.isEmpty()) { 
+            return dataFileBaseDir;
+        }
+        else {
+            return new File(dataFileBaseDir, path);
+        }
+    }
+
     /**
      * Deactivates all bundles registered in this mocked bundle context.
      */
@@ -335,6 +357,13 @@ class MockBundleContext implements BundleContext {
                 // ignore, no deactivate method is available then
             }
         }
+        if (dataFileBaseDir != null) {
+            try {
+                FileUtils.deleteDirectory(dataFileBaseDir);
+            } catch (IOException e) {
+                // ignore
+            }
+        }
     }
 
     // --- unsupported operations ---
@@ -354,11 +383,6 @@ class MockBundleContext implements BundleContext {
     }
 
     @Override
-    public File getDataFile(final String s) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public Bundle getBundle(String location) {
         throw new UnsupportedOperationException();
     }
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 2b1cded..ef7e3b7 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
@@ -29,10 +29,12 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -55,7 +57,12 @@ public class MockBundleContextTest {
 
     @Before
     public void setUp() {
-        bundleContext = MockOsgi.newBundleContext();
+        bundleContext = (MockBundleContext)MockOsgi.newBundleContext();
+    }
+
+    @After
+    public void tearDown() {
+        MockOsgi.shutdown(bundleContext);
     }
 
     @Test
@@ -215,4 +222,15 @@ public class MockBundleContextTest {
         
         assertFalse(filter.match(serviceRegistration.getReference()));
     }
+
+    @Test
+    public void testGetDataFile() {
+        File rootFile = bundleContext.getDataFile("");
+        assertNotNull(rootFile);
+        
+        File childFile = bundleContext.getDataFile("child");
+        assertNotNull(childFile);
+        
+        assertEquals(childFile.getParentFile(), rootFile);
+    }
 }

-- 
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/10: SLING-5453 implement MockBundleContext.getDataFile

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

commit 7d50f992890c01e185afa9e7e828dc5fce05fd6e
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Jan 25 22:34:14 2016 +0000

    SLING-5453 implement MockBundleContext.getDataFile
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1726708 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 ef7e3b7..2a5c44e 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
@@ -57,7 +57,7 @@ public class MockBundleContextTest {
 
     @Before
     public void setUp() {
-        bundleContext = (MockBundleContext)MockOsgi.newBundleContext();
+        bundleContext = MockOsgi.newBundleContext();
     }
 
     @After

-- 
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/10: [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.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git

commit 9c07ff37a3574d2c1e9cb6e24150c393a2559593
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Dec 10 21:53:30 2015 +0000

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

diff --git a/pom.xml b/pom.xml
index f8f8527..c80085a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-    <version>2.0.0</version>
+    <version>2.0.1-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.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.osgi-mock-2.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.osgi-mock-2.0.0</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] 07/10: SLING-5462 ensure service references are sorted ascending by service ranking, not descending

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

commit 0e10e4502e5bfa1833689b19ed57fe2730c65935
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Jan 28 15:55:06 2016 +0000

    SLING-5462 ensure service references are sorted ascending by service ranking, not descending
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1727389 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 60 -----------------
 .../testing/mock/osgi/MockServiceReference.java    |  9 ++-
 .../testing/mock/osgi/MockBundleContextTest.java   |  2 +-
 .../mock/osgi/MockServiceReferencesSortTest.java   | 58 +++++++++++++++-
 .../mock/osgi/RealServiceReferencesSortTest.java   | 49 --------------
 .../testing/mock/osgi/ServiceReferencesUtil.java   | 77 ----------------------
 6 files changed, 60 insertions(+), 195 deletions(-)

diff --git a/pom.xml b/pom.xml
index aac673c..81baf92 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,11 +34,6 @@
     <name>Apache Sling Testing OSGi Mock</name>
     <description>Mock implementation of selected OSGi APIs.</description>
 
-    <properties>
-        <pax-exam.version>4.6.0</pax-exam.version>
-        <pax-link.version>2.4.3</pax-link.version>
-    </properties>
-    
     <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>
@@ -126,61 +121,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-container-forked</artifactId>
-            <version>${pax-exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit4</artifactId>
-            <version>${pax-exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-link-mvn</artifactId>
-            <version>${pax-exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-aether</artifactId>
-            <version>${pax-link.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-wrap</artifactId>
-            <version>${pax-link.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-atinject_1.0_spec</artifactId>
-            <version>1.0</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.base</groupId>
-            <artifactId>ops4j-base-lang</artifactId>
-            <version>1.2.3</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.base</groupId>
-            <artifactId>ops4j-base-net</artifactId>
-            <version>1.2.3</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.tinybundles</groupId>
-            <artifactId>tinybundles</artifactId>
-            <version>1.0.0</version>
-            <scope>test</scope>
-        </dependency>
-        
     </dependencies>
   
     <build>
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 6af3a37..dfe84c6 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
@@ -81,14 +81,13 @@ class MockServiceReference<T> implements ServiceReference<T> {
         if (!(obj instanceof MockServiceReference)) {
             return 0;
         }
-        // sort by decreasing by service ranking, and secondary increasing by
-        // service id
+        // sort by ascending by service ranking, and secondary ascending by service id
         Integer serviceRanking = getServiceRanking();
-        Integer otherServiceRanking = ((MockServiceReference) obj).getServiceRanking();
-        int serviceRankingCompare = otherServiceRanking.compareTo(serviceRanking);
+        Integer otherServiceRanking = ((MockServiceReference)obj).getServiceRanking();
+        int serviceRankingCompare = serviceRanking.compareTo(otherServiceRanking);
         if (serviceRankingCompare == 0) {
             Long serviceId = getServiceId();
-            Long otherServiceId = ((MockServiceReference) obj).getServiceId();
+            Long otherServiceId = ((MockServiceReference)obj).getServiceId();
             return serviceId.compareTo(otherServiceId);
         } else {
             return serviceRankingCompare;
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 2a5c44e..9fc5dc8 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
@@ -85,7 +85,7 @@ public class MockBundleContextTest {
 
         String clazz3 = Integer.class.getName();
         Object service3 = new Object();
-        Dictionary<String, Object> properties3 = getServiceProperties(100L);
+        Dictionary<String, Object> properties3 = getServiceProperties(-100L);
         ServiceRegistration reg3 = bundleContext.registerService(clazz3, service3, properties3);
 
         // test get service references
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 cdf085d..b34add1 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
@@ -19,11 +19,22 @@
 package org.apache.sling.testing.mock.osgi;
 
 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;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 
 /** Test the service-ranking based sorting of mock service references */
 public class MockServiceReferencesSortTest {
@@ -39,10 +50,51 @@ public class MockServiceReferencesSortTest {
     public void tearDown() {
         MockOsgi.shutdown(bundleContext);
     }
-    
+
     @Test
     public void testServicesOrder() {
-        // TODO this should return the same result as in RealServiceReferencesSortTest
-        assertEquals("54321", ServiceReferencesUtil.getSortedServicesString(bundleContext));
+        assertEquals("12345", getSortedServicesString(bundleContext));
+    }
+
+    private static ServiceRegistration<?> registerStringService(BundleContext ctx, 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);
+    }
+    
+    /** 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;
+        try {
+            refs = ctx.getServiceReferences(String.class.getName(), null);
+        } catch(InvalidSyntaxException ise) {
+            fail("Unexpected InvalidSyntaxException");
+        }
+        assertNotNull("Expecting our service references", refs);
+        Arrays.sort(refs);
+        
+        final StringBuilder sb = new StringBuilder();
+        for(ServiceReference<?> ref : refs) {
+            sb.append(ctx.getService(ref).toString());
+            ctx.ungetService(ref);
+        }
+        
+        for(ServiceRegistration<?> reg : toCleanup) {
+            reg.unregister();
+        }
+        
+        return sb.toString();
     }
+
 }
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/RealServiceReferencesSortTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/RealServiceReferencesSortTest.java
deleted file mode 100644
index 4ec7694..0000000
--- a/src/test/java/org/apache/sling/testing/mock/osgi/RealServiceReferencesSortTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.assertEquals;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.options;
-
-import javax.inject.Inject;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.osgi.framework.BundleContext;
-
-@RunWith(PaxExam.class)
-/** Test the service-ranking based sorting of real OSGi framework service references */
-public class RealServiceReferencesSortTest {
-    @Inject
-    protected BundleContext bundleContext;
-
-    @Configuration
-    public Option[] config() {
-        return options(junitBundles());
-    }
-    
-    @Test
-    public void testServicesOrder() {
-        assertEquals("12345", ServiceReferencesUtil.getSortedServicesString(bundleContext));
-    }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/ServiceReferencesUtil.java b/src/test/java/org/apache/sling/testing/mock/osgi/ServiceReferencesUtil.java
deleted file mode 100644
index 22f33ed..0000000
--- a/src/test/java/org/apache/sling/testing/mock/osgi/ServiceReferencesUtil.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.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.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-class ServiceReferencesUtil {
- 
-    static private ServiceRegistration<?> registerStringService(BundleContext ctx, 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);
-    }
-    
-    /** Register services with a specific ranking, sort their references and 
-     *  return their concatenated toString() values.
-     *  Use to test service references sorting.
-     */
-    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;
-        try {
-            refs = ctx.getServiceReferences(String.class.getName(), null);
-        } catch(InvalidSyntaxException ise) {
-            fail("Unexpected InvalidSyntaxException");
-        }
-        assertNotNull("Expecting our service references", refs);
-        Arrays.sort(refs);
-        
-        final StringBuilder sb = new StringBuilder();
-        for(ServiceReference<?> ref : refs) {
-            sb.append(ctx.getService(ref).toString());
-            ctx.ungetService(ref);
-        }
-        
-        for(ServiceRegistration<?> reg : toCleanup) {
-            reg.unregister();
-        }
-        
-        return sb.toString();
-    }
-}

-- 
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/10: SLING-5391 osgi-mock: Switch to osgi.core and osgi.cmpn dependencies

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

commit b3f468c37c0e41a55c96270af9d862f6413c6900
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Dec 18 23:09:32 2015 +0000

    SLING-5391 osgi-mock: Switch to osgi.core and osgi.cmpn dependencies
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1720855 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/pom.xml b/pom.xml
index c80085a..380911e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,32 +45,14 @@
         <!-- This version of OSGi mocks is targeted at OSGi R6. osgi-mocks 1.x is compatible with older versions. -->
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
+            <artifactId>osgi.core</artifactId>
             <version>6.0.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.cm</artifactId>
-            <version>1.5.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.event</artifactId>
-            <version>1.3.1</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.log</artifactId>
-            <version>1.3.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.component</artifactId>
-            <version>1.3.0</version>
+            <artifactId>osgi.cmpn</artifactId>
+            <version>6.0.0</version>
             <scope>compile</scope>
         </dependency>
     

-- 
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] 06/10: SLING-5462 - demonstrate the wrong sorting of mock service references

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

commit c79ef61347f8eef803e2acbdcc307e57f4797d41
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Jan 28 11:14:14 2016 +0000

    SLING-5462 - demonstrate the wrong sorting of mock service references
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1727309 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 60 +++++++++++++++++
 .../mock/osgi/MockServiceReferencesSortTest.java   | 48 ++++++++++++++
 .../mock/osgi/RealServiceReferencesSortTest.java   | 49 ++++++++++++++
 .../testing/mock/osgi/ServiceReferencesUtil.java   | 77 ++++++++++++++++++++++
 4 files changed, 234 insertions(+)

diff --git a/pom.xml b/pom.xml
index 81baf92..aac673c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,6 +34,11 @@
     <name>Apache Sling Testing OSGi Mock</name>
     <description>Mock implementation of selected OSGi APIs.</description>
 
+    <properties>
+        <pax-exam.version>4.6.0</pax-exam.version>
+        <pax-link.version>2.4.3</pax-link.version>
+    </properties>
+    
     <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>
@@ -121,6 +126,61 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-forked</artifactId>
+            <version>${pax-exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${pax-exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${pax-exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>${pax-link.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-wrap</artifactId>
+            <version>${pax-link.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.base</groupId>
+            <artifactId>ops4j-base-lang</artifactId>
+            <version>1.2.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.base</groupId>
+            <artifactId>ops4j-base-net</artifactId>
+            <version>1.2.3</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        
     </dependencies>
   
     <build>
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
new file mode 100644
index 0000000..cdf085d
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.assertEquals;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+
+/** Test the service-ranking based sorting of mock service references */
+public class MockServiceReferencesSortTest {
+    
+    private BundleContext bundleContext;
+
+    @Before
+    public void setUp() {
+        bundleContext = MockOsgi.newBundleContext();
+    }
+
+    @After
+    public void tearDown() {
+        MockOsgi.shutdown(bundleContext);
+    }
+    
+    @Test
+    public void testServicesOrder() {
+        // TODO this should return the same result as in RealServiceReferencesSortTest
+        assertEquals("54321", ServiceReferencesUtil.getSortedServicesString(bundleContext));
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/RealServiceReferencesSortTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/RealServiceReferencesSortTest.java
new file mode 100644
index 0000000..4ec7694
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/RealServiceReferencesSortTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.assertEquals;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.options;
+
+import javax.inject.Inject;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.BundleContext;
+
+@RunWith(PaxExam.class)
+/** Test the service-ranking based sorting of real OSGi framework service references */
+public class RealServiceReferencesSortTest {
+    @Inject
+    protected BundleContext bundleContext;
+
+    @Configuration
+    public Option[] config() {
+        return options(junitBundles());
+    }
+    
+    @Test
+    public void testServicesOrder() {
+        assertEquals("12345", ServiceReferencesUtil.getSortedServicesString(bundleContext));
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/ServiceReferencesUtil.java b/src/test/java/org/apache/sling/testing/mock/osgi/ServiceReferencesUtil.java
new file mode 100644
index 0000000..22f33ed
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/osgi/ServiceReferencesUtil.java
@@ -0,0 +1,77 @@
+/*
+ * 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.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.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+class ServiceReferencesUtil {
+ 
+    static private ServiceRegistration<?> registerStringService(BundleContext ctx, 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);
+    }
+    
+    /** Register services with a specific ranking, sort their references and 
+     *  return their concatenated toString() values.
+     *  Use to test service references sorting.
+     */
+    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;
+        try {
+            refs = ctx.getServiceReferences(String.class.getName(), null);
+        } catch(InvalidSyntaxException ise) {
+            fail("Unexpected InvalidSyntaxException");
+        }
+        assertNotNull("Expecting our service references", refs);
+        Arrays.sort(refs);
+        
+        final StringBuilder sb = new StringBuilder();
+        for(ServiceReference<?> ref : refs) {
+            sb.append(ctx.getService(ref).toString());
+            ctx.ungetService(ref);
+        }
+        
+        for(ServiceRegistration<?> reg : toCleanup) {
+            reg.unregister();
+        }
+        
+        return sb.toString();
+    }
+}

-- 
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] 09/10: [maven-release-plugin] prepare release org.apache.sling.testing.osgi-mock-2.0.2

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

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

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

diff --git a/pom.xml b/pom.xml
index 81baf92..76fb08f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-    <version>2.0.1-SNAPSHOT</version>
+    <version>2.0.2</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.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>
     </scm>
     
     <dependencies>

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