incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r731309 - /incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2Test.java
Date Sun, 04 Jan 2009 18:19:44 GMT
Author: fmeschbe
Date: Sun Jan  4 10:19:44 2009
New Revision: 731309

URL: http://svn.apache.org/viewvc?rev=731309&view=rev
Log:
Add more unit tests

Modified:
    incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2Test.java

Modified: incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2Test.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2Test.java?rev=731309&r1=731308&r2=731309&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2Test.java
(original)
+++ incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2Test.java
Sun Jan  4 10:19:44 2009
@@ -811,6 +811,51 @@
         String path = rootNode.getPath();
         String mapped = resResolver.map(path);
         assertEquals(path, mapped);
+        
+        Node child = rootNode.addNode("child");
+        session.save();
+        
+        // absolute path, expect rootPath segment to be
+        // cut off the mapped path because we map the rootPath
+        // onto root
+        path = "/child";
+        mapped = resResolver.map(child.getPath());
+        assertEquals(path, mapped);
+    }
+    
+    public void testMapNamespaceMangling() throws Exception {
+        
+        final String mapHost = "virtual.host.com";
+        final String mapRootPath = "/content/virtual";
+        
+        Node virtualhost80 = mapRoot.getNode("map/http").addNode(
+            mapHost + ".80", "sling:Mapping");
+        virtualhost80.setProperty(JcrResourceResolver2.PROP_REDIRECT_INTERNAL,
+            mapRootPath);
+        session.save();
+
+        Thread.sleep(1000L);
+
+        final HttpServletRequest foreignRequest = new ResourceResolverTestRequest(null,
+            "foreign.host.com", -1, rootPath);
+        final HttpServletRequest virtualRequest = new ResourceResolverTestRequest(null,
+            mapHost, -1, rootPath);
+
+        // simple mapping - cut off prefix and add host
+        final String path0 = "/sample";
+        final String mapped0 = resResolver.map(foreignRequest, mapRootPath + path0);
+        assertEquals("http://" + mapHost + path0, mapped0);
+        
+        // expected name mangling without host prefix
+        final String path1 = "/sample/jcr:content";
+        final String mapped1 = resResolver.map(virtualRequest, mapRootPath + path1);
+        assertEquals(path1, mapped1);
+    }
+    
+    public void testMapContext() throws Exception {
+        String path = rootNode.getPath();
+        String mapped = resResolver.map(path);
+        assertEquals(path, mapped);
 
         Node child = rootNode.addNode("child");
         session.save();



Mime
View raw message