You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2012/05/24 08:42:54 UTC

svn commit: r1342154 [5/5] - in /sling/whiteboard/SLING-2396/resourceresolver: ./ src/main/java/org/apache/sling/jcr/resource/ src/main/java/org/apache/sling/jcr/resource/internal/ src/main/java/org/apache/sling/jcr/resource/internal/helper/ src/main/j...

Modified: sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java?rev=1342154&r1=1342153&r2=1342154&view=diff
==============================================================================
--- sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java (original)
+++ sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverTest.java Thu May 24 06:42:52 2012
@@ -63,6 +63,7 @@ import org.apache.sling.jcr.resource.int
 import org.apache.sling.jcr.resource.internal.helper.Mapping;
 import org.apache.sling.jcr.resource.internal.helper.RedirectResource;
 import org.apache.sling.jcr.resource.internal.helper.starresource.StarResource;
+import org.apache.sling.resourceresolver.impl.ResourceResolverImpl;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.service.event.Event;
@@ -703,7 +704,7 @@ public class JcrResourceResolverTest ext
         HttpServletRequest request = new ResourceResolverTestRequest("https",
             null, -1, rootPath);
         Node localhost443 = mapRoot.getNode("map/https/localhost.443");
-        localhost443.setProperty(JcrResourceResolver.PROP_REDIRECT_EXTERNAL,
+        localhost443.setProperty(ResourceResolverImpl.PROP_REDIRECT_EXTERNAL,
             "http://localhost");
         session.save();
 
@@ -722,7 +723,7 @@ public class JcrResourceResolverTest ext
         HttpServletRequest request = new ResourceResolverTestRequest("https",
             null, -1, rootPath);
         Node localhost443 = mapRoot.getNode("map/https/localhost.443");
-        localhost443.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        localhost443.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "http://localhost");
         session.save();
 
@@ -744,9 +745,9 @@ public class JcrResourceResolverTest ext
         Node localhost443 = mapRoot.getNode("map/https/localhost.443");
         Node toContent = localhost443.addNode("_playground_designground_",
             "sling:Mapping");
-        toContent.setProperty(JcrResourceResolver.PROP_REG_EXP,
+        toContent.setProperty(ResourceResolverImpl.PROP_REG_EXP,
             "(playground|designground)");
-        toContent.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        toContent.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content/$1");
         session.save();
 
@@ -769,8 +770,8 @@ public class JcrResourceResolverTest ext
         HttpServletRequest request = new ResourceResolverTestRequest("https", null, -1, rootPath);
         Node localhost443 = mapRoot.getNode("map/https/localhost.443");
         Node toContent = localhost443.addNode("_playground_designground_", "sling:Mapping");
-        toContent.setProperty(JcrResourceResolver.PROP_REG_EXP, "(playground|designground)");
-        toContent.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL, "/content/$1");
+        toContent.setProperty(ResourceResolverImpl.PROP_REG_EXP, "(playground|designground)");
+        toContent.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL, "/content/$1");
         session.save();
 
         Thread.sleep(1000L);
@@ -788,7 +789,7 @@ public class JcrResourceResolverTest ext
         assertEquals("/libs/nt/folder.html", res.getPath());
 
         // update the match
-        toContent.setProperty(JcrResourceResolver.PROP_REG_EXP, "(homeground|foreignground)");
+        toContent.setProperty(ResourceResolverImpl.PROP_REG_EXP, "(homeground|foreignground)");
         session.save();
         Thread.sleep(1000L);
 
@@ -810,8 +811,8 @@ public class JcrResourceResolverTest ext
             null, -1, rootPath);
         Node localhost443 = mapRoot.getNode("map/https/localhost.443");
         Node toContent = localhost443.addNode("virtual", "sling:Mapping");
-        toContent.setProperty(JcrResourceResolver.PROP_REG_EXP, "virtual$");
-        toContent.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        toContent.setProperty(ResourceResolverImpl.PROP_REG_EXP, "virtual$");
+        toContent.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content/virtual.html");
         session.save();
 
@@ -845,13 +846,13 @@ public class JcrResourceResolverTest ext
 
         // map anything
         Node localhost443 = mapRoot.getNode("map/https/localhost.443");
-        localhost443.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        localhost443.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content");
 
         // map only ../virtual
         Node toContent = localhost443.addNode("virtual", "sling:Mapping");
