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 2015/09/27 11:46:12 UTC

svn commit: r1705520 - in /sling/trunk/testing/mocks: sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/ sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/ sling-mock/src/main/java/o...

Author: sseifert
Date: Sun Sep 27 09:46:11 2015
New Revision: 1705520

URL: http://svn.apache.org/viewvc?rev=1705520&view=rev
Log:
SLING-5067 sling-mock: "uniqueRoot()" to simplify creation and cleanup of unique root paths in repository

Added:
    sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java   (with props)
    sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java   (with props)
    sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java   (with props)
    sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java   (with props)
    sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java   (with props)
    sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.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/junit/package-info.java
    sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java
    sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java

Added: sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java?rev=1705520&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java Sun Sep 27 09:46:11 2015
@@ -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.jackrabbit.resource;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.resource.AbstractUniqueRootTest;
+
+public class UniqueRootTest extends AbstractUniqueRootTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_JACKRABBIT;
+    }
+
+}

Propchange: sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Sep 27 09:46:11 2015
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/trunk/testing/mocks/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java?rev=1705520&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java Sun Sep 27 09:46:11 2015
@@ -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.oak.resource;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.resource.AbstractUniqueRootTest;
+
+public class UniqueRootTest extends AbstractUniqueRootTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_OAK;
+    }
+
+}

Propchange: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Sep 27 09:46:11 2015
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/trunk/testing/mocks/sling-mock-oak/src/test/java/org/apache/sling/testing/mock/sling/oak/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1705520&r1=1705519&r2=1705520&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 Sun Sep 27 09:46:11 2015
@@ -77,6 +77,7 @@ public class SlingContextImpl extends Os
     protected SlingScriptHelper slingScriptHelper;
     protected ContentLoader contentLoader;
     protected ContentBuilder contentBuilder;
+    protected UniqueRoot uniqueRoot;
 
     /**
      * @param resourceResolverType Resource resolver type
@@ -136,8 +137,9 @@ public class SlingContextImpl extends Os
      * Teardown actions after test method execution
      */
     protected void tearDown() {
-
+        
         if (this.resourceResolver != null) {
+            
             // revert potential unsaved changes in resource resolver/JCR session
             this.resourceResolver.revert();
             Session session = this.resourceResolver.adaptTo(Session.class);
@@ -148,6 +150,13 @@ public class SlingContextImpl extends Os
                     // ignore
                 }
             }
+            
+            // remove unique roots
+            if (this.uniqueRoot != null) {
+                this.uniqueRoot.cleanUp();
+            }
+            
+            // close resource resolver
             this.resourceResolver.close();
         }
 
@@ -305,5 +314,12 @@ public class SlingContextImpl extends Os
             slingSettings.setRunModes(newRunModes);
         }
     }
+    
+    public UniqueRoot uniqueRoot() {
+        if (uniqueRoot == null) {
+            uniqueRoot = new UniqueRoot(this);
+        }
+        return uniqueRoot;
+    }
 
 }

