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 15:55:11 UTC

svn commit: r925610 - in /websites/staging/sling/trunk/content: ./ documentation/ documentation/development/

Author: buildbot
Date: Mon Oct 13 13:55:11 2014
New Revision: 925610

Log:
Staging update by buildbot for sling

Added:
    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
Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/development.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Oct 13 13:55:11 2014
@@ -1 +1 @@
-1631346
+1631393

Modified: websites/staging/sling/trunk/content/documentation/development.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development.html (original)
+++ websites/staging/sling/trunk/content/documentation/development.html Mon Oct 13 13:55:11 2014
@@ -100,9 +100,16 @@
 <li><a href="/documentation/development/client-request-logging.html">Client Request Logging</a></li>
 <li><a href="/documentation/development/monitoring-requests.html">Monitoring Requests</a></li>
 <li><a href="/documentation/development/repository-based-development.html">Repository Based Development</a></li>
-<li><a href="/documentation/development/sling-testing-tools.html">Sling Testing Tools</a></li>
 <li><a href="/documentation/development/ide-tooling.html">Sling IDE Tooling</a></li>
 </ul>
+<h2 id="testing-sling-based-applications">Testing Sling-based Applications</h2>
+<ul>
+<li><a href="/documentation/development/sling-testing-tools.html">Sling Testing Tools</a></li>
+<li><a href="/documentation/development/resourceresolver-mock.html">Resource Resolver Mock</a></li>
+<li><a href="/documentation/development/sling-mock.html">Sling Mock</a></li>
+<li><a href="/documentation/development/osgi-mock.html">OSGi Mock</a></li>
+<li><a href="/documentation/development/jcr-mock.html">JCR Mock</a></li>
+</ul>
 <h2 id="maven-stuff">Maven Stuff</h2>
 <p>Sling is using Apache Maven 3 as its build system. Over time we have created a number of Maven 3 plugins and gathered a whole range of knowledge about using Maven.</p>
 <ul>
@@ -123,7 +130,7 @@
 <li>A Sonar analysis is available on the <a href="https://analysis.apache.org/dashboard/index/org.apache.sling:sling-builder">analysis.apache.org</a> server.</li>
 </ul>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1607072 by rombert on Tue, 1 Jul 2014 13:35:08 +0000
