You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2014/10/13 16:12:52 UTC

svn commit: r1631403 - in /sling/site/trunk/content/documentation/development: jcr-mock.mdtext osgi-mock.mdtext resourceresolver-mock.mdtext sling-mock.mdtext

Author: sseifert
Date: Mon Oct 13 14:12:52 2014
New Revision: 1631403

URL: http://svn.apache.org/r1631403
Log:
SLING-4042 mock documentation

Modified:
    sling/site/trunk/content/documentation/development/jcr-mock.mdtext
    sling/site/trunk/content/documentation/development/osgi-mock.mdtext
    sling/site/trunk/content/documentation/development/resourceresolver-mock.mdtext
    sling/site/trunk/content/documentation/development/sling-mock.mdtext

Modified: sling/site/trunk/content/documentation/development/jcr-mock.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/jcr-mock.mdtext?rev=1631403&r1=1631402&r2=1631403&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development/jcr-mock.mdtext (original)
+++ sling/site/trunk/content/documentation/development/jcr-mock.mdtext Mon Oct 13 14:12:52 2014
@@ -11,7 +11,7 @@ Mock implementation of selected JCR APIs
       <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
     </dependency>
 
-See latest version on the [downloads page]({{ refs.downloads.path }}).
+See latest version on the [downloads page](/downloads.cgi).
 
 
 ## Implemented mock features

Modified: sling/site/trunk/content/documentation/development/osgi-mock.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/osgi-mock.mdtext?rev=1631403&r1=1631402&r2=1631403&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development/osgi-mock.mdtext (original)
+++ sling/site/trunk/content/documentation/development/osgi-mock.mdtext Mon Oct 13 14:12:52 2014
@@ -11,7 +11,7 @@ Mock implementation of selected OSGi API
       <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
     </dependency>
 
-See latest version on the [downloads page]({{ refs.downloads.path }}).
+See latest version on the [downloads page](/downloads.cgi).
 
 
 ## Implemented mock features

Modified: sling/site/trunk/content/documentation/development/resourceresolver-mock.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/resourceresolver-mock.mdtext?rev=1631403&r1=1631402&r2=1631403&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development/resourceresolver-mock.mdtext (original)
+++ sling/site/trunk/content/documentation/development/resourceresolver-mock.mdtext Mon Oct 13 14:12:52 2014
@@ -11,7 +11,7 @@ Mock for the resource resolver / factory
       <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
     </dependency>
 
-See latest version on the [downloads page]({{ refs.downloads.path }}).
+See latest version on the [downloads page](/downloads.cgi).
 
 
 ## Implemented mock features

Modified: sling/site/trunk/content/documentation/development/sling-mock.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/sling-mock.mdtext?rev=1631403&r1=1631402&r2=1631403&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development/sling-mock.mdtext (original)
+++ sling/site/trunk/content/documentation/development/sling-mock.mdtext Mon Oct 13 14:12:52 2014
@@ -11,7 +11,7 @@ Mock implementation of selected Sling AP
       <artifactId>org.apache.sling.testing.sling-mock</artifactId>
     </dependency>
 
-See latest version on the [downloads page]({{ refs.downloads.path }}).
+See latest version on the [downloads page](/downloads.cgi).
 
 
 ## Implemented mock features
@@ -41,6 +41,7 @@ The following features are *not supporte
 
 Additional features provided:
 
+* `SlingContext` JUnit Rule for easily setting up a Sling Mock environment in your JUnit testcases
 * `ContentLoader` supports importing JSON data and binary data into the mock resource hierarchy to easily 
   prepare a test fixture consisting of a hierarchy of resources and properties.
     * The same JSON format can be used that is provided by the Sling GET servlet for output
@@ -105,7 +106,7 @@ The Sling mock context supports differen
 Different resource resolver mock types are supported with pros and cons, see next chapter for details.
 
 
-## Resource Resolver Types
+### Resource Resolver Types
 
 The Sling Mocks resource resolver implementation supports different "types" of adapters for the mocks.
 Depending on the type an underlying JCR repository is used or not, and the data ist stored in-memory or in a real 