Added: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java?rev=1705520&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java (added)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java Sun Sep 27 09:46:11 2015
@@ -0,0 +1,143 @@
+/*
+ * 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.apache.sling.jcr.resource.JcrResourceConstants.NT_SLING_ORDERED_FOLDER;
+
+import java.util.UUID;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Manages unique root paths in JCR repository.
+ * This is important for resource resolver types like JCR_JACKRABBIT and JCR_OAK 
+ * where the repository is not cleand for each test run. This class provides
+ * unique root paths for each run, and cleans them up when done.
+ */
+public class UniqueRoot {
+    
+    private final SlingContextImpl context;
+    
+    protected final String uniquePathPart;
+    
+    private Resource contentRoot;
+    private Resource appsRoot;
+    private Resource libsRoot;
+    
+    private static final Logger log = LoggerFactory.getLogger(UniqueRoot.class);
+    
+    protected UniqueRoot(SlingContextImpl context) {
+        this.context = context;
+        // generate unique path part by using a UUID
+        uniquePathPart = UUID.randomUUID().toString();
+    }
+    
+    /**
+     * Get or create resource with given JCR primary type
+     * @param path Path
+     * @param primaryType JCR primary type
+     * @return Resource (never null)
+     */
+    protected final Resource getOrCreateResource(String path, String primaryType) {
+        try {
+            return ResourceUtil.getOrCreateResource(context.resourceResolver(), path, 
+                    ImmutableMap.<String,Object>of(JcrConstants.JCR_PRIMARYTYPE, primaryType),
+                    null, true);
+        }
+        catch (PersistenceException ex) {
+            throw new RuntimeException("Unable to create resource at " + path + ": " + ex.getMessage(), ex);
+        }
+    }
+    
+    /**
+     * Gets (and creates if required) a unique path at <code>/content/xxx</code>.
+     * The path (incl. all children) is automatically removed when the unit test completes.
+     * @return Unique content path
+     */
+    public final String content() {
+        if (contentRoot == null) {
+            contentRoot = getOrCreateResource("/content/" + uniquePathPart, NT_SLING_ORDERED_FOLDER);
+        }
+        return contentRoot.getPath();
+    }
+        
+    /**
+     * Gets (and creates if required) a unique path at <code>/apps/xxx</code>.
+     * The path (incl. all children) is automatically removed when the unit test completes.
+     * @return Unique content path
+     */
+    public final String apps() {
+        if (appsRoot == null) {
+            appsRoot = getOrCreateResource("/apps/" + uniquePathPart, NT_SLING_ORDERED_FOLDER);
+        }
+        return appsRoot.getPath();
+    }
+        
+    /**
+     * Gets (and creates if required) a unique path at <code>/libs/xxx</code>.
+     * The path (incl. all children) is automatically removed when the unit test completes.
+     * @return Unique content path
+     */
+    public final String libs() {
+        if (libsRoot == null) {
+            libsRoot = getOrCreateResource("/libs/" + uniquePathPart, NT_SLING_ORDERED_FOLDER);
+        }
+        return libsRoot.getPath();
+    }
+    
+    /**
+     * Cleanup is called when the unit test rule completes a unit test run.
+     * All resources created have to be removed.
+     */
+    protected void cleanUp() {
+        deleteResources(contentRoot, appsRoot, libsRoot);
+    }
+    
+    /**
+     * Deletes the given set of resources and commits afterwards.
+     * @param resources Resources to be deleted
+     */
+    protected final void deleteResources(Resource... resources) {
+        for (Resource resource : resources) {
+            if (resource != null) {
+                try {
+                    context.resourceResolver().delete(resource);
+                }
+                catch (PersistenceException ex) {
+                    log.warn("Unable to delete root path " + resource.getPath(), ex);
+                }
+            }
+        }
+        try {
+            context.resourceResolver().commit();
+        }
+        catch (PersistenceException ex) {
+            log.warn("Unable to commit root path deletions.", ex);
+        }
+            
+    }
+    
+}

Propchange: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Sep 27 09:46:11 2015
@@ -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/context/UniqueRoot.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=1705520&r1=1705519&r2=1705520&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 Sun Sep 27 09:46:11 2015
@@ -19,5 +19,5 @@
 /**
  * Rule for providing easy access to Sling context in JUnit tests.
  */
-@aQute.bnd.annotation.Version("3.0")
+@aQute.bnd.annotation.Version("3.1")
 package org.apache.sling.testing.mock.sling.junit;

Added: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java?rev=1705520&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java Sun Sep 27 09:46:11 2015
@@ -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.jcrmock.resource;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.resource.AbstractUniqueRootTest;
+
+public class UniqueRootTest extends AbstractUniqueRootTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_MOCK;
+    }
+
+}

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Sep 27 09:46:11 2015
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java?rev=1705520&r1=1705519&r2=1705520&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java Sun Sep 27 09:46:11 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.sling.resource;
 
+import static org.apache.sling.jcr.resource.JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY;
 import static org.junit.Assert.assertEquals;
 
 import javax.jcr.NamespaceRegistry;
