sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1594147 - /sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java
Date Tue, 13 May 2014 06:48:24 GMT
Author: asanso
Date: Tue May 13 06:48:23 2014
New Revision: 1594147

URL: http://svn.apache.org/r1594147
Log:
SLING-3505 - Improve handling of updates to mapping (alias, vanity path)

Modified:
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java

Modified: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java?rev=1594147&r1=1594146&r2=1594147&view=diff
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java
(original)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java
Tue May 13 06:48:23 2014
@@ -1334,7 +1334,68 @@ public class ResourceResolverTest {
             saveMappings(session);
         }
     }
+    
+    @Test public void testResolveRemovedVanityPath() throws Exception {          
+        String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
+                + "/" + vanity[0] + ".print.html");
 
+        HttpServletRequest request = new FakeSlingHttpServletRequest(path);
+        Resource res = resResolver.resolve(request, path);
+        assertNotNull(res);
+        assertEquals(rootPath, res.getPath());
+        assertEquals(rootNode.getPrimaryNodeType().getName(),
+                res.getResourceType());
+
+        assertEquals(".print.html",
+                res.getResourceMetadata().getResolutionPathInfo());
+
+        assertNotNull(res.adaptTo(Node.class));
+        assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
+
+        //remove vanityPath property
+        rootNode.getProperty("sling:vanityPath").remove();
+        saveMappings(session);
+
+        res = resResolver.resolve(request, path);
+        assertNotNull(res);
+        assertTrue(res instanceof NonExistingResource);
+        assertEquals("/"+vanity[0]+".print.html", res.getPath());
+
+        //restore vanityPath
+        rootNode.setProperty("sling:vanityPath", vanity);
+        saveMappings(session);
+
+        //create new child with vanity path
+        Node childNode = maybeCreateNode(rootNode, "rootChild", "nt:unstructured");
+        childNode.setProperty("sling:vanityPath", "childVanity");
+        childNode.addMixin("sling:VanityPath");
+        saveMappings(session);
+
+        path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
+                + "/childVanity.print.html");
+
+        request = new FakeSlingHttpServletRequest(path);
+        res = resResolver.resolve(request, path);
+        assertNotNull(res);
+        assertEquals(childNode.getPath(), res.getPath());
+        assertEquals(childNode.getPrimaryNodeType().getName(),
+                res.getResourceType());
+
+        assertEquals(".print.html",
+                res.getResourceMetadata().getResolutionPathInfo());
+
+        assertNotNull(res.adaptTo(Node.class));
+        assertTrue(childNode.isSame(res.adaptTo(Node.class)));
+
+        //remove node with vanity path
+        childNode.remove();
+        saveMappings(session);
+
+        res = resResolver.resolve(request, path);
+        assertNotNull(res);
+        assertTrue(res instanceof NonExistingResource);
+        assertEquals("/childVanity.print.html", res.getPath());
+    }
 
     @Test public void testGetDoesNotGoUp() throws Exception {
 



Mime
View raw message