incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r653479 - in /incubator/sling/trunk/sling/servlet-resolver/src: main/java/org/apache/sling/servlet/resolver/helper/ test/java/org/apache/sling/servlet/resolver/helper/
Date Mon, 05 May 2008 13:42:23 GMT
Author: fmeschbe
Date: Mon May  5 06:42:23 2008
New Revision: 653479

URL: http://svn.apache.org/viewvc?rev=653479&view=rev
Log:
SLING-387 Fix last resort to only accept servlets and not any script and
modify test for POST method to not expected selector consideration

Modified:
    incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java
    incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java
    incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java

Modified: incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java?rev=653479&r1=653478&r2=653479&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java
(original)
+++ incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java
Mon May  5 06:42:23 2008
@@ -30,6 +30,7 @@
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.api.resource.SyntheticResource;
 import org.apache.sling.api.servlets.HttpConstants;
+import org.apache.sling.servlet.resolver.resource.ServletResourceProvider;
 
 public class LocationUtil {
 
@@ -91,26 +92,17 @@
                 ordinal++;
             }
         }
-        
+
         // special treatment for servlets registered with neither a method
         // name nor extensions and selectors
-        String path = location.getPath();
-        String label = ResourceUtil.getName(path);
-        location = getResource(null, ResourceUtil.getParent(path));
-        children = getResolver().listChildren(location);
-        while (children.hasNext()) {
-            Resource child = children.next();
-
-            String name = ResourceUtil.getName(child.getPath());
-            String[] parts = name.split("\\.");
-
-            // require base name plus script extension
-            if (parts.length == 2 && label.equals(parts[0])) {
-                LocationResource lr = new LocationResource(ordinal, child, 0,
-                    LocationResource.WEIGHT_LAST_RESSORT);
-                resources.add(lr);
-                ordinal++;
-            }
+        String path = location.getPath()
+            + ServletResourceProvider.SERVLET_PATH_EXTENSION;
+        location = getResolver().getResource(path);
+        if (location != null) {
+            LocationResource lr = new LocationResource(ordinal, location, 0,
+                LocationResource.WEIGHT_LAST_RESSORT);
+            resources.add(lr);
+            ordinal++;
         }
 
         return ordinal;

Modified: incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java?rev=653479&r1=653478&r2=653479&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java
(original)
+++ incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java
Mon May  5 06:42:23 2008
@@ -108,6 +108,26 @@
         effectiveTest(names, baseIdxs, indices);
     }
     
+    public void testGetServlets4() {
+        String[] names = { ".servlet", // 0
+                "/" + label + ".esp", // 1
+                "/GET.esp", // 2
+                "/" + label + ".html.esp", // 3
+                "/html.esp", // 4
+                ".esp", // 5
+                "/image.esp", // 6
+                "/print/other.esp", // 7
+                "/print.other.esp", // 8
+                "/print.html.esp", // 9
+                "/print/a4.html.esp", // 10
+        };
+        
+        int[] baseIdxs = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 };
+        int[] indices = { 10, 9, 3, 4, 1, 2, 0 };
+        
+        effectiveTest(names, baseIdxs, indices);
+    }
+    
     protected void effectiveTest(String[] names, int[] baseIdxs, int[] indices) {
 
         String[] base = { "/apps/" + resourceTypePath,

Modified: incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java?rev=653479&r1=653478&r2=653479&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java
(original)
+++ incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java
Mon May  5 06:42:23 2008
@@ -149,9 +149,7 @@
         assertScript("POST", null, "html", scripts, null);
     }
     
-    /** CURRENTLY FAILS, SLING-387
     public void testHtmlPostSelectors() {
-        assertScript("POST", "print.a4", "html", SET_A, "/apps/foo/bar/print/POST.esp");
+        assertScript("POST", "print.a4", "html", SET_A, "/apps/foo/bar/POST.esp");
     }
-    */
 }



Mime
View raw message