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:04:11 UTC

svn commit: r925612 - 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:04:10 2014
New Revision: 925612

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:04:10 2014
@@ -1 +1 @@
-1631393
+1631398

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:04:10 2014
@@ -92,11 +92,16 @@
       <h1>JCR Mock</h1>
       <p>Mock implementation of selected JCR APIs for easier testing.</p>
 <h2 id="maven-dependency">Maven Dependency</h2>
-<p><code>xml
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
-  &lt;artifactId&gt;org.apache.sling.testing.jcr-mock&lt;/artifactId&gt;
-&lt;/dependency&gt;</code></p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4</pre></div></td><td class="code"><div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+  <span class="nt">&lt;groupId&gt;</span>org.apache.sling<span class="nt">&lt;/groupId&gt;</span>
+  <span class="nt">&lt;artifactId&gt;</span>org.apache.sling.testing.jcr-mock<span class="nt">&lt;/artifactId&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+</td></tr></table>
+
 <p>See latest version on the <a href="">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
@@ -120,15 +125,21 @@
 <h3 id="getting-jcr-mock-objects">Getting JCR mock objects</h3>
 <p>The factory class <code>MockJcr</code> allows to instantiate the different mock implementations.</p>
 <p>Example:</p>
-<p>```java
-// get session
-Session session = MockJcr.newSession();</p>
-<p>// get repository
-Repository repository = MockJcr.newRepository();
-```</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">// get session</span>
+<span class="n">Session</span> <span class="n">session</span> <span class="o">=</span> <span class="n">MockJcr</span><span class="o">.</span><span class="na">newSession</span><span class="o">();</span>
+
+<span class="c1">// get repository</span>
+<span class="n">Repository</span> <span class="n">repository</span> <span class="o">=</span> <span class="n">MockJcr</span><span class="o">.</span><span class="na">newRepository</span><span class="o">();</span>
+</pre></div>
+</td></tr></table>
+
 <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. 1631393 by sseifert on Mon, 13 Oct 2014 13:54:56 +0000
+        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +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:04:10 2014
@@ -92,11 +92,16 @@
       <h1>OSGi Mock</h1>
       <p>Mock implementation of selected OSGi APIs for easier testing.</p>
 <h2 id="maven-dependency">Maven Dependency</h2>
-<p><code>xml
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
-  &lt;artifactId&gt;org.apache.sling.testing.osgi-mock&lt;/artifactId&gt;
-&lt;/dependency&gt;</code></p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4</pre></div></td><td class="code"><div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+  <span class="nt">&lt;groupId&gt;</span>org.apache.sling<span class="nt">&lt;/groupId&gt;</span>
+  <span class="nt">&lt;artifactId&gt;</span>org.apache.sling.testing.osgi-mock<span class="nt">&lt;/artifactId&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+</td></tr></table>
+
 <p>See latest version on the <a href="">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
@@ -117,45 +122,81 @@
 <h3 id="getting-osgi-mock-objects">Getting OSGi mock objects</h3>
 <p>The factory class <code>MockOsgi</code> allows to instantiate the different mock implementations.</p>
 <p>Example:</p>
-<p>```java
-// get bundle context
-BundleContext bundleContext = MockOsgi.newBundleContext();</p>
-<p>// get component context
-Dictionary<String,Object> properties = new Hashtable&lt;&gt;();
-properties.put("prop1", "value1");
-BundleContext bundleContext = MockOsgi.newComponentContext(properties);
-```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4
+5
+6
+7</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// get bundle context</span>
+<span class="n">BundleContext</span> <span class="n">bundleContext</span> <span class="o">=</span> <span class="n">MockOsgi</span><span class="o">.</span><span class="na">newBundleContext</span><span class="o">();</span>
+
+<span class="c1">// get component context</span>
+<span class="n">Dictionary</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">properties</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">&lt;&gt;();</span>
+<span class="n">properties</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="n">BundleContext</span> <span class="n">bundleContext</span> <span class="o">=</span> <span class="n">MockOsgi</span><span class="o">.</span><span class="na">newComponentContext</span><span class="o">(</span><span class="n">properties</span><span class="o">);</span>
+</pre></div>
+</td></tr></table>
+
 <p>It is possible to simulate registering of OSGi services (backed by a simple hash map internally):</p>
