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-1.1.0
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git

commit 183c25ab785415b3f805b2cd487bb19870c2f31f
Author: Stefan Seifert <[email protected]>
AuthorDate: Mon Oct 13 09:58:40 2014 +0000

    SLING-4040 Return null for getResource für null path
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/testing/resourceresolver-mock@1631326
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/testing/resourceresolver/MockResourceResolver.java |  6 +++++-
 .../resourceresolver/SlingCrudResourceResolverTest.java      | 12 +++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
 
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
index ea01646..9798b2f 100644
--- 
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
+++ 
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
@@ -127,7 +127,7 @@ public class MockResourceResolver extends SlingAdaptable 
implements ResourceReso
         Resource resource = getResourceInternal(path);
         
         // if not resource found check if this is a reference to a property
-        if (resource == null) {
+        if (resource == null && path != null) {
             String name = ResourceUtil.getName(path);
             String parentPath = ResourceUtil.getParent(path);
             Resource parentResource = getResourceInternal(parentPath);
@@ -143,6 +143,10 @@ public class MockResourceResolver extends SlingAdaptable 
implements ResourceReso
     }
     
     private Resource getResourceInternal(final String path) {
+        if (path == null) {
+            return null;
+        }
+        
         String normalizedPath = ResourceUtil.normalize(path);
         if ( normalizedPath.startsWith("/") ) {
             if ( this.deletedResources.contains(normalizedPath) ) {
diff --git 
a/src/test/java/org/apache/sling/testing/resourceresolver/SlingCrudResourceResolverTest.java
 
b/src/test/java/org/apache/sling/testing/resourceresolver/SlingCrudResourceResolverTest.java
index 7c0f9c8..466e67d 100644
--- 
a/src/test/java/org/apache/sling/testing/resourceresolver/SlingCrudResourceResolverTest.java
+++ 
b/src/test/java/org/apache/sling/testing/resourceresolver/SlingCrudResourceResolverTest.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.resourceresolver;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -33,7 +34,6 @@ import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ModifiableValueMap;
-import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceUtil;
@@ -177,13 +177,13 @@ public class SlingCrudResourceResolverTest {
     }
 
     @Test
-    public void testPrimaryTypeResourceType() throws PersistenceException {
+    public void testPrimaryTypeResourceType() {
         Resource resource1 = resourceResolver.getResource(testRoot.getPath() + 
"/node1");
         assertEquals(NT_UNSTRUCTURED, resource1.getResourceType());
     }
 
     @Test
-    public void testNormalizePath() throws PersistenceException {
+    public void testNormalizePath() {
         Resource resource1 = resourceResolver.getResource(testRoot.getPath() + 
"/./node1");
         assertEquals("node1", resource1.getName());
 
@@ -191,4 +191,10 @@ public class SlingCrudResourceResolverTest {
         assertEquals("node11", resource11.getName());
     }
 
+    @Test
+    public void testGetResourceNullPath() {
+        Resource resource = resourceResolver.getResource((String)null);
+        assertNull(resource);
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to