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:25:32 UTC

[sling-org-apache-sling-testing-sling-mock] annotated tag org.apache.sling.testing.sling-mock-2.0.0 created (now 7d4f8ed)

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

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


      at 7d4f8ed  (tag)
 tagging cc88bfba12944e12ce7c4ec19dd208ffd4696f24 (commit)
      by Stefan Seifert
      on Tue Jul 12 10:29:15 2016 +0000

- Log -----------------------------------------------------------------
org.apache.sling.testing.sling-mock-2.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 2aa4712  SLING-4042 Donate sling-mock, jcr-mock, osgi-mock implementation
     new d63d89c  svn:ignore
     new a6e7c1a  SLING-4042 move all mock projects to mocks/ subdirectory
     new d1f839a  SLING-4042 add missing package-info files
     new e9e968a  SLING-4042 per default no charencoding should be set in mock response
     new 43eb350  SLING-4042 do not forget to register ResourceResolverFactory in OSGi context as well
     new 3d36daf  SLING-4042 make sure JCR mock supports accessing data using multiple sessions
     new 4fc4baf  SLING-4042 add README files
     new 4aa90b9  add/update SCM urls
     new 22c8024  update to released versions
     new 1ba5459  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.0.0
     new 5dcb3d7  [maven-release-plugin] prepare for next development iteration
     new 5b0b3fe  update dependencies in release process to next snapshot version
     new 1f52235  SLING-4085 NPE when using SlingContext rule without constructor argument
     new 9442dd8  SLING-4086 SlingHttpServlerRequest should support getResourceBundle() methods
     new 2f5faf4  set to released version now available on maven central
     new 6964d49  SLING-4090 Define package versions for Sling Mock, JCR Mock, OSGi Mock
     new 448fe45  SLING-4108 JCR/Sling/ResourceResolver Mock: Support providing authentication info
     new 5b4c01c  fix some javadoc errors and warnings
     new cb5f237  SLING-4162 Introduce "OsgiContext" junit rule for OSGi and OsgiContextImpl
     new e72ad4b  SLING-4229 add test cases for deep path access support in sling-mock as well
     new a07abf8  SLING-4108 default to getAdministrativeResourceResolver in sling-mock to support jackrabbit resource resolver adapter as well
     new 3cbedc6  fix some javadoc errors/warnings
     new 47cc45e  update to released versions
     new fccd947  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.1.0
     new 4b72ed2  [maven-release-plugin] prepare for next development iteration
     new 85cdaa4  update to next snapshot version until releases available in maven central
     new 2de8a96  SLING-4266 - SlingContext always uses the default resourceResolverType
     new 0a167f6  SLING-4268 - ContentLoader should not try to import ACLs
     new 9ee66c6  SLING-4269 - SlingContextImpl's resource resolver should be an administrative one
     new 6f6321b  switch back to released versions for dependencies
     new a969262  SLING-4267 add some more property names to be ignored on import because they are managed by JCR internally
     new 62e7e2a  SLING-4267 support importing nt:resource noded in jackrabbit with empty binary data enable content loader unit tests in sling-mock-jackrabbit
     new 6569ce2  assertions can be activated now after updating to latest mock dependencies
     new b816e47  SLING-4267 support importing nt:resource nodes in jackrabbit with empty binary data
     new 32c3978  update dependencies to released versions
     new c05aeae  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.1.2
     new e57b7e1  [maven-release-plugin] prepare for next development iteration
     new d9fcb59  update to next development snapshot unit released artifacts are in maven central
     new c0e8f71  switch back to released versions now available in maven central
     new e8d2807  SLING-4362 make sure JCR namespaces are correctly registered in JCR mock on initialization through sling mock
     new 90ddb94  SLING-4376 ResourceResolver.resolve(null) should resolve to root resource
     new c49b0e1  SLING-4394 Sling Mock with JCR-based Resource Resolver: Support default search paths
     new 5e1c2d6  SLING-848 Support getting versioned resources by using uri path parameters
     new 4e72c06  Use the recent resourceresolver SNAPSHOT in sling-mock
     new eb9da99  SLING-848 revert updating sling api/resource resolver/jcr resource dependenciens - using sling mock in a project should not enforce using the latest version of those keep adding of getThreadResourceResolver() method, but throw UnsupportedOperationException
     new 2259bfe  SLING-4431 Sling Mocks: Remove Dependency on ResourceResolverInjector
     new 74de88f  cosmetic code formatting changes
     new 9e35c02  SLING-4434 refactor integration with sling models: remove MockModelAdapterFactory and directly integrate the original ModelAdapterFactory using the new osgi mock dynamic service reference feature
     new 71bbb5c  SLING-4437 MockJcrResourceResolverFactory should allow to register services dynamically
     new fc5346f  SLING-4433 use real AdapterManagerImpl implementation with support for ADAPTER_CLASSES/ADAPTABLE_CLASSES
     new a4d3ac9  SLING-4433 remove dependency to org.apache.sling.adapter and inline helper classes instead
     new 58f81ee  update to release versions
     new ac35a62  update package version
     new 29e7fda  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.2.0
     new f96f34a  [maven-release-plugin] prepare for next development iteration
     new 93110e5  remove service description and vendor for this mock service - makes problems with baseline check
     new f187b33  remove service description and vendor for this mock service - makes problems with baseline check
     new 1b68139  update to next development snapshot unit released artifacts are in maven central
     new 53be964  switch to released versions
     new 34954fa  SLING-4522 Sling Mocks: ContentLoader fails for UTF8 encoded json files on Windows Systems
     new 75d379a  Fix scr xml parsing when updating to new scr plugin by using fix for SLING-4670
     new b0f4a0a  SLING-4698 - Set parent.relativePath to empty for all modules
     new 28f1b00  SLING-4654 Support ResourceResolver.findResources with JCR_MOCK
     new 6728203  SLING-4721 sling-mock: Fully support ResourceResolverFactoryActivator for jcr-mock
     new 8a9b3c4  SLING-4729 Sling Mock: Add "NONE" resource resolver type
     new 5d2ffa2  SLING-4470 introduce separate "logging-mock" project for default log configuration in mock tests, remove compile-dependency on slf4j-simple
     new 192936d  update dependencies for release
     new ab204bb  update dependencies for release
     new 5482f51  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.3.0
     new 7baf341  [maven-release-plugin] prepare for next development iteration
     new 9a0fa2b  update to next development snapshot unit released artifacts are in maven central
     new bb58061  SLING-4605 - Add support for an Oak resource resolver type mock
     new 3601bfd  Mocks: use latest snapshots
     new b6207fb  SLING-4605 - Add support for an Oak resource resolver type mock
     new bac4c7f  update to released mock versions
     new 37c868a  SLING-4756 add support for filtering via felix.framework FilterImpl implementation
     new 546986a  SLING-4605 javadoc updates and add initializing for ContextResourceResolverFactory
     new 6e3e339  Minor wording fixes when the ResourceResolverTypeAdapter can't be found.
     new f4c6d5d  SLING-4775 - MockSlingSettingService shoud support getSlingId()
     new 7a57b01  SLING-4775 move the now supported method out of the "unsupported operations" block
     new e0cc675  SLING-4773 ensure sling namespace is always registered when using JCR_MOCK resource resolver adapter
     new d39a8a6  update to released versions
     new 54d3fe0  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.4.0
     new 8913f6c  [maven-release-plugin] prepare for next development iteration
     new 37fa126  update to latest development snapshots
     new df31839  Update to Sling Parent 23
     new e497760  Testing: remove superflous sling.java.version=6 as it's the default now
     new d8691fa  switch to released versions
     new a3f2ae9  set parent version to 24 and add empty relativePath where missing
     new 05758ef  SLING-4932, make compatible with o.a.s.jcr.resource 2.5 (requires also an upgrade to Sling API 2.9)
     new 169f6e0  SLING-4932 switch back to old api/jcr.resource versions and ensure compatibility by initiating PathMapper service by reflection if it exists
     new 9ab5f09  SLING-4938 exclude optional transitive dependencies of reflections
     new 347ce2a  SLING-4990 Support HttpSession invalidate, new, lastAccessedTime, maxInteractiveInterval
     new 602f4a9  SLING-4993 Support RequestParameter in MockSlingHttpServlerRequest
     new ec0efee  SLING-4994 Support InputStream, ContentLenght, ContentType and CharacterEncoding in Request
     new 489ae34  SLING-4998 ResponseBodySupport - use default charset if no response charset is set
     new 9832809  cosmetic: beautify error messages when setup/teardown fails
     new da53509  SLING-5002 - [sling-mock] Update dependency version of org.reflections
     new 3fafd8e  SLING-5003 Support request dispatcher in MockSlingHttpServletRequest
     new b4037bf  SLING-5002 switch back to 0.9.9 due to threading issues in 0.9.10 when running junit tests in parallel
     new e52575e  update other mocks to latest releases
     new 2a934a4  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.5.0
     new 8f19c45  [maven-release-plugin] prepare for next development iteration
     new d58abbe  switch to latest snapshot version until release is available in maven central
     new 07c6650  SLING-5007 add unit test to explicitly test root path child listing in sling-mock as well
     new d5ebb42  SLING-5007 realx unit test to test root path child listing in sling-mock-jackrabbit and sling-mock-jackrabbit and sling-mock-oak because in real repositories multiple root test nodes may be created in parallel, or nodes already exist
     new 8580a55  update release versions
     new 5846795  update to next snapshot version until releases are available in maven central
     new f960880  SLING-5007 use same unit tests for root node tests for all resource resolver types without counting the number of children.
     new 0ac864b  switch back to released version
     new add520f  SLING-5042 ResourceResolver.commit() does not call session.save() on the backing JCR Session
     new 8123868  SLING-5043 sling-mocks: Execute commit() after ContentLoader operations
     new c1ce2e6  SLING-5057 - Support HttpServletRequest#getRemoteUser
     new b10d3bb  SLING-5057 - Support HttpServletRequest#getRemoteUser
     new 53bfbe5  SLING-5064 sling-mock: Register JCR node types for OSGi bundles in class path
     new 853e02b  SLING-5064 sling-mock: Register JCR node types for OSGi bundles in class path
     new c7551b3  cosmetic: fix log message
     new 317bf58  SLING-5066 sling-mock: Close ResourceResolver on JUnit test tearDown
     new f008644  SLING-5064 sling-mock: Register JCR node types for OSGi bundles in class path
     new 8c79b81  SLING-5067 sling-mock: "uniqueRoot()" to simplify creation and cleanup of unique root paths in repository
     new b24a116  SLING-5067 rewrite unit tests to use new "uniqueRoot" feature
     new 3c296a7  SLING-5064 manual registration of node types no longer required; register namespaces and node types centrally depending on NodeTypeMode
     new d795bcc  SLING-5067 fix cleanup issue with "uniqueRoot" feature
     new d74181d  SLING-5086 sling-mock: Add SlingContext.registerAdapter convenience method
     new fd0b260  SLING-5086 sling-mock: Add SlingContext.registerAdapter convenience method
     new cf03565  cosmetic: eliminate some javadoc warnings
     new 5c7c77d  SLING-5088 update to latest osgi-mock to make sure all services are deactivated properly
     new 856784c  SLING-5088 refactor unit test to make sure resource resolver and bundle contexts are properly shutdown
     new b90bd44  SLING-5088 refactor resource resolver initialization
     new 81f87d0  SLING-5088 rewrite setup code for resource resolver factory
     new 1b9e8db  SLING-5088 deprecate all methods that may lead to thread leaks
     new 8801d99  SLING-5088 control SlingRepository resources via activate/deactivate methods; make sure all oak ExecutorServices are shutdown properly
     new c1525db  cosmetic: fix javadoc errors
     new 47f0035  SLING-5088 avoid registering ResourceResolverFactory twice
     new 21a5c64  SLING-5088 register default service user mapping for mock bundle
     new 2b7ac22  Update the main reactor to parent 25
     new 1089980  update dependency
     new 8949c00  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.6.0
     new 90239a1  [maven-release-plugin] prepare for next development iteration
     new 9f9253b  set dependencies to next snapshot version until released versions are available in maven central
     new 7ac242f  switch back to released versions of dependency
     new 1f318cf  SLING-5197 sling-mock: Do not override ResourceResolverFactoryActivator's default values
     new f7609c8  SLING-5197 sling-mock: Do not override ResourceResolverFactoryActivator's default values
     new d444456  update to latest osgi-mock version
     new dd7948a  SLING-5339 sling-mock: Support remote add, remote host and remote port in MockSlingHttpSevletRequest
     new a52790b  SLING-5392 sling-mock: Use javax.servlet-api dependency instead of mortbay version
     new 3234a24  Switch to parent pom 26
     new dfd873c  SLING-5428 Move MockSlingHttpServletRequest+Response to org.apache.sling.servlet-helpers
     new e7cd297  update mock dependencies to latest versions
     new 0186990  fix javadoc errors
     new 64a8b38  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.6.2
     new a56450f  [maven-release-plugin] prepare for next development iteration
     new 37d2b26  update to next snapshot dependency until released artifacts are available in maven central
     new e39da4c  update to released versions
     new 6759ae4  SLING-5546 Update to Sling API 2.11 and dependencies
     new 41b471d  SLING-5546 remove deprecated methods
     new 22cce0c  SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15
     new 05a8c47  SLING-5548 Remove JCR_JACKRABBIT resource resolver type
     new e2054b1  SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15
     new 8476a66  add unit test to test adapter factory overlays
     new 57b714b  SLING-5667 adapt to changes service ranking order in osgi-mock
     new 08b7fd5  SLING-5769 expose resource resolver factory from SlingContext
     new ec77950  SLING-5769 reverted r1747508 since it is already exposed through getService(...)
     new 3239d98  SLING-5770 add support for custom resource resolver factory activator configuration via SlingContextBuilder add support for additional callbacks before setup and after teardown
     new 7d5c794  SLING-5770 update javadoc
     new 0b0cd7e  update dependencies to released versions
     new 17d3932  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-2.0.0
     new cc88bfb  [maven-release-plugin] copy for tag org.apache.sling.testing.sling-mock-2.0.0