-<p>```java
-// register service
-bundleContext.registerService(MyClass.class, myService, properties);</p>
-<p>// get service instance
-ServiceReference ref = bundleContext.getServiceReference(MyClass.class.getName());
-MyClass service = bundleContext.getService(ref);
-```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4
+5
+6</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// register service</span>
+<span class="n">bundleContext</span><span class="o">.</span><span class="na">registerService</span><span class="o">(</span><span class="n">MyClass</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">myService</span><span class="o">,</span> <span class="n">properties</span><span class="o">);</span>
+
+<span class="c1">// get service instance</span>
+<span class="n">ServiceReference</span> <span class="n">ref</span> <span class="o">=</span> <span class="n">bundleContext</span><span class="o">.</span><span class="na">getServiceReference</span><span class="o">(</span><span class="n">MyClass</span><span class="o">.</span><span class="na">class</span><span class="o">.</span><span class="na">getName</span><span class="o">());</span>
+<span class="n">MyClass</span> <span class="n">service</span> <span class="o">=</span> <span class="n">bundleContext</span><span class="o">.</span><span class="na">getService</span><span class="o">(</span><span class="n">ref</span><span class="o">);</span>
+</pre></div>
+</td></tr></table>
+
 <h3 id="activation-and-dependency-injection">Activation and Dependency Injection</h3>
 <p>It is possible to simulate OSGi service activation, deactivation and dependency injection and the mock implementation
 tries to to its best to execute all as expected for an OSGi environment.</p>
 <p>Example:</p>
-<p>```java
-// get bundle context
-BundleContext bundleContext = MockOsgi.newBundleContext();</p>
-<p>// create service instance manually
-MyService service = new MyService();</p>
-<p>// inject dependencies
-MockOsgi.injectServices(service, bundleContext);</p>
-<p>// activate service
-MockOsgi.activate(service, props);</p>
-<p>// operate with service...</p>
-<p>// deactivate service
-MockOsgi.deactivate(service);
-```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// get bundle context</span>
+<span class="n">BundleContext</span> <span class="n">bundleContext</span> <span class="o">=</span> <span class="n">MockOsgi</span><span class="o">.</span><span class="na">newBundleContext</span><span class="o">();</span>
+
+<span class="c1">// create service instance manually</span>
+<span class="n">MyService</span> <span class="n">service</span> <span class="o">=</span> <span class="k">new</span> <span class="n">MyService</span><span class="o">();</span>
+
+<span class="c1">// inject dependencies</span>
+<span class="n">MockOsgi</span><span class="o">.</span><span class="na">injectServices</span><span class="o">(</span><span class="n">service</span><span class="o">,</span> <span class="n">bundleContext</span><span class="o">);</span>
+
+<span class="c1">// activate service</span>
+<span class="n">MockOsgi</span><span class="o">.</span><span class="na">activate</span><span class="o">(</span><span class="n">service</span><span class="o">,</span> <span class="n">props</span><span class="o">);</span>
+
+<span class="c1">// operate with service...</span>
+
+<span class="c1">// deactivate service</span>
+<span class="n">MockOsgi</span><span class="o">.</span><span class="na">deactivate</span><span class="o">(</span><span class="n">service</span><span class="o">);</span>
+</pre></div>
+</td></tr></table>
+
 <p>Please note: The injectServices, activate and deactivate Methods can only work properly when the SCR XML metadata files
 are preset in the classpath at <code>/OSGI-INF</code>. They are generated automatically by the Maven SCR plugin, but might be
 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. 1631393 by sseifert on Mon, 13 Oct 2014 13:54:56 +0000
+        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +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:04:10 2014
@@ -92,11 +92,16 @@
       <h1>Resource Resolver Mock</h1>
       <p>Mock for the resource resolver / factory for easier testing.</p>
 <h2 id="maven-dependency">Maven Dependency</h2>
-<p><code>xml
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
-  &lt;artifactId&gt;org.apache.sling.testing.resourceresolver-mock&lt;/artifactId&gt;
-&lt;/dependency&gt;</code></p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4</pre></div></td><td class="code"><div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+  <span class="nt">&lt;groupId&gt;</span>org.apache.sling<span class="nt">&lt;/groupId&gt;</span>
+  <span class="nt">&lt;artifactId&gt;</span>org.apache.sling.testing.resourceresolver-mock<span class="nt">&lt;/artifactId&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+</td></tr></table>
+
 <p>See latest version on the <a href="">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
@@ -124,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. 1631393 by sseifert on Mon, 13 Oct 2014 13:54:56 +0000
+        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +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:04:10 2014
@@ -92,11 +92,16 @@
       <h1>Sling Mock</h1>
       <p>Mock implementation of selected Sling APIs for easier testing.</p>
 <h2 id="maven-dependency">Maven Dependency</h2>
-<p><code>xml
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
-  &lt;artifactId&gt;org.apache.sling.testing.sling-mock&lt;/artifactId&gt;
-&lt;/dependency&gt;</code></p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4</pre></div></td><td class="code"><div class="codehilite"><pre><span class="nt">&lt;dependency&gt;</span>
+  <span class="nt">&lt;groupId&gt;</span>org.apache.sling<span class="nt">&lt;/groupId&gt;</span>
+  <span class="nt">&lt;artifactId&gt;</span>org.apache.sling.testing.sling-mock<span class="nt">&lt;/artifactId&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+</td></tr></table>
+
 <p>See latest version on the <a href="">downloads page</a>.</p>
 <h2 id="implemented-mock-features">Implemented mock features</h2>
 <p>The mock implementation supports:</p>
@@ -143,17 +148,32 @@
 This rules takes care of all initialization and cleanup tasks required to make sure all unit tests can run 
 independently (and in parallel, if required).</p>
 <p>Example:</p>
-<p>```java
-public class ExampleTest {</p>
-<p>@Rule
-  public final SlingContext context = new SlingContext();</p>
-<p>@Test
-  public void testSomething() {
-    Resource resource = context.resourceResolver().getResource("/content/sample/en");
-    // further testing
-  }</p>
-<p>}</p>
-<p>```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ExampleTest</span> <span class="o">{</span>
+
+  <span class="nd">@Rule</span>
+  <span class="kd">public</span> <span class="kd">final</span> <span class="n">SlingContext</span> <span class="n">context</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SlingContext</span><span class="o">();</span>
+
+  <span class="nd">@Test</span>
+  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">testSomething</span><span class="o">()</span> <span class="o">{</span>
+    <span class="n">Resource</span> <span class="n">resource</span> <span class="o">=</span> <span class="n">context</span><span class="o">.</span><span class="na">resourceResolver</span><span class="o">().</span><span class="na">getResource</span><span class="o">(</span><span class="s">&quot;/content/sample/en&quot;</span><span class="o">);</span>
+    <span class="c1">// further testing</span>
+  <span class="o">}</span>
+
+<span class="o">}</span>
+</pre></div>
+</td></tr></table>
+
 <p>It is possible to combine such a unit test with a <code>@RunWith</code> annotation e.g. for
 [Mockito JUnit Runner][mockito-testrunner].</p>
 <p>The <code>SlingContext</code> object provides access to mock implementations of:</p>
