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

svn commit: r925617 - in /websites/staging/sling/trunk/content: ./ documentation/development/jcr-mock.html documentation/development/osgi-mock.html documentation/development/resourceresolver-mock.html documentation/development/sling-mock.html

Author: buildbot
Date: Mon Oct 13 14:13:00 2014
New Revision: 925617

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/development/jcr-mock.html
    websites/staging/sling/trunk/content/documentation/development/osgi-mock.html
    websites/staging/sling/trunk/content/documentation/development/resourceresolver-mock.html
    websites/staging/sling/trunk/content/documentation/development/sling-mock.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Oct 13 14:13:00 2014
@@ -1 +1 @@
-1631398
+1631403

Modified: websites/staging/sling/trunk/content/documentation/development/jcr-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/jcr-mock.html (original)
+++ websites/staging/sling/trunk/content/documentation/development/jcr-mock.html Mon Oct 13 14:13:00 2014
@@ -102,7 +102,7 @@
 </pre></div>
 </td></tr></table>
 
-<p>See latest version on the <a href="">downloads page</a>.</p>
+<p>See latest version on the <a href="/downloads.cgi">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
 <ul>
@@ -139,7 +139,7 @@
 
 <p>The repository is empty and contains only the root node. You can use the JCR API to fill it with content.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +0000
+        Rev. 1631403 by sseifert on Mon, 13 Oct 2014 14:12:52 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Modified: websites/staging/sling/trunk/content/documentation/development/osgi-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/osgi-mock.html (original)
+++ websites/staging/sling/trunk/content/documentation/development/osgi-mock.html Mon Oct 13 14:13:00 2014
@@ -102,7 +102,7 @@
 </pre></div>
 </td></tr></table>
 
-<p>See latest version on the <a href="">downloads page</a>.</p>
+<p>See latest version on the <a href="/downloads.cgi">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
 <ul>
@@ -196,7 +196,7 @@ are preset in the classpath at <code>/OS
 missing if your clean and build the project within your IDE (e.g. Eclipse). In this case you have to compile the
 project again with maven and can run the tests - or use a Maven IDE Integration like m2eclipse.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +0000
+        Rev. 1631403 by sseifert on Mon, 13 Oct 2014 14:12:52 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Modified: websites/staging/sling/trunk/content/documentation/development/resourceresolver-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/resourceresolver-mock.html (original)
+++ websites/staging/sling/trunk/content/documentation/development/resourceresolver-mock.html Mon Oct 13 14:13:00 2014
@@ -102,7 +102,7 @@
 </pre></div>
 </td></tr></table>
 
-<p>See latest version on the <a href="">downloads page</a>.</p>
+<p>See latest version on the <a href="/downloads.cgi">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
 <ul>
@@ -129,7 +129,7 @@
 <p>With the resolver you can use all Sling Resource features including reading and writing data using the Sling API.</p>
 <p>You cannot do any operations that require the JCR API because no JCR is underlying and adapting to JCR objects will just return null.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +0000
+        Rev. 1631403 by sseifert on Mon, 13 Oct 2014 14:12:52 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Modified: websites/staging/sling/trunk/content/documentation/development/sling-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/sling-mock.html (original)
+++ websites/staging/sling/trunk/content/documentation/development/sling-mock.html Mon Oct 13 14:13:00 2014
@@ -102,7 +102,7 @@
 </pre></div>
 </td></tr></table>
 
-<p>See latest version on the <a href="">downloads page</a>.</p>
+<p>See latest version on the <a href="/downloads.cgi">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
 <ul>
@@ -135,6 +135,7 @@
 <h3 id="additional-features">Additional features</h3>
 <p>Additional features provided:</p>
 <ul>
+<li><code>SlingContext</code> JUnit Rule for easily setting up a Sling Mock environment in your JUnit testcases</li>
 <li><code>ContentLoader</code> 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.<ul>
 <li>The same JSON format can be used that is provided by the Sling GET servlet for output</li>
