Author: buildbot
Date: Mon Sep 19 14:49:12 2016
New Revision: 997747

Log:
Staging update by buildbot for sling

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

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Sep 19 14:49:12 2016
@@ -1 +1 @@
-1761404
+1761462

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 Sep 19 14:49:12 2016
@@ -134,6 +134,8 @@ h2:hover > .headerlink, h3:hover > .head
 <li><a href="#import-resource-data-from-json-file-in-classpath">Import 
resource data from JSON file in classpath</a></li>
 <li><a href="#import-binary-data-from-file-in-classpath">Import binary data 
from file in classpath</a></li>
 <li><a href="#building-content">Building content</a></li>
+<li><a href="#building-content-using-contentbuilder">Building content using 
ContentBuilder</a></li>
+<li><a href="#building-content-using-resourcebuilder">Building content using 
ResourceBuilder</a></li>
 </ul>
 </li>
 </ul>
@@ -193,7 +195,7 @@ h2:hover > .headerlink, h3:hover > .head
 <li>The same JSON format can be used that is provided by the Sling GET servlet 
for output</li>
 </ul>
 </li>
-<li><code>ContentBuilder</code> makes it easier to create resources and 
properties as test fixture</li>
+<li><code>ContentBuilder</code> and <code>ResourceBuilder</code> make it 
easier to create resources and properties as test fixture</li>
 </ul>
 <h2 id="usage">Usage<a class="headerlink" href="#usage" title="Permanent 
link">&para;</a></h2>
 <h3 id="sling-context-junit-rule">Sling Context JUnit Rule<a 
