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 2016/07/08 15:45:02 UTC
svn commit: r1751927 - in /sling/trunk/testing/mocks/sling-mock/src:
main/java/org/apache/sling/testing/mock/sling/context/
main/java/org/apache/sling/testing/mock/sling/junit/
test/java/org/apache/sling/testing/mock/sling/junit/
Author: sseifert
Date: Fri Jul 8 15:45:02 2016
New Revision: 1751927
URL: http://svn.apache.org/viewvc?rev=1751927&view=rev
Log:
SLING-5770 add support for custom resource resolver factory activator configuration via SlingContextBuilder
add support for additional callbacks before setup and after teardown
Added:
sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java (with props)
Modified:
sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java
sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java
sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java?rev=1751927&r1=1751926&r2=1751927&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java Fri Jul 8 15:45:02 2016
@@ -18,6 +18,10 @@
*/
package org.apache.sling.testing.mock.sling.context;
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
import javax.jcr.RepositoryException;
@@ -55,13 +59,17 @@ import org.apache.sling.testing.mock.sli
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
-
-import aQute.bnd.annotation.ConsumerType;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import aQute.bnd.annotation.ConsumerType;
+
/**
* Defines Sling context objects with lazy initialization. Should not be used
* directly but via the {@link org.apache.sling.testing.mock.sling.junit.SlingContext} JUnit
@@ -73,6 +81,10 @@ public class SlingContextImpl extends Os
// default to publish instance run mode
static final Set<String> DEFAULT_RUN_MODES = ImmutableSet.<String> builder().add("publish").build();
+ private static final String RESOURCERESOLVERFACTORYACTIVATOR_PID = "org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl";
+
+ private static final Logger log = LoggerFactory.getLogger(SlingContextImpl.class);
+
protected ResourceResolverFactory resourceResolverFactory;
protected ResourceResolverType resourceResolverType;
protected ResourceResolver resourceResolver;
@@ -82,6 +94,8 @@ public class SlingContextImpl extends Os
protected ContentLoader contentLoader;
protected ContentBuilder contentBuilder;
protected UniqueRoot uniqueRoot;
+
+ private Map<String, Object> resourceResolverFactoryActivatorProps;
/**
* @param resourceResolverType Resource resolver type
@@ -90,12 +104,38 @@ public class SlingContextImpl extends Os
this.resourceResolverType = resourceResolverType;
}
+ protected void setResourceResolverFactoryActivatorProps(Map<String, Object> props) {
+ this.resourceResolverFactoryActivatorProps = props;
+ }
+
/**
* Setup actions before test method execution
*/
protected void setUp() {
super.setUp();
MockSling.setAdapterManagerBundleContext(bundleContext());
+
+ if (this.resourceResolverFactoryActivatorProps != null) {
+ // use OSGi ConfigurationAdmin to pass over customized configuration to Resource Resolver Factory Activator service
+ ConfigurationAdmin configAdmin = getService(ConfigurationAdmin.class);
+ if (configAdmin == null) {
+ log.warn("ConfigAdmin not found in osgi-mock context - please make sure osgi-mock 1.7.0 or higher is used.");
+ }
+ else {
+ try {
+ Configuration resourceResolverFactoryActivatorConfig = configAdmin.getConfiguration(RESOURCERESOLVERFACTORYACTIVATOR_PID);
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ for (Map.Entry<String, Object> item : this.resourceResolverFactoryActivatorProps.entrySet()) {
+ props.put(item.getKey(), item.getValue());
+ }
+ resourceResolverFactoryActivatorConfig.update(props);
+ }
+ catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+
this.resourceResolverFactory = newResourceResolverFactory();
registerDefaultServices();
}
Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java?rev=1751927&r1=1751926&r2=1751927&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/package-info.java Fri Jul 8 15:45:02 2016
@@ -19,5 +19,5 @@
/**
* Sling context implementation for unit tests.
*/
-@aQute.bnd.annotation.Version("3.1")
+@aQute.bnd.annotation.Version("3.2")
package org.apache.sling.testing.mock.sling.context;
Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java?rev=1751927&r1=1751926&r2=1751927&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java Fri Jul 8 15:45:02 2016
@@ -18,6 +18,8 @@
*/
package org.apache.sling.testing.mock.sling.junit;
+import java.util.Map;
+
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
import org.junit.rules.ExternalResource;
@@ -31,8 +33,10 @@ import org.junit.runners.model.Statement
*/
public final class SlingContext extends SlingContextImpl implements TestRule {
- private final SlingContextCallback setUpCallback;
- private final SlingContextCallback tearDownCallback;
+ private final SlingContextCallback beforeSetUpCallback;
+ private final SlingContextCallback afterSetUpCallback;
+ private final SlingContextCallback beforeTearDownCallback;
+ private final SlingContextCallback afterTearDownCallback;
private final TestRule delegate;
/**
@@ -54,54 +58,61 @@ public final class SlingContext extends
/**
* Initialize Sling context with default resource resolver type:
* {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
- * @param setUpCallback Allows the application to register an own callback
- * function that is called after the built-in setup rules are
- * executed.
+ * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
*/
- public SlingContext(final SlingContextCallback setUpCallback) {
- this(setUpCallback, null, null);
+ public SlingContext(final SlingContextCallback afterSetUpCallback) {
+ this(afterSetUpCallback, null, null);
}
/**
* Initialize Sling context with resource resolver type.
- * @param setUpCallback Allows the application to register an own callback
- * function that is called after the built-in setup rules are
- * executed.
+ * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
* @param resourceResolverType Resource resolver type.
*/
- public SlingContext(final SlingContextCallback setUpCallback, final ResourceResolverType resourceResolverType) {
- this(setUpCallback, null, resourceResolverType);
+ public SlingContext(final SlingContextCallback afterSetUpCallback, final ResourceResolverType resourceResolverType) {
+ this(afterSetUpCallback, null, resourceResolverType);
}
/**
* Initialize Sling context with default resource resolver type:
* {@link org.apache.sling.testing.mock.sling.MockSling#DEFAULT_RESOURCERESOLVER_TYPE}.
- * @param setUpCallback Allows the application to register an own callback
- * function that is called after the built-in setup rules are
- * executed.
- * @param tearDownCallback Allows the application to register an own
- * callback function that is called before the built-in teardown
- * rules are executed.
+ * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+ * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+ */
+ public SlingContext(final SlingContextCallback afterSetUpCallback, final SlingContextCallback beforeTearDownCallback) {
+ this(afterSetUpCallback, beforeTearDownCallback, null);
+ }
+
+ /**
+ * Initialize Sling context with resource resolver type.
+ * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+ * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+ * @param resourceResolverType Resource resolver type.
*/
- public SlingContext(final SlingContextCallback setUpCallback, final SlingContextCallback tearDownCallback) {
- this(setUpCallback, tearDownCallback, null);
+ public SlingContext(final SlingContextCallback afterSetUpCallback, final SlingContextCallback beforeTearDownCallback,
+ final ResourceResolverType resourceResolverType) {
+ this(null, afterSetUpCallback, beforeTearDownCallback, null, null, resourceResolverType);
}
/**
* Initialize Sling context with resource resolver type.
- * @param setUpCallback Allows the application to register an own callback
- * function that is called after the built-in setup rules are
- * executed.
- * @param tearDownCallback Allows the application to register an own
- * callback function that is called before the built-in teardown
- * rules are executed.
+ * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the built-in setup rules are executed.
+ * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+ * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+ * @param afterTearDownCallback Allows the application to register an own callback function that is after before the built-in teardown rules are executed.
+ * @param resourceResolverFactoryActivatorProps Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
* @param resourceResolverType Resource resolver type.
*/
- public SlingContext(final SlingContextCallback setUpCallback, final SlingContextCallback tearDownCallback,
+ SlingContext(final SlingContextCallback beforeSetUpCallback, final SlingContextCallback afterSetUpCallback,
+ final SlingContextCallback beforeTearDownCallback, final SlingContextCallback afterTearDownCallback,
+ final Map<String, Object> resourceResolverFactoryActivatorProps,
final ResourceResolverType resourceResolverType) {
- this.setUpCallback = setUpCallback;
- this.tearDownCallback = tearDownCallback;
+ this.beforeSetUpCallback = beforeSetUpCallback;
+ this.afterSetUpCallback = afterSetUpCallback;
+ this.beforeTearDownCallback = beforeTearDownCallback;
+ this.afterTearDownCallback = afterTearDownCallback;
+ setResourceResolverFactoryActivatorProps(resourceResolverFactoryActivatorProps);
// set resource resolver type in parent context
setResourceResolverType(resourceResolverType);
@@ -110,14 +121,16 @@ public final class SlingContext extends
this.delegate = new ExternalResource() {
@Override
protected void before() {
+ SlingContext.this.executeBeforeSetUpCallback();
SlingContext.this.setUp();
- SlingContext.this.executeSetUpCallback();
+ SlingContext.this.executeAfterSetUpCallback();
}
@Override
protected void after() {
- SlingContext.this.executeTearDownCallback();
+ SlingContext.this.executeBeforeTearDownCallback();
SlingContext.this.tearDown();
+ SlingContext.this.executeAfterTearDownCallback();
}
};
}
@@ -127,22 +140,42 @@ public final class SlingContext extends
return this.delegate.apply(base, description);
}
- private void executeSetUpCallback() {
- if (this.setUpCallback != null) {
+ private void executeBeforeSetUpCallback() {
+ if (this.beforeSetUpCallback != null) {
+ try {
+ this.beforeSetUpCallback.execute(this);
+ } catch (Throwable ex) {
+ throw new RuntimeException("Before setup failed: " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ private void executeAfterSetUpCallback() {
+ if (this.afterSetUpCallback != null) {
+ try {
+ this.afterSetUpCallback.execute(this);
+ } catch (Throwable ex) {
+ throw new RuntimeException("After setup failed: " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ private void executeBeforeTearDownCallback() {
+ if (this.beforeTearDownCallback != null) {
try {
- this.setUpCallback.execute(this);
+ this.beforeTearDownCallback.execute(this);
} catch (Throwable ex) {
- throw new RuntimeException("Setup failed: " + ex.getMessage(), ex);
+ throw new RuntimeException("Before teardown failed: " + ex.getMessage(), ex);
}
}
}
- private void executeTearDownCallback() {
- if (this.tearDownCallback != null) {
+ private void executeAfterTearDownCallback() {
+ if (this.afterTearDownCallback != null) {
try {
- this.tearDownCallback.execute(this);
+ this.afterTearDownCallback.execute(this);
} catch (Throwable ex) {
- throw new RuntimeException("Teardown failed: " + ex.getMessage(), ex);
+ throw new RuntimeException("After teardown failed: " + ex.getMessage(), ex);
}
}
}
Added: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java?rev=1751927&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java (added)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java Fri Jul 8 15:45:02 2016
@@ -0,0 +1,115 @@
+/*
+ * 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.junit;
+
+import java.util.Map;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+
+/**
+ * Builder class for creating {@link SlingContext} instances with different sets of parameters.
+ */
+public final class SlingContextBuilder {
+
+ private ResourceResolverType resourceResolverType;
+ private SlingContextCallback beforeSetUpCallback;
+ private SlingContextCallback afterSetUpCallback;
+ private SlingContextCallback beforeTearDownCallback;
+ private SlingContextCallback afterTearDownCallback;
+ private Map<String, Object> resourceResolverFactoryActivatorProps;
+
+ /**
+ * Create builder with default resource resolver type.
+ */
+ public SlingContextBuilder() {}
+
+ /**
+ * Create builder with given resource resolver type.
+ * @param resourceResolverType Resource resolver type.
+ */
+ public SlingContextBuilder(ResourceResolverType resourceResolverType) {
+ this.resourceResolverType(resourceResolverType);
+ }
+
+ /**
+ * @param resourceResolverType Resource resolver type.
+ * @return this
+ */
+ public SlingContextBuilder resourceResolverType(ResourceResolverType resourceResolverType) {
+ this.resourceResolverType = resourceResolverType;
+ return this;
+ }
+
+ /**
+ * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the built-in setup rules are executed.
+ * @return this
+ */
+ public SlingContextBuilder beforeSetUp(SlingContextCallback beforeSetUpCallback) {
+ this.beforeSetUpCallback = beforeSetUpCallback;
+ return this;
+ }
+
+ /**
+ * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+ * @return this
+ */
+ public SlingContextBuilder afterSetUp(SlingContextCallback afterSetUpCallback) {
+ this.afterSetUpCallback = afterSetUpCallback;
+ return this;
+ }
+
+ /**
+ * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+ * @return this
+ */
+ public SlingContextBuilder beforeTearDown(SlingContextCallback beforeTearDownCallback) {
+ this.beforeTearDownCallback = beforeTearDownCallback;
+ return this;
+ }
+
+ /**
+ * @param afterTearDownCallback Allows the application to register an own callback function that is after before the built-in teardown rules are executed.
+ * @return this
+ */
+ public SlingContextBuilder afterTearDown(SlingContextCallback afterTearDownCallback) {
+ this.afterTearDownCallback = afterTearDownCallback;
+ return this;
+ }
+
+ /**
+ * Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
+ * @param props Configuration properties
+ * @return this
+ */
+ public SlingContextBuilder resourceResolverFactoryActivatorProps(Map<String, Object> props) {
+ this.resourceResolverFactoryActivatorProps = props;
+ return this;
+ }
+
+ /**
+ * @return Build {@link SlingContext} instance.
+ */
+ public SlingContext build() {
+ return new SlingContext(this.beforeSetUpCallback, this.afterSetUpCallback,
+ this.beforeTearDownCallback, this.afterTearDownCallback,
+ this.resourceResolverFactoryActivatorProps,
+ this.resourceResolverType);
+ }
+
+}
Propchange: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Fri Jul 8 15:45:02 2016
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
Propchange: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java?rev=1751927&r1=1751926&r2=1751927&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/junit/package-info.java Fri Jul 8 15:45:02 2016
@@ -19,5 +19,5 @@
/**
* Rule for providing easy access to Sling context in JUnit tests.
*/
-@aQute.bnd.annotation.Version("3.1")
+@aQute.bnd.annotation.Version("3.2")
package org.apache.sling.testing.mock.sling.junit;
Modified: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java?rev=1751927&r1=1751926&r2=1751927&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java Fri Jul 8 15:45:02 2016
@@ -43,17 +43,29 @@ import com.google.common.collect.Immutab
@RunWith(MockitoJUnitRunner.class)
public class SlingContextTest {
- private final SlingContextCallback contextSetup = mock(SlingContextCallback.class);
- private final SlingContextCallback contextTeardown = mock(SlingContextCallback.class);
+ private final SlingContextCallback contextBeforeSetup = mock(SlingContextCallback.class);
+ private final SlingContextCallback contextAfterSetup = mock(SlingContextCallback.class);
+ private final SlingContextCallback contextBeforeTeardown = mock(SlingContextCallback.class);
+ private final SlingContextCallback contextAfterTeardown = mock(SlingContextCallback.class);
// Run all unit tests for each resource resolver types listed here
@Rule
- public SlingContext context = new SlingContext(contextSetup, contextTeardown,
- ResourceResolverType.RESOURCERESOLVER_MOCK);
+ public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK)
+ .beforeSetUp(contextBeforeSetup)
+ .afterSetUp(contextAfterSetup)
+ .beforeTearDown(contextBeforeTeardown)
+ .afterTearDown(contextAfterTeardown)
+ .resourceResolverFactoryActivatorProps(ImmutableMap.<String, Object>of("resource.resolver.searchpath", new String[] {
+ "/apps",
+ "/libs",
+ "/testpath",
+ }))
+ .build();
@Before
public void setUp() throws IOException, PersistenceException {
- verify(contextSetup).execute(context);
+ verify(contextBeforeSetup).execute(context);
+ verify(contextAfterSetup).execute(context);
}
@Test
@@ -61,6 +73,26 @@ public class SlingContextTest {
assertNotNull(context.request());
}
+ /**
+ * Test if custom searchpath /testpath added in this SlingContext is handled correctly.
+ */
+ @Test
+ public void testResourceResolverFactoryActivatorProps() {
+ context.create().resource("/apps/node1");
+
+ context.create().resource("/libs/node1");
+ context.create().resource("/libs/node2");
+
+ context.create().resource("/testpath/node1");
+ context.create().resource("/testpath/node2");
+ context.create().resource("/testpath/node3");
+
+ assertEquals("/apps/node1", context.resourceResolver().getResource("node1").getPath());
+ assertEquals("/libs/node2", context.resourceResolver().getResource("node2").getPath());
+ assertEquals("/testpath/node3", context.resourceResolver().getResource("node3").getPath());
+ assertNull(context.resourceResolver().getResource("node4"));
+ }
+
@Test
public void testRegisterAdapter() {