@@ -208,12 +209,12 @@ independently (and in parallel, if requi
 </td></tr></table>
 
 <p>Different resource resolver mock types are supported with pros and cons, see next chapter for details.</p>
-<h2 id="resource-resolver-types">Resource Resolver Types</h2>
+<h3 id="resource-resolver-types">Resource Resolver Types</h3>
 <p>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 
 repository.</p>
 <p>This pages lists all resource resolver types currently supported.</p>
-<h3 id="resourceresolver_mock-default">RESOURCERESOLVER_MOCK (default)</h3>
+<h4 id="resourceresolver_mock-default">RESOURCERESOLVER_MOCK (default)</h4>
 <ul>
 <li>Simulates an In-Memory resource tree, does not provide adaptions to JCR API.</li>
 <li>Based on the <a href="/documentation/development/resourceresolver-mock.html">Sling resourceresolver-mock implementation</a> implementation</li>
@@ -221,13 +222,13 @@ repository.</p>
 <li>Behaves slightly different from JCR resource mapping e.g. handling binary and date values.</li>
 <li>This resource resolver type is very fast because data is stored in memory and no JCR mapping is applied.</li>
 </ul>
-<h3 id="jcr_mock">JCR_MOCK</h3>
+<h4 id="jcr_mock">JCR_MOCK</h4>
 <ul>
 <li>Based on the <a href="/documentation/development/jcr-mock.html">JCR Mocks</a> implementation</li>
 <li>Uses the productive <a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resource">Sling JCR resource provider implementation</a> internally to do the Resource-JCR mapping</li>
 <li>Is quite fast because data is stored only in-memory</li>
 </ul>
-<h3 id="jcr_jackrabbit">JCR_JACKRABBIT</h3>
+<h4 id="jcr_jackrabbit">JCR_JACKRABBIT</h4>
 <ul>
 <li>Uses a real JCR Jackrabbit implementation (not Oak) as provided by <a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/testing">sling/commons/testing</a></li>
 <li>Full JCR/Sling features supported e.g. observations manager, transactions, versioning</li>
@@ -255,7 +256,7 @@ repository.</p>
 </pre></div>
 </td></tr></table>
 
-<p>See latest version on the <a href="">downloads page</a>.</p>
+<p>See latest version on the <a href="/downloads.cgi">downloads page</a>.</p>
 <h3 id="sling-resource-resolver">Sling Resource Resolver</h3>
 <p>Example:</p>
 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
@@ -270,6 +271,7 @@ repository.</p>
 </pre></div>
 </td></tr></table>
 
+<p>If you use the <code>SlingContext</code> JUnit rule you case just use <code>context.resourceResolver()</code>.</p>
 <h3 id="adapter-factories">Adapter Factories</h3>
 <p>You can register your own or existing adapter factories to support adaptions e.g. for classes extending <code>SlingAdaptable</code>.</p>
 <p>Example:</p>
@@ -297,6 +299,7 @@ repository.</p>
 
 <p>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 <code>SlingContext</code> Junit rule this is done automatically for you.</p>
+<p>If you use the <code>SlingContext</code> JUnit rule you case just use <code>context.registerService()</code>.</p>
 <h3 id="slingscripthelper">SlingScriptHelper</h3>
 <p>Example:</p>
 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
@@ -320,6 +323,7 @@ interfere with the following tests. If y
 <p>To support getting OSGi services you have to register them via the <code>BundleContext</code> interface of the
 <a href="/documentation/development/jcr-mock.html">JCR Mocks</a> before. You can use an alternative factory method for the <code>SlingScriptHelper</code> providing
 existing instances of request, response and bundle context. </p>
+<p>If you use the <code>SlingContext</code> JUnit rule you case just use <code>context.slingScriptHelper()</code>.</p>
 <h3 id="slinghttpservletrequest">SlingHttpServletRequest</h3>
 <p>Example for preparing a sling request with custom request data:</p>
 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
@@ -493,6 +497,7 @@ in the classpath beneath the unit tests.
 
 <p>This codes creates a new resource at <code>/content/sample/en</code> (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.</p>
+<p>If you use the <code>SlingContext</code> JUnit rule you case just use <code>context.load()</code>.</p>
 <h3 id="import-binary-data-from-file-in-classpath">Import binary data from file in classpath</h3>
 <p>With the <code>ContentLoader</code> it is possible to import a binary file stored in the classpath beneath the unit tests.
 The data is stored usig a nt:file/nt:resource or nt:resource node type. </p>
@@ -507,8 +512,25 @@ The data is stored usig a nt:file/nt:res
 
 <p>This codes creates a new resource at <code>/content/binary/sample-file.gif</code> (and - if not existent - the parent 
 resources) and imports the binary data to a jcr:content subnode.</p>
+<p>If you use the <code>SlingContext</code> JUnit rule you case just use <code>context.load()</code>.</p>
+<h3 id="building-content">Building content</h3>
+<p>For easily building resources a <code>ContentBuilder</code> provides convenience methods.</p>
+<p>Example:</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4
+5</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// create resource</span>
+<span class="n">context</span><span class="o">.</span><span class="na">create</span><span class="o">().</span><span class="na">resource</span><span class="o">(</span><span class="s">&quot;/content/test1&quot;</span><span class="o">,</span> <span class="n">ImmutableMap</span><span class="o">.&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span><span class="n">builder</span><span class="o">()</span>
+        <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;prop1&quot;</span><span class="o">,</span> <span class="s">&quot;value1&quot;</span><span class="o">)</span>
+        <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;prop2&quot;</span><span class="o">,</span> <span class="s">&quot;value2&quot;</span><span class="o">)</span>
+        <span class="o">.</span><span class="na">build</span><span class="o">());</span>
+</pre></div>
+</td></tr></table>
+
+<p>If you use the <code>SlingContext</code> JUnit rule you case just use <code>context.create()</code>.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +0000
+        Rev. 1631403 by sseifert on Mon, 13 Oct 2014 14:12:52 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project