sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sseif...@apache.org
Subject svn commit: r1627360 - /sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
Date Wed, 24 Sep 2014 16:22:37 GMT
Author: sseifert
Date: Wed Sep 24 16:22:37 2014
New Revision: 1627360

URL: http://svn.apache.org/r1627360
Log:
SLING-3969 add hint to testing/resourceresolver-mock

Modified:
    sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext

Modified: sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext?rev=1627360&r1=1627359&r2=1627360&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
(original)
+++ sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
Wed Sep 24 16:22:37 2014
@@ -26,6 +26,12 @@ The next step is to use mock classes and
 
 We have a number of custom-written mock services in Sling, like [MockNodeType](https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/MockNodeType.java)
for example. These handwritten mocks implement just what's needed for their tests, so they
might not be reusable as is.
 
+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 [testing/resourceresolver-mock](https://svn.eu.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock).
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:
+
+    #!java
+    MockResourceResolverFactory factory = new MockResourceResolverFactory();
+    ResourceResolver resolver = factory.getResourceResolver(null);
+
 In other cases we use [jmock](http://www.jmock.org/) or [Mockito][1] 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 [org.apache.sling.event](https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/event/)
bundle, for example, make extensive use of such mock services.
 
 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.



Mime
View raw message