Author: buildbot Date: Fri Sep 18 13:38:39 2015 New Revision: 965904 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 Fri Sep 18 13:38:39 2015 @@ -1 +1 @@ -1703508 +1703847 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 Fri Sep 18 13:38:39 2015 @@ -39,7 +39,18 @@ </div> <div class="menu"> - <p><strong><a href="/documentation.html">Documentation</a></strong> <br /> + <style type="text/css"> +/* The following code is added by mdx_elementid.py + It was originally lifted from http://subversion.apache.org/style/site.css */ +/* + * Hide class="elementid-permalink", except when an enclosing heading + * has the :hover property. + */ +.headerlink, .elementid-permalink { + visibility: hidden; +} +h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style> +<p><strong><a href="/documentation.html">Documentation</a></strong> <br /> <a href="/documentation/getting-started.html">Getting Started</a> <br /> <a href="/documentation/the-sling-engine.html">The Sling Engine</a> <br /> <a href="/documentation/development.html">Development</a> <br /> @@ -90,7 +101,18 @@ <h1>Sling Mocks</h1> - <p>Mock implementation of selected Sling APIs for easier testing.</p> + <style type="text/css"> +/* The following code is added by mdx_elementid.py + It was originally lifted from http://subversion.apache.org/style/site.css */ +/* + * Hide class="elementid-permalink", except when an enclosing heading + * has the :hover property. + */ +.headerlink, .elementid-permalink { + visibility: hidden; +} +h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style> +<p>Mock implementation of selected Sling APIs for easier testing.</p> <div class="toc"> <ul> <li><a href="#maven-dependency">Maven Dependency</a></li> @@ -114,7 +136,7 @@ </li> </ul> </div> -<h2 id="maven-dependency">Maven Dependency</h2> +<h2 id="maven-dependency">Maven Dependency<a class="headerlink" href="#maven-dependency" title="Permanent link">¶</a></h2> <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 @@ -126,7 +148,7 @@ </td></tr></table> <p>See latest version on the <a href="/downloads.cgi">downloads page</a>.</p> -<h2 id="implemented-mock-features">Implemented mock features</h2> +<h2 id="implemented-mock-features">Implemented mock features<a class="headerlink" href="#implemented-mock-features" title="Permanent link">¶</a></h2> <p>The mock implementation supports:</p> <ul> <li><code>ResourceResolver</code> implementation for reading and writing resource data using the Sling Resource API<ul> @@ -155,7 +177,7 @@ </ul> </li> </ul> -<h3 id="additional-features">Additional features</h3> +<h3 id="additional-features">Additional features<a class="headerlink" href="#additional-features" title="Permanent link">¶</a></h3> <p>Additional features provided:</p> <ul> <li><code>SlingContext</code> JUnit Rule for easily setting up a Sling Mock environment in your JUnit test cases</li> @@ -166,8 +188,8 @@ </li> <li><code>ContentBuilder</code> makes it easier to create resources and properties as test fixture</li> </ul> -<h2 id="usage">Usage</h2> -<h3 id="sling-context-junit-rule">Sling Context JUnit Rule</h3> +<h2 id="usage">Usage<a class="headerlink" href="#usage" title="Permanent link">¶</a></h2> +<h3 id="sling-context-junit-rule">Sling Context JUnit Rule<a class="headerlink" href="#sling-context-junit-rule" title="Permanent link">¶</a></h3> <p>The Sling mock context can be injected into a JUnit test using a custom JUnit rule named <code>SlingContext</code>. 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> @@ -215,7 +237,7 @@ independently (and in parallel, if requi <li>Registering adapter factories</li> <li>Accessing Content Loader and Content Builder</li> </ul> -<h3 id="choosing-resource-resolver-mock-type">Choosing Resource Resolver Mock Type</h3> +<h3 id="choosing-resource-resolver-mock-type">Choosing Resource Resolver Mock Type<a class="headerlink" href="#choosing-resource-resolver-mock-type" title="Permanent link">¶</a></h3> <p>The Sling mock context supports different resource resolver types. Example:</p> <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 @@ -232,7 +254,7 @@ 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> -<h3 id="resource-resolver-types">Resource Resolver Types</h3> +<h3 id="resource-resolver-types">Resource Resolver Types<a class="headerlink" href="#resource-resolver-types" title="Permanent link">¶</a></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 is stored in-memory or in a real repository.</p> @@ -303,12 +325,12 @@ repository.</p> <p>This version is not yet released.</p> <p><em>Remarks on the JCR_JACKRABBIT and JCR_OAK types:</em></p> <ul> -<li>The repository is not cleared for each unit test, so make sure us use a unique node path for each unit test.</li> +<li>The repository is not cleared for each unit test, so make sure to use a unique node path for each unit test.</li> <li>To import Sling content you have to fully register all node types required for the data</li> <li>The <a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/testing">sling/commons/testing</a> dependency introduces a lot of further dependencies from jackrabbit and others, be careful that they do not conflict and are imported in the right order in your test project</li> </ul> -<h3 id="sling-resource-resolver">Sling Resource Resolver</h3> +<h3 id="sling-resource-resolver">Sling Resource Resolver<a class="headerlink" href="#sling-resource-resolver" title="Permanent link">¶</a></h3> <p>Example:</p> <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 @@ -323,7 +345,7 @@ repository.</p> </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> +<h3 id="adapter-factories">Adapter Factories<a class="headerlink" href="#adapter-factories" title="Permanent link">¶</a></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> <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1 @@ -351,7 +373,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> +<h3 id="slingscripthelper">SlingScriptHelper<a class="headerlink" href="#slingscripthelper" title="Permanent link">¶</a></h3> <p>Example:</p> <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 @@ -375,7 +397,7 @@ interfere with the following tests. If y <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> +<h3 id="slinghttpservletrequest">SlingHttpServletRequest<a class="headerlink" href="#slinghttpservletrequest" title="Permanent link">¶</a></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 2 @@ -443,7 +465,7 @@ existing instances of request, response </pre></div> </td></tr></table> -<h3 id="slinghttpservletresponse">SlingHttpServletResponse</h3> +<h3 id="slinghttpservletresponse">SlingHttpServletResponse<a class="headerlink" href="#slinghttpservletresponse" title="Permanent link">¶</a></h3> <p>Example for preparing a sling response which can collect the data that was written to it:</p> <table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1 2 @@ -491,7 +513,7 @@ existing instances of request, response </pre></div> </td></tr></table> -<h3 id="import-resource-data-from-json-file-in-classpath">Import resource data from JSON file in classpath</h3> +<h3 id="import-resource-data-from-json-file-in-classpath">Import resource data from JSON file in classpath<a class="headerlink" href="#import-resource-data-from-json-file-in-classpath" title="Permanent link">¶</a></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> @@ -547,7 +569,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> +<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">¶</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> @@ -560,7 +582,7 @@ The data is stored using a nt:file/nt:re <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> +<h3 id="building-content">Building content<a class="headerlink" href="#building-content" title="Permanent link">¶</a></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 @@ -577,7 +599,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. 1682056 by rombert on Wed, 27 May 2015 15:13:12 +0000 + Rev. 1703847 by sseifert on Fri, 18 Sep 2015 13:38:24 +0000 </div> <div class="trademarkFooter"> Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project