This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.testing.sling-mock-2.2.10 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git
commit 863898e502f702477ec155fd537ff7277e894d92 Author: Stefan Seifert <[email protected]> AuthorDate: Mon Mar 27 15:04:42 2017 +0000 SLING-6728 sling-mock: Resource Resolver Type "NONE" does not work git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1788943 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/ResourceResolverFactoryInitializer.java | 2 ++ .../sling/context/NoResourceResolverTypeTest.java | 41 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java index 8b3d3d1..65d8dc1 100644 --- a/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java +++ b/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java @@ -122,6 +122,8 @@ class ResourceResolverFactoryInitializer { */ private static void initializeResourceResolverFactoryActivator(BundleContext bundleContext) { Dictionary<String, Object> config = new Hashtable<String, Object>(); + // do not required a specific resource provider (otherwise "NONE" will not work) + config.put("resource.resolver.required.providers", ""); ResourceResolverFactoryActivator activator = new ResourceResolverFactoryActivator(); MockOsgi.injectServices(activator, bundleContext); MockOsgi.activate(activator, bundleContext, config); diff --git a/src/test/java/org/apache/sling/testing/mock/sling/context/NoResourceResolverTypeTest.java b/src/test/java/org/apache/sling/testing/mock/sling/context/NoResourceResolverTypeTest.java new file mode 100644 index 0000000..bf861f3 --- /dev/null +++ b/src/test/java/org/apache/sling/testing/mock/sling/context/NoResourceResolverTypeTest.java @@ -0,0 +1,41 @@ +/* + * 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.context; + +import static org.junit.Assert.assertTrue; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.SyntheticResource; +import org.apache.sling.testing.mock.sling.ResourceResolverType; +import org.apache.sling.testing.mock.sling.junit.SlingContext; +import org.junit.Rule; +import org.junit.Test; + +public class NoResourceResolverTypeTest { + + @Rule + public SlingContext context = new SlingContext(ResourceResolverType.NONE); + + @Test + public void testRoot() { + Resource root = context.resourceResolver().getResource("/"); + assertTrue(root instanceof SyntheticResource); + } + +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