class="headerlink" href="#sling-context-junit-rule" title="Permanent 
link">&para;</a></h3>
@@ -242,7 +244,7 @@ independently (and in parallel, if requi
 <ul>
 <li>Registering OSGi services</li>
 <li>Registering adapter factories</li>
-<li>Accessing Content Loader and Content Builder</li>
+<li>Accessing ContentLoader, and ContentBuilder and ResourceBuilder</li>
 </ul>
 <h3 id="choosing-resource-resolver-mock-type">Choosing Resource Resolver Mock 
Type<a class="headerlink" href="#choosing-resource-resolver-mock-type" 
title="Permanent link">&para;</a></h3>
 <p>The Sling mock context supports different resource resolver types. 
Example:</p>
@@ -567,46 +569,69 @@ in the classpath beneath the unit tests.
 </td></tr></table>
 
 <p>Example code to import the JSON data:</p>
-<table class="codehilitetable"><tr><td class="linenos"><div 
class="linenodiv"><pre>1
-2</pre></div></td><td class="code"><div class="codehilite"><pre><span 
class="n">ContentLoader</span> <span class="n">contentLoader</span> <span 
class="o">=</span> <span class="k">new</span> <span 
class="n">ContentLoader</span><span class="o">(</span><span 
class="n">resolver</span><span class="o">);</span>
-<span class="n">contentLoader</span><span class="o">.</span><span 
class="na">json</span><span class="o">(</span><span 
class="s">&quot;/sample-data.json&quot;</span><span class="o">,</span> <span 
class="s">&quot;/content/sample/en&quot;</span><span class="o">);</span>
+<table class="codehilitetable"><tr><td class="linenos"><div 
class="linenodiv"><pre>1</pre></div></td><td class="code"><div 
class="codehilite"><pre><span class="n">context</span><span 
class="o">.</span><span class="na">load</span><span class="o">().</span><span 
class="na">json</span><span class="o">(</span><span 
class="s">&quot;/sample-data.json&quot;</span><span class="o">,</span> <span 
class="s">&quot;/content/sample/en&quot;</span><span class="o">);</span>
 </pre></div>
 </td></tr></table>
 
 <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<a class="headerlink" 
href="#import-binary-data-from-file-in-classpath" title="Permanent 
link">&para;</a></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 using a nt:file/nt:resource or nt:resource node type. </p>
 <p>Example code to import a binary file:</p>
-<table class="codehilitetable"><tr><td class="linenos"><div 
class="linenodiv"><pre>1
-2</pre></div></td><td class="code"><div class="codehilite"><pre><span 
class="n">ContentLoader</span> <span class="n">contentLoader</span> <span 
class="o">=</span> <span class="k">new</span> <span 
class="n">ContentLoader</span><span class="o">(</span><span 
class="n">resolver</span><span class="o">);</span>
-<span class="n">contentLoader</span><span class="o">.</span><span 
class="na">binaryFile</span><span class="o">(</span><span 
class="s">&quot;/sample-file.gif&quot;</span><span class="o">,</span> <span 
class="s">&quot;/content/binary/sample-file.gif&quot;</span><span 
class="o">);</span>
+<table class="codehilitetable"><tr><td class="linenos"><div 
class="linenodiv"><pre>1</pre></div></td><td class="code"><div 
class="codehilite"><pre><span class="n">context</span><span 
class="o">.</span><span class="na">load</span><span class="o">().</span><span 
class="na">binaryFile</span><span class="o">(</span><span 
class="s">&quot;/sample-file.gif&quot;</span><span class="o">,</span> <span 
class="s">&quot;/content/binary/sample-file.gif&quot;</span><span 
class="o">);</span>
 </pre></div>
 </td></tr></table>
 
 <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<a class="headerlink" 
href="#building-content" title="Permanent link">&para;</a></h3>
-<p>For easily building resources a <code>ContentBuilder</code> provides 
convenience methods.</p>
+<p>Sling Mocks provides two alterantives for quickly building test content in 
the repository with as few code as possible. Sling Mocks provides two 
alternatives. Both are quite similar in their results, but follow different API 
concepts. You can choose whatever matches your needs and mix them as well.</p>
+<ul>
+<li><code>ContentBuilder</code>: Part of Sling Mocks since its first release. 
If you need a references to each created resource this is the easiest way.</li>
+<li><code>ResourceBuilder</code>: Separate bundle that can also be used in 
integration tests or live instances. Supports a "fluent" API to create a bunch 
of resources in hierarchy at once.</li>
+</ul>
+<h3 id="building-content-using-contentbuilder">Building content using 
<code>ContentBuilder</code><a class="headerlink" 
href="#building-content-using-contentbuilder" title="Permanent 
link">&para;</a></h3>
+<p>The entry point for the <code>ContentBuilder</code> is the 
<code>create()</code> method on the Sling context.</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="n">ContentBuilder</span> <span class="n">contentBuilder</span> <span 
class="o">=</span> <span class="k">new</span> <span 
class="n">ContentBuilder</span><span class="o">(</span><span 
class="n">resolver</span><span class="o">);</span>
-<span class="n">contentBuilder</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>
+4</pre></div></td><td class="code"><div class="codehilite"><pre><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>Simplified syntax without using a map:</p>
+<table class="codehilitetable"><tr><td class="linenos"><div 
class="linenodiv"><pre>1
+2
+3</pre></div></td><td class="code"><div class="codehilite"><pre><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="s">&quot;prop1&quot;</span><span class="o">,</span> <span 
class="s">&quot;value1&quot;</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>
+</pre></div>
+</td></tr></table>
+
 <p>If you use the <code>SlingContext</code> JUnit rule you case just use 
<code>context.create()</code>.</p>
+<h3 id="building-content-using-resourcebuilder">Building content using 
<code>ResourceBuilder</code><a class="headerlink" 
href="#building-content-using-resourcebuilder" title="Permanent 
link">&para;</a></h3>
+<p>The entry point for the <code>ResourceBuilder</code> is the 
<code>build()</code> method on the Sling context.</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="n">context</span><span class="o">.</span><span 
class="na">build</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="o">.</span><span class="na">siblingsMode</span><span 
class="o">()</span>
+        <span class="o">.</span><span class="na">resource</span><span 
class="o">(</span><span class="s">&quot;test1.1&quot;</span><span 
class="o">,</span> <span class="s">&quot;stringParam&quot;</span><span 
class="o">,</span> <span class="s">&quot;configValue1.1&quot;</span><span 
class="o">)</span>
+        <span class="o">.</span><span class="na">resource</span><span 
class="o">(</span><span class="s">&quot;test1.2&quot;</span><span 
class="o">,</span> <span class="s">&quot;stringParam&quot;</span><span 
class="o">,</span> <span class="s">&quot;configValue1.2&quot;</span><span 
class="o">)</span>
+        <span class="o">.</span><span class="na">resource</span><span 
class="o">(</span><span class="s">&quot;test1.2&quot;</span><span 
class="o">,</span> <span class="s">&quot;stringParam&quot;</span><span 
class="o">,</span> <span class="s">&quot;configValue1.3&quot;</span><span 
class="o">);</span>
+</pre></div>
+</td></tr></table>
+
+<p>See JavaDocs of the class 
<code>org.apache.sling.resourcebuilder.api.ResourceBuilder</code> for a 
detailed documentation.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; 
text-align: right;">
-        Rev. 1752256 by sseifert on Tue, 12 Jul 2016 09:48:27 +0000
+        Rev. 1761462 by sseifert on Mon, 19 Sep 2016 14:48:57 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache 
Sling project


Reply via email to