-        toContent.setProperty(JcrResourceResolver.PROP_REG_EXP, "virtual$");
-        toContent.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        toContent.setProperty(ResourceResolverImpl.PROP_REG_EXP, "virtual$");
+        toContent.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content/virtual.html");
         session.save();
 
@@ -875,7 +876,7 @@ public class JcrResourceResolverTest ext
             "virtual.host.com", -1, rootPath);
         Node virtualhost80 = mapRoot.getNode("map/http").addNode(
             "virtual.host.com.80", "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content/virtual");
         session.save();
 
@@ -912,11 +913,11 @@ public class JcrResourceResolverTest ext
 
         Node virtualhost80 = mapRoot.getNode("map/http").addNode(
             hostDE + ".80", "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             contentDE);
         virtualhost80 = mapRoot.getNode("map/http").addNode(hostEN + ".80",
             "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             contentEN);
         session.save();
 
@@ -982,11 +983,11 @@ public class JcrResourceResolverTest ext
 
         Node virtualhost80 = mapRoot.getNode("map/http").addNode(
             hostDE + ".80", "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/");
         virtualhost80 = mapRoot.getNode("map/http").addNode(hostEN + ".80",
             "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/");
         session.save();
 
@@ -1077,7 +1078,7 @@ public class JcrResourceResolverTest ext
             "virtual.host.com", 8080, rootPath);
         Node virtualhost80 = mapRoot.getNode("map/http").addNode(
             "virtual.host.com.8080", "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content/virtual");
         session.save();
 
@@ -1109,7 +1110,7 @@ public class JcrResourceResolverTest ext
             "virtual.host.com", 8080, rootPath);
         Node virtualhost80 = mapRoot.getNode("map/http").addNode(
             "virtual.host.com.8080", "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/");
         session.save();
 
@@ -1141,7 +1142,7 @@ public class JcrResourceResolverTest ext
             "virtual.host.com", -1, rootPath);
         Node virtualhost443 = mapRoot.getNode("map/https").addNode(
             "virtual.host.com.443", "sling:Mapping");
-        virtualhost443.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost443.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content/virtual");
         session.save();
 
@@ -1172,7 +1173,7 @@ public class JcrResourceResolverTest ext
             "virtual.host.com", 4443, rootPath);
         Node virtualhost4443 = mapRoot.getNode("map/https").addNode(
             "virtual.host.com.4443", "sling:Mapping");
-        virtualhost4443.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost4443.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             "/content/virtual");
         session.save();
 
@@ -1207,11 +1208,11 @@ public class JcrResourceResolverTest ext
 
         Node virtualhost80 = mapRoot.getNode("map/http").addNode(host0 + ".80",
             "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             content);
         Node virtualhost443 = mapRoot.getNode("map/https").addNode(
             host0 + ".443", "sling:Mapping");
-        virtualhost443.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost443.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             content);
         session.save();
 
@@ -1284,7 +1285,7 @@ public class JcrResourceResolverTest ext
     public void testResolveResourceAlias() throws Exception {
         // define an alias for the rootPath
         String alias = "testAlias";
-        rootNode.setProperty(JcrResourceResolver.PROP_ALIAS, alias);
+        rootNode.setProperty(ResourceResolverImpl.PROP_ALIAS, alias);
         session.save();
 
         String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
@@ -1324,7 +1325,7 @@ public class JcrResourceResolverTest ext
         // define an alias for the rootPath in the jcr:content child node
         String alias = "testAlias";
         Node content = rootNode.addNode("jcr:content", "nt:unstructured");
-        content.setProperty(JcrResourceResolver.PROP_ALIAS, alias);
+        content.setProperty(ResourceResolverImpl.PROP_ALIAS, alias);
         session.save();
 
         String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
@@ -1366,7 +1367,7 @@ public class JcrResourceResolverTest ext
                 Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
 
         Node child = rootNode.addNode("child", "nt:unstructured");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, alias);
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, alias);
         session.save();
 
         res = resResolver.resolve(request, path);
