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

[sling-org-apache-sling-testing-sling-mock] annotated tag org.apache.sling.testing.sling-mock-1.9.0 created (now b1ecd64)

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


      at b1ecd64  (tag)
 tagging 6812f2c839abedee733c722e83e3e5705a59b6ba (commit)
      by Stefan Seifert
      on Mon Dec 5 17:41:54 2016 +0000

- Log -----------------------------------------------------------------
org.apache.sling.testing.sling-mock-1.9.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 7335608  1.x maintenance branch
     new 0ac29f6  update branch url
     new 780dae1  SLING-5551 MockSlingHttpServletRequest: make sure given bundleContext is used
     new 1d3a77f  SLING-5552 ModelAdapterFactoryUtil: Suppress info log messages from Reflections library
     new 16788a7  SLING-5770 add support for custom resource resolver factory activator configuration via SlingContextBuilder add support for additional callbacks before setup and after teardown
     new 9c111ba  SLING-5770 update javadoc
     new 117debd  update dependencies to released versions
     new 124d98e  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.7.0
     new a58defe  [maven-release-plugin] prepare for next development iteration
     new 0aaa86f  SLING-5968 sling-mock: Update to latest servlet-helpers
     new 10aa538  SLING-6040 add ResourceBuilder support to SlingContext This closes #167
     new ceb4f5e  SLING-6049 sling-mock ContentBuilder: Support creating resources with object vararg parameter
     new 387c8ad  SLING-6049 use MapUtil from osgi-mock
     new 1f8f4b4  update dependencies
     new dfc0de6  revert: SLING-5968 sling-mock: Update to latest servlet-helpers update creates problesm with javadoc generated - and is not really required, users can choose dependency themselves
     new f4f63ae  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.8.0
     new fea50a3  [maven-release-plugin] prepare for next development iteration
     new a59a81f  update to latest jcr-mock
     new 641e366  update dependencies to latest snapshots until released versions are available in maven central
     new a22c110  switch back to released versions
     new fc94229  SLING-6077 enhance unit test to ensure the problem from this bug ticket does not exist in sling-mock 1.x
     new 7ed1e91  update to latest resourcebuilder snapshot
     new 502088e  SLING-6358 osgi-mock: OsgiContext.getServices should return correctly typed array when empty
     new 9125ce1  SLING-6359 osgi-mock, sling-mock: Make ContextCallback and ContextBuilder more flexible
     new 6e46477  SLING-6359 context plugin support
     new 3423b62  SLING-6359 context plugin support
     new 0efe53a  SLING-6363 Automatically register Sling Models from Classpath also: - add SlingContext.addModelsForClasses method - fix bug in addModelsForPackages that registered "sibling" packages with same prefix as well - make sure classpath scanning takes place only once for alle unit tests, not for each unit test which requests the same package - witch NodeTypeDefinitionScanner to osgi-mock ManifestScanner as well
     new 37ef0fe  SLING-6363 add methods for OSGi R5/R6 support
     new 984c0de  update to release version
     new db06b23  update osgi-mock dependency
     new 328bd46  fix javadoc errors
     new 6781b1e  [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.9.0
     new 6812f2c  [maven-release-plugin] copy for tag org.apache.sling.testing.sling-mock-1.9.0

The 188 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] 16/17: [maven-release-plugin] prepare release org.apache.sling.testing.sling-mock-1.9.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-1.9.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git

commit 6781b1e7772a99bc18e6906496b5e7d45a5b0d0a
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Dec 5 17:41:41 2016 +0000

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

diff --git a/pom.xml b/pom.xml
index a7f74a4..e94df3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.sling-mock</artifactId>
-    <version>1.8.1-SNAPSHOT</version>
+    <version>1.9.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/branches/testing/mocks/sling-mock-1.x</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/branches/testing/mocks/sling-mock-1.x</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.sling-mock-1.9.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.sling-mock-1.9.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.sling-mock-1.9.0</url>
     </scm>
 
     <dependencies>

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

[sling-org-apache-sling-testing-sling-mock] 07/17: SLING-6358 osgi-mock: OsgiContext.getServices should return correctly typed array when empty

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

commit 502088e32089f402f13ae128f7ebd216d016ddee
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Dec 2 16:55:22 2016 +0000

    SLING-6358 osgi-mock: OsgiContext.getServices should return correctly typed array when empty
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772374 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 03946fd..1c8bb31 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,7 +45,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>1.8.0</version>
+            <version>1.8.1-SNAPSHOT</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] 15/17: fix javadoc errors

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

commit 328bd4615eb77e2ab86e47088bdffd71d4c96770
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Dec 5 17:41:05 2016 +0000

    fix javadoc errors
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772724 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/testing/mock/sling/context/SlingContextImpl.java | 4 ++--
 1 file changed, 2 insertions(+), 2 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 5cbb02b..361e3e4 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