+        Rev. 1631393 by sseifert on Mon, 13 Oct 2014 13:54:56 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Added: websites/staging/sling/trunk/content/documentation/development/jcr-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/jcr-mock.html (added)
+++ websites/staging/sling/trunk/content/documentation/development/jcr-mock.html Mon Oct 13 13:55:11 2014
@@ -0,0 +1,140 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - JCR Mock</title>
+    <link rel="icon" href="/res/favicon.ico">
+    <link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
+    <link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/">
+          <img border="0" alt="Apache Sling" src="/res/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="/res/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <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 />
+<a href="/documentation/bundles.html">Bundles</a> <br />
+<a href="/documentation/tutorials-how-tos.html">Tutorials &amp; How-Tos</a> <br />
+<a href="/documentation/configuration.html">Configuration</a>   </p>
+<p><a href="http://s.apache.org/sling.wiki">Wiki</a> <br />
+<a href="http://s.apache.org/sling.faq">FAQ</a>   </p>
+<p><strong>API Docs</strong>  <br />
+<a href="/apidocs/sling7/index.html">Sling 7</a> <br />
+<a href="/apidocs/sling6/index.html">Sling 6</a> <br />
+<a href="/apidocs/sling5/index.html">Sling 5</a>   </p>
+<p><strong>Project info</strong> <br />
+<a href="/downloads.cgi">Downloads</a> <br />
+<a href="http://www.apache.org/licenses/">License</a> <br />
+<a href="/contributing.html">Contributing</a> <br />
+<a href="/news.html">News</a> <br />
+<a href="/links.html">Links</a> <br />
+<a href="/project-information.html">Project Information</a> <br />
+<a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a> <br />
+<a href="http://ci.apache.org/builders/sling-trunk">Build Server</a> <br />
+<a href="/project-information/security.html">Security</a>   </p>
+<p><strong>Source</strong> <br />
+<a href="http://svn.apache.org/viewvc/sling/trunk">Subversion</a> <br />
+<a href="git://git.apache.org/sling.git">Git</a> <br />
+<a href="https://github.com/apache/sling">Github Mirror</a>   </p>
+<p><strong>Sponsorship</strong> <br />
+<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a> <br />
+<a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a>   </p>
+<p><strong><a href="/sitemap.html">Site Map</a></strong></p>
+<!-- no valid ads for now, we'll  reactivate this when needed
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+-->
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/development.html">Development</a>
+      </div>
+
+      
+      
+      <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>
+<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>
+<ul>
+<li>Reading and writing all data (primitive values, arrays, binary data) via the JCR API</li>
+<li>Creating any number of nodes and properties (stored in-memory in a hash map)</li>
+<li>Register namespaces</li>
+</ul>
+<p>The following features are <em>not supported</em>:</p>
+<ul>
+<li>Node types are supported in the API, but their definitions and constraints are not applied</li>
+<li>Versioning not supported</li>
+<li>Search not supported</li>
+<li>Transactions not supported</li>
+<li>Observation events can be registered but are ignored</li>
+<li>Access control always grants access</li>
+<li>Exporting/Importing data via document and system views not supported </li>
+<li>Workspace management methods not supported</li>
+</ul>
+<h2 id="usage">Usage</h2>
+<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>
+<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
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/documentation/development/osgi-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/osgi-mock.html (added)
+++ websites/staging/sling/trunk/content/documentation/development/osgi-mock.html Mon Oct 13 13:55:11 2014
@@ -0,0 +1,167 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - OSGi Mock</title>
+    <link rel="icon" href="/res/favicon.ico">
+    <link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
+    <link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/">
+          <img border="0" alt="Apache Sling" src="/res/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="/res/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <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 />
+<a href="/documentation/bundles.html">Bundles</a> <br />
+<a href="/documentation/tutorials-how-tos.html">Tutorials &amp; How-Tos</a> <br />
+<a href="/documentation/configuration.html">Configuration</a>   </p>
+<p><a href="http://s.apache.org/sling.wiki">Wiki</a> <br />
+<a href="http://s.apache.org/sling.faq">FAQ</a>   </p>
+<p><strong>API Docs</strong>  <br />
+<a href="/apidocs/sling7/index.html">Sling 7</a> <br />
+<a href="/apidocs/sling6/index.html">Sling 6</a> <br />
+<a href="/apidocs/sling5/index.html">Sling 5</a>   </p>
+<p><strong>Project info</strong> <br />
+<a href="/downloads.cgi">Downloads</a> <br />
+<a href="http://www.apache.org/licenses/">License</a> <br />
+<a href="/contributing.html">Contributing</a> <br />
+<a href="/news.html">News</a> <br />
+<a href="/links.html">Links</a> <br />
+<a href="/project-information.html">Project Information</a> <br />
+<a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a> <br />
+<a href="http://ci.apache.org/builders/sling-trunk">Build Server</a> <br />
+<a href="/project-information/security.html">Security</a>   </p>
+<p><strong>Source</strong> <br />
+<a href="http://svn.apache.org/viewvc/sling/trunk">Subversion</a> <br />
+<a href="git://git.apache.org/sling.git">Git</a> <br />
+<a href="https://github.com/apache/sling">Github Mirror</a>   </p>
+<p><strong>Sponsorship</strong> <br />
+<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a> <br />
+<a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a>   </p>
+<p><strong><a href="/sitemap.html">Site Map</a></strong></p>
+<!-- no valid ads for now, we'll  reactivate this when needed
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+-->
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/development.html">Development</a>
+      </div>
+
+      
+      
+      <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>
+<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>
+<ul>
+<li>Instantiating OSGi <code>Bundle</code>, <code>BundleContext</code> and <code>ComponentContext</code> objects and navigate between them.</li>
+<li>Read and write properties on them.</li>
+<li>Register OSGi services and get references to service instances</li>
+<li>Service and bundle listener implementation</li>
+<li>When adding services to BundleContext OSGi metadata from <code>/OSGI-INF/&lt;pid&gt;.xml</code> is read (e.g. for service ranking property)</li>
+<li>Mock implementation of <code>LogService</code> which logs to SLF4J in JUnit context</li>
+</ul>
+<p>The following features are <em>not supported</em>:</p>
+<ul>
+<li>Activation and deactivation methods of services are not called automatically (but helper methods exist)</li>
+<li>Dependency injection does not take place automatically (but helper methods exist)</li>
+</ul>
+<h2 id="usage">Usage</h2>
+<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>
+<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>
+<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>
+<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
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/documentation/development/resourceresolver-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/resourceresolver-mock.html (added)
+++ websites/staging/sling/trunk/content/documentation/development/resourceresolver-mock.html Mon Oct 13 13:55:11 2014
@@ -0,0 +1,136 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Resource Resolver Mock</title>
+    <link rel="icon" href="/res/favicon.ico">
+    <link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
+    <link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/">
+          <img border="0" alt="Apache Sling" src="/res/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="/res/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <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 />
+<a href="/documentation/bundles.html">Bundles</a> <br />
+<a href="/documentation/tutorials-how-tos.html">Tutorials &amp; How-Tos</a> <br />
+<a href="/documentation/configuration.html">Configuration</a>   </p>
+<p><a href="http://s.apache.org/sling.wiki">Wiki</a> <br />
+<a href="http://s.apache.org/sling.faq">FAQ</a>   </p>
+<p><strong>API Docs</strong>  <br />
+<a href="/apidocs/sling7/index.html">Sling 7</a> <br />
+<a href="/apidocs/sling6/index.html">Sling 6</a> <br />
+<a href="/apidocs/sling5/index.html">Sling 5</a>   </p>
+<p><strong>Project info</strong> <br />
+<a href="/downloads.cgi">Downloads</a> <br />
+<a href="http://www.apache.org/licenses/">License</a> <br />
+<a href="/contributing.html">Contributing</a> <br />
+<a href="/news.html">News</a> <br />
+<a href="/links.html">Links</a> <br />
+<a href="/project-information.html">Project Information</a> <br />
+<a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a> <br />
+<a href="http://ci.apache.org/builders/sling-trunk">Build Server</a> <br />
+<a href="/project-information/security.html">Security</a>   </p>
+<p><strong>Source</strong> <br />
+<a href="http://svn.apache.org/viewvc/sling/trunk">Subversion</a> <br />
+<a href="git://git.apache.org/sling.git">Git</a> <br />
+<a href="https://github.com/apache/sling">Github Mirror</a>   </p>
+<p><strong>Sponsorship</strong> <br />
+<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a> <br />
+<a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a>   </p>
+<p><strong><a href="/sitemap.html">Site Map</a></strong></p>
+<!-- no valid ads for now, we'll  reactivate this when needed
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+-->
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/development.html">Development</a>
+      </div>
+
+      
+      
+      <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>
+<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>
+<ul>
+<li>All read and write operations of the Sling Resource API</li>
+<li>Mimicks transactions using via commit()/revert() methods</li>
+<li>OSGi events for adding/changing/removing resources</li>
+<li>The implementation tries to be as close as possible to the behavior of the JCR resource implementation e.g. concerning date and binary handling</li>
+</ul>
+<p>The following features are <em>not supported</em>:</p>
+<ul>
+<li>Authentication not supported ("login" always possible with null authentication info)</li>
+<li>Querying with qeuryResources/findResources not supported (always returns empty result set)</li>
+<li>Sling Mapping is not supported</li>
+<li>Resolving resouce super types</li>
+</ul>
+<h2 id="usage">Usage</h2>
+<p>To create a mocked resource resolver:</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>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
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>