@@ -1519,7 +1520,7 @@ public class JcrResourceResolverTest ext
         Node internalRedirect = mapRoot.getNode("map/http").addNode(
             mapHostInternal + ".80", "sling:Mapping");
         internalRedirect.setProperty(
-            JcrResourceResolver.PROP_REDIRECT_INTERNAL, mapRootInternal);
+            ResourceResolverImpl.PROP_REDIRECT_INTERNAL, mapRootInternal);
         session.save();
 
         Thread.sleep(1000L);
@@ -1573,7 +1574,7 @@ public class JcrResourceResolverTest ext
 
         Node virtualhost80 = mapRoot.getNode("map/http").addNode(
             mapHost + ".80", "sling:Mapping");
-        virtualhost80.setProperty(JcrResourceResolver.PROP_REDIRECT_INTERNAL,
+        virtualhost80.setProperty(ResourceResolverImpl.PROP_REDIRECT_INTERNAL,
             mapRootPath);
         session.save();
 
@@ -1797,7 +1798,7 @@ public class JcrResourceResolverTest ext
     public void testMapResourceAlias() throws Exception {
     	// define an alias for the rootPath
         String alias = "testAlias";
-        rootNode.setProperty(JcrResourceResolver.PROP_ALIAS, alias);
+        rootNode.setProperty(ResourceResolverImpl.PROP_ALIAS, alias);
         session.save();
 
     	String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
@@ -1817,7 +1818,7 @@ public class JcrResourceResolverTest ext
         // define an alias for the rootPath in the jcr:content child node
         String alias = "testAlias";
         Node content = rootNode.addNode("jcr:content", "nt:unstructured");
-        content.setProperty(JcrResourceResolver.PROP_ALIAS, alias);
+        content.setProperty(ResourceResolverImpl.PROP_ALIAS, alias);
         session.save();
 
         String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath)
@@ -2077,7 +2078,7 @@ public class JcrResourceResolverTest ext
     public void test_resolve_with_sling_alias() throws Exception {
 
         Node child = rootNode.addNode("child");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, "kind");
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, "kind");
         session.save();
 
         // expect kind due to alias and no parent due to mapping
@@ -2099,7 +2100,7 @@ public class JcrResourceResolverTest ext
 
         // second level alias
         Node grandchild = child.addNode("grandchild");
-        grandchild.setProperty(JcrResourceResolver.PROP_ALIAS, "enkel");
+        grandchild.setProperty(ResourceResolverImpl.PROP_ALIAS, "enkel");
         session.save();
 
         // expect kind/enkel due to alias and no parent due to mapping
@@ -2123,7 +2124,7 @@ public class JcrResourceResolverTest ext
         Principal testUserPrincipal = AccessControlUtil.getPrincipalManager(session).getPrincipal("testuser");
 
         Node child = rootNode.addNode("child");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, "kind");
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, "kind");
         AccessControlUtil.replaceAccessControlEntry(session, child.getPath(), testUserPrincipal, null, new String[] {"jcr:all"}, null, "last");
         session.save();
 
@@ -2147,7 +2148,7 @@ public class JcrResourceResolverTest ext
 
             // second level alias
             Node grandchild = child.addNode("grandchild");
-            grandchild.setProperty(JcrResourceResolver.PROP_ALIAS, "enkel");
+            grandchild.setProperty(ResourceResolverImpl.PROP_ALIAS, "enkel");
             AccessControlUtil.replaceAccessControlEntry(session, grandchild.getPath(), testUserPrincipal, new String[] { "jcr:all" }, null, null, "first");
             session.save();
 
@@ -2178,7 +2179,7 @@ public class JcrResourceResolverTest ext
     public void test_resolve_with_sling_alias_ws() throws Exception {
 
         Node child = rootWs2Node.addNode("child");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, "kind");
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, "kind");
         ws2Session.save();
 
         String path = "/kind";
@@ -2200,7 +2201,7 @@ public class JcrResourceResolverTest ext
 
         // second level alias
         Node grandchild = child.addNode("grandchild");
-        grandchild.setProperty(JcrResourceResolver.PROP_ALIAS, "enkel");
+        grandchild.setProperty(ResourceResolverImpl.PROP_ALIAS, "enkel");
         ws2Session.save();
 
         // expect kind/enkel due to alias and no parent due to mapping
