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:23:05 UTC

svn commit: r925620 - in /websites/staging/sling/trunk/content: ./ documentation/development/ documentation/tutorials-how-tos/

Author: buildbot
Date: Mon Oct 13 14:23:05 2014
New Revision: 925620

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/resourceresolver-mock.html
    websites/staging/sling/trunk/content/documentation/development/sling-mock.html
    websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Oct 13 14:23:05 2014
@@ -1 +1 @@
-1631405
+1631408

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:23:05 2014
@@ -90,7 +90,7 @@
       
       
       <h1>JCR Mock</h1>
-      <p>Mock implementation of selected JCR APIs for easier testing.</p>
+      <p>Mock implementation of selected JCR APIs for easier testing. It stores all data in-memory in a HashMap to ensure instantly creating and destroying of the JCR repository.</p>
 <h2 id="maven-dependency">Maven Dependency</h2>
 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
 2
@@ -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. 1631403 by sseifert on Mon, 13 Oct 2014 14:12:52 +0000
+        Rev. 1631408 by sseifert on Mon, 13 Oct 2014 14:22:57 +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:23:05 2014
@@ -90,7 +90,7 @@
       
       
       <h1>Resource Resolver Mock</h1>
-      <p>Mock for the resource resolver / factory for easier testing.</p>
+      <p>Mock for the resource resolver / factory for easier testing. It uses an in-memory map for storing the resource data, and supports reading, writing and a certain level of transaction and eventing support.</p>
 <h2 id="maven-dependency">Maven Dependency</h2>
 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
 2
@@ -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. 1631403 by sseifert on Mon, 13 Oct 2014 14:12:52 +0000
+        Rev. 1631408 by sseifert on Mon, 13 Oct 2014 14:22:57 +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:23:05 2014
@@ -91,6 +91,34 @@
       
       <h1>Sling Mock</h1>
       <p>Mock implementation of selected Sling APIs for easier testing.</p>
+<div class="toc">
+<ul>
+<li><a href="#maven-dependency">Maven Dependency</a></li>
+<li><a href="#implemented-mock-features">Implemented mock features</a><ul>
+<li><a href="#additional-features">Additional features</a></li>
+</ul>
+</li>
+<li><a href="#usage">Usage</a><ul>
+<li><a href="#sling-context-junit-rule">Sling Context JUnit Rule</a></li>
+<li><a href="#choosing-resource-resolver-mock-type">Choosing Resource Resolver Mock Type</a></li>
+<li><a href="#resource-resolver-types">Resource Resolver Types</a><ul>
+<li><a href="#resourceresolver_mock-default">RESOURCERESOLVER_MOCK (default)</a></li>
+<li><a href="#jcr_mock">JCR_MOCK</a></li>
+<li><a href="#jcr_jackrabbit">JCR_JACKRABBIT</a></li>
+</ul>
+</li>
+<li><a href="#sling-resource-resolver">Sling Resource Resolver</a></li>
+<li><a href="#adapter-factories">Adapter Factories</a></li>
+<li><a href="#slingscripthelper">SlingScriptHelper</a></li>
+<li><a href="#slinghttpservletrequest">SlingHttpServletRequest</a></li>
+<li><a href="#slinghttpservletresponse">SlingHttpServletResponse</a></li>
+<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>
+</ul>
+</li>
+</ul>
+</div>
 <h2 id="maven-dependency">Maven Dependency</h2>
 <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
 2
@@ -526,7 +554,7 @@ resources) and imports the binary data t
 
 <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. 1631405 by sseifert on Mon, 13 Oct 2014 14:15:42 +0000
+        Rev. 1631408 by sseifert on Mon, 13 Oct 2014 14:22:57 +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/tutorials-how-tos/testing-sling-based-applications.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html (original)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html Mon Oct 13 14:23:05 2014
@@ -114,15 +114,8 @@
 <p>The <code>RepositoryProviderTest</code> in that module uses this technique to get a JCR repository.</p>
 <p>Note that our utilities do not cleanup the repository between tests, so you must be careful about test isolation, for example by using unique paths for each test.</p>
 <h2 id="mock-classes-and-services">Mock classes and services</h2>
-<p>The next step is to use mock classes and services to simulate components that are needed for testing. This makes it possible to test OSGi service classes without an OSGi framework.</p>
-<p>We have a number of custom-written mock services in Sling, like <a href="https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/MockNodeType.java">MockNodeType</a> for example. These handwritten mocks implement just what's needed for their tests, so they might not be reusable as is.</p>
-<p>A quite powerful mock implementation of a Sling Resource Resolver (without underlying JCR respository, but mimicking the behavior of the JCR Resource Provider) is provided in <a href="https://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock">testing/resourceresolver-mock</a>. It uses an in-memory map for storing the resource data, and supports reading, writing and a certain level of transaction and eventing support. Usage example:</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">MockResourceResolverFactory</span> <span class="n">factory</span> <span class="o">=</span> <span class="k">new</span> <span class="n">MockResourceResolverFactory</span><span class="o">();</span>
-<span class="n">ResourceResolver</span> <span class="n">resolver</span> <span class="o">=</span> <span class="n">factory</span><span class="o">.</span><span class="na">getResourceResolver</span><span class="o">(</span><span class="kc">null</span><span class="o">);</span>
-</pre></div>
-</td></tr></table>
-
+<p>The next step is to use mock classes and services to simulate components that are needed for testing. This makes it possible to test OSGi service classes without an OSGi framework, or classes accessing the Sling or JCR API without a running Sling instance or JCR repository.</p>
+<p>The <a href="/documentation/development.html">Development</a> documentation page contains a section "Testing Sling-based Applications" lising all mock implementations available as part of the Apache Sling project.</p>
 <p>In other cases we use <a href="http://www.jmock.org/">jmock</a> or <a href="https://code.google.com/p/mockito/">Mockito</a> to help create mock objects without having to write much code - such mocking libraries take care of the plumbing and allow you to write just the bits of code that matter (often with funny syntaxes). The tests of the <a href="https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/event/">org.apache.sling.event</a> bundle, for example, make extensive use of such mock services.</p>
 <p>The problem with mocks is that it can become hard to make sure you're actually testing something, and not just "mocking mocks". At a certain level of complexity, it becomes quicker and clearer to actually start an OSGi framework for automated tests.</p>
 <h3 id="side-note-injecting-services-in-private-fields">Side note: injecting services in private fields</h3>
@@ -162,7 +155,7 @@ such as the <a href="http://junit-addons
 <h2 id="summary">Summary</h2>
 <p>Combining the above testing techniques has worked well for us in creating and testing Sling. Being able to test things at different levels of integration has proved an efficient way to get good test coverage without having to write too much boring test code.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1627361 by sseifert on Wed, 24 Sep 2014 16:24:21 +0000
+        Rev. 1631408 by sseifert on Mon, 13 Oct 2014 14:22:57 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project