@@ -173,12 +193,20 @@ public class ExampleTest {</p>
 </ul>
 <h3 id="choosing-resource-resolver-mock-type">Choosing Resource Resolver Mock Type</h3>
 <p>The Sling mock context supports different resource resolver types. Example:</p>
-<p>```java
-public class ExampleTest {</p>
-<p>@Rule
-  public final SlingContext context = new SlingContext(ResourceResolverType.RESOURCERESOLVER_MOCK);</p>
-<p>}</p>
-<p>```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4
+5
+6</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ExampleTest</span> <span class="o">{</span>
+
+  <span class="nd">@Rule</span>
+  <span class="kd">public</span> <span class="kd">final</span> <span class="n">SlingContext</span> <span class="n">context</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SlingContext</span><span class="o">(</span><span class="n">ResourceResolverType</span><span class="o">.</span><span class="na">RESOURCERESOLVER_MOCK</span><span class="o">);</span>
+
+<span class="o">}</span>
+</pre></div>
+</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>
 <p>The Sling Mocks resource resolver implementation supports different "types" of adapters for the mocks.
@@ -215,141 +243,272 @@ repository.</p>
   jackrabbit and others, be careful that they do not conflict and are imported in the right order in your test project</li>
 </ul>
 <p>To use this type you have to declare an additional dependency in your test project:</p>
-<p><code>xml
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
-  &lt;artifactId&gt;org.apache.sling.testing.sling-mock-jackrabbit&lt;/artifactId&gt;
-  &lt;scope&gt;test&lt;/scope&gt;
-&lt;/dependency&gt;</code></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="nt">&lt;dependency&gt;</span>
+  <span class="nt">&lt;groupId&gt;</span>org.apache.sling<span class="nt">&lt;/groupId&gt;</span>
+  <span class="nt">&lt;artifactId&gt;</span>org.apache.sling.testing.sling-mock-jackrabbit<span class="nt">&lt;/artifactId&gt;</span>
+  <span class="nt">&lt;scope&gt;</span>test<span class="nt">&lt;/scope&gt;</span>
+<span class="nt">&lt;/dependency&gt;</span>
+</pre></div>
+</td></tr></table>
+
 <p>See latest version on the <a href="">downloads page</a>.</p>
 <h3 id="sling-resource-resolver">Sling Resource Resolver</h3>
 <p>Example:</p>
-<p>```java
-// get a resource resolver
-ResourceResolver resolver = MockSling.newResourceResolver();</p>
-<p>// get a resource resolver backed by a specific repository type
-ResourceResolver resolver = MockSling.newResourceResolver(ResourceResolverType.JCR_MOCK);
-```</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">// get a resource resolver</span>
+<span class="n">ResourceResolver</span> <span class="n">resolver</span> <span class="o">=</span> <span class="n">MockSling</span><span class="o">.</span><span class="na">newResourceResolver</span><span class="o">();</span>
+
+<span class="c1">// get a resource resolver backed by a specific repository type</span>
+<span class="n">ResourceResolver</span> <span class="n">resolver</span> <span class="o">=</span> <span class="n">MockSling</span><span class="o">.</span><span class="na">newResourceResolver</span><span class="o">(</span><span class="n">ResourceResolverType</span><span class="o">.</span><span class="na">JCR_MOCK</span><span class="o">);</span>
+</pre></div>
+</td></tr></table>
+
 <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>
-<p>```java
-// register adapter factory
-BundleContext bundleContext = MockOsgi.newBundleContext();
-MockSling.setAdapterManagerBundleContext(bundleContext);
-bundleContext.registerService(myAdapterFactory);</p>
-<p>// test adaption
-MyClass object = resource.adaptTo(MyClass.class);</p>
-<p>// cleanup after unit test
-MockSling.clearAdapterManagerBundleContext();
-```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// register adapter factory</span>
+<span class="n">BundleContext</span> <span class="n">bundleContext</span> <span class="o">=</span> <span class="n">MockOsgi</span><span class="o">.</span><span class="na">newBundleContext</span><span class="o">();</span>
+<span class="n">MockSling</span><span class="o">.</span><span class="na">setAdapterManagerBundleContext</span><span class="o">(</span><span class="n">bundleContext</span><span class="o">);</span>
+<span class="n">bundleContext</span><span class="o">.</span><span class="na">registerService</span><span class="o">(</span><span class="n">myAdapterFactory</span><span class="o">);</span>
+
+<span class="c1">// test adaption</span>
+<span class="n">MyClass</span> <span class="n">object</span> <span class="o">=</span> <span class="n">resource</span><span class="o">.</span><span class="na">adaptTo</span><span class="o">(</span><span class="n">MyClass</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
+
+<span class="c1">// cleanup after unit test</span>
+<span class="n">MockSling</span><span class="o">.</span><span class="na">clearAdapterManagerBundleContext</span><span class="o">();</span>
+</pre></div>
+</td></tr></table>
+
 <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>
 <h3 id="slingscripthelper">SlingScriptHelper</h3>
 <p>Example:</p>
-<p>```java
-// get script helper
-SlingScriptHelper scriptHelper = MockSling.newSlingScriptHelper();</p>
-<p>// get request
-SlingHttpServletRequest request = scriptHelper.getRequest();</p>
-<p>// get service
-MyService object = scriptHelper.getService(MyService.class);
-```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
+2
+3
+4
+5
+6
+7
+8</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// get script helper</span>
+<span class="n">SlingScriptHelper</span> <span class="n">scriptHelper</span> <span class="o">=</span> <span class="n">MockSling</span><span class="o">.</span><span class="na">newSlingScriptHelper</span><span class="o">();</span>
+
+<span class="c1">// get request</span>
+<span class="n">SlingHttpServletRequest</span> <span class="n">request</span> <span class="o">=</span> <span class="n">scriptHelper</span><span class="o">.</span><span class="na">getRequest</span><span class="o">();</span>
+
+<span class="c1">// get service</span>
+<span class="n">MyService</span> <span class="n">object</span> <span class="o">=</span> <span class="n">scriptHelper</span><span class="o">.</span><span class="na">getService</span><span class="o">(</span><span class="n">MyService</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
+</pre></div>
+</td></tr></table>
+
 <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>
 <h3 id="slinghttpservletrequest">SlingHttpServletRequest</h3>
 <p>Example for preparing a sling request with custom request data:</p>
-<p>```java
-// prepare sling request
-ResourceResolver resourceResolver = MockSling.newResourceResolver();
-MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(resourceResolver);</p>
-<p>// simulate query string
-request.setQueryString("param1=aaa&amp;param2=bbb");</p>
-<p>// alternative - set query parameters as map
-request.setParameterMap(ImmutableMap.<String,Object>builder()
-    .put("param1", "aaa")
-    .put("param2", "bbb")
-    .build());</p>
-<p>// set current resource
-request.setResource(resourceResolver.getResource("/content/sample"));</p>
-<p>// set sling request path info properties
-MockRequestPathInfo requestPathInfo = (MockRequestPathInfo)request.getRequestPathInfo();
-requestPathInfo.setSelectorString("selector1.selector2");
-requestPathInfo.setExtension("html");</p>
-<p>// set method
-request.setMethod(HttpConstants.METHOD_POST);</p>
-<p>// set attributes
-request.setAttribute("attr1", "value1");</p>
-<p>// set headers
-request.addHeader("header1", "value1");</p>
-<p>// set cookies
-request.addCookie(new Cookie("cookie1", "value1"));
-```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// prepare sling request</span>
+<span class="n">ResourceResolver</span> <span class="n">resourceResolver</span> <span class="o">=</span> <span class="n">MockSling</span><span class="o">.</span><span class="na">newResourceResolver</span><span class="o">();</span>
+<span class="n">MockSlingHttpServletRequest</span> <span class="n">request</span> <span class="o">=</span> <span class="k">new</span> <span class="n">MockSlingHttpServletRequest</span><span class="o">(</span><span class="n">resourceResolver</span><span class="o">);</span>
+
+<span class="c1">// simulate query string</span>
+<span class="n">request</span><span class="o">.</span><span class="na">setQueryString</span><span class="o">(</span><span class="s">&quot;param1=aaa&amp;param2=bbb&quot;</span><span class="o">);</span>
+
+<span class="c1">// alternative - set query parameters as map</span>
+<span class="n">request</span><span class="o">.</span><span class="na">setParameterMap</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;param1&quot;</span><span class="o">,</span> <span class="s">&quot;aaa&quot;</span><span class="o">)</span>
+    <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;param2&quot;</span><span class="o">,</span> <span class="s">&quot;bbb&quot;</span><span class="o">)</span>
+    <span class="o">.</span><span class="na">build</span><span class="o">());</span>
+
+<span class="c1">// set current resource</span>
+<span class="n">request</span><span class="o">.</span><span class="na">setResource</span><span class="o">(</span><span class="n">resourceResolver</span><span class="o">.</span><span class="na">getResource</span><span class="o">(</span><span class="s">&quot;/content/sample&quot;</span><span class="o">));</span>
+
+<span class="c1">// set sling request path info properties</span>
+<span class="n">MockRequestPathInfo</span> <span class="n">requestPathInfo</span> <span class="o">=</span> <span class="o">(</span><span class="n">MockRequestPathInfo</span><span class="o">)</span><span class="n">request</span><span class="o">.</span><span class="na">getRequestPathInfo</span><span class="o">();</span>
+<span class="n">requestPathInfo</span><span class="o">.</span><span class="na">setSelectorString</span><span class="o">(</span><span class="s">&quot;selector1.selector2&quot;</span><span class="o">);</span>
+<span class="n">requestPathInfo</span><span class="o">.</span><span class="na">setExtension</span><span class="o">(</span><span class="s">&quot;html&quot;</span><span class="o">);</span>
+
+<span class="c1">// set method</span>
+<span class="n">request</span><span class="o">.</span><span class="na">setMethod</span><span class="o">(</span><span class="n">HttpConstants</span><span class="o">.</span><span class="na">METHOD_POST</span><span class="o">);</span>
+
+<span class="c1">// set attributes</span>
+<span class="n">request</span><span class="o">.</span><span class="na">setAttribute</span><span class="o">(</span><span class="s">&quot;attr1&quot;</span><span class="o">,</span> <span class="s">&quot;value1&quot;</span><span class="o">);</span>
+
+<span class="c1">// set headers</span>
+<span class="n">request</span><span class="o">.</span><span class="na">addHeader</span><span class="o">(</span><span class="s">&quot;header1&quot;</span><span class="o">,</span> <span class="s">&quot;value1&quot;</span><span class="o">);</span>
+
+<span class="c1">// set cookies</span>
+<span class="n">request</span><span class="o">.</span><span class="na">addCookie</span><span class="o">(</span><span class="k">new</span> <span class="n">Cookie</span><span class="o">(</span><span class="s">&quot;cookie1&quot;</span><span class="o">,</span> <span class="s">&quot;value1&quot;</span><span class="o">));</span>
+</pre></div>
+</td></tr></table>
+
 <h3 id="slinghttpservletresponse">SlingHttpServletResponse</h3>
 <p>Example for preparing a sling response which can collect the data that was written to it:</p>
