incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1130846 - /sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
Date Thu, 02 Jun 2011 22:06:01 GMT
Author: justin
Date: Thu Jun  2 22:06:01 2011
New Revision: 1130846

URL: http://svn.apache.org/viewvc?rev=1130846&view=rev
Log:
adding a test for aliases within a non-default workspace

Modified:
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java?rev=1130846&r1=1130845&r2=1130846&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
Thu Jun  2 22:06:01 2011
@@ -1826,6 +1826,52 @@ public class JcrResourceResolverTest ext
         assertEquals(grandchild.getPath(), resNodeEnkel.getPath());
     }
 
+    public void test_resolve_with_sling_alias_ws() throws Exception {
+
+        Node child = rootWs2Node.addNode("child");
+        child.setProperty(JcrResourceResolver.PROP_ALIAS, "kind");
+        ws2Session.save();
+
+        String path = "/kind";
+
+        HttpServletRequest request = new ResourceResolverTestRequest(path);
+        request.setAttribute(ResourceResolver.REQUEST_ATTR_WORKSPACE_INFO,
+            "ws2");
+
+        Resource res = mwResResolver.resolve(request, path);
+        assertNotNull(res);
+        assertEquals(rootWs2Node.getPath() + "/kind",
+            res.getResourceMetadata().getResolutionPath());
+        assertEquals("", res.getResourceMetadata().getResolutionPathInfo());
+
+        Node resNode = res.adaptTo(Node.class);
+        assertNotNull(resNode);
+
+        assertEquals(child.getPath(), resNode.getPath());
+
+        // second level alias
+        Node grandchild = child.addNode("grandchild");
+        grandchild.setProperty(JcrResourceResolver.PROP_ALIAS, "enkel");
+        ws2Session.save();
+
+        // expect kind/enkel due to alias and no parent due to mapping
+        // the rootPath onto root
+        String pathEnkelNoWS = "/kind/enkel";
+        String pathEnkel = "ws2:" + pathEnkelNoWS;
+        String mappedEnkel = mwResResolver.map(request, grandchild.getPath());
+        assertEquals(pathEnkelNoWS, mappedEnkel);
+
+        Resource resEnkel = mwResResolver.resolve(request, pathEnkel);
+        assertNotNull(resEnkel);
+        assertEquals(rootNode.getPath() + "/kind/enkel",
+            resEnkel.getResourceMetadata().getResolutionPath());
+        assertEquals("", resEnkel.getResourceMetadata().getResolutionPathInfo());
+
+        Node resNodeEnkel = resEnkel.adaptTo(Node.class);
+        assertNotNull(resNodeEnkel);
+        assertEquals(grandchild.getPath(), resNodeEnkel.getPath());
+    }
+
     public void test_resolve_with_sling_alias_multi_value() throws Exception {
 
         Node child = rootNode.addNode("child");



Mime
View raw message