@@ -358,7 +358,7 @@ public class SlingContextImpl extends OsgiContextImpl {
     /**
      * Search classpath for given java package names (and sub packages) to scan for and
      * register all classes with @Model annotation.
-     * @param packageNames Java package name
+     * @param packageName Java package name
      */
     public final void addModelsForPackage(String packageName) {
         ModelAdapterFactoryUtil.addModelsForPackages(bundleContext(),  packageName);
@@ -383,7 +383,7 @@ public class SlingContextImpl extends OsgiContextImpl {
 
     /**
      * Search classpath for given class names to scan for and register all classes with @Model annotation.
-     * @param classNames Java class names
+     * @param classes Java classes
      */
     public final void addModelsForClasses(Class... classes) {
         ModelAdapterFactoryUtil.addModelsForClasses(bundleContext(), classes);

-- 
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/17: SLING-6077 enhance unit test to ensure the problem from this bug ticket does not exist in sling-mock 1.x

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

commit fc9422952dabcf1a82ffeefb1bb8f674c782d59d
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 29 15:27:09 2016 +0000

    SLING-6077 enhance unit test to ensure the problem from this bug ticket does not exist in sling-mock 1.x
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1762796 13f79535-47bb-0310-9956-ffa450edef68
---
 .../testing/mock/sling/context/AbstractSlingContextImplTest.java      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java b/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
index b32dc1d..a921e10 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
@@ -143,8 +143,8 @@ public abstract class AbstractSlingContextImplTest {
     
     @Test
     public void testResourceResolverFactory() {
-        ResourceResolverFactory factory = context.getService(ResourceResolverFactory.class);
-        assertNotNull(factory);
+        ResourceResolverFactory[] factories = context.getServices(ResourceResolverFactory.class, null);
+        assertEquals(1, factories.length);
     }
 
     @Model(adaptables = SlingHttpServletRequest.class)

-- 
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/17: SLING-6359 context plugin support

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

commit 6e46477439d0e78689910cf2a23e44c40a78a43f
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Dec 3 13:14:34 2016 +0000

    SLING-6359 context plugin support
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772466 13f79535-47bb-0310-9956-ffa450edef68
---
 .../context/ContextResourceResolverFactory.java    |   3 +
 .../sling/context/ModelAdapterFactoryUtil.java     |   3 +
 .../testing/mock/sling/context/UniqueRoot.java     |   3 +
 .../testing/mock/sling/junit/CallbackParams.java   |  43 ---------
 .../testing/mock/sling/junit/SlingContext.java     | 105 ++++++---------------
 .../mock/sling/junit/SlingContextBuilder.java      |  75 ++++++++-------
 .../mock/sling/junit/SlingContextCallback.java     |   7 +-
 .../testing/mock/sling/junit/SlingContextTest.java |   1 +
 8 files changed, 84 insertions(+), 156 deletions(-)

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..64dcff8 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
@@ -26,9 +26,12 @@ import org.apache.sling.testing.mock.sling.MockSling;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.osgi.framework.BundleContext;
 
+import aQute.bnd.annotation.ProviderType;
+
 /**
  * Create resolve resolver instance and initialize it depending on it's type.
  */
+@ProviderType
 final class ContextResourceResolverFactory {
 
     private ContextResourceResolverFactory() {
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 3cc6327..52568d3 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
@@ -39,9 +39,12 @@ import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.reflections.Reflections;
 
+import aQute.bnd.annotation.ProviderType;
+
 /**
  * Helper methos for simulating sling models bundle events.
  */
+@ProviderType
 final class ModelAdapterFactoryUtil {
     
     static {
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java b/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
index 39bc2cc..cc00d75 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
@@ -31,12 +31,15 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableMap;
 
+import aQute.bnd.annotation.ConsumerType;
+
 /**
  * Manages unique root paths in JCR repository.
  * This is important for resource resolver types like JCR_JACKRABBIT  
  * where the repository is not cleaned for each test run. This class provides
  * unique root paths for each run, and cleans them up when done.
  */
+@ConsumerType
 public class UniqueRoot {
     
     private final SlingContextImpl context;
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/CallbackParams.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/CallbackParams.java
deleted file mode 100644
index 680ce04..0000000
--- a/src/main/java/org/apache/sling/testing/mock/sling/junit/CallbackParams.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sling.testing.mock.sling.junit;
-
-import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
-
-final class CallbackParams {
-
-    ContextCallback[] beforeSetUpCallback;
-    ContextCallback[] afterSetUpCallback;
-    ContextCallback[] beforeTearDownCallback;
-    ContextCallback[] afterTearDownCallback;
-    
-    CallbackParams() {
-        // no callbacks
-    }
-    
-    CallbackParams(ContextCallback afterSetUpCallback) {
-        this.afterSetUpCallback = new ContextCallback[] { afterSetUpCallback }; 
-    }
-    
-    CallbackParams(ContextCallback afterSetUpCallback, ContextCallback beforeTearDownCallback) {
-        this.afterSetUpCallback = new ContextCallback[] { afterSetUpCallback }; 
-        this.beforeTearDownCallback = new ContextCallback[] { beforeTearDownCallback }; 
-    }
-    
-}
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 9201f79..52aa2ff 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
@@ -20,7 +20,9 @@ package org.apache.sling.testing.mock.sling.junit;
 
 import java.util.Map;
 
-import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
+import org.apache.sling.testing.mock.osgi.context.ContextCallback;
+import org.apache.sling.testing.mock.osgi.context.ContextPlugins;
+import org.apache.sling.testing.mock.osgi.context.OsgiContextImpl;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
 import org.junit.rules.ExternalResource;
@@ -28,14 +30,17 @@ import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 
+import aQute.bnd.annotation.ProviderType;
+
 /**
  * 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.
  */
+@ProviderType
 public final class SlingContext extends SlingContextImpl implements TestRule {
 
-    private final CallbackParams callbackParams;
+    private final ContextPlugins plugins;
     private final TestRule delegate;
 
     /**
@@ -43,7 +48,7 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      * {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
      */
     public SlingContext() {
-        this(new CallbackParams(), null, null);
+        this(new ContextPlugins(), null, null);
     }
 
     /**
@@ -51,59 +56,65 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      * @param resourceResolverType Resource resolver type.
      */
     public SlingContext(final ResourceResolverType resourceResolverType) {
-        this(new CallbackParams(), null, resourceResolverType);
+        this(new ContextPlugins(), null, resourceResolverType);
     }
 
     /**
      * Initialize Sling context with default resource resolver type:
      * {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
+     * @param <T> context type
      * @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 afterSetUpCallback) {
-        this(new CallbackParams(afterSetUpCallback), null, null);
+    public <T extends OsgiContextImpl> SlingContext(final ContextCallback<T> afterSetUpCallback) {
+        this(new ContextPlugins(afterSetUpCallback), null, null);
     }
 
     /**
      * Initialize Sling context with resource resolver type.
+     * @param <T> context type
      * @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 afterSetUpCallback, final ResourceResolverType resourceResolverType) {
-        this(new CallbackParams(afterSetUpCallback), null, resourceResolverType);
+    public <T extends OsgiContextImpl> SlingContext(final ContextCallback<T> afterSetUpCallback, final ResourceResolverType resourceResolverType) {
+        this(new ContextPlugins(afterSetUpCallback), null, resourceResolverType);
     }
 
     /**
      * Initialize Sling context with default resource resolver type:
      * {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
+     * @param <U> context type
+     * @param <V> context 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.
      */
-    public SlingContext(final SlingContextCallback afterSetUpCallback, final SlingContextCallback beforeTearDownCallback) {
-        this(new CallbackParams(afterSetUpCallback, beforeTearDownCallback), null, null);
+    public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(final ContextCallback<U> afterSetUpCallback, final ContextCallback<V> beforeTearDownCallback) {
+        this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, null);
     }
     
     /**
      * Initialize Sling context with resource resolver type.
+     * @param <U> context type
+     * @param <V> context 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 afterSetUpCallback, final SlingContextCallback beforeTearDownCallback,
+    public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(final ContextCallback<U> afterSetUpCallback, final ContextCallback<V> beforeTearDownCallback,
             final ResourceResolverType resourceResolverType) {
-        this(new CallbackParams(afterSetUpCallback, beforeTearDownCallback), null, resourceResolverType);
+        this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, resourceResolverType);
     }
     
     /**
      * Initialize Sling context with resource resolver type.
-     * @param callbackParams Callback parameters
+     * @param contextPlugins Context plugins
      * @param resourceResolverFactoryActivatorProps Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
      * @param resourceResolverType Resource resolver type.
      */
-    SlingContext(final CallbackParams callbackParams,
+    SlingContext(final ContextPlugins contextPlugins,
             final Map<String, Object> resourceResolverFactoryActivatorProps,
             final ResourceResolverType resourceResolverType) {
 
-        this.callbackParams = callbackParams;
+        this.plugins = contextPlugins;
         setResourceResolverFactoryActivatorProps(resourceResolverFactoryActivatorProps);
 
         // set resource resolver type in parent context
@@ -113,16 +124,16 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
         this.delegate = new ExternalResource() {
             @Override
             protected void before() {
-                SlingContext.this.executeBeforeSetUpCallback();
+                plugins.executeBeforeSetUpCallback(SlingContext.this);
                 SlingContext.this.setUp();
-                SlingContext.this.executeAfterSetUpCallback();
+                plugins.executeAfterSetUpCallback(SlingContext.this);
             }
 
             @Override
             protected void after() {
-                SlingContext.this.executeBeforeTearDownCallback();
+                plugins.executeBeforeTearDownCallback(SlingContext.this);
                 SlingContext.this.tearDown();
-                SlingContext.this.executeAfterTearDownCallback();
+                plugins.executeAfterTearDownCallback(SlingContext.this);
             }
         };
     }
@@ -132,60 +143,4 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
         return this.delegate.apply(base, description);
     }
 
-    @SuppressWarnings("unchecked")
-    private void executeBeforeSetUpCallback() {
-      if (callbackParams.beforeSetUpCallback != null) {
-        try {
-          for (ContextCallback callback : callbackParams.beforeSetUpCallback) {
-            callback.execute(this);
-          }
-        }
-        catch (Throwable ex) {
-          throw new RuntimeException("Before setup failed: " + ex.getMessage(), ex);
-        }
-      }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void executeAfterSetUpCallback() {
-      if (callbackParams.afterSetUpCallback != null) {
-        try {
-          for (ContextCallback callback : callbackParams.afterSetUpCallback) {
-            callback.execute(this);
-          }
-        }
-        catch (Throwable ex) {
-          throw new RuntimeException("After setup failed: " + ex.getMessage(), ex);
-        }
-      }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void executeBeforeTearDownCallback() {
-      if (callbackParams.beforeTearDownCallback != null) {
-        try {
-          for (ContextCallback callback : callbackParams.beforeTearDownCallback) {
-            callback.execute(this);
-          }
-        }
-        catch (Throwable ex) {
-          throw new RuntimeException("Before teardown failed: " + ex.getMessage(), ex);
-        }
-      }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void executeAfterTearDownCallback() {
-      if (callbackParams.afterTearDownCallback != null) {
-        try {
-          for (ContextCallback callback : callbackParams.afterTearDownCallback) {
-            callback.execute(this);
-          }
-        }
-        catch (Throwable 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
index 3fd870f..37780dd 100644
--- 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
@@ -20,15 +20,21 @@ package org.apache.sling.testing.mock.sling.junit;
 
 import java.util.Map;
 
-import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
+import org.apache.sling.testing.mock.osgi.context.ContextCallback;
+import org.apache.sling.testing.mock.osgi.context.ContextPlugin;
+import org.apache.sling.testing.mock.osgi.context.ContextPlugins;
+import org.apache.sling.testing.mock.osgi.context.OsgiContextImpl;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 
+import aQute.bnd.annotation.ProviderType;
+
 /**
  * Builder class for creating {@link SlingContext} instances with different sets of parameters.
  */
+@ProviderType
 public final class SlingContextBuilder {
     
-    private final CallbackParams callbackParams = new CallbackParams();
+    private final ContextPlugins plugins = new ContextPlugins();
     private ResourceResolverType resourceResolverType;
     private Map<String, Object> resourceResolverFactoryActivatorProps;
     
@@ -55,61 +61,58 @@ public final class SlingContextBuilder {
     }
     
     /**
-     * @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 setUp(ContextCallback... afterSetUpCallback) {
-      return afterSetUp(afterSetUpCallback);
-    }
-
-    /**
-     * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the
-     *          built-in setup rules are executed.
+     * @param <T> context type
+     * @param plugin Context plugin which listens to context lifecycle events.
      * @return this
      */
-    public SlingContextBuilder beforeSetUp(ContextCallback... beforeSetUpCallback) {
-      callbackParams.beforeSetUpCallback = beforeSetUpCallback;
-      return this;
+    @SafeVarargs
+    public final <T extends OsgiContextImpl> SlingContextBuilder plugin(ContextPlugin<T>... plugin) {
+        plugins.addPlugin(plugin);
+        return this;
     }
 
     /**
-     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the
-     *          built-in setup rules are executed.
+     * @param <T> context type
+     * @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 afterSetUp(ContextCallback... afterSetUpCallback) {
-      callbackParams.afterSetUpCallback = afterSetUpCallback;
-      return this;
+    @SafeVarargs
+    public final <T extends OsgiContextImpl> SlingContextBuilder beforeSetUp(ContextCallback<T>... beforeSetUpCallback) {
+        plugins.addBeforeSetUpCallback(beforeSetUpCallback);
+        return this;
     }
 
     /**
-     * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the
-     *          built-in teardown rules are executed.
+     * @param <T> context type
+     * @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 tearDown(ContextCallback... beforeTearDownCallback) {
-      return beforeTearDown(beforeTearDownCallback);
+    @SafeVarargs
+    public final <T extends OsgiContextImpl> SlingContextBuilder afterSetUp(ContextCallback<T>... afterSetUpCallback) {
+        plugins.addAfterSetUpCallback(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.
+     * @param <T> context type
+     * @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(ContextCallback... beforeTearDownCallback) {
-      callbackParams.beforeTearDownCallback = beforeTearDownCallback;
-      return this;
+    @SafeVarargs
+    public final <T extends OsgiContextImpl> SlingContextBuilder beforeTearDown(ContextCallback<T>... beforeTearDownCallback) {
+        plugins.addBeforeTearDownCallback(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.
+     * @param <T> context type
+     * @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(ContextCallback... afterTearDownCallback) {
-      callbackParams.afterTearDownCallback = afterTearDownCallback;
-      return this;
+    @SafeVarargs
+    public final <T extends OsgiContextImpl> SlingContextBuilder afterTearDown(ContextCallback<T>... afterTearDownCallback) {
+        plugins.addAfterTearDownCallback(afterTearDownCallback);
+        return this;
     }
 
     /**
@@ -126,7 +129,7 @@ public final class SlingContextBuilder {
      * @return Build {@link SlingContext} instance.
      */
     public SlingContext build() {
-        return new SlingContext(this.callbackParams,
+        return new SlingContext(this.plugins,
                 this.resourceResolverFactoryActivatorProps,
                 this.resourceResolverType);
     }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
index 4efdf44..d4fc9c4 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
@@ -18,12 +18,15 @@
  */
 package org.apache.sling.testing.mock.sling.junit;
 
-import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
+import org.apache.sling.testing.mock.osgi.context.ContextCallback;
+
+import aQute.bnd.annotation.ConsumerType;
 
 /**
- * Callback-interface for application-specific setup and teardown operations to
+ * Callback interface for application-specific setup and teardown operations to
  * customize the {@link SlingContext} JUnit rule.
  */
+@ConsumerType
 public interface SlingContextCallback extends ContextCallback<SlingContext> {
 
     // specialized version of ContextCallback
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 d186c92..ead89a6 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
@@ -46,6 +46,7 @@ public class SlingContextTest {
     private final SlingContextCallback contextAfterTeardown = mock(SlingContextCallback.class);
 
     // Run all unit tests for each resource resolver types listed here
+    @SuppressWarnings("unchecked")
     @Rule
     public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK)
         .beforeSetUp(contextBeforeSetup)

-- 
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] 17/17: [maven-release-plugin] copy for tag org.apache.sling.testing.sling-mock-1.9.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-1.9.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git

commit 6812f2c839abedee733c722e83e3e5705a59b6ba
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Dec 5 17:41:54 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.testing.sling-mock-1.9.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.sling-mock-1.9.0@1772726 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] 01/17: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fea50a3e34b9f454436becafe1b5a8803ccd26be
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 22:01:39 2016 +0000

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

diff --git a/pom.xml b/pom.xml
index 9a303df..d76dfcd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.sling-mock</artifactId>
-    <version>1.8.0</version>
+    <version>1.8.1-SNAPSHOT</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/tags/org.apache.sling.testing.sling-mock-1.8.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.sling-mock-1.8.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.sling-mock-1.8.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/branches/testing/mocks/sling-mock-1.x</url>
     </scm>
 
     <dependencies>

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

[sling-org-apache-sling-testing-sling-mock] 10/17: SLING-6359 context plugin support

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

commit 3423b62c621499d4c896d6a9b38c5d81215a7749
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Dec 3 13:19:15 2016 +0000

    SLING-6359 context plugin support
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772468 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/testing/mock/sling/context/package-info.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 804ad90..e7f08ad 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.3")
+@aQute.bnd.annotation.Version("3.4")
 package org.apache.sling.testing.mock.sling.context;

-- 
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/17: SLING-6359 osgi-mock, sling-mock: Make ContextCallback and ContextBuilder more flexible

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

commit 9125ce1e9885d68fc7c3a0d1ff1a3d1e951fa72b
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Dec 3 10:01:00 2016 +0000

    SLING-6359 osgi-mock, sling-mock: Make ContextCallback and ContextBuilder more flexible
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772443 13f79535-47bb-0310-9956-ffa450edef68
---
 ...ingContextCallback.java => CallbackParams.java} | 36 ++++----
 .../testing/mock/sling/junit/SlingContext.java     | 95 ++++++++++++----------
 .../mock/sling/junit/SlingContextBuilder.java      | 63 +++++++++-----
 .../mock/sling/junit/SlingContextCallback.java     | 14 +---
 .../testing/mock/sling/junit/package-info.java     |  2 +-
 .../testing/mock/sling/junit/SlingContextTest.java |  5 +-
 6 files changed, 117 insertions(+), 98 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/CallbackParams.java
similarity index 53%
copy from src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
copy to src/main/java/org/apache/sling/testing/mock/sling/junit/CallbackParams.java
index 247185b..680ce04 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/junit/CallbackParams.java
@@ -18,22 +18,26 @@
  */
 package org.apache.sling.testing.mock.sling.junit;
 
-import java.io.IOException;
+import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
 
-import org.apache.sling.api.resource.PersistenceException;
-
-/**
- * Callback-interface for application-specific setup and teardown operations to
- * customize the {@link SlingContext} JUnit rule.
- */
-public interface SlingContextCallback {
-
-    /**
-     * Execute callback action
-     * @param context Sling context
-     * @throws IOException I/O exception
-     * @throws PersistenceException Persistence exception
-     */
-    void execute(SlingContext context) throws IOException, PersistenceException;
+final class CallbackParams {
 
+    ContextCallback[] beforeSetUpCallback;
+    ContextCallback[] afterSetUpCallback;
+    ContextCallback[] beforeTearDownCallback;
+    ContextCallback[] afterTearDownCallback;
+    
+    CallbackParams() {
+        // no callbacks
+    }
+    
+    CallbackParams(ContextCallback afterSetUpCallback) {
+        this.afterSetUpCallback = new ContextCallback[] { afterSetUpCallback }; 
+    }
+    
+    CallbackParams(ContextCallback afterSetUpCallback, ContextCallback beforeTearDownCallback) {
+        this.afterSetUpCallback = new ContextCallback[] { afterSetUpCallback }; 
+        this.beforeTearDownCallback = new ContextCallback[] { beforeTearDownCallback }; 
+    }
+    
 }
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 9dcd712..9201f79 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
@@ -20,6 +20,7 @@ package org.apache.sling.testing.mock.sling.junit;
 
 import java.util.Map;
 
+import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
 import org.junit.rules.ExternalResource;
@@ -34,10 +35,7 @@ import org.junit.runners.model.Statement;
  */
 public final class SlingContext extends SlingContextImpl implements TestRule {
 
-    private final SlingContextCallback beforeSetUpCallback;
-    private final SlingContextCallback afterSetUpCallback;
-    private final SlingContextCallback beforeTearDownCallback;
-    private final SlingContextCallback afterTearDownCallback;
+    private final CallbackParams callbackParams;
     private final TestRule delegate;
 
     /**
@@ -45,7 +43,7 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      * {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
      */
     public SlingContext() {
-        this(null, null, null);
+        this(new CallbackParams(), null, null);
     }
 
     /**
@@ -53,7 +51,7 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      * @param resourceResolverType Resource resolver type.
      */
     public SlingContext(final ResourceResolverType resourceResolverType) {
-        this(null, null, resourceResolverType);
+        this(new CallbackParams(), null, resourceResolverType);
     }
 
     /**
@@ -62,7 +60,7 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      * @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 afterSetUpCallback) {
-        this(afterSetUpCallback, null, null);
+        this(new CallbackParams(afterSetUpCallback), null, null);
     }
 
     /**
@@ -71,7 +69,7 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      * @param resourceResolverType Resource resolver type.
      */
     public SlingContext(final SlingContextCallback afterSetUpCallback, final ResourceResolverType resourceResolverType) {
-        this(afterSetUpCallback, null, resourceResolverType);
+        this(new CallbackParams(afterSetUpCallback), null, resourceResolverType);
     }
 
     /**
@@ -81,7 +79,7 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      * @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);
+        this(new CallbackParams(afterSetUpCallback, beforeTearDownCallback), null, null);
     }
     
     /**
@@ -92,27 +90,20 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
      */
     public SlingContext(final SlingContextCallback afterSetUpCallback, final SlingContextCallback beforeTearDownCallback,
             final ResourceResolverType resourceResolverType) {
-        this(null, afterSetUpCallback, beforeTearDownCallback, null, null, resourceResolverType);
+        this(new CallbackParams(afterSetUpCallback, beforeTearDownCallback), null, resourceResolverType);
     }
     
     /**
      * Initialize Sling context with resource resolver type.
-     * @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 callbackParams Callback parameters
      * @param resourceResolverFactoryActivatorProps Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
      * @param resourceResolverType Resource resolver type.
      */
-    SlingContext(final SlingContextCallback beforeSetUpCallback, final SlingContextCallback afterSetUpCallback,
-            final SlingContextCallback beforeTearDownCallback, final SlingContextCallback afterTearDownCallback,
+    SlingContext(final CallbackParams callbackParams,
             final Map<String, Object> resourceResolverFactoryActivatorProps,
             final ResourceResolverType resourceResolverType) {
 
-        this.beforeSetUpCallback = beforeSetUpCallback;
-        this.afterSetUpCallback = afterSetUpCallback;
-        this.beforeTearDownCallback = beforeTearDownCallback;
-        this.afterTearDownCallback = afterTearDownCallback;
+        this.callbackParams = callbackParams;
         setResourceResolverFactoryActivatorProps(resourceResolverFactoryActivatorProps);
 
         // set resource resolver type in parent context
@@ -141,44 +132,60 @@ public final class SlingContext extends SlingContextImpl implements TestRule {
         return this.delegate.apply(base, description);
     }
 
+    @SuppressWarnings("unchecked")
     private void executeBeforeSetUpCallback() {
-        if (this.beforeSetUpCallback != null) {
-            try {
-                this.beforeSetUpCallback.execute(this);
-            } catch (Throwable ex) {
-                throw new RuntimeException("Before setup failed: " + ex.getMessage(), ex);
-            }
+      if (callbackParams.beforeSetUpCallback != null) {
+        try {
+          for (ContextCallback callback : callbackParams.beforeSetUpCallback) {
+            callback.execute(this);
+          }
         }
+        catch (Throwable ex) {
+          throw new RuntimeException("Before setup failed: " + ex.getMessage(), ex);
+        }
+      }
     }
 
+    @SuppressWarnings("unchecked")
     private void executeAfterSetUpCallback() {
-        if (this.afterSetUpCallback != null) {
-            try {
-                this.afterSetUpCallback.execute(this);
-            } catch (Throwable ex) {
-                throw new RuntimeException("After setup failed: " + ex.getMessage(), ex);
-            }
+      if (callbackParams.afterSetUpCallback != null) {
+        try {
+          for (ContextCallback callback : callbackParams.afterSetUpCallback) {
+            callback.execute(this);
+          }
         }
+        catch (Throwable ex) {
+          throw new RuntimeException("After setup failed: " + ex.getMessage(), ex);
+        }
+      }
     }
 
+    @SuppressWarnings("unchecked")
     private void executeBeforeTearDownCallback() {
-        if (this.beforeTearDownCallback != null) {
-            try {
-                this.beforeTearDownCallback.execute(this);
-            } catch (Throwable ex) {
-                throw new RuntimeException("Before teardown failed: " + ex.getMessage(), ex);
-            }
+      if (callbackParams.beforeTearDownCallback != null) {
+        try {
+          for (ContextCallback callback : callbackParams.beforeTearDownCallback) {
+            callback.execute(this);
+          }
+        }
+        catch (Throwable ex) {
+          throw new RuntimeException("Before teardown failed: " + ex.getMessage(), ex);
         }
+      }
     }
 
+    @SuppressWarnings("unchecked")
     private void executeAfterTearDownCallback() {
-        if (this.afterTearDownCallback != null) {
-            try {
-                this.afterTearDownCallback.execute(this);
-            } catch (Throwable ex) {
-                throw new RuntimeException("After teardown failed: " + ex.getMessage(), ex);
-            }
+      if (callbackParams.afterTearDownCallback != null) {
+        try {
+          for (ContextCallback callback : callbackParams.afterTearDownCallback) {
+            callback.execute(this);
+          }
+        }
+        catch (Throwable 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
index 62080fa..3fd870f 100644
--- 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
@@ -20,6 +20,7 @@ package org.apache.sling.testing.mock.sling.junit;
 
 import java.util.Map;
 
+import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 
 /**
@@ -27,11 +28,8 @@ import org.apache.sling.testing.mock.sling.ResourceResolverType;
  */
 public final class SlingContextBuilder {
     
+    private final CallbackParams callbackParams = new CallbackParams();
     private ResourceResolverType resourceResolverType;
-    private SlingContextCallback beforeSetUpCallback;
-    private SlingContextCallback afterSetUpCallback;
-    private SlingContextCallback beforeTearDownCallback;
-    private SlingContextCallback afterTearDownCallback;
     private Map<String, Object> resourceResolverFactoryActivatorProps;
     
     /**
@@ -57,39 +55,61 @@ public final class SlingContextBuilder {
     }
     
     /**
-     * @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.
      * @return this
      */
-    public SlingContextBuilder beforeSetUp(SlingContextCallback beforeSetUpCallback) {
-        this.beforeSetUpCallback = beforeSetUpCallback;
-        return this;
+    public SlingContextBuilder setUp(ContextCallback... afterSetUpCallback) {
+      return afterSetUp(afterSetUpCallback);
     }
 
     /**
-     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup 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.
      * @return this
      */
-    public SlingContextBuilder afterSetUp(SlingContextCallback afterSetUpCallback) {
-        this.afterSetUpCallback = afterSetUpCallback;
-        return this;
+    public SlingContextBuilder beforeSetUp(ContextCallback... beforeSetUpCallback) {
+      callbackParams.beforeSetUpCallback = beforeSetUpCallback;
+      return this;
     }
 
     /**
-     * @param beforeTearDownCallback 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.
      * @return this
      */
-    public SlingContextBuilder beforeTearDown(SlingContextCallback beforeTearDownCallback) {
-        this.beforeTearDownCallback = beforeTearDownCallback;
-        return this;
+    public SlingContextBuilder afterSetUp(ContextCallback... afterSetUpCallback) {
+      callbackParams.afterSetUpCallback = afterSetUpCallback;
+      return this;
     }
 
     /**
-     * @param afterTearDownCallback Allows the application to register an own callback function that is after before the built-in teardown 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.
      * @return this
      */
-    public SlingContextBuilder afterTearDown(SlingContextCallback afterTearDownCallback) {
-        this.afterTearDownCallback = afterTearDownCallback;
-        return this;
+    public SlingContextBuilder tearDown(ContextCallback... beforeTearDownCallback) {
+      return beforeTearDown(beforeTearDownCallback);
+    }
+
+    /**
+     * @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(ContextCallback... beforeTearDownCallback) {
+      callbackParams.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(ContextCallback... afterTearDownCallback) {
+      callbackParams.afterTearDownCallback = afterTearDownCallback;
+      return this;
     }
 
     /**
@@ -106,8 +126,7 @@ public final class SlingContextBuilder {
      * @return Build {@link SlingContext} instance.
      */
     public SlingContext build() {
-        return new SlingContext(this.beforeSetUpCallback, this.afterSetUpCallback,
-                this.beforeTearDownCallback, this.afterTearDownCallback,
+        return new SlingContext(this.callbackParams,
                 this.resourceResolverFactoryActivatorProps,
                 this.resourceResolverType);
     }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
index 247185b..4efdf44 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextCallback.java
@@ -18,22 +18,14 @@
  */
 package org.apache.sling.testing.mock.sling.junit;
 
-import java.io.IOException;
-
-import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.testing.mock.osgi.junit.ContextCallback;
 
 /**
  * Callback-interface for application-specific setup and teardown operations to
  * customize the {@link SlingContext} JUnit rule.
  */
-public interface SlingContextCallback {
+public interface SlingContextCallback extends ContextCallback<SlingContext> {
 
-    /**
-     * Execute callback action
-     * @param context Sling context
-     * @throws IOException I/O exception
-     * @throws PersistenceException Persistence exception
-     */
-    void execute(SlingContext context) throws IOException, PersistenceException;
+    // specialized version of ContextCallback
 
 }
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 72cb53a..f8109b3 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.3")
+@aQute.bnd.annotation.Version("4.0")
 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 d99ed80..d186c92 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
@@ -24,9 +24,6 @@ import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
-import java.io.IOException;
-
-import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceUtil;
@@ -63,7 +60,7 @@ public class SlingContextTest {
         .build();
 
     @Before
-    public void setUp() throws IOException, PersistenceException {
+    public void setUp() throws Exception {
         verify(contextBeforeSetup).execute(context);
         verify(contextAfterSetup).execute(context);
     }

-- 
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/17: update to latest resourcebuilder snapshot

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

commit 7ed1e91209ae835a85b30abb5620ea6cb61f9e29
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Oct 11 17:00:49 2016 +0000

    update to latest resourcebuilder snapshot
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1764305 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index c2ec922..03946fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,7 +143,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourcebuilder</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
 

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

[sling-org-apache-sling-testing-sling-mock] 04/17: switch back 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-1.9.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git

commit a22c110b57686e6655e7c81b670ee57b6f00e3c9
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 19 09:26:36 2016 +0000

    switch back to released versions
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1761405 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 3d5ff1d..c2ec922 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,13 +45,13 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>1.8.1-SNAPSHOT</version>
+            <version>1.8.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
-            <version>1.1.17-SNAPSHOT</version>
+            <version>1.1.16</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
@@ -143,7 +143,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourcebuilder</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.0.0</version>
             <scope>compile</scope>
         </dependency>
 

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

[sling-org-apache-sling-testing-sling-mock] 02/17: update to latest jcr-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-1.9.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git

commit a59a81f22932ad3ff99a1f6993548b13ef61ee3c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 22:03:39 2016 +0000

    update to latest jcr-mock
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1760810 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index d76dfcd..c2ec922 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
-            <version>1.1.14</version>
+            <version>1.1.16</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] 13/17: update to release version

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

commit 984c0de58b1debe5e0cf3ac3c46d86c69fdb58a9
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Dec 5 17:35:09 2016 +0000

    update to release version
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772719 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 1c8bb31..6d2007a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,7 +143,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourcebuilder</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.0.2</version>
             <scope>compile</scope>
         </dependency>
 

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

[sling-org-apache-sling-testing-sling-mock] 03/17: update dependencies to latest snapshots until released versions are available in maven central

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

commit 641e3664db2d6110315ce2a3ef9041d1411e79ef
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 14 22:15:54 2016 +0000

    update dependencies to latest snapshots until released versions are available in maven central
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1760812 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index c2ec922..3d5ff1d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,13 +45,13 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>1.8.0</version>
+            <version>1.8.1-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
-            <version>1.1.16</version>
+            <version>1.1.17-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
@@ -143,7 +143,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourcebuilder</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
 

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

[sling-org-apache-sling-testing-sling-mock] 12/17: SLING-6363 add methods for OSGi R5/R6 support

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

commit 37ef0fe8fce462a7641339766b4e70426f208ba8
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sun Dec 4 10:40:07 2016 +0000

    SLING-6363 add methods for OSGi R5/R6 support
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772519 13f79535-47bb-0310-9956-ffa450edef68
---
 .../mock/sling/context/ModelAdapterFactoryUtil.java    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

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 8ef50d0..5bfcaa8 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,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.sling.context;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -218,7 +219,7 @@ final class ModelAdapterFactoryUtil {
 
         @Override
         public Dictionary getHeaders() {
-            Dictionary<String, Object> headers = new Hashtable<String, Object>();
+            Dictionary<String, String> headers = new Hashtable<String, String>();
             headers.put(PACKAGE_HEADER, MAGIC_STRING);
             return headers;
         }
@@ -350,6 +351,21 @@ final class ModelAdapterFactoryUtil {
             return null;
         }
 
+        // this is part of osgi 5/6
+        public int compareTo(Bundle o) {
+            return 0;
+        }
+
+        // this is part of osgi 5/6
+        public <A> A adapt(Class<A> type) {
+            return null;
+        }
+
+        // this is part of osgi 5/6
+        public File getDataFile(String filename) {
+            return null;
+        }
+
     }
 
 }

-- 
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/17: SLING-6363 Automatically register Sling Models from Classpath also: - add SlingContext.addModelsForClasses method - fix bug in addModelsForPackages that registered "sibling" packages with same prefix as well - make sure classpath scanning takes place only once for alle unit tests, not for each unit test which requests the same package - witch NodeTypeDefinitionScanner to osgi-mock ManifestScanner as well

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

commit 0efe53a2db9507521d6452f7b48a2366052826e3
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sun Dec 4 10:27:03 2016 +0000

    SLING-6363 Automatically register Sling Models from Classpath
    also:
    - add SlingContext.addModelsForClasses method
    - fix bug in addModelsForPackages that registered "sibling" packages with same prefix as well
    - make sure classpath scanning takes place only once for alle unit tests, not for each unit test which requests the same package
    - witch NodeTypeDefinitionScanner to osgi-mock ManifestScanner as well
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772517 13f79535-47bb-0310-9956-ffa450edef68
---
 .../mock/sling/NodeTypeDefinitionScanner.java      |  44 +-----
 .../context/ContextResourceResolverFactory.java    |   3 -
 .../sling/context/ModelAdapterFactoryUtil.java     | 175 ++++++++++++++++++---
 .../mock/sling/context/SlingContextImpl.java       |  34 +++-
 ...va => AbstractModelAdapterFactoryUtilTest.java} |  62 ++------
 .../context/AbstractSlingContextImplTest.java      |  39 +----
 .../ModelAdapterFactoryUtilClassesTest.java        |  52 ++++++
 .../ModelAdapterFactoryUtilPackagesTest.java       |  44 ++++++
 .../sling/context/models/OsgiServiceModel.java     |  36 +++++
 .../context/models/RequestAttributeModel.java      |  35 +++++
 .../sling/context/models/ServiceInterface.java     |  28 ++++
 .../sling/context/models/ServiceInterfaceImpl.java |  40 +++++
 12 files changed, 436 insertions(+), 156 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java b/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java
index fed6cd7..55287e9 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java
@@ -18,18 +18,12 @@
  */
 package org.apache.sling.testing.mock.sling;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
-import java.net.URL;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
@@ -48,11 +42,11 @@ import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory;
 import org.apache.jackrabbit.commons.cnd.TemplateBuilderFactory;
+import org.apache.sling.testing.mock.osgi.ManifestScanner;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -231,41 +225,7 @@ public final class NodeTypeDefinitionScanner {
      * @return List of node type definition class paths
      */
     private static List<String> findeNodeTypeDefinitions() {
-        List<String> nodeTypeDefinitions = new ArrayList<String>();
-        try {
-            Enumeration<URL> resEnum = NodeTypeDefinitionScanner.class.getClassLoader().getResources(JarFile.MANIFEST_NAME);
-            while (resEnum.hasMoreElements()) {
-                try {
-                    URL url = (URL)resEnum.nextElement();
-                    InputStream is = url.openStream();
-                    if (is != null) {
-                        try {
-                            Manifest manifest = new Manifest(is);
-                            Attributes mainAttribs = manifest.getMainAttributes();
-                            String nodeTypeDefinitionList = mainAttribs.getValue("Sling-Nodetypes");
-                            String[] nodeTypeDefinitionArray = StringUtils.split(nodeTypeDefinitionList, ",");
-                            if (nodeTypeDefinitionArray != null) {
-                                for (String nodeTypeDefinition : nodeTypeDefinitionArray) {
-                                    if (!StringUtils.isBlank(nodeTypeDefinition)) {
-                                        nodeTypeDefinitions.add(StringUtils.trim(nodeTypeDefinition));
-                                    }
-                                }
-                            }
-                        }
-                        finally {
-                            is.close();
-                        }
-                    }
-                }
-                catch (Throwable ex) {
-                    log.warn("Unable to read JAR manifest.", ex);
-                }
-            }
-        }
-        catch (IOException ex2) {
-            log.warn("Unable to read JAR manifests.", ex2);
-        }
-        return nodeTypeDefinitions; 
+        return new ArrayList<String>(ManifestScanner.getValues("Sling-Nodetypes"));
     }
     
     public static NodeTypeDefinitionScanner get() {
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 64dcff8..2448e07 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
@@ -26,12 +26,9 @@ import org.apache.sling.testing.mock.sling.MockSling;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.osgi.framework.BundleContext;
 
-import aQute.bnd.annotation.ProviderType;
-
 /**
  * Create resolve resolver instance and initialize it depending on it's type.
  */
-@ProviderType
 final class ContextResourceResolverFactory {
 
     private ContextResourceResolverFactory() {
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 52568d3..8ef50d0 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
@@ -22,14 +22,21 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
 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;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.models.annotations.Model;
+import org.apache.sling.testing.mock.osgi.ManifestScanner;
 import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -39,44 +46,169 @@ import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.reflections.Reflections;
 
-import aQute.bnd.annotation.ProviderType;
-
 /**
  * Helper methos for simulating sling models bundle events.
  */
-@ProviderType
 final class ModelAdapterFactoryUtil {
     
+    private static final String PACKAGE_HEADER = "Sling-Model-Packages";
+    private static final String CLASSES_HEADER = "Sling-Model-Classes";
+    
+    private static final String[] MODELS_PACKAGES_FROM_MANIFEST;
+    private static final String[] MODELS_CLASSES_FROM_MANIFEST;
+    
+    private static final ConcurrentMap<String, List<URL>> MODEL_URLS_FOR_PACKAGES = new ConcurrentHashMap<String, List<URL>>();
+    private static final ConcurrentMap<String, List<URL>> MODEL_URLS_FOR_CLASSES = new ConcurrentHashMap<String, List<URL>>();
+    
     static {
+        // suppress log entries from Reflections library
         Reflections.log = null;
+
+        // scan classpath for models bundle header entries only once
+        MODELS_PACKAGES_FROM_MANIFEST = toArray(ManifestScanner.getValues(PACKAGE_HEADER));
+        MODELS_CLASSES_FROM_MANIFEST = toArray(ManifestScanner.getValues(CLASSES_HEADER));
     }
     
     private ModelAdapterFactoryUtil() {
         // static methods only
     }
 
+    private static String[] toArray(Collection<String> values) {
+        return values.toArray(new String[values.size()]);
+    }
+        
     /**
-     * Scan classpaths for given package name (and sub packages) to scan for and
+     * Search classpath for given java package names (and sub packages) to scan for and
      * register all classes with @Model annotation.
-     * @param packageName Java package name
+     * @param bundleContext Bundle context
+     * @param packageNames Java package names
      */
-    public static void addModelsForPackage(String packageName, BundleContext bundleContext) {
-        Bundle bundle = new ModelsPackageBundle(packageName, Bundle.ACTIVE, bundleContext);
+    public static void addModelsForPackages(BundleContext bundleContext, String... packageNames) {
+        Bundle bundle = new RegisterModelsBundle(bundleContext, Bundle.ACTIVE, packageNames, null);
         BundleEvent event = new BundleEvent(BundleEvent.STARTED, bundle);
         MockOsgi.sendBundleEvent(bundleContext, event);
     }
 
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Model annotation.
+     * @param bundleContext Bundle context
+     * @param classNames Java class names
+     */
+    public static void addModelsForClasses(BundleContext bundleContext, String... classNames) {
+        Bundle bundle = new RegisterModelsBundle(bundleContext, Bundle.ACTIVE, null, classNames);
+        BundleEvent event = new BundleEvent(BundleEvent.STARTED, bundle);
+        MockOsgi.sendBundleEvent(bundleContext, event);
+    }
+
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Model annotation.
+     * @param bundleContext Bundle context
+     * @param classNames Java class names
+     */
+    public static void addModelsForClasses(BundleContext bundleContext, Class... classes) {
+        String[] classNames = new String[classes.length];
+        for (int i = 0; i < classes.length; i++) {
+            classNames[i] = classes[i].getName();
+        }
+        addModelsForClasses(bundleContext, classNames);
+    }
+    
+    /**
+     * Scan MANIFEST.MF in the classpath and automatically register all sling model classes found.
+     * @param bundleContext Bundle context
+     */
+    public static void addModelsForManifestEntries(BundleContext bundleContext) {
+        if (MODELS_PACKAGES_FROM_MANIFEST.length > 0) {
+            addModelsForPackages(bundleContext, MODELS_PACKAGES_FROM_MANIFEST);
+        }
+        if (MODELS_CLASSES_FROM_MANIFEST.length > 0) {
+            addModelsForClasses(bundleContext, MODELS_CLASSES_FROM_MANIFEST);
+        }
+    }
+    
+    /**
+     * Get model classes in list of packages (and subpackages), and cache result in static map.
+     * @param packageNames Package names
+     * @return List of URLs
+     */
+    private static Collection<URL> getModelClassUrlsForPackages(String packageNames) {
+        List<URL> urls = MODEL_URLS_FOR_PACKAGES.get(packageNames);
+        if (urls == null) {
+            urls = new ArrayList<URL>();
+            String[] packageNameArray = StringUtils.split(packageNames, ",");
+            // add "." to each package name because it's a prefix, not a package name
+            Object[] prefixArray = new Object[packageNameArray.length];
+            for (int i = 0; i < packageNameArray.length; i++) {
+                prefixArray[i] = packageNameArray[i] + ".";
+            }
+            Reflections reflections = new Reflections(prefixArray);
+            Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Model.class);
+            for (Class<?> clazz : classes) {
+                urls.add(classToUrl(clazz));
+            }
+            MODEL_URLS_FOR_PACKAGES.putIfAbsent(packageNames, urls);
+        }
+        return urls;
+    }
+    
+    /**
+     * Get model classes in list of class names, and cache result in static map.
+     * @param packageNames Class names
+     * @return List of URLs
+     */
+    private static Collection<URL> getModelClassUrlsForClasses(String classNames) {
+        List<URL> urls = MODEL_URLS_FOR_CLASSES.get(classNames);
+        if (urls == null) {
+            urls = new ArrayList<URL>();
+            String[] packageNameArray = StringUtils.split(classNames, ",");
+            for (String className : packageNameArray) {
+                try {
+                    Class<?> clazz = Class.forName(className);
+                    if (clazz.isAnnotationPresent(Model.class)) {
+                        urls.add(classToUrl(clazz));
+                    }
+                }
+                catch (ClassNotFoundException e) {
+                    // ignore
+                }
+            }
+            MODEL_URLS_FOR_CLASSES.putIfAbsent(classNames, urls);
+        }
+        return urls;
+    }
+    
+    private static URL classToUrl(Class clazz) {
+        try {
+            return new URL("file:/" + clazz.getName().replace('.', '/') + ".class");
+        }
+        catch (MalformedURLException ex) {
+            throw new RuntimeException("Malformed URL.", ex);
+        }
+    }
+
+
     @SuppressWarnings("unused")
-    private static class ModelsPackageBundle implements Bundle {
+    private static class RegisterModelsBundle implements Bundle {
+        
+        private static final String MAGIC_STRING = "MOCKS-YOU-KNOW-WHAT-TO-SCAN";
 
-        private final String packageName;
-        private final int state;
         private final BundleContext bundleContext;
+        private final int state;
+        private final String packageNames;
+        private final String classNames;
 
-        public ModelsPackageBundle(String packageName, int state, BundleContext bundleContext) {
-            this.packageName = packageName;
-            this.state = state;
+        public RegisterModelsBundle(BundleContext bundleContext, int state, String[] packageNames, String[] classNames) {
             this.bundleContext = bundleContext;
+            this.state = state;
+            this.packageNames = normalizeValueList(packageNames);
+            this.classNames = normalizeValueList(classNames);
+        }
+        
+        private String normalizeValueList(String[] values) {
+            if (values == null || values.length == 0) {
+                return null;
+            }
+            return StringUtils.join(values, ",");
         }
 
         @Override
@@ -87,25 +219,22 @@ final class ModelAdapterFactoryUtil {
         @Override
         public Dictionary getHeaders() {
             Dictionary<String, Object> headers = new Hashtable<String, Object>();
-            headers.put("Sling-Model-Packages", this.packageName);
+            headers.put(PACKAGE_HEADER, MAGIC_STRING);
             return headers;
         }
 
         @Override
         public Enumeration 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
-            try {
-                for (Class<?> type : types) {
-                    urls.add(new URL("file:/" + type.getName().replace('.', '/') + ".class"));
-                }
-            } catch (MalformedURLException ex) {
-                throw new RuntimeException("Malformed URL.", ex);
+            if (packageNames != null) {
+                urls.addAll(getModelClassUrlsForPackages(packageNames));
+            }
+            if (classNames != null) {
+                urls.addAll(getModelClassUrlsForClasses(classNames));
             }
             return urls.elements();
         }
-
+        
         @Override
         public Class loadClass(String name) throws ClassNotFoundException {
             return getClass().getClassLoader().loadClass(name);
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 72a0ba2..5cbb02b 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
@@ -176,6 +176,9 @@ public class SlingContextImpl extends OsgiContextImpl {
         registerService(SlingSettingsService.class, new MockSlingSettingService(DEFAULT_RUN_MODES));
         registerService(MimeTypeService.class, new MockMimeTypeService());
         registerInjectActivateService(new ResourceBuilderFactoryService());
+        
+        // scan for models defined via bundle headers in classpath
+        ModelAdapterFactoryUtil.addModelsForManifestEntries(this.bundleContext());
     }
 
     /**
@@ -353,12 +356,37 @@ public class SlingContextImpl extends OsgiContextImpl {
     }
 
     /**
-     * Scan classpaths for given package name (and sub packages) to scan for and
+     * Search classpath for given java package names (and sub packages) to scan for and
      * register all classes with @Model annotation.
-     * @param packageName Java package name
+     * @param packageNames Java package name
      */
     public final void addModelsForPackage(String packageName) {
-        ModelAdapterFactoryUtil.addModelsForPackage(packageName, bundleContext());
+        ModelAdapterFactoryUtil.addModelsForPackages(bundleContext(),  packageName);
+    }
+
+    /**
+     * Search classpath for given java package names (and sub packages) to scan for and
+     * register all classes with @Model annotation.
+     * @param packageNames Java package names
+     */
+    public final void addModelsForPackage(String... packageNames) {
+        ModelAdapterFactoryUtil.addModelsForPackages(bundleContext(), packageNames);
+    }
+
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Model annotation.
+     * @param classNames Java class names
+     */
+    public final void addModelsForClasses(String... classNames) {
+        ModelAdapterFactoryUtil.addModelsForClasses(bundleContext(), classNames);
+    }
+
+    /**
+     * Search classpath for given class names to scan for and register all classes with @Model annotation.
+     * @param classNames Java class names
+     */
+    public final void addModelsForClasses(Class... classes) {
+        ModelAdapterFactoryUtil.addModelsForClasses(bundleContext(), classes);
     }
 
     /**
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilTest.java b/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractModelAdapterFactoryUtilTest.java
similarity index 50%
rename from src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilTest.java
rename to src/test/java/org/apache/sling/testing/mock/sling/context/AbstractModelAdapterFactoryUtilTest.java
index 68a707d..eb68682 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractModelAdapterFactoryUtilTest.java
@@ -22,42 +22,31 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
-import javax.inject.Inject;
-
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.commons.mime.MimeTypeService;
-import org.apache.sling.models.annotations.Model;
+import org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel;
+import org.apache.sling.testing.mock.sling.context.models.RequestAttributeModel;
+import org.apache.sling.testing.mock.sling.context.models.ServiceInterface;
 import org.apache.sling.testing.mock.sling.junit.SlingContext;
 import org.apache.sling.testing.mock.sling.services.MockMimeTypeService;
-import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
 
-public class ModelAdapterFactoryUtilTest {
-
-    @Rule
-    public SlingContext context = new SlingContext();
+public abstract class AbstractModelAdapterFactoryUtilTest {
     
-    @Before
-    public void setUp() throws Exception {
-        // scan for @Model classes
-        context.addModelsForPackage("org.apache.sling.testing.mock.sling.context");
-    }
+    protected abstract SlingContext context();
 
     @Test
     public void testRequestAttribute() {
-        context.request().setAttribute("prop1", "myValue");
-        RequestAttributeModel model = context.request().adaptTo(RequestAttributeModel.class);
+        context().request().setAttribute("prop1", "myValue");
+        RequestAttributeModel model = context().request().adaptTo(RequestAttributeModel.class);
         assertNotNull(model);
         assertEquals("myValue", model.getProp1());
     }
 
     @Test
     public void testOsgiService() {
-        context.registerService(MimeTypeService.class, new MockMimeTypeService());
+        context().registerService(MimeTypeService.class, new MockMimeTypeService());
 
-        OsgiServiceModel model = context.resourceResolver().adaptTo(OsgiServiceModel.class);
+        OsgiServiceModel model = context().resourceResolver().adaptTo(OsgiServiceModel.class);
         assertNotNull(model);
         assertNotNull(model.getMimeTypeService());
         assertEquals("text/html", model.getMimeTypeService().getMimeType("html"));
@@ -65,43 +54,16 @@ public class ModelAdapterFactoryUtilTest {
 
     @Test
     public void testInvalidAdapt() {
-        OsgiServiceModel model = context.request().adaptTo(OsgiServiceModel.class);
+        OsgiServiceModel model = context().request().adaptTo(OsgiServiceModel.class);
         assertNull(model);
     }
 
     @Test
     public void testAdaptToInterface() {
-        context.request().setAttribute("prop1", "myValue");
-        ServiceInterface model = context.request().adaptTo(ServiceInterface.class);
+        context().request().setAttribute("prop1", "myValue");
+        ServiceInterface model = context().request().adaptTo(ServiceInterface.class);
         assertNotNull(model);
         assertEquals("myValue", model.getPropValue());
     }
 
-    @Model(adaptables = SlingHttpServletRequest.class)
-    public interface RequestAttributeModel {
-        @Inject
-        String getProp1();
-    }
-
-    @Model(adaptables = ResourceResolver.class)
-    public interface OsgiServiceModel {
-        @Inject
-        MimeTypeService getMimeTypeService();
-    }
-
-    public interface ServiceInterface {
-        String getPropValue();
-    }
-
-    @Model(adaptables = SlingHttpServletRequest.class, adapters = ServiceInterface.class)
-    public static class ServiceInterfaceImpl implements ServiceInterface {
-        @Inject
-        private String prop1;
-
-        @Override
-        public String getPropValue() {
-            return this.prop1;
-        }
-    }
-
 }
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java b/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
index a921e10..6299dfb 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
@@ -26,17 +26,14 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.Set;
 
-import javax.inject.Inject;
-
-import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.api.scripting.SlingBindings;
-import org.apache.sling.commons.mime.MimeTypeService;
-import org.apache.sling.models.annotations.Model;
 import org.apache.sling.settings.SlingSettingsService;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel;
+import org.apache.sling.testing.mock.sling.context.models.RequestAttributeModel;
+import org.apache.sling.testing.mock.sling.context.models.ServiceInterface;
 import org.apache.sling.testing.mock.sling.junit.SlingContext;
 import org.apache.sling.testing.mock.sling.loader.ContentLoader;
 import org.apache.sling.testing.mock.sling.services.MockMimeTypeService;
@@ -51,7 +48,7 @@ public abstract class AbstractSlingContextImplTest {
 
     @Before
     public void setUp() throws Exception {
-        context.addModelsForPackage("org.apache.sling.testing.mock.sling.context");
+        context.addModelsForPackage("org.apache.sling.testing.mock.sling.context.models");
         
         ContentLoader contentLoader = this.context.load();
         contentLoader.json("/json-import-samples/content.json", "/content/sample/en");
@@ -147,32 +144,4 @@ public abstract class AbstractSlingContextImplTest {
         assertEquals(1, factories.length);
     }
 
-    @Model(adaptables = SlingHttpServletRequest.class)
-    public interface RequestAttributeModel {
-        @Inject
-        String getProp1();
-    }
-
-    @Model(adaptables = ResourceResolver.class)
-    public interface OsgiServiceModel {
-        @Inject
-        MimeTypeService getMimeTypeService();
-    }
-
-    public interface ServiceInterface {
-        String getPropValue();
-    }
-
-    @Model(adaptables = SlingHttpServletRequest.class, adapters = ServiceInterface.class)
-    public static class ServiceInterfaceImpl implements ServiceInterface {
-
-        @Inject
-        private String prop1;
-
-        @Override
-        public String getPropValue() {
-            return this.prop1;
-        }
-    }
-
 }
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilClassesTest.java b/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilClassesTest.java
new file mode 100644
index 0000000..f576075
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilClassesTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.context;
+
+import org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel;
+import org.apache.sling.testing.mock.sling.context.models.RequestAttributeModel;
+import org.apache.sling.testing.mock.sling.context.models.ServiceInterfaceImpl;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+
+public class ModelAdapterFactoryUtilClassesTest extends AbstractModelAdapterFactoryUtilTest {
+
+    @Rule
+    public SlingContext context = new SlingContext();
+    
+    @Override
+    protected SlingContext context() {
+        return context;
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        // add Model classes individually
+        // although this is not supported before Sling Models Impl 1.3.4 in mocks this works even with older sling models versions
+        // because the class path scanning is implemented differently
+        context.addModelsForClasses(
+                OsgiServiceModel.class.getName()
+                );
+        context.addModelsForClasses(
+                RequestAttributeModel.class,
+                ServiceInterfaceImpl.class
+                );
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilPackagesTest.java b/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilPackagesTest.java
new file mode 100644
index 0000000..204d40e
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilPackagesTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.context;
+
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+
+public class ModelAdapterFactoryUtilPackagesTest extends AbstractModelAdapterFactoryUtilTest {
+
+    @Rule
+    public SlingContext context = new SlingContext();
+    
+    @Override
+    protected SlingContext context() {
+        return context;
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        // scan for @Model classes
+        context.addModelsForPackage(
+                "org.apache.sling.testing.mock.sling.context",
+                "org.apache.sling.testing.mock.sling.context.models"
+                );
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/models/OsgiServiceModel.java b/src/test/java/org/apache/sling/testing/mock/sling/context/models/OsgiServiceModel.java
new file mode 100644
index 0000000..add20e9
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/models/OsgiServiceModel.java
@@ -0,0 +1,36 @@
+/*
+ * 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.context.models;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.models.annotations.Model;
+
+/**
+ * For testing Sling Models support.
+ */
+@Model(adaptables = ResourceResolver.class)
+public interface OsgiServiceModel {
+
+    @Inject
+    MimeTypeService getMimeTypeService();
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/models/RequestAttributeModel.java b/src/test/java/org/apache/sling/testing/mock/sling/context/models/RequestAttributeModel.java
new file mode 100644
index 0000000..958b67d
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/models/RequestAttributeModel.java
@@ -0,0 +1,35 @@
+/*
+ * 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.context.models;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+
+/**
+ * For testing Sling Models support.
+ */
+@Model(adaptables = SlingHttpServletRequest.class)
+public interface RequestAttributeModel {
+
+    @Inject
+    String getProp1();
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterface.java b/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterface.java
new file mode 100644
index 0000000..d434f56
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterface.java
@@ -0,0 +1,28 @@
+/*
+ * 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.context.models;
+
+/**
+ * For testing Sling Models support.
+ */
+public interface ServiceInterface {
+
+    String getPropValue();
+
+}
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterfaceImpl.java b/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterfaceImpl.java
new file mode 100644
index 0000000..ef1a639
--- /dev/null
+++ b/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterfaceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * 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.context.models;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+
+/**
+ * For testing Sling Models support.
+ */
+@Model(adaptables = SlingHttpServletRequest.class, adapters = ServiceInterface.class)
+public class ServiceInterfaceImpl implements ServiceInterface {
+
+    @Inject
+    private String prop1;
+
+    @Override
+    public String getPropValue() {
+        return this.prop1;
+    }
+
+}

-- 
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/17: update osgi-mock dependency

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

commit db06b23cd0386d5c17487994753590d7c7e43403
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Dec 5 17:37:54 2016 +0000

    update osgi-mock dependency
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/branches/testing/mocks/sling-mock-1.x@1772723 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 6d2007a..a7f74a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,7 +45,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
-            <version>1.8.1-SNAPSHOT</version>
+            <version>1.9.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

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