-<p>```java
-// prepare sling response
-MockSlingHttpServletResponse response = new MockSlingHttpServletResponse();</p>
-<p>// execute your unit test code that writes to the response...</p>
-<p>// validate status code
-assertEquals(HttpServletResponse.SC_OK, response.getStatus());</p>
-<p>// validate content type and content length
-assertEquals("text/plain;charset=UTF-8", response.getContentType());
-assertEquals(CharEncoding.UTF_8, response.getCharacterEncoding());
-assertEquals(55, response.getContentLength());</p>
-<p>// validate headers
-assertTrue(response.containsHeader("header1"));
-assertEquals("5", response.getHeader("header2"));</p>
-<p>// validate response body as string
-assertEquals(TEST_CONTENT, response.getOutputAsString());</p>
-<p>// validate response body as binary data
-assertArrayEquals(TEST_DATA, response.getOutput());
-```</p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22</pre></div></td><td class="code"><div class="codehilite"><pre><span class="c1">// prepare sling response</span>
+<span class="n">MockSlingHttpServletResponse</span> <span class="n">response</span> <span class="o">=</span> <span class="k">new</span> <span class="n">MockSlingHttpServletResponse</span><span class="o">();</span>
+
+<span class="c1">// execute your unit test code that writes to the response...</span>
+
+<span class="c1">// validate status code</span>
+<span class="n">assertEquals</span><span class="o">(</span><span class="n">HttpServletResponse</span><span class="o">.</span><span class="na">SC_OK</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getStatus</span><span class="o">());</span>
+
+<span class="c1">// validate content type and content length</span>
+<span class="n">assertEquals</span><span class="o">(</span><span class="s">&quot;text/plain;charset=UTF-8&quot;</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getContentType</span><span class="o">());</span>
+<span class="n">assertEquals</span><span class="o">(</span><span class="n">CharEncoding</span><span class="o">.</span><span class="na">UTF_8</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getCharacterEncoding</span><span class="o">());</span>
+<span class="n">assertEquals</span><span class="o">(</span><span class="mi">55</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getContentLength</span><span class="o">());</span>
+
+<span class="c1">// validate headers</span>
+<span class="n">assertTrue</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">containsHeader</span><span class="o">(</span><span class="s">&quot;header1&quot;</span><span class="o">));</span>
+<span class="n">assertEquals</span><span class="o">(</span><span class="s">&quot;5&quot;</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getHeader</span><span class="o">(</span><span class="s">&quot;header2&quot;</span><span class="o">));</span>
+
+<span class="c1">// validate response body as string</span>
+<span class="n">assertEquals</span><span class="o">(</span><span class="n">TEST_CONTENT</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getOutputAsString</span><span class="o">());</span>
+
+<span class="c1">// validate response body as binary data</span>
+<span class="n">assertArrayEquals</span><span class="o">(</span><span class="n">TEST_DATA</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getOutput</span><span class="o">());</span>
+</pre></div>
+</td></tr></table>
+
 <h3 id="import-resource-data-from-json-file-in-classpath">Import resource data from JSON file in classpath</h3>
 <p>With the <code>ContentLoader</code> it is possible to import structured resource and property data from a JSON file stored
 in the classpath beneath the unit tests. This data can be used as text fixture for unit tests.</p>
 <p>Example JSON data:</p>