Added: websites/staging/sling/trunk/content/documentation/development/sling-mock.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/sling-mock.html (added)
+++ websites/staging/sling/trunk/content/documentation/development/sling-mock.html Mon Oct 13 13:55:11 2014
@@ -0,0 +1,361 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  <head>
+    <title>Apache Sling - Sling Mock</title>
+    <link rel="icon" href="/res/favicon.ico">
+    <link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
+    <link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+  </head>
+  <body>
+    <div class="title">
+      <div class="logo">
+        <a href="http://sling.apache.org/">
+          <img border="0" alt="Apache Sling" src="/res/logo.png">
+        </a>
+      </div>
+      <div class="header">
+        <a href="http://www.apache.org/">
+          <img border="0" alt="Apache" src="/res/apache.png">
+        </a>
+      </div>
+    </div>
+    
+    <div class="menu"> 
+      <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 />
+<a href="/documentation/bundles.html">Bundles</a> <br />
+<a href="/documentation/tutorials-how-tos.html">Tutorials &amp; How-Tos</a> <br />
+<a href="/documentation/configuration.html">Configuration</a>   </p>
+<p><a href="http://s.apache.org/sling.wiki">Wiki</a> <br />
+<a href="http://s.apache.org/sling.faq">FAQ</a>   </p>
+<p><strong>API Docs</strong>  <br />
+<a href="/apidocs/sling7/index.html">Sling 7</a> <br />
+<a href="/apidocs/sling6/index.html">Sling 6</a> <br />
+<a href="/apidocs/sling5/index.html">Sling 5</a>   </p>
+<p><strong>Project info</strong> <br />
+<a href="/downloads.cgi">Downloads</a> <br />
+<a href="http://www.apache.org/licenses/">License</a> <br />
+<a href="/contributing.html">Contributing</a> <br />
+<a href="/news.html">News</a> <br />
+<a href="/links.html">Links</a> <br />
+<a href="/project-information.html">Project Information</a> <br />
+<a href="https://issues.apache.org/jira/browse/SLING">Issue Tracker</a> <br />
+<a href="http://ci.apache.org/builders/sling-trunk">Build Server</a> <br />
+<a href="/project-information/security.html">Security</a>   </p>
+<p><strong>Source</strong> <br />
+<a href="http://svn.apache.org/viewvc/sling/trunk">Subversion</a> <br />
+<a href="git://git.apache.org/sling.git">Git</a> <br />
+<a href="https://github.com/apache/sling">Github Mirror</a>   </p>
+<p><strong>Sponsorship</strong> <br />
+<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> <br />
+<a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a> <br />
+<a href="http://www.apache.org/foundation/buy_stuff.html">Buy Stuff</a>   </p>
+<p><strong><a href="/sitemap.html">Site Map</a></strong></p>
+<!-- no valid ads for now, we'll  reactivate this when needed
+<iframe 
+    src="http://www.apache.org/ads/button.html"
+    style="border-width:0; float: left" frameborder="0" 
+    scrolling="no"
+    width="135" 
+    height="135">
+</iframe>
+-->
+    </div>
+    
+    <div class="main">
+      <div class="breadcrump" style="font-size: 80%;">
+        <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/development.html">Development</a>
+      </div>
+
+      
+      
+      <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>
+<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>
+<ul>
+<li><code>ResourceResolver</code> implementation for reading and writing resource data using the Sling Resource API<ul>
+<li>Backed by a <a href="/documentation/development/jcr-mock.html">mocked</a> or real Jackrabbit JCR 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>Alternatively the non-JCR mock implementation provided by the 
+   <a href="/documentation/development/resourceresolver-mock.html">Sling resourceresolver-mock implementation</a> can be used</li>
+</ul>
+</li>
+<li><code>AdpaterManager</code> implementation for registering adapter factories and resolving adaptions<ul>
+<li>The implementation is thread-safe so it can be used in parallel running unit tests</li>
+</ul>
+</li>
+<li><code>SlingScriptHelper</code> implementation providing access to mocked request/response objects and supports getting
+   OSGi services from the <a href="/documentation/development/osgi-mock.html">mocked OSGi</a> environment.</li>
+<li>Implementations of the servlet-related Sling API classes like <code>SlingHttpServletRequest</code> and <code>SlingHttpServletRequest</code><ul>
+<li>It is possible to set request data to simulate a certian Sling HTTP request</li>
+</ul>
+</li>
+<li>Additional services like <code>MockModelAdapterFactory</code> and  <code>MimeTypeService</code> </li>
+</ul>
+<p>The following features are <em>not supported</em>:</p>
+<ul>
+<li>It is not possible (nor intended) to really execute sling components/scripts and render their results.<ul>
+<li>The goal is to test supporting classes in Sling context, not the sling components/scripts themselves</li>
+</ul>
+</li>
+</ul>
+<h3 id="additional-features">Additional features</h3>
+<p>Additional features provided:</p>
+<ul>
+<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>
+</ul>
+</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>
+<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>
+<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>
+<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>
+<ul>
+<li>OSGi Component Context</li>
+<li>OSGi Bundle Context</li>
+<li>Sling Resource Resolver</li>
+<li>Sling Request</li>
+<li>Sling Response</li>
+<li>Sling Script Helper</li>
+</ul>
+<p>Additionally it supports:</p>
+<ul>
+<li>Registering OSGi services</li>
+<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>
+<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>
+<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.
+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>
+<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>
+<li>You can use it to make sure the code you want to test does not contain references to JCR API.</li>
+<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>
+<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>
+<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>
+<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>Takes some seconds for startup on the first access </li>
+<li>All node types that are used when reading/writing data have to be registered</li>
+</ul>
+<p><em>Warnings/Remarks</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>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>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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
+      </div>
+      <div class="trademarkFooter"> 
+        Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
+        logo are trademarks of The Apache Software Foundation. All other marks mentioned
+        may be trademarks or registered trademarks of their respective owners.
+      </div>
+    </div>
+  </body>
+</html>