You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:19:50 UTC

[sling-org-apache-sling-testing-resourceresolver-mock] annotated tag org.apache.sling.testing.resourceresolver-mock-0.1.0 created (now f37f5a4)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.testing.resourceresolver-mock-0.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git.


      at f37f5a4  (tag)
 tagging 502d7f4deeb42437d98e6f3fb6eb3753d677f3ff (commit)
      by Carsten Ziegeler
      on Thu Apr 18 06:10:02 2013 +0000

- Log -----------------------------------------------------------------
org.apache.sling.testing.resourceresolver-mock-0.1.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new cb4683b  Add new testing module for easy mocking of a resource resolver
     new 3f7aa2f  Prepare release
     new 831dff1  [maven-release-plugin] prepare release org.apache.sling.testing.resourceresolver-mock-0.1.0
     new 502d7f4  [maven-release-plugin]  copy for tag org.apache.sling.testing.resourceresolver-mock-0.1.0

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-testing-resourceresolver-mock] 02/04: Prepare release

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.testing.resourceresolver-mock-0.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git

commit 3f7aa2f483d42991884d2c8f1f6f649581c44429
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Apr 18 06:09:22 2013 +0000

    Prepare release
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock@1469174 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 2e149dd..7818d91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,7 +58,7 @@
          <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.4.1-SNAPSHOT</version>
+            <version>2.4.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-testing-resourceresolver-mock] 04/04: [maven-release-plugin] copy for tag org.apache.sling.testing.resourceresolver-mock-0.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.testing.resourceresolver-mock-0.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git

commit 502d7f4deeb42437d98e6f3fb6eb3753d677f3ff
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Apr 18 06:10:02 2013 +0000

    [maven-release-plugin]  copy for tag org.apache.sling.testing.resourceresolver-mock-0.1.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.resourceresolver-mock-0.1.0@1469176 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-testing-resourceresolver-mock] 03/04: [maven-release-plugin] prepare release org.apache.sling.testing.resourceresolver-mock-0.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.testing.resourceresolver-mock-0.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git

commit 831dff1c2b96c8020e48c6df10a25e7502d10484
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Apr 18 06:09:51 2013 +0000

    [maven-release-plugin] prepare release org.apache.sling.testing.resourceresolver-mock-0.1.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock@1469175 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7818d91..6981dc1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
-    <version>0.0.1-SNAPSHOT</version>
+    <version>0.1.0</version>
 
     <name>Apache Sling Testing Resource Resolver Mock</name>
     <description>
@@ -36,9 +36,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/testing/resourceresolver-mock</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.resourceresolver-mock-0.1.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.testing.resourceresolver-mock-0.1.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.testing.resourceresolver-mock-0.1.0</url>
     </scm>
 
     <reporting>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-testing-resourceresolver-mock] 01/04: Add new testing module for easy mocking of a resource resolver

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.testing.resourceresolver-mock-0.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git

commit cb4683b08937877dad4c89f3caa53e7e46873e43
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 17 07:39:28 2013 +0000

    Add new testing module for easy mocking of a resource resolver
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock@1468784 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  74 +++++
 .../testing/resourceresolver/MockResource.java     |  90 ++++++
 .../resourceresolver/MockResourceResolver.java     | 325 +++++++++++++++++++++
 .../MockResourceResolverFactory.java               |  56 ++++
 4 files changed, 545 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2e149dd
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>15</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+
+    <name>Apache Sling Testing Resource Resolver Mock</name>
+    <description>
+        Mock for the resource resolver / factory for easier testing.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/resourceresolver-mock</url>
+    </scm>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>
+                        org.apache.sling.testing.resourceresolver
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+    <dependencies>
+         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.4.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/testing/resourceresolver/MockResource.java b/src/main/java/org/apache/sling/testing/resourceresolver/MockResource.java
new file mode 100644
index 0000000..d99db9c
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/resourceresolver/MockResource.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+package org.apache.sling.testing.resourceresolver;
+
+import java.util.Map;
+
+import org.apache.sling.api.resource.AbstractResource;
+import org.apache.sling.api.resource.ModifiableValueMap;
+import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.wrappers.ModifiableValueMapDecorator;
+import org.apache.sling.api.wrappers.ValueMapDecorator;
+
+public class MockResource extends AbstractResource {
+
+    private final String path;
+
+    private final Map<String, Object> props;
+
+    private final ResourceMetadata rm = new ResourceMetadata();
+
+    private final ResourceResolver resolver;
+
+    public MockResource(final String path,
+            final Map<String, Object> props,
+            final ResourceResolver resolver) {
+        this.path = path;
+        this.props = props;
+        this.resolver = resolver;
+    }
+
+    @Override
+    public String getPath() {
+        return this.path;
+    }
+
+    @Override
+    public String getResourceType() {
+        return (String)this.props.get(ResourceResolver.PROPERTY_RESOURCE_TYPE);
+    }
+
+    @Override
+    public String getResourceSuperType() {
+        return (String)this.props.get("sling:resourceSuperType");
+    }
+
+    @Override
+    public ResourceMetadata getResourceMetadata() {
+        return rm;
+    }
+
+    @Override
+    public ResourceResolver getResourceResolver() {
+        return this.resolver;
+    }
+
+    @Override
+    public <AdapterType> AdapterType adaptTo(final Class<AdapterType> type) {
+        if ( type == ValueMap.class ) {
+            return (AdapterType)new ValueMapDecorator(this.props);
+        } else if ( type == ModifiableValueMap.class ) {
+            ((MockResourceResolver)this.resolver).addChanged(this.path, this.props);
+            return (AdapterType)new ModifiableValueMapDecorator(this.props);
+        }
+        return super.adaptTo(type);
+    }
+
+    @Override
+    public String toString() {
+        return "MockResource [path=" + path + ", props=" + props + "]";
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
new file mode 100644
index 0000000..0414374
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
@@ -0,0 +1,325 @@
+/*
+ * 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.
+ */
+package org.apache.sling.testing.resourceresolver;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.api.SlingConstants;
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+
+public class MockResourceResolver implements ResourceResolver {
+
+    private final Map<String, Map<String, Object>> resources;
+
+    private final Map<String, Map<String, Object>> temporaryResources = new HashMap<String, Map<String,Object>>();
+
+    private final Set<String> deletedResources = new HashSet<String>();
+
+    private final EventAdmin eventAdmin;
+
+    public MockResourceResolver(final EventAdmin eventAdmin,
+            final Map<String, Map<String, Object>> resources) {
+        this.eventAdmin = eventAdmin;
+        this.resources = resources;
+    }
+
+    @Override
+    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
+        return null;
+    }
+
+    @Override
+    public Resource resolve(final HttpServletRequest request, final String absPath) {
+        return this.getResource(absPath);
+    }
+
+    @Override
+    public Resource resolve(final String absPath) {
+        return this.getResource(absPath);
+    }
+
+    @Override
+    @Deprecated
+    public Resource resolve(final HttpServletRequest request) {
+        return null;
+    }
+
+    @Override
+    public String map(final String resourcePath) {
+        return resourcePath;
+    }
+
+    @Override
+    public String map(final HttpServletRequest request, final String resourcePath) {
+        return resourcePath;
+    }
+
+    @Override
+    public Resource getResource(final String path) {
+        if ( path.startsWith("/") ) {
+            if ( this.deletedResources.contains(path) ) {
+                return null;
+            }
+            final Map<String, Object> tempProps = this.temporaryResources.get(path);
+            if ( tempProps != null ) {
+                final Resource rsrc = new MockResource(path, tempProps, this);
+                return rsrc;
+            }
+            synchronized ( this.resources ) {
+                final Map<String, Object> props = this.resources.get(path);
+                if ( props != null ) {
+                    final Resource rsrc = new MockResource(path, props, this);
+                    return rsrc;
+                }
+            }
+        } else {
+            for(final String s : this.getSearchPath() ) {
+                final Resource rsrc = this.getResource(s + '/' + path);
+                if ( rsrc != null ) {
+                    return rsrc;
+                }
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public Resource getResource(Resource base, String path) {
+        if ( path == null || path.length() == 0 ) {
+            path = "/";
+        }
+        if ( path.startsWith("/") ) {
+            return getResource(path);
+        }
+        if ( base.getPath().equals("/") ) {
+            return getResource(base.getPath() + path);
+        }
+        return getResource(base.getPath() + '/' + path);
+    }
+
+    @Override
+    public String[] getSearchPath() {
+        return new String[] {"/libs", "/apps"};
+    }
+
+    @Override
+    public Iterator<Resource> listChildren(final Resource parent) {
+        final String prefixPath = parent.getPath() + "/";
+        final Map<String, Map<String, Object>> candidates = new HashMap<String, Map<String,Object>>();
+        synchronized ( this.resources ) {
+            for(final Map.Entry<String, Map<String, Object>> e : this.resources.entrySet()) {
+                if (e.getKey().startsWith(prefixPath) && e.getKey().lastIndexOf('/') < prefixPath.length() ) {
+                    if ( !this.deletedResources.contains(e.getKey()) ) {
+                        candidates.put(e.getKey(), e.getValue());
+                    }
+                }
+            }
+            for(final Map.Entry<String, Map<String, Object>> e : this.temporaryResources.entrySet()) {
+                if (e.getKey().startsWith(prefixPath) && e.getKey().lastIndexOf('/') < prefixPath.length() ) {
+                    if ( !this.deletedResources.contains(e.getKey()) ) {
+                        candidates.put(e.getKey(), e.getValue());
+                    }
+                }
+            }
+        }
+        final List<Resource> children = new ArrayList<Resource>();
+        for(final Map.Entry<String, Map<String, Object>> e : candidates.entrySet()) {
+            children.add(new MockResource(e.getKey(), e.getValue(), this));
+        }
+        return children.iterator();
+    }
+
+    @Override
+    public Iterable<Resource> getChildren(final Resource parent) {
+        return new Iterable<Resource>() {
+
+            @Override
+            public Iterator<Resource> iterator() {
+                return listChildren(parent);
+            }
+        };
+    }
+
+    @Override
+    public Iterator<Resource> findResources(final String query, final String language) {
+        final List<Resource> emptyList = Collections.emptyList();
+        return emptyList.iterator();
+    }
+
+    @Override
+    public Iterator<Map<String, Object>> queryResources(String query,
+            String language) {
+        final List<Map<String, Object>> emptyList = Collections.emptyList();
+        return emptyList.iterator();
+    }
+
+    @Override
+    public ResourceResolver clone(Map<String, Object> authenticationInfo)
+            throws LoginException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean isLive() {
+        return true;
+    }
+
+    @Override
+    public void close() {
+        // nothing to do
+    }
+
+    @Override
+    public String getUserID() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Iterator<String> getAttributeNames() {
+        final List<String> emptyList = Collections.emptyList();
+        return emptyList.iterator();
+    }
+
+    @Override
+    public Object getAttribute(final String name) {
+        return null;
+    }
+
+    @Override
+    public void delete(final Resource resource) throws PersistenceException {
+        this.deletedResources.add(resource.getPath());
+        this.temporaryResources.remove(resource.getPath());
+        final String prefixPath = resource.getPath() + '/';
+        synchronized ( this.resources ) {
+            for(final Map.Entry<String, Map<String, Object>> e : this.resources.entrySet()) {
+                if (e.getKey().startsWith(prefixPath)) {
+                    this.deletedResources.add(e.getKey());
+                }
+            }
+            final Iterator<Map.Entry<String, Map<String, Object>>> i = this.temporaryResources.entrySet().iterator();
+            while ( i.hasNext() ) {
+                final Map.Entry<String, Map<String, Object>> e = i.next();
+                if (e.getKey().startsWith(prefixPath) ) {
+                    i.remove();
+                }
+            }
+        }
+    }
+
+    @Override
+    public Resource create(Resource parent, String name,
+            Map<String, Object> properties) throws PersistenceException {
+        final String path = (parent.getPath().equals("/") ? parent.getPath() + name : parent.getPath() + '/' + name);
+        if ( this.temporaryResources.containsKey(path) ) {
+            throw new PersistenceException("Path already exists: " + path);
+        }
+        synchronized ( this.resources ) {
+            if ( this.resources.containsKey(path) ) {
+                throw new PersistenceException("Path already exists: " + path);
+            }
+        }
+        this.deletedResources.remove(path);
+        if ( properties == null ) {
+            properties = new HashMap<String, Object>();
+        }
+        this.temporaryResources.put(path, properties);
+
+        return new MockResource(path, properties, this);
+    }
+
+    @Override
+    public void revert() {
+        this.deletedResources.clear();
+        this.temporaryResources.clear();
+    }
+
+    @Override
+    public void commit() throws PersistenceException {
+        synchronized ( this.resources ) {
+            for(final String path : this.deletedResources ) {
+                if ( this.resources.remove(path) != null && this.eventAdmin != null ) {
+                    final Map<String, Object> props = new HashMap<String, Object>();
+                    props.put(SlingConstants.PROPERTY_PATH, path);
+                    final Event e = new Event(SlingConstants.TOPIC_RESOURCE_REMOVED, props);
+                    this.eventAdmin.sendEvent(e);
+                }
+                this.temporaryResources.remove(path);
+            }
+            for(final String path : this.temporaryResources.keySet() ) {
+                final boolean changed = this.resources.containsKey(path);
+                this.resources.put(path, this.temporaryResources.get(path));
+                if ( this.eventAdmin != null ) {
+                    final Map<String, Object> props = new HashMap<String, Object>();
+                    props.put(SlingConstants.PROPERTY_PATH, path);
+                    if ( this.resources.get(path).get(ResourceResolver.PROPERTY_RESOURCE_TYPE) != null ) {
+                        props.put(SlingConstants.PROPERTY_RESOURCE_TYPE, this.resources.get(path).get(ResourceResolver.PROPERTY_RESOURCE_TYPE));
+                    }
+                    final Event e = new Event(changed ? SlingConstants.TOPIC_RESOURCE_CHANGED : SlingConstants.TOPIC_RESOURCE_ADDED, props);
+                    this.eventAdmin.sendEvent(e);
+                }
+            }
+        }
+        this.revert();
+    }
+
+    @Override
+    public boolean hasChanges() {
+        return this.temporaryResources.size() > 0 || this.deletedResources.size() > 0;
+    }
+
+    @Override
+    public String getParentResourceType(Resource resource) {
+        return null;
+    }
+
+    @Override
+    public String getParentResourceType(String resourceType) {
+        return null;
+    }
+
+    @Override
+    public boolean isResourceType(Resource resource, String resourceType) {
+        return resource.getResourceType().equals(resourceType);
+    }
+
+    @Override
+    public void refresh() {
+        // nothing to do
+    }
+
+    public void addChanged(final String path, final Map<String, Object> props) {
+        this.temporaryResources.put(path, props);
+    }
+}
diff --git a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
new file mode 100644
index 0000000..9caf5ac
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.sling.testing.resourceresolver;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.osgi.service.event.EventAdmin;
+
+public class MockResourceResolverFactory implements ResourceResolverFactory {
+
+    private final Map<String, Map<String, Object>> resources = new HashMap<String, Map<String, Object>>();
+
+    private final EventAdmin eventAdmin;
+
+    public MockResourceResolverFactory(final EventAdmin eventAdmin) {
+        this.eventAdmin = eventAdmin;
+        resources.put("/", new HashMap<String, Object>());
+    }
+
+    public MockResourceResolverFactory() {
+        this(null);
+    }
+
+    @Override
+    public ResourceResolver getResourceResolver(
+            final Map<String, Object> authenticationInfo) throws LoginException {
+        return new MockResourceResolver(this.eventAdmin, resources);
+    }
+
+    @Override
+    public ResourceResolver getAdministrativeResourceResolver(
+            final Map<String, Object> authenticationInfo) throws LoginException {
+        return new MockResourceResolver(this.eventAdmin, resources);
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.