@@ -58,7 +59,7 @@ public abstract class AbstractJcrNamespa
         Resource resource = resolver.getResource("/content/foo");
         
         ValueMap props = ResourceUtil.getValueMap(resource);
-        assertEquals("fooType", props.get("sling:resourceType"));
+        assertEquals("fooType", props.get(SLING_RESOURCE_TYPE_PROPERTY));
         assertEquals("fooType", resource.getResourceType());
     }
 
@@ -72,7 +73,7 @@ public abstract class AbstractJcrNamespa
         Resource resource = resolver.getResource("/content/foo");
         
         ValueMap props = ResourceUtil.getValueMap(resource);
-        assertEquals("fooType", props.get("sling:resourceType"));
+        assertEquals("fooType", props.get(SLING_RESOURCE_TYPE_PROPERTY));
         
         // since SLING-4773 sling namespace is readly registered in the MockJcrResourceResolverAdapter, so this will still work here
         assertEquals("fooType", resource.getResourceType());
@@ -88,7 +89,7 @@ public abstract class AbstractJcrNamespa
         Resource resource = resolver.getResource("/content/foo");
         
         ValueMap props = ResourceUtil.getValueMap(resource);
-        assertEquals("fooType", props.get("sling:resourceType"));
+        assertEquals("fooType", props.get(SLING_RESOURCE_TYPE_PROPERTY));
         assertEquals("fooType", resource.getResourceType());
     }
 

Modified: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java?rev=1705520&r1=1705519&r2=1705520&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java (original)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java Sun Sep 27 09:46:11 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.testing.mock.sling.resource;
 
+import static org.apache.sling.jcr.resource.JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -162,7 +163,7 @@ public abstract class AbstractJcrResourc
         Resource parent = resourceResolver.getResource(getTestRootNode().getPath());
 
         Resource child = resourceResolver.create(parent, "nodeTypeResource", ImmutableMap.<String, Object> builder()
-                .put("sling:resourceType", JcrConstants.NT_UNSTRUCTURED).build());
+                .put(SLING_RESOURCE_TYPE_PROPERTY, JcrConstants.NT_UNSTRUCTURED).build());
         assertNotNull(child);
         assertEquals(JcrConstants.NT_UNSTRUCTURED, child.getResourceType());
         assertEquals(JcrConstants.NT_UNSTRUCTURED, child.adaptTo(Node.class).getPrimaryNodeType().getName());

Added: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java?rev=1705520&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java Sun Sep 27 09:46:11 2015
@@ -0,0 +1,57 @@
+/*
+ * 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.resource;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+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 abstract class AbstractUniqueRootTest {
+    
+    @Rule
+    public SlingContext context = new SlingContext(getResourceResolverType());
+
+    protected abstract ResourceResolverType getResourceResolverType();
+
+    @Test
+    public void testContent() {
+        String path = context.uniqueRoot().content();
+        assertNotNull(context.resourceResolver().getResource(path));
+        assertTrue(path.matches("^/content/[^/]+"));
+    }
+
+    @Test
+    public void testApps() throws Exception {
+        String path = context.uniqueRoot().apps();
+        assertNotNull(context.resourceResolver().getResource(path));
+        assertTrue(path.matches("^/apps/[^/]+"));
+    }
+
+    @Test
+    public void testLibs() throws Exception {
+        String path = context.uniqueRoot().libs();
+        assertNotNull(context.resourceResolver().getResource(path));
+        assertTrue(path.matches("^/libs/[^/]+"));
+    }
+
+}

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Sep 27 09:46:11 2015
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java?rev=1705520&view=auto
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java (added)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java Sun Sep 27 09:46:11 2015
@@ -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.resource;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.resource.AbstractUniqueRootTest;
+
+public class UniqueRootTest extends AbstractUniqueRootTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.RESOURCERESOLVER_MOCK;
+    }
+
+}

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Sep 27 09:46:11 2015
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain