You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2021/08/25 14:36:34 UTC

[sling-org-apache-sling-testing-sling-mock] 01/02: SLING-5922 add simplified resource provider support for resource resolver mock

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

sseifert pushed a commit to branch feature/SLING-5922-load-folder
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git

commit 57926fa4ddaaf2ebdb9184e00aa6076bcd442fc7
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Wed Aug 25 15:37:29 2021 +0200

    SLING-5922 add simplified resource provider support for resource resolver mock
---
 .../apache/sling/testing/mock/sling/MockSling.java |  32 +++---
 .../sling/RRMockMockResourceResolverAdapter.java   |  14 ++-
 .../RRMockResourceResolverFactoryWrapper.java      | 113 +++++++++++++++++++
 .../mock/sling/RRMockResourceResolverWrapper.java  | 121 +++++++++++++++++++++
 .../testing/mock/sling/loader/ContentLoader.java   |   6 +-
 .../sling/spi/ResourceResolverTypeAdapter.java     |   5 +
 .../AbstractContentLoaderFolderJsonTest.java       |   9 ++
 .../AbstractContentLoaderFolderXmlJcrTest.java     |  11 ++
 .../rrmock/loader/ContentLoaderFolderJsonTest.java |  31 ++++++
 .../loader/ContentLoaderFolderXmlJcrTest.java      |  31 ++++++
 .../mock/sling/junit5/SlingContextMemberTest.java  |   5 +-
 .../mock/sling/junit5/SlingContextTest.java        |   5 +-
 12 files changed, 353 insertions(+), 30 deletions(-)

diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
index 35489ab..31a7162 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
@@ -18,6 +18,9 @@
  */
 package org.apache.sling.testing.mock.sling;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.adapter.SlingAdaptable;
