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.
<dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId> </dependency>
See latest version on the downloads page.
The mock implementation supports:
The following features are not supported:
To create a mocked resource resolver:
MockResourceResolverFactory factory = new MockResourceResolverFactory(); ResourceResolver resolver = factory.getResourceResolver(null);
With the resolver you can use all Sling Resource features including reading and writing data using the Sling API.
You cannot do any operations that require the JCR API because no JCR is underlying and adapting to JCR objects will just return null.