@@ -113,7 +114,7 @@ repository.
 
 This pages lists all resource resolver types currently supported.
 
-### RESOURCERESOLVER_MOCK (default)
+#### RESOURCERESOLVER_MOCK (default)
 
 * Simulates an In-Memory resource tree, does not provide adaptions to JCR API.
 * Based on the [Sling resourceresolver-mock implementation][resourceresolver-mock] implementation
@@ -121,13 +122,13 @@ This pages lists all resource resolver t
 * Behaves slightly different from JCR resource mapping e.g. handling binary and date values.
 * This resource resolver type is very fast because data is stored in memory and no JCR mapping is applied.
 
-### JCR_MOCK
+#### JCR_MOCK
 
 * Based on the [JCR Mocks][jcr-mock] implementation
 * Uses the productive [Sling JCR resource provider implementation][jcr-resource] internally to do the Resource-JCR mapping
 * Is quite fast because data is stored only in-memory
 
-### JCR_JACKRABBIT
+#### JCR_JACKRABBIT
 
 * Uses a real JCR Jackrabbit implementation (not Oak) as provided by [sling/commons/testing][sling-comons-testing]
 * Full JCR/Sling features supported e.g. observations manager, transactions, versioning
@@ -151,7 +152,7 @@ To use this type you have to declare an 
       <scope>test</scope>
     </dependency>
 
-See latest version on the [downloads page]({{ refs.downloads.path }}).
+See latest version on the [downloads page](/downloads.cgi).
 
 
 ### Sling Resource Resolver
@@ -165,6 +166,9 @@ Example:
     // get a resource resolver backed by a specific repository type
     ResourceResolver resolver = MockSling.newResourceResolver(ResourceResolverType.JCR_MOCK);
 
+If you use the `SlingContext` JUnit rule you case just use `context.resourceResolver()`.
+
+
 ### Adapter Factories
 
 You can register your own or existing adapter factories to support adaptions e.g. for classes extending `SlingAdaptable`.
@@ -186,6 +190,8 @@ Example:
 Make sure you clean up the adapter manager bundle association after running the unit test otherwise it can 
 interfere with the following tests. If you use the `SlingContext` Junit rule this is done automatically for you.
 
+If you use the `SlingContext` JUnit rule you case just use `context.registerService()`.
+
 
 ### SlingScriptHelper
 
@@ -205,6 +211,8 @@ To support getting OSGi services you hav
 [JCR Mocks][jcr-mock] before. You can use an alternative factory method for the `SlingScriptHelper` providing
 existing instances of request, response and bundle context. 
 
+If you use the `SlingContext` JUnit rule you case just use `context.slingScriptHelper()`.
+
 
 ### SlingHttpServletRequest
 
@@ -244,6 +252,7 @@ Example for preparing a sling request wi
     // set cookies
     request.addCookie(new Cookie("cookie1", "value1"));
 
+
 ### SlingHttpServletResponse
 
 Example for preparing a sling response which can collect the data that was written to it:
@@ -312,6 +321,8 @@ Example code to import the JSON data:
 This codes creates a new resource at `/content/sample/en` (and - if not existent - the parent resources) and
 imports the JSON data to this node. It can be accessed using the Sling Resource or JCR API afterwards.
 
+If you use the `SlingContext` JUnit rule you case just use `context.load()`.
+
 
 ### Import binary data from file in classpath
 
@@ -328,6 +339,23 @@ Example code to import a binary file:
 This codes creates a new resource at `/content/binary/sample-file.gif` (and - if not existent - the parent 
 resources) and imports the binary data to a jcr:content subnode.
 
+If you use the `SlingContext` JUnit rule you case just use `context.load()`.
+
+
+### Building content
+
+For easily building resources a `ContentBuilder` provides convenience methods.
+
+Example:
+
+    #!java
+    // create resource
+    context.create().resource("/content/test1", ImmutableMap.<String, Object>builder()
+            .put("prop1", "value1")
+            .put("prop2", "value2")
+            .build());
+
+If you use the `SlingContext` JUnit rule you case just use `context.create()`.
 
 
 [osgi-mock]: {{ refs.osgi-mock.path }}