The 169 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-sling-mock] 01/14: SLING-5546 Update to Sling API 2.11 and 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.sling-mock-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git

commit 6759ae459b823cf805dfb901b61725d4f5c3a9bb
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Feb 23 00:09:40 2016 +0000

    SLING-5546 Update to Sling API 2.11 and dependencies
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1731761 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  71 ++++-----
 .../testing/mock/sling/MockAdapterManagerImpl.java | 168 ++++++++++++---------
 ...nfo.java => MockDynamicClassLoaderManager.java} |  16 +-
 .../testing/mock/sling/MockJcrSlingRepository.java |   6 +
 .../sling/ResourceResolverFactoryInitializer.java  |  39 +++--
 .../sling/ThreadsafeMockAdapterManagerWrapper.java |   2 +-
 .../sling/context/ModelAdapterFactoryUtil.java     |  43 ++++--
 .../mock/sling/context/SlingContextImpl.java       |   4 +-
 .../testing/mock/sling/loader/ContentLoader.java   |   4 +-
 .../sling/testing/mock/sling/package-info.java     |   2 +-
 .../sling/servlet/MockSlingHttpServletRequest.java |   2 +-
 11 files changed, 203 insertions(+), 154 deletions(-)

diff --git a/pom.xml b/pom.xml
index f5b10e2..decc8fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.sling-mock</artifactId>
-    <version>1.6.3-SNAPSHOT</version>
+    <version>2.0.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Testing Sling Mock</name>
@@ -45,7 +45,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>1.7.2</version>
+            <version>2.0.3-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
@@ -70,81 +70,93 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.models.api</artifactId>
-            <version>1.1.0</version>
+            <version>1.2.2</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.models.impl</artifactId>
-            <version>1.1.0</version>
+            <version>1.2.2</version>
             <scope>compile</scope>
         </dependency>
     
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.4.0</version>
+            <version>2.11.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourceresolver</artifactId>
-            <version>1.1.0</version>
+            <version>1.4.3-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.api</artifactId>
-            <version>2.2.0</version>
+            <version>2.3.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.resource</artifactId>
-            <version>2.3.6</version>
+            <version>2.7.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.mime</artifactId>
-            <version>2.1.4</version>
+            <version>2.1.8</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.json</artifactId>
-            <version>2.0.6</version>
+            <version>2.0.16</version>
             <scope>compile</scope>
         </dependency>
         <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>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.classloader</artifactId>
-            <version>1.3.0</version>
+            <version>1.3.2</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.settings</artifactId>
-            <version>1.2.2</version>
+            <version>1.3.8</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.i18n</artifactId>
-            <version>2.2.4</version>
+            <version>2.4.4</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.adapter</artifactId>
+            <version>2.1.6</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>2.11.3</version>
             <scope>compile</scope>
         </dependency>
 
         <dependency>
             <groupId>commons-collections</groupId>
             <artifactId>commons-collections</artifactId>
-            <version>3.2.1</version>
+            <version>3.2.2</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
@@ -204,10 +216,10 @@
         </dependency>
     
         <dependency>
-            <groupId>javax.inject</groupId>
-            <artifactId>javax.inject</artifactId>
-            <version>1</version>
-            <scope>compile</scope>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-atinject_1.0_spec</artifactId>
+          <version>1.0</version>
+          <scope>compile</scope>
         </dependency>
     
         <dependency>
@@ -267,25 +279,4 @@
         </plugins>
     </build>
   
-    <!-- Profiles to run unit tests against different JCR Resource versions -->
-    <profiles>
-        <profile>
-            <id>jcr.resource-2.5.4</id>
-            <dependencies>
-                <dependency>
-                    <groupId>org.apache.sling</groupId>
-                    <artifactId>org.apache.sling.api</artifactId>
-                    <version>2.9.0</version>
-                    <scope>compile</scope>
-                </dependency>
-                <dependency>
-                    <groupId>org.apache.sling</groupId>
-                    <artifactId>org.apache.sling.jcr.resource</artifactId>
-                    <version>2.5.4</version>
-                    <scope>compile</scope>
-                </dependency>
-            </dependencies>
-        </profile>
-    </profiles>
-    
 </project>
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java b/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
index 889022b..d058e12 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
@@ -22,26 +22,34 @@ import static org.apache.sling.api.adapter.AdapterFactory.ADAPTABLE_CLASSES;
 import static org.apache.sling.api.adapter.AdapterFactory.ADAPTER_CLASSES;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
 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.adapter.Adaption;
+import org.apache.sling.adapter.internal.AdapterFactoryDescriptor;
+import org.apache.sling.adapter.internal.AdapterFactoryDescriptorMap;
+import org.apache.sling.adapter.internal.AdaptionImpl;
 import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.adapter.AdapterFactory;
 import org.apache.sling.api.adapter.AdapterManager;
 import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
@@ -49,12 +57,18 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * This is a copy of org.apache.sling.adapter.internal.AdpaterManagerImpl from Sling Adapter 2.1.0,
+ * This is a copy of org.apache.sling.adapter.internal.AdpaterManagerImpl from Sling Adapter 2.1.6,
  * with all calls to SyntheticResource.setAdapterManager/unsetAdapterManager disabled, because this would
  * break the {@link ThreadsafeMockAdapterManagerWrapper} concept.
+ * Additionally the reference to PackageAdmin is disabled.
  */
 @Component(immediate=true)
 @Service