-<p><code>json
-{
-  "jcr:primaryType": "app:Page",
-  "jcr:content": {
-    "jcr:primaryType": "app:PageContent",
-    "jcr:title": "English",
-    "app:template": "/apps/sample/templates/homepage",
-    "sling:resourceType": "sample/components/homepage",
-    "jcr:createdBy": "admin",
-    "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
-    "par": {
-      "jcr:primaryType": "nt:unstructured",
-      "sling:resourceType": "foundation/components/parsys",
-      "colctrl": {
-        "jcr:primaryType": "nt:unstructured",
-        "layout": "2;colctrl-lt0",
-        "sling:resourceType": "foundation/components/parsys/colctrl"
-      }
-    }
-  }
-}</code></p>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20</pre></div></td><td class="code"><div class="codehilite"><pre><span class="p">{</span>
+  <span class="nt">&quot;jcr:primaryType&quot;</span><span class="p">:</span> <span class="s2">&quot;app:Page&quot;</span><span class="p">,</span>
+  <span class="nt">&quot;jcr:content&quot;</span><span class="p">:</span> <span class="p">{</span>
+    <span class="nt">&quot;jcr:primaryType&quot;</span><span class="p">:</span> <span class="s2">&quot;app:PageContent&quot;</span><span class="p">,</span>
+    <span class="nt">&quot;jcr:title&quot;</span><span class="p">:</span> <span class="s2">&quot;English&quot;</span><span class="p">,</span>
+    <span class="nt">&quot;app:template&quot;</span><span class="p">:</span> <span class="s2">&quot;/apps/sample/templates/homepage&quot;</span><span class="p">,</span>
+    <span class="nt">&quot;sling:resourceType&quot;</span><span class="p">:</span> <span class="s2">&quot;sample/components/homepage&quot;</span><span class="p">,</span>
+    <span class="nt">&quot;jcr:createdBy&quot;</span><span class="p">:</span> <span class="s2">&quot;admin&quot;</span><span class="p">,</span>
+    <span class="nt">&quot;jcr:created&quot;</span><span class="p">:</span> <span class="s2">&quot;Thu Aug 07 2014 16:32:59 GMT+0200&quot;</span><span class="p">,</span>
+    <span class="nt">&quot;par&quot;</span><span class="p">:</span> <span class="p">{</span>
+      <span class="nt">&quot;jcr:primaryType&quot;</span><span class="p">:</span> <span class="s2">&quot;nt:unstructured&quot;</span><span class="p">,</span>
+      <span class="nt">&quot;sling:resourceType&quot;</span><span class="p">:</span> <span class="s2">&quot;foundation/components/parsys&quot;</span><span class="p">,</span>
+      <span class="nt">&quot;colctrl&quot;</span><span class="p">:</span> <span class="p">{</span>
+        <span class="nt">&quot;jcr:primaryType&quot;</span><span class="p">:</span> <span class="s2">&quot;nt:unstructured&quot;</span><span class="p">,</span>
+        <span class="nt">&quot;layout&quot;</span><span class="p">:</span> <span class="s2">&quot;2;colctrl-lt0&quot;</span><span class="p">,</span>
+        <span class="nt">&quot;sling:resourceType&quot;</span><span class="p">:</span> <span class="s2">&quot;foundation/components/parsys/colctrl&quot;</span>
+      <span class="p">}</span>
+    <span class="p">}</span>
+  <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+</td></tr></table>
+
 <p>Example code to import the JSON data:</p>
-<p><code>java
-ResourceResolver resolver = MockSling.newResourceResolver();
-ContentLoader contentLoader = new ContentLoader(resolver);
-contentLoader.json("/sample-data.json", "/content/sample/en");</code></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">ResourceResolver</span> <span class="n">resolver</span> <span class="o">=</span> <span class="n">MockSling</span><span class="o">.</span><span class="na">newResourceResolver</span><span class="o">();</span>
+<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>
+</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>
 <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>
 <p>Example code to import a binary file:</p>
-<p><code>java
-ResourceResolver resolver = MockSling.newResourceResolver();
-ContentLoader contentLoader = new ContentLoader(resolver);
-contentLoader.binaryFile("/sample-file.gif", "/content/binary/sample-file.gif");</code></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">ResourceResolver</span> <span class="n">resolver</span> <span class="o">=</span> <span class="n">MockSling</span><span class="o">.</span><span class="na">newResourceResolver</span><span class="o">();</span>
+<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>
+</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>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1631393 by sseifert on Mon, 13 Oct 2014 13:54:56 +0000
+        Rev. 1631398 by sseifert on Mon, 13 Oct 2014 14:04:03 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project