@@ -69,7 +72,7 @@ public final class MockSling {
      */
     public static @NotNull ResourceResolverFactory newResourceResolverFactory(@NotNull final ResourceResolverType type,
             @NotNull final BundleContext bundleContext) {
-        ResourceResolverTypeAdapter adapter = getResourceResolverTypeAdapter(type);
+        ResourceResolverTypeAdapter adapter = getResourceResolverTypeAdapter(type, bundleContext);
         ResourceResolverFactory factory = adapter.newResourceResolverFactory();
         if (factory == null) {
             SlingRepository repository = adapter.newSlingRepository();
@@ -81,24 +84,21 @@ public final class MockSling {
         return factory;
     }
 
-    private static ResourceResolverTypeAdapter getResourceResolverTypeAdapter(final ResourceResolverType type) {
+    private static ResourceResolverTypeAdapter getResourceResolverTypeAdapter(final ResourceResolverType type,
+            @NotNull final BundleContext bundleContext) {
         try {
             Class clazz = Class.forName(type.getResourceResolverTypeAdapterClass());
-            return (ResourceResolverTypeAdapter) clazz.newInstance();
-        }
-        catch (ClassNotFoundException ex) {
-            throw new RuntimeException("Unable to instantiate resourcer resolver: "
-                    + type.getResourceResolverTypeAdapterClass()
-                    + (type.getArtifactCoordinates() != null ? ". Make sure this maven dependency is included: "
-                            + type.getArtifactCoordinates() : ""), ex);
-        }
-        catch (InstantiationException ex) {
-            throw new RuntimeException("Unable to instantiate resourcer resolver: "
-                    + type.getResourceResolverTypeAdapterClass()
-                    + (type.getArtifactCoordinates() != null ? ". Make sure this maven dependency is included: "
-                            + type.getArtifactCoordinates() : ""), ex);
+            try {
+                Constructor<ResourceResolverTypeAdapter> bundleContextConstructor = clazz.getConstructor(BundleContext.class);
+                // use constructor with bundle context
+                return bundleContextConstructor.newInstance(bundleContext);
+            }
+            catch (NoSuchMethodException ex) {
+                // fallback to default constructor
+                return (ResourceResolverTypeAdapter)clazz.newInstance();
+            }
         }
-        catch (IllegalAccessException ex) {
+        catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException ex) {
             throw new RuntimeException("Unable to instantiate resourcer resolver: "
                     + type.getResourceResolverTypeAdapterClass()
                     + (type.getArtifactCoordinates() != null ? ". Make sure this maven dependency is included: "
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
index 84f9248..ccb2c2e 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
@@ -23,26 +23,28 @@ import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
 import org.apache.sling.testing.resourceresolver.MockResourceResolverFactory;
 import org.apache.sling.testing.resourceresolver.MockResourceResolverFactoryOptions;
-import org.jetbrains.annotations.NotNull;
+import org.osgi.framework.BundleContext;
 
 /**
  * Resource resolver type adapter for Sling Resource Resolver Mock implementation.
  */
 class RRMockMockResourceResolverAdapter implements ResourceResolverTypeAdapter {
 
-    private final @NotNull MockResourceResolverFactoryOptions options;
+    private final MockResourceResolverFactoryOptions options;
+    private final BundleContext bundleContext;
 
     /**
      * Constructor
      */
-    public RRMockMockResourceResolverAdapter() {
-        options = new MockResourceResolverFactoryOptions();
-        options.setMangleNamespacePrefixes(true);
+    public RRMockMockResourceResolverAdapter(BundleContext bundleContext) {
+        this.options = new MockResourceResolverFactoryOptions();
+        this.options.setMangleNamespacePrefixes(true);
+        this.bundleContext = bundleContext;
     }
 
     @Override
     public ResourceResolverFactory newResourceResolverFactory() {
-        return new MockResourceResolverFactory(options);
+        return new RRMockResourceResolverFactoryWrapper(new MockResourceResolverFactory(options), bundleContext);
     }
 
     @Override
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockResourceResolverFactoryWrapper.java b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockResourceResolverFactoryWrapper.java
new file mode 100644
index 0000000..f72ff91
--- /dev/null
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockResourceResolverFactoryWrapper.java
@@ -0,0 +1,113 @@
+/*
+ * 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.mock.sling;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.spi.resource.provider.ResourceProvider;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * Wraps the ResourceResolverFactory from ResourceResolverMock to add a service tracker
+ * for ResourceProvider (e.g. injected by ContentLoader for mounting filesystem folders).
+ */
+class RRMockResourceResolverFactoryWrapper implements ResourceResolverFactory,
+        ServiceTrackerCustomizer<ResourceProvider, ResourceProvider> {
+
+    private final ResourceResolverFactory delegate;
+    private final BundleContext bundleContext;
+    private final ServiceTracker<ResourceProvider, ResourceProvider> serviceTracker;
+    private final ConcurrentMap<String, ResourceProvider> resourceProviders = new ConcurrentHashMap<>();
+
+    @SuppressWarnings("null")
+    RRMockResourceResolverFactoryWrapper(ResourceResolverFactory delegate, BundleContext bundleContext) {
+        this.delegate = delegate;
+        this.bundleContext = bundleContext;
+        // track registered resource provider implementations
+        this.serviceTracker = new ServiceTracker<ResourceProvider, ResourceProvider>(bundleContext, ResourceProvider.class, this);
+        this.serviceTracker.open();
+    }
+
+    @Override
+    public @NotNull ResourceResolver getResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
+        return wrap(delegate.getResourceResolver(authenticationInfo));
+    }
+
+    @Override
+    @Deprecated
+    public @NotNull ResourceResolver getAdministrativeResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
+        return wrap(delegate.getAdministrativeResourceResolver(authenticationInfo));
+    }
+
+    @Override
+    public @NotNull ResourceResolver getServiceResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
+        return wrap(delegate.getServiceResourceResolver(authenticationInfo));
+    }
+
+    @Override
+    public @Nullable ResourceResolver getThreadResourceResolver() {
+        return wrap(delegate.getThreadResourceResolver());
+    }
+
+    private ResourceResolver wrap(ResourceResolver resourceResolver) {
+        return new RRMockResourceResolverWrapper(resourceResolver, resourceProviders);
+    }
+
+    @Override
+    public ResourceProvider addingService(ServiceReference<ResourceProvider> reference) {
+        String rootPath = getRootPath(reference);
+        ResourceProvider service = bundleContext.getService(reference);
+        if (rootPath != null) {
+            resourceProviders.put(rootPath, service);
+        }
+        return service;
+    }
+
+    @Override
+    public void modifiedService(ServiceReference<ResourceProvider> reference, ResourceProvider service) {
+        // ignore
+    }
+
+    @Override
+    public void removedService(ServiceReference<ResourceProvider> reference, ResourceProvider service) {
+        String rootPath = getRootPath(reference);
+        if (rootPath != null) {
+            resourceProviders.remove(rootPath);
+        }
+    }
+
+    private String getRootPath(ServiceReference<ResourceProvider> reference) {
+        Object value = reference.getProperty(ResourceProvider.PROPERTY_ROOT);
+        if (value instanceof String) {
+            return (String)value;
+        }
+        return null;
+    }
+
+}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockResourceResolverWrapper.java b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockResourceResolverWrapper.java
new file mode 100644
index 0000000..6689e5d
--- /dev/null
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockResourceResolverWrapper.java
@@ -0,0 +1,121 @@
+/*
+ * 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.mock.sling;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.wrappers.ResourceResolverWrapper;
+import org.apache.sling.spi.resource.provider.ResolveContext;
+import org.apache.sling.spi.resource.provider.ResourceContext;
+import org.apache.sling.spi.resource.provider.ResourceProvider;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Wraps resource resolver form ResourceResolverMock to check for resource provider implementations
+ * registered to specific path. This is a very simplified implementation to overlay the mocked
+ * resource tree with resource providers, but should be sufficient for unit tests.
+ */
+class RRMockResourceResolverWrapper extends ResourceResolverWrapper implements ResolveContext {
+
+    private final ConcurrentMap<String, ResourceProvider> resourceProviders;
+
+    RRMockResourceResolverWrapper(ResourceResolver delegate, ConcurrentMap<String, ResourceProvider> resourceProviders) {
+        super(delegate);
+        this.resourceProviders = resourceProviders;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Resource getResource(@NotNull String path) {
+        ResourceProvider resourceProvider = getMatchingResourceProvider(path);
+        if (resourceProvider != null) {
+            return resourceProvider.getResource(this, path, ResourceContext.EMPTY_CONTEXT, null);
+        }
+        return super.getResource(path);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public @NotNull Iterator<Resource> listChildren(@NotNull Resource parent) {
+        ResourceProvider resourceProvider = getMatchingResourceProvider(parent.getPath());
+        if (resourceProvider != null) {
+            Iterator<Resource> result = resourceProvider.listChildren(this,  parent);
+            if (result == null) {
+                return Collections.emptyIterator();
+            }
+            else {
+                return result;
+            }
+        }
+        return super.listChildren(parent);
+    }
+
+    private ResourceProvider getMatchingResourceProvider(String path) {
+        if (resourceProviders.isEmpty()) {
+            return null;
+        }
+        String normalizedPath = ResourceUtil.normalize(path);
+        if (!StringUtils.startsWith(normalizedPath, "/")) {
+            return null;
+        }
+        return getMatchingResourceProviderRecursively(normalizedPath);
+    }
+
+    private ResourceProvider getMatchingResourceProviderRecursively(String path) {
+        ResourceProvider provider = resourceProviders.get(path);
+        if (provider != null) {
+            return provider;
+        }
+        String parentPath = ResourceUtil.getParent(path);
+        if (parentPath != null) {
+            return getMatchingResourceProviderRecursively(parentPath);
+        }
+        else {
+            return null;
+        }
+    }
+
+    @Override
+    public @NotNull ResourceResolver getResourceResolver() {
+        return this;
+    }
+
+    @Override
+    public @Nullable Object getProviderState() {
+        return null;
+    }
+
+    @Override
+    public @Nullable ResolveContext getParentResolveContext() {
+        return null;
+    }
+
+    @Override
+    public @Nullable ResourceProvider getParentResourceProvider() {
+        return null;
+    }
+
+}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java b/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
index e8a107f..a7c2238 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
@@ -568,7 +568,8 @@ public final class ContentLoader {
                 "provider.file", mountFolder.getAbsolutePath(),
                 "provider.root", destPath,
                 "provider.fs.mode", "INITIAL_CONTENT",
-                "provider.initial.content.import.options", "overwrite:=true;ignoreImportProviders:=\"xml\"");
+                "provider.initial.content.import.options", "overwrite:=true;ignoreImportProviders:=\"xml\"",
+                "provider.checkinterval", 0);
         FsResourceProvider service = MockOsgi.activateInjectServices(FsResourceProvider.class, bundleContext, serviceProperties);
         bundleContext.registerService(ResourceProvider.class, service, serviceProperties);
     }
@@ -615,7 +616,8 @@ public final class ContentLoader {
         Dictionary<String, Object> serviceProperties = MapUtil.toDictionary(
                 "provider.file", mountFolder.getAbsolutePath(),
                 "provider.root", destPath,
-                "provider.fs.mode", "FILEVAULT_XML");
+                "provider.fs.mode", "FILEVAULT_XML",
+                "provider.checkinterval", 0);
         FsResourceProvider service = MockOsgi.activateInjectServices(FsResourceProvider.class, bundleContext, serviceProperties);
         bundleContext.registerService(ResourceProvider.class, service, serviceProperties);
     }
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
index 66bde79..55bf8cf 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
@@ -25,6 +25,11 @@ import org.jetbrains.annotations.Nullable;
 /**
  * SPI interface for resource resolver type implementations to provide a mock
  * resource resolver factory.
+ * <p>Supported constructors for implementing classes:</p>
+ * <ul>
+ * <li>Empty constructor</li>
+ * <li>Constructor with {@link org.osgi.framework.BundleContext} parameter</li>
+ * </ul>
  */
 public interface ResourceResolverTypeAdapter {
 
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java
index e247041..237daab 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
 import java.io.IOException;
+import java.util.List;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -76,6 +77,14 @@ public abstract class AbstractContentLoaderFolderJsonTest {
     }
 
     @Test
+    public void testContentListChildren() {
+        Resource resource = context.resourceResolver().getResource(path + "/mount/content");
+        List<Resource> result = ImmutableList.copyOf(resource.listChildren());
+        assertEquals("jcr:content", result.get(0).getName());
+        assertEquals("toolbar", result.get(1).getName());
+    }
+
+    @Test
     public void testDamResourceType() {
         Resource resource = context.resourceResolver().getResource(path + "/mount/dam/portraits/scott_reynolds.jpg");
         assertEquals("dam:Asset", resource.getResourceType());
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderXmlJcrTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderXmlJcrTest.java
index 89f4c84..e2806aa 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderXmlJcrTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderXmlJcrTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.sling.api.resource.Resource;
@@ -34,6 +35,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
+import com.google.common.collect.ImmutableList;
+
 @SuppressWarnings("null")
 public abstract class AbstractContentLoaderFolderXmlJcrTest {
 
@@ -63,6 +66,14 @@ public abstract class AbstractContentLoaderFolderXmlJcrTest {
     }
 
     @Test
+    public void testContentListChildren() {
+        Resource resource = context.resourceResolver().getResource(path + "/samples/en");
+        List<Resource> result = ImmutableList.copyOf(resource.listChildren());
+        assertEquals("jcr:content", result.get(0).getName());
+        assertEquals("tools", result.get(1).getName());
+    }
+
+    @Test
     public void testDamResourceType() {
         Resource resource = context.resourceResolver().getResource(path + "/dam/talk.png/jcr:content");
         assertEquals("app:AssetContent", resource.getResourceType());
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFolderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFolderJsonTest.java
new file mode 100644
index 0000000..01f0c5c
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFolderJsonTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.mock.sling.rrmock.loader;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderFolderJsonTest;
+
+public class ContentLoaderFolderJsonTest extends AbstractContentLoaderFolderJsonTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.RESOURCERESOLVER_MOCK;
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFolderXmlJcrTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFolderXmlJcrTest.java
new file mode 100644
index 0000000..2b10dc4
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFolderXmlJcrTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.mock.sling.rrmock.loader;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderFolderXmlJcrTest;
+
+public class ContentLoaderFolderXmlJcrTest extends AbstractContentLoaderFolderXmlJcrTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.RESOURCERESOLVER_MOCK;
+    }
+
+}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java
index 74231df..ff8d07c 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java
@@ -19,10 +19,9 @@
 package org.apache.sling.testing.mock.sling.junit5;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.testing.resourceresolver.MockResourceResolver;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -38,7 +37,7 @@ class SlingContextMemberTest {
 
     @BeforeEach
     void setUp() {
-        assertTrue(context.resourceResolver() instanceof MockResourceResolver);
+        assertEquals(ResourceResolverType.RESOURCERESOLVER_MOCK, context.resourceResolverType());
 
         context.create().resource("/content/test", "prop1", "value1");
     }
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java
index fc956ab..485d9a7 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java
@@ -19,11 +19,10 @@
 package org.apache.sling.testing.mock.sling.junit5;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.context.modelsautoreg.ClasspathRegisteredModel;
-import org.apache.sling.testing.resourceresolver.MockResourceResolver;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -38,7 +37,7 @@ class SlingContextTest {
 
     @BeforeEach
     void setUp(SlingContext context) {
-        assertTrue(context.resourceResolver() instanceof MockResourceResolver);
+        assertEquals(ResourceResolverType.RESOURCERESOLVER_MOCK, context.resourceResolverType());
 
         context.create().resource("/content/test", "prop1", "value1");
     }