+@Properties({
+    @Property(name=Constants.SERVICE_DESCRIPTION, value="Sling Adapter Manager"),
+    @Property(name=Constants.SERVICE_VENDOR, value="The Apache Software Foundation")
+
+})
 @Reference(name="AdapterFactory", referenceInterface=AdapterFactory.class,
 cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC)
 public class MockAdapterManagerImpl implements AdapterManager {
@@ -102,6 +116,12 @@ public class MockAdapterManagerImpl implements AdapterManager {
     @Reference(cardinality=ReferenceCardinality.OPTIONAL_UNARY, policy=ReferencePolicy.DYNAMIC)
     private volatile EventAdmin eventAdmin;
 
+    // DISABLED IN THIS COPY OF CLASS
+    /*
+    @Reference
+    private PackageAdmin packageAdmin;
+    */
+
     // ---------- AdapterManager interface -------------------------------------
 
     /**
@@ -181,7 +201,6 @@ public class MockAdapterManagerImpl implements AdapterManager {
 
     /**
      * Bind a new adapter factory.
-     * @param reference Service reference
      */
     protected void bindAdapterFactory(final ServiceReference reference) {
         boolean create = true;
@@ -199,8 +218,7 @@ public class MockAdapterManagerImpl implements AdapterManager {
     }
 
     /**
-     * Unbind an adapter factory.
-     * @param reference Service reference
+     * Unbind a adapter factory.
      */
     protected void unbindAdapterFactory(final ServiceReference reference) {
         unregisterAdapterFactory(reference);
@@ -242,6 +260,21 @@ public class MockAdapterManagerImpl implements AdapterManager {
             return;
         }
 
+        // DISABLED IN THIS COPY OF CLASS
+        /*
+        for (String clazz : adaptables) {
+            if (!checkPackage(packageAdmin, clazz)) {
+                log.warn("Adaptable class {} in factory service {} is not in an exported package.", clazz, reference.getProperty(Constants.SERVICE_ID));
+            }
+        }
+
+        for (String clazz : adapters) {
+            if (!checkPackage(packageAdmin, clazz)) {
+                log.warn("Adapter class {} in factory service {} is not in an exported package.", clazz, reference.getProperty(Constants.SERVICE_ID));
+            }
+        }
+        */
+
         final AdapterFactoryDescriptor factoryDesc = new AdapterFactoryDescriptor(context,
                 reference, adapters);
 
@@ -262,16 +295,51 @@ public class MockAdapterManagerImpl implements AdapterManager {
         // clear the factory cache to force rebuild on next access
         this.factoryCache.clear();
 
+        // register adaption
+        final Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(SlingConstants.PROPERTY_ADAPTABLE_CLASSES, adaptables);
+        props.put(SlingConstants.PROPERTY_ADAPTER_CLASSES, adapters);
+
+        ServiceRegistration adaptionRegistration = this.context.getBundleContext().registerService(
+                Adaption.class.getName(), AdaptionImpl.INSTANCE, props);
+        if (log.isDebugEnabled()) {
+            log.debug("Registered service {} with {} : {} and {} : {}", new Object[] { Adaption.class.getName(),
+                    SlingConstants.PROPERTY_ADAPTABLE_CLASSES, Arrays.toString(adaptables),
+                    SlingConstants.PROPERTY_ADAPTER_CLASSES, Arrays.toString(adapters) });
+        }
+        factoryDesc.setAdaption(adaptionRegistration);
+
         // send event
         final EventAdmin localEA = this.eventAdmin;
         if ( localEA != null ) {
-            final Dictionary<String, Object> props = new Hashtable<String, Object>();
-            props.put(SlingConstants.PROPERTY_ADAPTABLE_CLASSES, adaptables);
-            props.put(SlingConstants.PROPERTY_ADAPTER_CLASSES, adapters);
             localEA.postEvent(new Event(SlingConstants.TOPIC_ADAPTER_FACTORY_ADDED,
                     props));
         }
     }
+    
+    static String getPackageName(String clazz) {
+        final int lastDot = clazz.lastIndexOf('.');
+        return lastDot <= 0 ? "" : clazz.substring(0, lastDot);
+    }
+
+    /**
+     * Check that the package containing the class is exported or is a java.*
+     * class.
+     * 
+     * @param packageAdmin the PackageAdmin service
+     * @param clazz the class name
+     * @return true if the package is exported
+     */
+    // DISABLED IN THIS COPY OF CLASS
+    /*
+    static boolean checkPackage(PackageAdmin packageAdmin, String clazz) {
+        final String packageName = getPackageName(clazz); 
+        if (packageName.startsWith("java.")) {
+            return true;
+        }
+        return packageAdmin.getExportedPackage(packageName) != null;
+    }
+    */
 
     /**
      * Unregisters the {@link AdapterFactory} referred to by the service
@@ -291,13 +359,25 @@ public class MockAdapterManagerImpl implements AdapterManager {
 
         boolean factoriesModified = false;
         AdapterFactoryDescriptorMap adfMap = null;
+
+        AdapterFactoryDescriptor removedDescriptor = null;
         for (final String adaptable : adaptables) {
             synchronized ( this.descriptors ) {
                 adfMap = this.descriptors.get(adaptable);
             }
             if (adfMap != null) {
                 synchronized ( adfMap ) {
-                    factoriesModified |= (adfMap.remove(reference) != null);
+                    AdapterFactoryDescriptor factoryDesc = adfMap.remove(reference);
+                    if (factoryDesc != null) {
+                        factoriesModified = true;
+                        // A single ServiceReference should correspond to a single Adaption service being registered
+                        // Since the code paths above does not fully guarantee it though, let's keep this check in place
+                        if (removedDescriptor != null && removedDescriptor != factoryDesc) {
+                            log.error("When unregistering reference {} got duplicate service descriptors {} and {}. Unregistration of {} services may be incomplete.",
+                                    new Object[] { reference, removedDescriptor, factoryDesc, Adaption.class.getName()} );
+                        }
+                        removedDescriptor = factoryDesc;
+                    }
                 }
             }
         }
@@ -308,6 +388,16 @@ public class MockAdapterManagerImpl implements AdapterManager {
             this.factoryCache.clear();
         }
 
+        // unregister adaption
+        if (removedDescriptor != null) {
+            removedDescriptor.getAdaption().unregister();
+            if (log.isDebugEnabled()) {
+                log.debug("Unregistered service {} with {} : {} and {} : {}", new Object[] { Adaption.class.getName(),
+                        SlingConstants.PROPERTY_ADAPTABLE_CLASSES, Arrays.toString(adaptables),
+                        SlingConstants.PROPERTY_ADAPTER_CLASSES, Arrays.toString(adapters) });
+            }
+        }
+
         // send event
         final EventAdmin localEA = this.eventAdmin;
         if ( localEA != null ) {
@@ -428,64 +518,4 @@ public class MockAdapterManagerImpl implements AdapterManager {
             }
         }
     }
-
-
-    /**
-     * The <code>AdapterFactoryDescriptor</code> is an entry in the
-     * {@link AdapterFactoryDescriptorMap} conveying the list of adapter (target)
-     * types and the respective {@link AdapterFactory}.
-     */
-    private static class AdapterFactoryDescriptor {
-
-        private volatile AdapterFactory factory;
-
-        private final String[] adapters;
-
-        private final ServiceReference reference;
-
-        private final ComponentContext context;
-
-        public AdapterFactoryDescriptor(
-                final ComponentContext context,
-                final ServiceReference reference,
-                final String[] adapters) {
-            this.reference = reference;
-            this.context = context;
-            this.adapters = adapters;
-        }
-
-        public AdapterFactory getFactory() {
-            if ( factory == null ) {
-                factory = (AdapterFactory) context.locateService(
-                        "AdapterFactory", reference);
-            }
-            return factory;
-        }
-
-        public String[] getAdapters() {
-            return adapters;
-        }
-    }
-
-    /**
-     * The <code>AdapterFactoryDescriptorMap</code> is a sorted map of
-     * {@link AdapterFactoryDescriptor} instances indexed (and ordered) by their
-     * {@link ServiceReference}. This map is used to organize the
-     * registered {@link org.apache.sling.api.adapter.AdapterFactory} services for
-     * a given adaptable type.
-     * <p>
-     * Each entry in the map is a {@link AdapterFactoryDescriptor} thus enabling the
-     * registration of multiple factories for the same (adaptable, adapter) type
-     * tuple. Of course only the first entry (this is the reason for having a sorted
-     * map) for such a given tuple is actually being used. If that first instance is
-     * removed the eventual second instance may actually be used instead.
-     */
-    private static class AdapterFactoryDescriptorMap extends
-            TreeMap<ServiceReference, AdapterFactoryDescriptor> {
-
-        private static final long serialVersionUID = 2L;
-
-    }
-
-    
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/MockDynamicClassLoaderManager.java
similarity index 71%
copy from src/main/java/org/apache/sling/testing/mock/sling/package-info.java
copy to src/main/java/org/apache/sling/testing/mock/sling/MockDynamicClassLoaderManager.java
index 85ce5c4..2ec7f15 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockDynamicClassLoaderManager.java
@@ -16,8 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.sling.testing.mock.sling;
+
+import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+
 /**
- * Mock implementation of selected Sling APIs.
+ * Mock implementation of {@link DynamicClassLoaderManager}.
  */
-@aQute.bnd.annotation.Version("1.5")
-package org.apache.sling.testing.mock.sling;
+class MockDynamicClassLoaderManager implements DynamicClassLoaderManager {
+
+    @Override
+    public ClassLoader getDynamicClassLoader() {
+        return MockDynamicClassLoaderManager.class.getClassLoader();
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java b/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java
index 48fd567..ffd5f9c 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java
@@ -116,4 +116,10 @@ public final class MockJcrSlingRepository implements SlingRepository {
         return this.repository.login();
     }
 
+    @Override
+    public Session impersonateFromService(String subServiceName, Credentials credentials, String workspaceName)
+            throws LoginException, RepositoryException {
+        return this.repository.login(credentials);
+    }
+
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
index dd8b69e..e98a5e4 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
@@ -23,18 +23,17 @@ import java.util.Hashtable;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.query.Query;
 
-import org.apache.sling.api.resource.QueriableResourceProvider;
-import org.apache.sling.api.resource.ResourceProvider;
-import org.apache.sling.api.resource.ResourceProviderFactory;
 import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory;
+import org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider;
+import org.apache.sling.jcr.resource.internal.helper.jcr.PathMapper;
 import org.apache.sling.resourceresolver.impl.ResourceAccessSecurityTracker;
 import org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator;
 import org.apache.sling.serviceusermapping.ServiceUserMapper;
 import org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl;
+import org.apache.sling.spi.resource.provider.ResourceProvider;
 import org.apache.sling.testing.mock.osgi.MockEventAdmin;
 import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.osgi.framework.BundleContext;
@@ -66,15 +65,15 @@ class ResourceResolverFactoryInitializer {
             registerJcrNodeTypes(slingRepository, nodeTypeMode);
             
             // initialize JCR resource provider factory
-            ensureJcrResourceProviderFactoryDependencies(bundleContext);
-            initializeJcrResourceProviderFactory(bundleContext);
+            ensureJcrResourceProviderDependencies(bundleContext);
+            initializeJcrResourceProvider(bundleContext);
         }
         
         // initialize resource resolver factory activator
         ensureResourceResolverFactoryActivatorDependencies(bundleContext);
         initializeResourceResolverFactoryActivator(bundleContext);
 
-        ServiceReference factoryRef = bundleContext.getServiceReference(ResourceResolverFactory.class.getName());
+        ServiceReference<ResourceResolverFactory> factoryRef = bundleContext.getServiceReference(ResourceResolverFactory.class);
         if (factoryRef == null) {
             throw new IllegalStateException("Unable to get ResourceResolverFactory.");
         }
@@ -85,26 +84,23 @@ class ResourceResolverFactoryInitializer {
      * Ensure dependencies for JcrResourceProviderFactory are present.
      * @param bundleContext Bundle context
      */
-    private static void ensureJcrResourceProviderFactoryDependencies(BundleContext bundleContext) {
+    private static void ensureJcrResourceProviderDependencies(BundleContext bundleContext) {
+        bundleContext.registerService(DynamicClassLoaderManager.class, new MockDynamicClassLoaderManager(), null);
         // setup PathMapper which is a mandatory service for JcrProviderFactory (since org.apache.sling.jcr.resource 2.5.4)
         // use reflection to not depend on it if running with older version of org.apache.sling.jcr.resource
-        registerServiceIfFoundInClasspath(bundleContext, "org.apache.sling.jcr.resource.internal.helper.jcr.PathMapper");
+        registerServiceIfFoundInClasspath(bundleContext, PathMapper.class.getName(), PathMapper.class.getName());
     }
  
     /**
      * Initialize JCR resource provider factory.
      * @param bundleContext Bundle context
      */
-    @SuppressWarnings("deprecation")
-    private static void initializeJcrResourceProviderFactory(BundleContext bundleContext) {
+    private static void initializeJcrResourceProvider(BundleContext bundleContext) {
         Dictionary<String, Object> config = new Hashtable<String, Object>();
-        config.put(ResourceProvider.ROOTS, new String[] { "/" });
-        config.put(QueriableResourceProvider.LANGUAGES, new String[] { Query.XPATH, Query.SQL, Query.JCR_SQL2 });
-
-        JcrResourceProviderFactory factory = new JcrResourceProviderFactory();
+        JcrResourceProvider factory = new JcrResourceProvider();
         MockOsgi.injectServices(factory, bundleContext);
         MockOsgi.activate(factory, bundleContext, config);
-        bundleContext.registerService(ResourceProviderFactory.class.getName(), factory, config);
+        bundleContext.registerService(ResourceProvider.class, factory, config);
     }
     
     /**
@@ -126,8 +122,6 @@ class ResourceResolverFactoryInitializer {
      */
     private static void initializeResourceResolverFactoryActivator(BundleContext bundleContext) {
         Dictionary<String, Object> config = new Hashtable<String, Object>();
-        config.put("resource.resolver.required.providers", new String[0]);
-
         ResourceResolverFactoryActivator activator = new ResourceResolverFactoryActivator();
         MockOsgi.injectServices(activator, bundleContext);
         MockOsgi.activate(activator, bundleContext, config);
@@ -167,10 +161,11 @@ class ResourceResolverFactoryInitializer {
      * and if no service with this class is already registered.
      * @param className Service class name
      */
-    private static void registerServiceIfFoundInClasspath(BundleContext bundleContext, String className) {
+    private static void registerServiceIfFoundInClasspath(BundleContext bundleContext, String serviceClassName, String implClassName) {
         try {
-            Class<?> serviceClass = Class.forName(className);
-            Object instance = serviceClass.newInstance();
+            Class<?> serviceClass = Class.forName(serviceClassName);
+            Class<?> implClass = Class.forName(implClassName);
+            Object instance = implClass.newInstance();
             registerServiceIfNotPresent(bundleContext, serviceClass, instance);
         }
         catch (ClassNotFoundException ex) {
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java b/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java
index d9c21e9..428bd4c 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java
@@ -87,7 +87,7 @@ class ThreadsafeMockAdapterManagerWrapper implements AdapterManager {
             if (bundleContext == null) {
                 setBundleContext(MockOsgi.newBundleContext());
             }
-            ServiceReference serviceReference = bundleContext.getServiceReference(AdapterManager.class.getName());
+            ServiceReference<AdapterManager> serviceReference = bundleContext.getServiceReference(AdapterManager.class);
             if (serviceReference != null) {
                 return (AdapterManager)bundleContext.getService(serviceReference);
             }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java b/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
index 43a4af4..3b649ca 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
@@ -18,13 +18,16 @@
  */
 package org.apache.sling.testing.mock.sling.context;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.security.cert.X509Certificate;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
@@ -59,7 +62,6 @@ final class ModelAdapterFactoryUtil {
         MockOsgi.sendBundleEvent(bundleContext, event);
     }
 
-    @SuppressWarnings("unused")
     private static class ModelsPackageBundle implements Bundle {
 
         private final String packageName;
@@ -78,14 +80,14 @@ final class ModelAdapterFactoryUtil {
         }
 
         @Override
-        public Dictionary getHeaders() {
-            Dictionary<String, Object> headers = new Hashtable<String, Object>();
+        public Dictionary<String,String> getHeaders() {
+            Dictionary<String, String> headers = new Hashtable<String, String>();
             headers.put("Sling-Model-Packages", this.packageName);
             return headers;
         }
 
         @Override
-        public Enumeration findEntries(String path, String filePattern, boolean recurse) {
+        public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
             Reflections reflections = new Reflections(this.packageName);
             Set<Class<?>> types = reflections.getTypesAnnotatedWith(Model.class);
             Vector<URL> urls = new Vector<URL>(); // NOPMD
@@ -100,7 +102,7 @@ final class ModelAdapterFactoryUtil {
         }
 
         @Override
-        public Class loadClass(String name) throws ClassNotFoundException {
+        public Class<?> loadClass(String name) throws ClassNotFoundException {
             return getClass().getClassLoader().loadClass(name);
         }
 
@@ -155,12 +157,12 @@ final class ModelAdapterFactoryUtil {
         }
 
         @Override
-        public ServiceReference[] getRegisteredServices() { // NOPMD
+        public ServiceReference<?>[] getRegisteredServices() { // NOPMD
             return null;
         }
 
         @Override
-        public ServiceReference[] getServicesInUse() { // NOPMD
+        public ServiceReference<?>[] getServicesInUse() { // NOPMD
             return null;
         }
 
@@ -175,7 +177,7 @@ final class ModelAdapterFactoryUtil {
         }
 
         @Override
-        public Dictionary getHeaders(String locale) {
+        public Dictionary<String,String> getHeaders(String locale) {
             return null;
         }
 
@@ -185,12 +187,12 @@ final class ModelAdapterFactoryUtil {
         }
 
         @Override
-        public Enumeration getResources(String name) throws IOException {
+        public Enumeration<URL> getResources(String name) throws IOException {
             return null;
         }
 
         @Override
-        public Enumeration getEntryPaths(String path) {
+        public Enumeration<String> getEntryPaths(String path) {
             return null;
         }
 
@@ -204,16 +206,31 @@ final class ModelAdapterFactoryUtil {
             return 0;
         }
 
-        // this is part of org.osgi 4.2.0
-        public Map getSignerCertificates(int signersType) {
+        @Override
+        public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType) {
             return null;
         }
 
-        // this is part of org.osgi 4.2.0
+        @Override
         public Version getVersion() {
             return null;
         }
 
+        @Override
+        public int compareTo(Bundle o) {
+            return 0;
+        }
+
+        @Override
+        public <A> A adapt(Class<A> type) {
+            return null;
+        }
+
+        @Override
+        public File getDataFile(String filename) {
+            return null;
+        }
+
     }
 
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
index c1be12f..e22b34e 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
@@ -308,9 +308,9 @@ public class SlingContextImpl extends OsgiContextImpl {
      */
     public final void runMode(String... runModes) {
         Set<String> newRunModes = ImmutableSet.<String> builder().add(runModes).build();
-        ServiceReference ref = bundleContext().getServiceReference(SlingSettingsService.class.getName());
+        ServiceReference<SlingSettingsService> ref = bundleContext().getServiceReference(SlingSettingsService.class);
         if (ref != null) {
-            MockSlingSettingService slingSettings = (MockSlingSettingService) bundleContext().getService(ref);
+            MockSlingSettingService slingSettings = (MockSlingSettingService)bundleContext().getService(ref);
             slingSettings.setRunModes(newRunModes);
         }
     }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java b/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
index 7729618..efbc82e 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
@@ -603,9 +603,9 @@ public final class ContentLoader {
         String mimeType = null;
         String fileExtension = StringUtils.substringAfterLast(name, ".");
         if (bundleContext != null && StringUtils.isNotEmpty(fileExtension)) {
-            ServiceReference ref = bundleContext.getServiceReference(MimeTypeService.class.getName());
+            ServiceReference<MimeTypeService> ref = bundleContext.getServiceReference(MimeTypeService.class);
             if (ref != null) {
-                MimeTypeService mimeTypeService = (MimeTypeService) bundleContext.getService(ref);
+                MimeTypeService mimeTypeService = (MimeTypeService)bundleContext.getService(ref);
                 mimeType = mimeTypeService.getMimeType(fileExtension);
             }
         }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
index 85ce5c4..b34a57d 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Mock implementation of selected Sling APIs.
  */
-@aQute.bnd.annotation.Version("1.5")
+@aQute.bnd.annotation.Version("1.6")
 package org.apache.sling.testing.mock.sling;
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java b/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
index a404c44..dc251c5 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
@@ -84,7 +84,7 @@ public class MockSlingHttpServletRequest extends org.apache.sling.servlethelpers
     public ResourceBundle getResourceBundle(String baseName, Locale locale) {
         // check of ResourceBundleProvider is registered in mock OSGI context
         ResourceBundle resourceBundle = null;
-        ServiceReference serviceReference = bundleContext.getServiceReference(ResourceBundleProvider.class.getName());
+        ServiceReference<ResourceBundleProvider> serviceReference = bundleContext.getServiceReference(ResourceBundleProvider.class);
         if (serviceReference != null) {
             ResourceBundleProvider provider = (ResourceBundleProvider)bundleContext.getService(serviceReference);
             resourceBundle = provider.getResourceBundle(baseName, locale);

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

[sling-org-apache-sling-testing-sling-mock] 12/14: update dependencies to released versions

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

commit 0b0cd7e27b26c40b59313f89c7a510d904ff8dcc
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jul 12 09:49:50 2016 +0000

    update dependencies to released versions
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1752257 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index e6df110..d4f596c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,19 +45,19 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>2.0.3-SNAPSHOT</version>
+            <version>2.0.4</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
-            <version>1.1.12</version>
+            <version>1.1.14</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
-            <version>1.1.12</version>
+            <version>1.1.14</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
@@ -96,7 +96,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourceresolver</artifactId>
-            <version>1.4.3-SNAPSHOT</version>
+            <version>1.4.4</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

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

[sling-org-apache-sling-testing-sling-mock] 05/14: SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15

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

commit e2054b1292f93242797e8d6b72b08b504e72fec2
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Feb 23 01:49:03 2016 +0000

    SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1731777 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/testing/mock/sling/MockJcrResourceResolverAdapter.java     | 5 ++---
 .../sling/testing/mock/sling/MockNoneResourceResolverAdapter.java    | 5 ++---
 src/main/java/org/apache/sling/testing/mock/sling/MockSling.java     | 4 ++--
 .../sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java  | 5 ++---
 .../sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java    | 5 ++---
 .../java/org/apache/sling/testing/mock/sling/spi/package-info.java   | 2 +-
 6 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
index 57bfd0b..d9df564 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
@@ -21,7 +21,6 @@ package org.apache.sling.testing.mock.sling;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
-import org.osgi.framework.BundleContext;
 
 /**
  * Resource resolver type adapter for JCR Mocks implementation.
@@ -29,12 +28,12 @@ import org.osgi.framework.BundleContext;
 class MockJcrResourceResolverAdapter implements ResourceResolverTypeAdapter {
 
     @Override
-    public ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext) {
+    public ResourceResolverFactory newResourceResolverFactory() {
         return null;
     }
 
     @Override
-    public SlingRepository newSlingRepository(BundleContext bundleContext) {
+    public SlingRepository newSlingRepository() {
         return new MockJcrSlingRepository();
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
index c99c23f..05a427c 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
@@ -21,7 +21,6 @@ package org.apache.sling.testing.mock.sling;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
-import org.osgi.framework.BundleContext;
 
 /**
  * Resource resolver type with no resource provider registered.
@@ -29,12 +28,12 @@ import org.osgi.framework.BundleContext;
 class MockNoneResourceResolverAdapter implements ResourceResolverTypeAdapter {
 
     @Override
-    public ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext) {
+    public ResourceResolverFactory newResourceResolverFactory() {
         return null;
     }
 
     @Override
-    public SlingRepository newSlingRepository(BundleContext bundleContext) {
+    public SlingRepository newSlingRepository() {
         return null;
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java b/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
index 31a3059..fdc222e 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
@@ -69,9 +69,9 @@ public final class MockSling {
     public static ResourceResolverFactory newResourceResolverFactory(final ResourceResolverType type,
             final BundleContext bundleContext) {
         ResourceResolverTypeAdapter adapter = getResourceResolverTypeAdapter(type);
-        ResourceResolverFactory factory = adapter.newResourceResolverFactory(bundleContext);
+        ResourceResolverFactory factory = adapter.newResourceResolverFactory();
         if (factory == null) {
-            SlingRepository repository = adapter.newSlingRepository(bundleContext);
+            SlingRepository repository = adapter.newSlingRepository();
             factory = ResourceResolverFactoryInitializer.setUp(repository, bundleContext, type.getNodeTypeMode());
         }
         else {
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
index 1329805..47c4a64 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
@@ -23,7 +23,6 @@ import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
 import org.apache.sling.testing.resourceresolver.MockResourceResolverFactory;
 import org.apache.sling.testing.resourceresolver.MockResourceResolverFactoryOptions;
-import org.osgi.framework.BundleContext;
 
 /**
  * Resource resolver type adapter for Sling Resource Resolver Mock implementation.
@@ -41,12 +40,12 @@ class RRMockMockResourceResolverAdapter implements ResourceResolverTypeAdapter {
     }
 
     @Override
-    public ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext) {
+    public ResourceResolverFactory newResourceResolverFactory() {
         return new MockResourceResolverFactory(options);
     }
 
     @Override
-    public SlingRepository newSlingRepository(BundleContext bundleContext) {
+    public SlingRepository newSlingRepository() {
         return null;
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
index 85d346c..cc20279 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
@@ -20,7 +20,6 @@ package org.apache.sling.testing.mock.sling.spi;
 
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.osgi.framework.BundleContext;
 
 /**
  * SPI interface for resource resolver type implementations to provide a mock
@@ -34,7 +33,7 @@ public interface ResourceResolverTypeAdapter {
      * {@link #newSlingRepository()} has to return a value.
      * @return Resource resolver factory instance or null
      */
-    ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext);
+    ResourceResolverFactory newResourceResolverFactory();
 
     /**
      * Get SlingRepository instance. Can be null if a resource resolver factory
@@ -42,6 +41,6 @@ public interface ResourceResolverTypeAdapter {
      * {@link #newResourceResolverFactory()} has to return a value.
      * @return Sling repository instance or null
      */
-    SlingRepository newSlingRepository(BundleContext bundleContext);
+    SlingRepository newSlingRepository();
 
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java
index c0720b9..0316d03 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java
@@ -19,5 +19,5 @@
 /**
  * SPI for hooking in alternative resource type adapter implementations.
  */
-@aQute.bnd.annotation.Version("2.0")
+@aQute.bnd.annotation.Version("1.0")
 package org.apache.sling.testing.mock.sling.spi;

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

[sling-org-apache-sling-testing-sling-mock] 02/14: SLING-5546 remove deprecated methods

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

commit 41b471d6363447255198366b88b2b19d38384697
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Feb 23 00:33:26 2016 +0000

    SLING-5546 remove deprecated methods
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1731765 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/testing/mock/sling/MockSling.java | 67 ----------------------
 .../sling/testing/mock/sling/package-info.java     |  2 +-
 .../sling/servlet/MockSlingHttpServletRequest.java | 23 +-------
 .../testing/mock/sling/servlet/package-info.java   |  2 +-
 4 files changed, 3 insertions(+), 91 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java b/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
index b53faae..fdc222e 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
@@ -26,7 +26,6 @@ import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
 import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
@@ -54,18 +53,6 @@ public final class MockSling {
 
     /**
      * Creates new sling resource resolver factory instance.
-     * @param type Type of underlying repository.
-     * @return Resource resolver factory instance
-     * @deprecated Please use {@link #newResourceResolverFactory(ResourceResolverType, BundleContext)}
-     *   and shutdown the bundle context after usage.
-     */
-    @Deprecated
-    public static ResourceResolverFactory newResourceResolverFactory(final ResourceResolverType type) {
-        return newResourceResolverFactory(type, MockOsgi.newBundleContext());
-    }
-    
-    /**
-     * Creates new sling resource resolver factory instance.
      * @param bundleContext Bundle context
      * @return Resource resolver factory instance
      */
@@ -119,47 +106,6 @@ public final class MockSling {
     }
 
     /**
-     * Creates new sling resource resolver factory instance using
-     * {@link #DEFAULT_RESOURCERESOLVER_TYPE}.
-     * @return Resource resolver factory instance
-     * @deprecated Please use {@link #newResourceResolverFactory(BundleContext)}
-     *   and shutdown the bundle context after usage.
-     */
-    @Deprecated
-    public static ResourceResolverFactory newResourceResolverFactory() {
-        return newResourceResolverFactory(DEFAULT_RESOURCERESOLVER_TYPE);
-    }
-
-    /**
-     * Creates new sling resource resolver instance.
-     * @param type Type of underlying repository.
-     * @return Resource resolver instance
-     * @deprecated Please use {@link #newResourceResolver(ResourceResolverType, BundleContext)}
-     *   and shutdown the bundle context after usage.
-     */
-    @Deprecated
-    public static ResourceResolver newResourceResolver(final ResourceResolverType type) {
-        ResourceResolverFactory factory = newResourceResolverFactory(type);
-        try {
-            return factory.getAdministrativeResourceResolver(null);
-        } catch (LoginException ex) {
-            throw new RuntimeException("Mock resource resolver factory implementation seems to require login.", ex);
-        }
-    }
-
-    /**
-     * Creates new sling resource resolver instance using
-     * {@link #DEFAULT_RESOURCERESOLVER_TYPE}.
-     * @return Resource resolver instance
-     * @deprecated Please use {@link #newResourceResolver(BundleContext)}
-     *   and shutdown the bundle context after usage.
-     */
-    @Deprecated
-    public static ResourceResolver newResourceResolver() {
-        return newResourceResolver(DEFAULT_RESOURCERESOLVER_TYPE);
-    }
-
-    /**
      * Creates new sling resource resolver instance.
      * @param type Type of underlying repository.
      * @param bundleContext Bundle context
@@ -199,19 +145,6 @@ public final class MockSling {
     /**
      * Creates a new sling script helper instance using
      * {@link #DEFAULT_RESOURCERESOLVER_TYPE} for the resource resolver.
-     * @return Sling script helper instance
-     * @deprecated Please use {@link #newSlingScriptHelper(BundleContext)}
-     *   and shutdown the bundle context after usage.
-     */
-    @Deprecated
-    public static SlingScriptHelper newSlingScriptHelper() {
-        BundleContext bundleContext = MockOsgi.newBundleContext();
-        return newSlingScriptHelper(bundleContext);
-    }
-
-    /**
-     * Creates a new sling script helper instance using
-     * {@link #DEFAULT_RESOURCERESOLVER_TYPE} for the resource resolver.
      * @param bundleContext Bundle context
      * @return Sling script helper instance
      */
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
index b34a57d..a0c9444 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Mock implementation of selected Sling APIs.
  */
-@aQute.bnd.annotation.Version("1.6")
+@aQute.bnd.annotation.Version("2.0")
 package org.apache.sling.testing.mock.sling;
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java b/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
index dc251c5..798ad02 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
@@ -23,7 +23,6 @@ import java.util.ResourceBundle;
 
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.i18n.ResourceBundleProvider;
-import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.apache.sling.testing.mock.sling.MockSling;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -37,30 +36,10 @@ public class MockSlingHttpServletRequest extends org.apache.sling.servlethelpers
 
     /**
      * Instantiate with default resource resolver
-     * @deprecated Please use {@link #MockSlingHttpServletRequest(BundleContext)}
-     *   and shutdown the bundle context after usage.
-     */
-    @Deprecated
-    public MockSlingHttpServletRequest() {
-        this(MockOsgi.newBundleContext());
-    }
-
-    /**
-     * Instantiate with default resource resolver
      * @param bundleContext Bundle context
      */
     public MockSlingHttpServletRequest(BundleContext bundleContext) {
-        this(MockSling.newResourceResolver(bundleContext));
-    }
-
-    /**
-     * @param resourceResolver Resource resolver
-     * @deprecated Please use {@link #MockSlingHttpServletRequest(ResourceResolver, BundleContext)}
-     *   and shutdown the bundle context after usage.
-     */
-    @Deprecated
-    public MockSlingHttpServletRequest(ResourceResolver resourceResolver) {
-        this(resourceResolver, MockOsgi.newBundleContext());
+        this(MockSling.newResourceResolver(bundleContext), bundleContext);
     }
 
     /**
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/servlet/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/servlet/package-info.java
index 0408710..67c2cbd 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/servlet/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/servlet/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Mock implementation of selected Servlet-related Sling APIs.
  */
-@aQute.bnd.annotation.Version("2.0")
+@aQute.bnd.annotation.Version("3.0")
 package org.apache.sling.testing.mock.sling.servlet;

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

[sling-org-apache-sling-testing-sling-mock] 09/14: SLING-5769 reverted r1747508 since it is already exposed through getService(...)

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

commit ec779507b96648820bf729ebbdf60041005b9a4f
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Jun 9 08:56:45 2016 +0000

    SLING-5769 reverted r1747508 since it is already exposed through getService(...)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1747511 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/testing/mock/sling/context/SlingContextImpl.java     | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
index 8a9aedb..66d6085 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
@@ -182,16 +182,6 @@ public class SlingContextImpl extends OsgiContextImpl {
     }
 
     /**
-     * Returns a {@code ResourceResolverFactory}. All resource resolvers being created with the returned factory need to be properly closed.
-     * In most of the cases {@link #resourceResolver()} should be used instead, because its life cycle is managed automatically
-     * (i.e. it is automatically closed after the test). 
-     * @return Resource resolver factory
-     */
-    public final ResourceResolverFactory resourceResolverFactory() {
-        return this.resourceResolverFactory;
-    }
-
-    /**
      * Returns the singleton resource resolver bound to this context.
      * It is automatically closed after the test.
      * @return Resource resolver

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

[sling-org-apache-sling-testing-sling-mock] 08/14: SLING-5769 expose resource resolver factory from SlingContext

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

commit 08b7fd53db69ba67740ed2a8466cfbd1d8614b50
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Jun 9 08:49:21 2016 +0000

    SLING-5769 expose resource resolver factory from SlingContext
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1747508 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/testing/mock/sling/context/SlingContextImpl.java   | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
index cfaad87..8a9aedb 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
@@ -182,6 +182,18 @@ public class SlingContextImpl extends OsgiContextImpl {
     }
 
     /**
+     * Returns a {@code ResourceResolverFactory}. All resource resolvers being created with the returned factory need to be properly closed.
+     * In most of the cases {@link #resourceResolver()} should be used instead, because its life cycle is managed automatically
+     * (i.e. it is automatically closed after the test). 
+     * @return Resource resolver factory
+     */
+    public final ResourceResolverFactory resourceResolverFactory() {
+        return this.resourceResolverFactory;
+    }
+
+    /**
+     * Returns the singleton resource resolver bound to this context.
+     * It is automatically closed after the test.
      * @return Resource resolver
      */
     public final ResourceResolver resourceResolver() {

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

[sling-org-apache-sling-testing-sling-mock] 10/14: SLING-5770 add support for custom resource resolver factory activator configuration via SlingContextBuilder add support for additional callbacks before setup and after teardown

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

commit 3239d982e81d3b20120ac88e09c8ee3188594150
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Jul 8 15:45:02 2016 +0000

    SLING-5770 add support for custom resource resolver factory activator configuration via SlingContextBuilder
    add support for additional callbacks before setup and after teardown
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1751927 13f79535-47bb-0310-9956-ffa450edef68
---
 .../mock/sling/context/SlingContextImpl.java       |  44 +++++++-
 .../testing/mock/sling/context/package-info.java   |   2 +-
 .../testing/mock/sling/junit/SlingContext.java     | 111 +++++++++++++-------
 .../mock/sling/junit/SlingContextBuilder.java      | 115 +++++++++++++++++++++
 .../testing/mock/sling/junit/package-info.java     |   2 +-
 .../testing/mock/sling/junit/SlingContextTest.java |  42 +++++++-
 6 files changed, 268 insertions(+), 48 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
index 66d6085..aceb506 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
@@ -18,6 +18,10 @@
  */
 package org.apache.sling.testing.mock.sling.context;
 
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
 import java.util.Set;
 
 import javax.jcr.RepositoryException;
@@ -55,13 +59,17 @@ import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
 import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
-
-import aQute.bnd.annotation.ConsumerType;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 
+import aQute.bnd.annotation.ConsumerType;
+
 /**
  * Defines Sling context objects with lazy initialization. Should not be used
  * directly but via the {@link org.apache.sling.testing.mock.sling.junit.SlingContext} JUnit
@@ -73,6 +81,10 @@ public class SlingContextImpl extends OsgiContextImpl {
     // default to publish instance run mode
     static final Set<String> DEFAULT_RUN_MODES = ImmutableSet.<String> builder().add("publish").build();
 
+    private static final String RESOURCERESOLVERFACTORYACTIVATOR_PID = "org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl";
+    
+    private static final Logger log = LoggerFactory.getLogger(SlingContextImpl.class);
+    
     protected ResourceResolverFactory resourceResolverFactory;
     protected ResourceResolverType resourceResolverType;
     protected ResourceResolver resourceResolver;
@@ -82,6 +94,8 @@ public class SlingContextImpl extends OsgiContextImpl {
     protected ContentLoader contentLoader;
     protected ContentBuilder contentBuilder;
     protected UniqueRoot uniqueRoot;
+    
+    private Map<String, Object> resourceResolverFactoryActivatorProps;
 
     /**
      * @param resourceResolverType Resource resolver type
@@ -90,12 +104,38 @@ public class SlingContextImpl extends OsgiContextImpl {
         this.resourceResolverType = resourceResolverType;
     }
 
+    protected void setResourceResolverFactoryActivatorProps(Map<String, Object> props) {
+        this.resourceResolverFactoryActivatorProps = props;
+    }
+    
     /**
      * Setup actions before test method execution
      */
     protected void setUp() {
         super.setUp();
         MockSling.setAdapterManagerBundleContext(bundleContext());
+        
+        if (this.resourceResolverFactoryActivatorProps != null) {
+            // use OSGi ConfigurationAdmin to pass over customized configuration to Resource Resolver Factory Activator service
+            ConfigurationAdmin configAdmin = getService(ConfigurationAdmin.class);
+            if (configAdmin == null) {
+              log.warn("ConfigAdmin not found in osgi-mock context - please make sure osgi-mock 1.7.0 or higher is used.");
+            }
+            else {
+              try {
+                Configuration resourceResolverFactoryActivatorConfig = configAdmin.getConfiguration(RESOURCERESOLVERFACTORYACTIVATOR_PID);
+                Dictionary<String, Object> props = new Hashtable<String, Object>();
+                for (Map.Entry<String, Object> item : this.resourceResolverFactoryActivatorProps.entrySet()) {
+                    props.put(item.getKey(), item.getValue());
+                }
+                resourceResolverFactoryActivatorConfig.update(props);
+              }
+              catch (IOException ex) {
+                throw new RuntimeException(ex);
+              }
+            }
+        }
+        
         this.resourceResolverFactory = newResourceResolverFactory();
         registerDefaultServices();
     }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java
index 827160f..e440a9e 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Sling context implementation for unit tests.
  */
-@aQute.bnd.annotation.Version("3.1")
+@aQute.bnd.annotation.Version("3.2")
 package org.apache.sling.testing.mock.sling.context;
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
index 2b8381b..7f7625a 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
@@ -18,6 +18,8 @@
  */
 package org.apache.sling.testing.mock.sling.junit;
 
+import java.util.Map;
+
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
 import org.junit.rules.ExternalResource;
@@ -31,8 +33,10 @@ import org.junit.runners.model.Statement;
  */
 public final class SlingContext extends SlingContextImpl implements TestRule {
 
-    private final SlingContextCallback setUpCallback;
-    private final SlingContextCallback tearDownCallback;
+    private final SlingContextCallback beforeSetUpCallback;
+    private final SlingContextCallback afterSetUpCallback;
+    private final SlingContextCallback beforeTearDownCallback;
+    private final SlingContextCallback afterTearDownCallback;
     private final TestRule delegate;
 
     /**
@@ -54,54 +58,61 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
     /**
      * Initialize Sling context with default resource resolver type:
      * {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
-     * @param setUpCallback Allows the application to register an own callback
-     *            function that is called after the built-in setup rules are
-     *            executed.
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
      */
-    public SlingContext(final SlingContextCallback setUpCallback) {
-        this(setUpCallback, null, null);
+    public SlingContext(final SlingContextCallback afterSetUpCallback) {
+        this(afterSetUpCallback, null, null);
     }
 
     /**
      * Initialize Sling context with resource resolver type.
-     * @param setUpCallback Allows the application to register an own callback
-     *            function that is called after the built-in setup rules are
-     *            executed.
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
      * @param resourceResolverType Resource resolver type.
      */
-    public SlingContext(final SlingContextCallback setUpCallback, final ResourceResolverType resourceResolverType) {
-        this(setUpCallback, null, resourceResolverType);
+    public SlingContext(final SlingContextCallback afterSetUpCallback, final ResourceResolverType resourceResolverType) {
+        this(afterSetUpCallback, null, resourceResolverType);
     }
 
     /**
      * Initialize Sling context with default resource resolver type:
      * {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
-     * @param setUpCallback Allows the application to register an own callback
-     *            function that is called after the built-in setup rules are
-     *            executed.
-     * @param tearDownCallback Allows the application to register an own
-     *            callback function that is called before the built-in teardown
-     *            rules are executed.
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+     * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+     */
+    public SlingContext(final SlingContextCallback afterSetUpCallback, final SlingContextCallback beforeTearDownCallback) {
+        this(afterSetUpCallback, beforeTearDownCallback, null);
+    }
+    
+    /**
+     * Initialize Sling context with resource resolver type.
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+     * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+     * @param resourceResolverType Resource resolver type.
      */
-    public SlingContext(final SlingContextCallback setUpCallback, final SlingContextCallback tearDownCallback) {
-        this(setUpCallback, tearDownCallback, null);
+    public SlingContext(final SlingContextCallback afterSetUpCallback, final SlingContextCallback beforeTearDownCallback,
+            final ResourceResolverType resourceResolverType) {
+        this(null, afterSetUpCallback, beforeTearDownCallback, null, null, resourceResolverType);
     }
     
     /**
      * Initialize Sling context with resource resolver type.
-     * @param setUpCallback Allows the application to register an own callback
-     *            function that is called after the built-in setup rules are
-     *            executed.
-     * @param tearDownCallback Allows the application to register an own
-     *            callback function that is called before the built-in teardown
-     *            rules are executed.
+     * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the built-in setup rules are executed.
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+     * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+     * @param afterTearDownCallback Allows the application to register an own callback function that is after before the built-in teardown rules are executed.
+     * @param resourceResolverFactoryActivatorProps Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
      * @param resourceResolverType Resource resolver type.
      */
-    public SlingContext(final SlingContextCallback setUpCallback, final SlingContextCallback tearDownCallback,
+    SlingContext(final SlingContextCallback beforeSetUpCallback, final SlingContextCallback afterSetUpCallback,
+            final SlingContextCallback beforeTearDownCallback, final SlingContextCallback afterTearDownCallback,
+            final Map<String, Object> resourceResolverFactoryActivatorProps,
             final ResourceResolverType resourceResolverType) {
 
-        this.setUpCallback = setUpCallback;
-        this.tearDownCallback = tearDownCallback;
+        this.beforeSetUpCallback = beforeSetUpCallback;
+        this.afterSetUpCallback = afterSetUpCallback;
+        this.beforeTearDownCallback = beforeTearDownCallback;
+        this.afterTearDownCallback = afterTearDownCallback;
+        setResourceResolverFactoryActivatorProps(resourceResolverFactoryActivatorProps);
 
         // set resource resolver type in parent context
         setResourceResolverType(resourceResolverType);
@@ -110,14 +121,16 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
         this.delegate = new ExternalResource() {
             @Override
             protected void before() {
+                SlingContext.this.executeBeforeSetUpCallback();
                 SlingContext.this.setUp();
-                SlingContext.this.executeSetUpCallback();
+                SlingContext.this.executeAfterSetUpCallback();
             }
 
             @Override
             protected void after() {
-                SlingContext.this.executeTearDownCallback();
+                SlingContext.this.executeBeforeTearDownCallback();
                 SlingContext.this.tearDown();
+                SlingContext.this.executeAfterTearDownCallback();
             }
         };
     }
@@ -127,22 +140,42 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
         return this.delegate.apply(base, description);
     }
 
-    private void executeSetUpCallback() {
-        if (this.setUpCallback != null) {
+    private void executeBeforeSetUpCallback() {
+        if (this.beforeSetUpCallback != null) {
+            try {
+                this.beforeSetUpCallback.execute(this);
+            } catch (Throwable ex) {
+                throw new RuntimeException("Before setup failed: " + ex.getMessage(), ex);
+            }
+        }
+    }
+
+    private void executeAfterSetUpCallback() {
+        if (this.afterSetUpCallback != null) {
+            try {
+                this.afterSetUpCallback.execute(this);
+            } catch (Throwable ex) {
+                throw new RuntimeException("After setup failed: " + ex.getMessage(), ex);
+            }
+        }
+    }
+
+    private void executeBeforeTearDownCallback() {
+        if (this.beforeTearDownCallback != null) {
             try {
-                this.setUpCallback.execute(this);
+                this.beforeTearDownCallback.execute(this);
             } catch (Throwable ex) {
-                throw new RuntimeException("Setup failed: " + ex.getMessage(), ex);
+                throw new RuntimeException("Before teardown failed: " + ex.getMessage(), ex);
             }
         }
     }
 
-    private void executeTearDownCallback() {
-        if (this.tearDownCallback != null) {
+    private void executeAfterTearDownCallback() {
+        if (this.afterTearDownCallback != null) {
             try {
-                this.tearDownCallback.execute(this);
+                this.afterTearDownCallback.execute(this);
             } catch (Throwable ex) {
-                throw new RuntimeException("Teardown failed: " + ex.getMessage(), ex);
+                throw new RuntimeException("After teardown failed: " + ex.getMessage(), ex);
             }
         }
     }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
new file mode 100644
index 0000000..62080fa
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
@@ -0,0 +1,115 @@
+/*
+ * 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.sling.junit;
+
+import java.util.Map;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+
+/**
+ * Builder class for creating {@link SlingContext} instances with different sets of parameters.
+ */
+public final class SlingContextBuilder {
+    
+    private ResourceResolverType resourceResolverType;
+    private SlingContextCallback beforeSetUpCallback;
+    private SlingContextCallback afterSetUpCallback;
+    private SlingContextCallback beforeTearDownCallback;
+    private SlingContextCallback afterTearDownCallback;
+    private Map<String, Object> resourceResolverFactoryActivatorProps;
+    
+    /**
+     * Create builder with default resource resolver type.
+     */
+    public SlingContextBuilder() {}
+    
+    /**
+     * Create builder with given resource resolver type.
+     * @param resourceResolverType Resource resolver type.
+     */
+    public SlingContextBuilder(ResourceResolverType resourceResolverType) {
+        this.resourceResolverType(resourceResolverType);
+    }
+    
+    /**
+     * @param resourceResolverType Resource resolver type.
+     * @return this
+     */
+    public SlingContextBuilder resourceResolverType(ResourceResolverType resourceResolverType) {
+        this.resourceResolverType = resourceResolverType;
+        return this;
+    }
+    
+    /**
+     * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the built-in setup rules are executed.
+     * @return this
+     */
+    public SlingContextBuilder beforeSetUp(SlingContextCallback beforeSetUpCallback) {
+        this.beforeSetUpCallback = beforeSetUpCallback;
+        return this;
+    }
+
+    /**
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+     * @return this
+     */
+    public SlingContextBuilder afterSetUp(SlingContextCallback afterSetUpCallback) {
+        this.afterSetUpCallback = afterSetUpCallback;
+        return this;
+    }
+
+    /**
+     * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+     * @return this
+     */
+    public SlingContextBuilder beforeTearDown(SlingContextCallback beforeTearDownCallback) {
+        this.beforeTearDownCallback = beforeTearDownCallback;
+        return this;
+    }
+
+    /**
+     * @param afterTearDownCallback Allows the application to register an own callback function that is after before the built-in teardown rules are executed.
+     * @return this
+     */
+    public SlingContextBuilder afterTearDown(SlingContextCallback afterTearDownCallback) {
+        this.afterTearDownCallback = afterTearDownCallback;
+        return this;
+    }
+
+    /**
+     * Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
+     * @param props Configuration properties
+     * @return this
+     */
+    public SlingContextBuilder resourceResolverFactoryActivatorProps(Map<String, Object> props) {
+      this.resourceResolverFactoryActivatorProps = props;
+      return this;
+    }
+
+    /**
+     * @return Build {@link SlingContext} instance.
+     */
+    public SlingContext build() {
+        return new SlingContext(this.beforeSetUpCallback, this.afterSetUpCallback,
+                this.beforeTearDownCallback, this.afterTearDownCallback,
+                this.resourceResolverFactoryActivatorProps,
+                this.resourceResolverType);
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java
index b7888e3..d7acc84 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Rule for providing easy access to Sling context in JUnit tests.
  */
-@aQute.bnd.annotation.Version("3.1")
+@aQute.bnd.annotation.Version("3.2")
 package org.apache.sling.testing.mock.sling.junit;
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java b/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
index 2a25e7c..39bad27 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
@@ -43,17 +43,29 @@ import com.google.common.collect.ImmutableMap;
 @RunWith(MockitoJUnitRunner.class)
 public class SlingContextTest {
 
-    private final SlingContextCallback contextSetup = mock(SlingContextCallback.class);
-    private final SlingContextCallback contextTeardown = mock(SlingContextCallback.class);
+    private final SlingContextCallback contextBeforeSetup = mock(SlingContextCallback.class);
+    private final SlingContextCallback contextAfterSetup = mock(SlingContextCallback.class);
+    private final SlingContextCallback contextBeforeTeardown = mock(SlingContextCallback.class);
+    private final SlingContextCallback contextAfterTeardown = mock(SlingContextCallback.class);
 
     // Run all unit tests for each resource resolver types listed here
     @Rule
-    public SlingContext context = new SlingContext(contextSetup, contextTeardown,
-            ResourceResolverType.RESOURCERESOLVER_MOCK);
+    public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK)
+        .beforeSetUp(contextBeforeSetup)
+        .afterSetUp(contextAfterSetup)
+        .beforeTearDown(contextBeforeTeardown)
+        .afterTearDown(contextAfterTeardown)
+        .resourceResolverFactoryActivatorProps(ImmutableMap.<String, Object>of("resource.resolver.searchpath", new String[] {
+            "/apps",
+            "/libs",
+            "/testpath",
+        }))
+        .build();
 
     @Before
     public void setUp() throws IOException, PersistenceException {
-        verify(contextSetup).execute(context);
+        verify(contextBeforeSetup).execute(context);
+        verify(contextAfterSetup).execute(context);
     }
 
     @Test
@@ -61,6 +73,26 @@ public class SlingContextTest {
         assertNotNull(context.request());
     }
 
+    /**
+     * Test if custom searchpath /testpath added in this SlingContext is handled correctly.
+     */
+    @Test
+    public void testResourceResolverFactoryActivatorProps() {
+      context.create().resource("/apps/node1");
+
+      context.create().resource("/libs/node1");
+      context.create().resource("/libs/node2");
+
+      context.create().resource("/testpath/node1");
+      context.create().resource("/testpath/node2");
+      context.create().resource("/testpath/node3");
+
+      assertEquals("/apps/node1", context.resourceResolver().getResource("node1").getPath());
+      assertEquals("/libs/node2", context.resourceResolver().getResource("node2").getPath());
+      assertEquals("/testpath/node3", context.resourceResolver().getResource("node3").getPath());
+      assertNull(context.resourceResolver().getResource("node4"));
+    }
+    
     @Test
     public void testRegisterAdapter() {
         

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

[sling-org-apache-sling-testing-sling-mock] 11/14: SLING-5770 update javadoc

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

commit 7d5c794294022e8b3dc1b8394189be0849005e64
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Jul 8 16:11:23 2016 +0000

    SLING-5770 update javadoc
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1751936 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/testing/mock/sling/junit/SlingContext.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
index 7f7625a..9dcd712 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
@@ -28,8 +28,9 @@ import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 
 /**
- * JUnit rule for setting up and tearing down Sling context objects for unit
- * tests.
+ * JUnit rule for setting up and tearing down Sling context objects for unit tests.
+ * You can use {@link SlingContextBuilder} alternatively to the constructors on this class - it offers
+ * more options and fine-grained control about setting up the test context.
  */
 public final class SlingContext extends SlingContextImpl implements TestRule {
 

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

[sling-org-apache-sling-testing-sling-mock] 03/14: SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15

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

commit 22cce0c7e7f6eaa7833ecae4ee68f830074002d9
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Feb 23 00:55:22 2016 +0000

    SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1731771 13f79535-47bb-0310-9956-ffa450edef68
---
 .../mock/sling/MockJcrResourceResolverAdapter.java |  5 +--
 .../sling/MockNoneResourceResolverAdapter.java     |  5 +--
 .../apache/sling/testing/mock/sling/MockSling.java |  4 +--
 .../sling/RRMockMockResourceResolverAdapter.java   |  5 +--
 .../sling/ResourceResolverFactoryInitializer.java  | 42 ++++++----------------
 .../sling/context/ModelAdapterFactoryUtil.java     |  5 +++
 .../sling/spi/ResourceResolverTypeAdapter.java     |  5 +--
 .../sling/testing/mock/sling/spi/package-info.java |  2 +-
 8 files changed, 30 insertions(+), 43 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
index d9df564..57bfd0b 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.mock.sling;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
+import org.osgi.framework.BundleContext;
 
 /**
  * Resource resolver type adapter for JCR Mocks implementation.
@@ -28,12 +29,12 @@ import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
 class MockJcrResourceResolverAdapter implements ResourceResolverTypeAdapter {
 
     @Override
-    public ResourceResolverFactory newResourceResolverFactory() {
+    public ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext) {
         return null;
     }
 
     @Override
-    public SlingRepository newSlingRepository() {
+    public SlingRepository newSlingRepository(BundleContext bundleContext) {
         return new MockJcrSlingRepository();
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
index 05a427c..c99c23f 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.mock.sling;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
+import org.osgi.framework.BundleContext;
 
 /**
  * Resource resolver type with no resource provider registered.
@@ -28,12 +29,12 @@ import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
 class MockNoneResourceResolverAdapter implements ResourceResolverTypeAdapter {
 
     @Override
-    public ResourceResolverFactory newResourceResolverFactory() {
+    public ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext) {
         return null;
     }
 
     @Override
-    public SlingRepository newSlingRepository() {
+    public SlingRepository newSlingRepository(BundleContext bundleContext) {
         return null;
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java b/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
index fdc222e..31a3059 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
@@ -69,9 +69,9 @@ public final class MockSling {
     public static ResourceResolverFactory newResourceResolverFactory(final ResourceResolverType type,
             final BundleContext bundleContext) {
         ResourceResolverTypeAdapter adapter = getResourceResolverTypeAdapter(type);
-        ResourceResolverFactory factory = adapter.newResourceResolverFactory();
+        ResourceResolverFactory factory = adapter.newResourceResolverFactory(bundleContext);
         if (factory == null) {
-            SlingRepository repository = adapter.newSlingRepository();
+            SlingRepository repository = adapter.newSlingRepository(bundleContext);
             factory = ResourceResolverFactoryInitializer.setUp(repository, bundleContext, type.getNodeTypeMode());
         }
         else {
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
index 47c4a64..1329805 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
@@ -23,6 +23,7 @@ import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
 import org.apache.sling.testing.resourceresolver.MockResourceResolverFactory;
 import org.apache.sling.testing.resourceresolver.MockResourceResolverFactoryOptions;
+import org.osgi.framework.BundleContext;
 
 /**
  * Resource resolver type adapter for Sling Resource Resolver Mock implementation.
@@ -40,12 +41,12 @@ class RRMockMockResourceResolverAdapter implements ResourceResolverTypeAdapter {
     }
 
     @Override
-    public ResourceResolverFactory newResourceResolverFactory() {
+    public ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext) {
         return new MockResourceResolverFactory(options);
     }
 
     @Override
-    public SlingRepository newSlingRepository() {
+    public SlingRepository newSlingRepository(BundleContext bundleContext) {
         return null;
     }
 
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
index e98a5e4..eae5323 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
@@ -85,10 +85,10 @@ class ResourceResolverFactoryInitializer {
      * @param bundleContext Bundle context
      */
     private static void ensureJcrResourceProviderDependencies(BundleContext bundleContext) {
-        bundleContext.registerService(DynamicClassLoaderManager.class, new MockDynamicClassLoaderManager(), null);
-        // setup PathMapper which is a mandatory service for JcrProviderFactory (since org.apache.sling.jcr.resource 2.5.4)
-        // use reflection to not depend on it if running with older version of org.apache.sling.jcr.resource
-        registerServiceIfFoundInClasspath(bundleContext, PathMapper.class.getName(), PathMapper.class.getName());
+        if (bundleContext.getServiceReference(DynamicClassLoaderManager.class) == null) {
+            bundleContext.registerService(DynamicClassLoaderManager.class, new MockDynamicClassLoaderManager(), null);
+        }
+        registerServiceIfNotPresent(bundleContext, PathMapper.class, new PathMapper());
     }
  
     /**
@@ -135,10 +135,11 @@ class ResourceResolverFactoryInitializer {
      * @param serviceClass Service class
      * @param instance Service instance
      */
-    private static void registerServiceIfNotPresent(BundleContext bundleContext, Class<?> serviceClass, 
-            Object instance) {
+    private static <T> void registerServiceIfNotPresent(BundleContext bundleContext, Class<T> serviceClass, 
+            T instance) {
         registerServiceIfNotPresent(bundleContext, serviceClass, instance, new Hashtable<String, Object>());
     }
+    
     /**
      * Registers a service if the service class is found in classpath,
      * and if no service with this class is already registered.
@@ -147,35 +148,12 @@ class ResourceResolverFactoryInitializer {
      * @param instance Service instance
      * @param config OSGi config
      */
-    private static void registerServiceIfNotPresent(BundleContext bundleContext, Class<?> serviceClass, 
-            Object instance, Dictionary<String, Object> config) {
+    private static <T> void registerServiceIfNotPresent(BundleContext bundleContext, Class<T> serviceClass, 
+            T instance, Dictionary<String, Object> config) {
         if (bundleContext.getServiceReference(serviceClass.getName()) == null) {
             MockOsgi.injectServices(instance, bundleContext);
             MockOsgi.activate(instance, bundleContext, config);
-            bundleContext.registerService(serviceClass.getName(), instance, config);
-        }
-    }
-    
-    /**
-     * Registers a service if the service class is found in classpath,
-     * and if no service with this class is already registered.
-     * @param className Service class name
-     */
-    private static void registerServiceIfFoundInClasspath(BundleContext bundleContext, String serviceClassName, String implClassName) {
-        try {
-            Class<?> serviceClass = Class.forName(serviceClassName);
-            Class<?> implClass = Class.forName(implClassName);
-            Object instance = implClass.newInstance();
-            registerServiceIfNotPresent(bundleContext, serviceClass, instance);
-        }
-        catch (ClassNotFoundException ex) {
-            // skip service registration
-        }
-        catch (InstantiationException e) {
-            // skip service registration
-        }
-        catch (IllegalAccessException e) {
-            // skip service registration
+            bundleContext.registerService(serviceClass, instance, config);
         }
     }
     
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java b/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
index 3b649ca..e0044a4 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
@@ -47,6 +47,11 @@ import org.reflections.Reflections;
  */
 final class ModelAdapterFactoryUtil {
     
+    static {
+        // disable logging of reflections library to avoid spamming log files during unit tests
+        Reflections.log = null;
+    }
+    
     private ModelAdapterFactoryUtil() {
         // static methods only
     }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
index cc20279..85d346c 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
@@ -20,6 +20,7 @@ package org.apache.sling.testing.mock.sling.spi;
 
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.osgi.framework.BundleContext;
 
 /**
  * SPI interface for resource resolver type implementations to provide a mock
@@ -33,7 +34,7 @@ public interface ResourceResolverTypeAdapter {
      * {@link #newSlingRepository()} has to return a value.
      * @return Resource resolver factory instance or null
      */
-    ResourceResolverFactory newResourceResolverFactory();
+    ResourceResolverFactory newResourceResolverFactory(BundleContext bundleContext);
 
     /**
      * Get SlingRepository instance. Can be null if a resource resolver factory
@@ -41,6 +42,6 @@ public interface ResourceResolverTypeAdapter {
      * {@link #newResourceResolverFactory()} has to return a value.
      * @return Sling repository instance or null
      */
-    SlingRepository newSlingRepository();
+    SlingRepository newSlingRepository(BundleContext bundleContext);
 
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java
index 0316d03..c0720b9 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/spi/package-info.java
@@ -19,5 +19,5 @@
 /**
  * SPI for hooking in alternative resource type adapter implementations.
  */
-@aQute.bnd.annotation.Version("1.0")
+@aQute.bnd.annotation.Version("2.0")
 package org.apache.sling.testing.mock.sling.spi;

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

[sling-org-apache-sling-testing-sling-mock] 06/14: add unit test to test adapter factory overlays

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

commit 8476a669e08f6760b407896302d0b686824ac6e5
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Mar 11 13:11:47 2016 +0000

    add unit test to test adapter factory overlays
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1734551 13f79535-47bb-0310-9956-ffa450edef68
---
 .../testing/mock/sling/junit/SlingContextTest.java | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java b/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
index b785f28..7d61856 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
@@ -26,6 +26,8 @@ import static org.mockito.Mockito.verify;
 
 import java.io.IOException;
 
+import org.apache.sling.api.adapter.AdapterFactory;
+import org.apache.sling.api.adapter.SlingAdaptable;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -36,6 +38,7 @@ import org.junit.runner.RunWith;
 import org.mockito.runners.MockitoJUnitRunner;
 
 import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
 
 @RunWith(MockitoJUnitRunner.class)
 public class SlingContextTest {
@@ -76,4 +79,56 @@ public class SlingContextTest {
         assertNull(context.resourceResolver().adaptTo(Double.class));
     }
 
+    @Test
+    public void testRegisterAdapterOverlay() {
+        
+        // register "traditional" adapter factory without specific service ranking
+        AdapterFactory adapterFactory = new AdapterFactory() {
+            @SuppressWarnings("unchecked")
+            @Override
+            public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
+                return (AdapterType)(((TestAdaptable)adaptable).getMessage() + "-initial");
+            }
+        };
+        context.registerService(AdapterFactory.class, adapterFactory, ImmutableMap.<String, Object>builder()
+                .put(AdapterFactory.ADAPTABLE_CLASSES, new String[] { TestAdaptable.class.getName() })
+                .put(AdapterFactory.ADAPTER_CLASSES, new String[] { String.class.getName() })
+                .build());
+        
+        // test initial adapter factory
+        assertEquals("testMessage1-initial", new TestAdaptable("testMessage1").adaptTo(String.class));
+        
+        // register overlay adapter with static adaption
+        context.registerAdapter(TestAdaptable.class, String.class, "static-adaption");
+
+        // test overlay adapter with static adaption
+        assertEquals("static-adaption", new TestAdaptable("testMessage2").adaptTo(String.class));
+
+        // register overlay adapter with dynamic adaption
+        context.registerAdapter(TestAdaptable.class, String.class, new Function<TestAdaptable, String>() {
+            @Override
+            public String apply(TestAdaptable input) {
+                return input.getMessage() + "-dynamic";
+            }
+        });
+
+        // test overlay adapter with dynamic adaption
+        assertEquals("testMessage3-dynamic", new TestAdaptable("testMessage3").adaptTo(String.class));
+    }
+
+
+    private static class TestAdaptable extends SlingAdaptable {
+        
+        private final String message;
+
+        public TestAdaptable(String message) {
+            this.message = message;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+        
+    }
+
 }

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

[sling-org-apache-sling-testing-sling-mock] 14/14: [maven-release-plugin] copy for tag org.apache.sling.testing.sling-mock-2.0.0

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

commit cc88bfba12944e12ce7c4ec19dd208ffd4696f24
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jul 12 10:29:15 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.testing.sling-mock-2.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.sling-mock-2.0.0@1752266 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-sling-mock] 07/14: SLING-5667 adapt to changes service ranking order in osgi-mock

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

commit 57b714b7529adb77c7e9b7bae40b29a4495cc263
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Apr 29 17:05:13 2016 +0000

    SLING-5667 adapt to changes service ranking order in osgi-mock
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1741667 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 13 +++----
 .../mock/sling/context/SlingContextImpl.java       |  3 ++
 .../testing/mock/sling/junit/SlingContextTest.java | 42 +++++++++++++---------
 3 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/pom.xml b/pom.xml
index decc8fc..e6df110 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,6 +69,13 @@
 
         <dependency>
             <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.osgi</artifactId>
+            <version>2.4.0</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.models.api</artifactId>
             <version>1.2.2</version>
             <scope>compile</scope>
@@ -118,12 +125,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.osgi</artifactId>
-            <version>2.4.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.classloader</artifactId>
             <version>1.3.2</version>
             <scope>compile</scope>
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
index e22b34e..cfaad87 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
@@ -53,6 +53,7 @@ import org.apache.sling.testing.mock.sling.services.MockSlingSettingService;
 import org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo;
 import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
 import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 
 import aQute.bnd.annotation.ConsumerType;
@@ -370,6 +371,8 @@ public class SlingContextImpl extends OsgiContextImpl {
                 .put(AdapterFactory.ADAPTER_CLASSES, new String[] {
                     adapterClass.getName()
                 })
+                // make sure this overlay has higher ranking than other adapter factories
+                .put(Constants.SERVICE_RANKING, Integer.MAX_VALUE)
                 .build());
     }
 
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java b/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
index 7d61856..2a25e7c 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
@@ -80,30 +80,20 @@ public class SlingContextTest {
     }
 
     @Test
-    public void testRegisterAdapterOverlay() {
-        
-        // register "traditional" adapter factory without specific service ranking
-        AdapterFactory adapterFactory = new AdapterFactory() {
-            @SuppressWarnings("unchecked")
-            @Override
-            public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
-                return (AdapterType)(((TestAdaptable)adaptable).getMessage() + "-initial");
-            }
-        };
-        context.registerService(AdapterFactory.class, adapterFactory, ImmutableMap.<String, Object>builder()
-                .put(AdapterFactory.ADAPTABLE_CLASSES, new String[] { TestAdaptable.class.getName() })
-                .put(AdapterFactory.ADAPTER_CLASSES, new String[] { String.class.getName() })
-                .build());
-        
-        // test initial adapter factory
-        assertEquals("testMessage1-initial", new TestAdaptable("testMessage1").adaptTo(String.class));
+    public void testRegisterAdapterOverlayStatic() {
+        prepareInitialAdapterFactory();
         
         // register overlay adapter with static adaption
         context.registerAdapter(TestAdaptable.class, String.class, "static-adaption");
 
         // test overlay adapter with static adaption
         assertEquals("static-adaption", new TestAdaptable("testMessage2").adaptTo(String.class));
+    }
 
+    @Test
+    public void testRegisterAdapterOverlayDynamic() {
+        prepareInitialAdapterFactory();
+        
         // register overlay adapter with dynamic adaption
         context.registerAdapter(TestAdaptable.class, String.class, new Function<TestAdaptable, String>() {
             @Override
@@ -115,6 +105,24 @@ public class SlingContextTest {
         // test overlay adapter with dynamic adaption
         assertEquals("testMessage3-dynamic", new TestAdaptable("testMessage3").adaptTo(String.class));
     }
+    
+    private void prepareInitialAdapterFactory() {
+        // register "traditional" adapter factory without specific service ranking
+        AdapterFactory adapterFactory = new AdapterFactory() {
+            @SuppressWarnings("unchecked")
+            @Override
+            public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
+                return (AdapterType)(((TestAdaptable)adaptable).getMessage() + "-initial");
+            }
+        };
+        context.registerService(AdapterFactory.class, adapterFactory, ImmutableMap.<String, Object>builder()
+                .put(AdapterFactory.ADAPTABLE_CLASSES, new String[] { TestAdaptable.class.getName() })
+                .put(AdapterFactory.ADAPTER_CLASSES, new String[] { String.class.getName() })
+                .build());
+        
+        // test initial adapter factory
+        assertEquals("testMessage1-initial", new TestAdaptable("testMessage1").adaptTo(String.class));        
+    }
 
 
     private static class TestAdaptable extends SlingAdaptable {

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

[sling-org-apache-sling-testing-sling-mock] 04/14: SLING-5548 Remove JCR_JACKRABBIT resource resolver type

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

commit 05a8c47c7e00e04fb39ee6d0a0f94a91496e7ae9
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Feb 23 01:05:32 2016 +0000

    SLING-5548 Remove JCR_JACKRABBIT resource resolver type
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1731774 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/testing/mock/sling/ResourceResolverType.java     | 14 --------------
 .../mock/sling/context/ContextResourceResolverFactory.java |  7 -------
 .../resource/AbstractSlingCrudResourceResolverTest.java    |  2 --
 3 files changed, 23 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
index bf77a6f..4390f74 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
@@ -54,20 +54,6 @@ public enum ResourceResolverType {
     JCR_MOCK(MockJcrResourceResolverAdapter.class.getName(), null, NodeTypeMode.NAMESPACES_ONLY),
 
     /**
-     * Uses a real JCR Jackrabbit repository.
-     * <ul>
-     * <li>Uses the real Sling Resource Resolver and JCR Resource mapping
-     * implementation.</li>
-     * <li>The JCR repository is started on first access, this may take some
-     * seconds.</li>
-     * <li>Beware: The repository is not cleared for each unit test, so make
-     * sure us use a unique node path for each unit test.</li>
-     * </ul>
-     */
-    JCR_JACKRABBIT("org.apache.sling.testing.mock.sling.jackrabbit.JackrabbitMockResourceResolverAdapter",
-            "org.apache.sling:org.apache.sling.testing.sling-mock-jackrabbit", NodeTypeMode.NODETYPES_REQUIRED),
-
-    /**
      * Uses a real JCR Jackrabbit Oak repository.
      * <ul>
      * <li>Uses the real Sling Resource Resolver and JCR Resource mapping
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java b/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java
index 2448e07..65cf6d2 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java
@@ -48,9 +48,6 @@ final class ContextResourceResolverFactory {
             case JCR_MOCK:
                 initializeJcrMock(factory);
                 break;
-            case JCR_JACKRABBIT:
-                initializeJcrJackrabbit(factory);
-                break;
             case JCR_OAK:
                 initializeJcrOak(factory);
                 break;
@@ -74,10 +71,6 @@ final class ContextResourceResolverFactory {
         // nothing to do
     }
 
-    private static void initializeJcrJackrabbit(ResourceResolverFactory factory) {
-        // register sling node types?
-    }
-
     private static void initializeJcrOak(ResourceResolverFactory factory) {
         // register sling node types?
     }
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java b/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
index e9f4dbd..12d54b2 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
@@ -145,7 +145,6 @@ public abstract class AbstractSlingCrudResourceResolverTest {
         // TODO: enable this test when JCR resource implementation supports
         // writing Date objects (SLING-3846)
         if (getResourceResolverType() != ResourceResolverType.JCR_MOCK
-                && getResourceResolverType() != ResourceResolverType.JCR_JACKRABBIT 
                 && getResourceResolverType() != ResourceResolverType.JCR_OAK ) {
             assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
         }
@@ -158,7 +157,6 @@ public abstract class AbstractSlingCrudResourceResolverTest {
         // TODO: enable this test when JCR resource implementation supports
         // writing Date objects (SLING-3846)
         if (getResourceResolverType() != ResourceResolverType.JCR_MOCK
-                && getResourceResolverType() != ResourceResolverType.JCR_JACKRABBIT
                 && getResourceResolverType() != ResourceResolverType.JCR_OAK ) {
             Calendar calendarValue = props.get("dateProp", Calendar.class);
             assertNotNull(calendarValue);

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

[sling-org-apache-sling-testing-sling-mock] 13/14: [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-2.0.0

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

commit 17d3932c663358798f4549decfec1d979fde918e
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jul 12 10:29:02 2016 +0000

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

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

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