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

commit f96088046c8177b145e54478efb84b1e10b6aa6d
Author: Stefan Seifert <[email protected]>
AuthorDate: Wed Sep 16 09:35:50 2015 +0000

    SLING-5007 use same unit tests for root node tests for all resource 
resolver types without counting the number of children.
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1703373 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../AbstractSlingCrudResourceResolverTest.java     | 30 +++++++++++++++-------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git 
a/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
 
b/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
index 4c17620..316d61d 100644
--- 
a/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
+++ 
b/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
@@ -20,7 +20,9 @@ package org.apache.sling.testing.mock.sling.resource;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -32,6 +34,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
@@ -115,12 +118,12 @@ public abstract class 
AbstractSlingCrudResourceResolverTest {
             Map<String, Object> props = new HashMap<String, Object>();
             props.put(JcrConstants.JCR_PRIMARYTYPE, 
JcrConstants.NT_UNSTRUCTURED);
             final Resource root = this.resourceResolver.getResource("/");
-            if (getResourceResolverType() == 
ResourceResolverType.JCR_JACKRABBIT) {
-                final Resource classRoot = this.resourceResolver.create(root, 
getClass().getSimpleName(), props);
-                this.testRoot = this.resourceResolver.create(classRoot, 
System.currentTimeMillis() + "_"
-                        + (rootNodeCounter++), props);
-            } else {
+            if (getResourceResolverType() == ResourceResolverType.JCR_MOCK
+                    || getResourceResolverType() == 
ResourceResolverType.RESOURCERESOLVER_MOCK) {
                 this.testRoot = this.resourceResolver.create(root, "test", 
props);
+            } else {
+                this.testRoot = this.resourceResolver.create(root, 
getClass().getSimpleName() + "_"
+                        + System.currentTimeMillis() + "_" + 
(rootNodeCounter++), props);
             }
         }
         return this.testRoot;
@@ -214,12 +217,21 @@ public abstract class 
AbstractSlingCrudResourceResolverTest {
         Resource resource1 = resourceResolver.getResource("/");
 
         List<Resource> children = Lists.newArrayList(resource1.listChildren());
-        assertEquals(1, children.size());
-        assertEquals(getTestRootResource().getName(), 
children.get(0).getName());
+        assertFalse(children.isEmpty());
+        assertTrue(containsResource(children, getTestRootResource()));
 
         children = Lists.newArrayList(resource1.getChildren());
-        assertEquals(1, children.size());
-        assertEquals(getTestRootResource().getName(), 
children.get(0).getName());
+        assertFalse(children.isEmpty());
+        assertTrue(containsResource(children, getTestRootResource()));
+    }
+    
+    private boolean containsResource(List<Resource> children, Resource 
resource) {
+        for (Resource child : children) {
+            if (StringUtils.equals(child.getPath(), resource.getPath())) {
+                return true;
+            }
+        }
+        return false;
     }
 
     @Test

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

Reply via email to