@@ -2224,7 +2225,7 @@ public class JcrResourceResolverTest ext
     public void test_resolve_with_sling_alias_multi_value() throws Exception {
 
         Node child = rootNode.addNode("child");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, new String[] {
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, new String[] {
             "kind", "enfant" });
         session.save();
 
@@ -2264,7 +2265,7 @@ public class JcrResourceResolverTest ext
 
         // second level alias
         Node grandchild = child.addNode("grandchild");
-        grandchild.setProperty(JcrResourceResolver.PROP_ALIAS, "enkel");
+        grandchild.setProperty(ResourceResolverImpl.PROP_ALIAS, "enkel");
         session.save();
 
         // expect kind/enkel due to alias and no parent due to mapping
@@ -2305,7 +2306,7 @@ public class JcrResourceResolverTest ext
         final String selExt = ".html";
 
         Node child = rootNode.addNode("child");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, "kind");
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, "kind");
         session.save();
 
         // expect kind due to alias and no parent due to mapping
@@ -2326,7 +2327,7 @@ public class JcrResourceResolverTest ext
 
         // second level alias
         Node grandchild = child.addNode("grandchild");
-        grandchild.setProperty(JcrResourceResolver.PROP_ALIAS, "enkel");
+        grandchild.setProperty(ResourceResolverImpl.PROP_ALIAS, "enkel");
         session.save();
 
         // expect kind/enkel due to alias and no parent due to mapping
@@ -2353,7 +2354,7 @@ public class JcrResourceResolverTest ext
         final String selExt = ".sel1.sel2.html";
 
         Node child = rootNode.addNode("child");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, "kind");
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, "kind");
         session.save();
 
         // expect kind due to alias and no parent due to mapping
@@ -2374,7 +2375,7 @@ public class JcrResourceResolverTest ext
 
         // second level alias
         Node grandchild = child.addNode("grandchild");
-        grandchild.setProperty(JcrResourceResolver.PROP_ALIAS, "enkel");
+        grandchild.setProperty(ResourceResolverImpl.PROP_ALIAS, "enkel");
         session.save();
 
         // expect kind/enkel due to alias and no parent due to mapping
@@ -2401,7 +2402,7 @@ public class JcrResourceResolverTest ext
         final String selExt = ".html/some/suffx.pdf";
 
         Node child = rootNode.addNode("child");
-        child.setProperty(JcrResourceResolver.PROP_ALIAS, "kind");
+        child.setProperty(ResourceResolverImpl.PROP_ALIAS, "kind");
         session.save();
 
         // expect kind due to alias and no parent due to mapping

Modified: sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/helper/RedirectResourceTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/helper/RedirectResourceTest.java?rev=1342154&r1=1342153&r2=1342154&view=diff
==============================================================================
--- sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/helper/RedirectResourceTest.java (original)
+++ sling/whiteboard/SLING-2396/resourceresolver/src/test/java/org/apache/sling/jcr/resource/internal/helper/RedirectResourceTest.java Thu May 24 06:42:52 2012
@@ -40,13 +40,13 @@ public class RedirectResourceTest extend
 
         final Map<?, ?> map = res.adaptTo(Map.class);
         assertNotNull("Expected Map adapter", map);
-        assertEquals(target, map.get(RedirectResource.PROP_SLING_TARGET));
-        assertEquals(status, ((Integer) map.get(RedirectResource.PROP_SLING_STATUS)).intValue());
+        assertEquals(target, map.getFactoryResourceProvider(RedirectResource.PROP_SLING_TARGET));
+        assertEquals(status, ((Integer) map.getFactoryResourceProvider(RedirectResource.PROP_SLING_STATUS)).intValue());
 
         final ValueMap valueMap = res.adaptTo(ValueMap.class);
         assertNotNull("Expected ValueMap adapter", valueMap);
-        assertEquals(target, valueMap.get(RedirectResource.PROP_SLING_TARGET));
-        assertEquals(status, ((Integer) valueMap.get(RedirectResource.PROP_SLING_STATUS)).intValue());
+        assertEquals(target, valueMap.getFactoryResourceProvider(RedirectResource.PROP_SLING_TARGET));
+        assertEquals(status, ((Integer) valueMap.getFactoryResourceProvider(RedirectResource.PROP_SLING_STATUS)).intValue());
         assertEquals(status, valueMap.get(RedirectResource.PROP_SLING_STATUS, Integer.class).intValue());
 
         final PersistableValueMap persistableValueMap = res.adaptTo(PersistableValueMap.class);