SLING-9203 - Perform script / class lookup using the Sling script naming conventions
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.DELETE.html
similarity index 100%
copy from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html
copy to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.DELETE.html
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.GET.html
similarity index 100%
rename from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html
rename to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.GET.html
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/HEAD.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.HEAD.html
similarity index 100%
rename from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/HEAD.selector-1.html
rename to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.HEAD.html
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.OPTIONS.html
similarity index 100%
copy from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html
copy to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.OPTIONS.html
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.PATCH.html
similarity index 100%
copy from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html
copy to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.PATCH.html
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.POST.html
similarity index 100%
copy from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html
copy to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.POST.html
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.PUT.html
similarity index 100%
copy from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html
copy to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.PUT.html
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.TRACE.html
similarity index 100%
copy from examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/GET.selector-1.html
copy to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.TRACE.html
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchIT.java
index adab69c..03427df 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchIT.java
@@ -60,7 +60,7 @@
         HttpResponse response = getResponse(HttpHead.METHOD_NAME, "/content/srr/examples/script-matching.selector-1.html", 200);
         Header[] header = response.getHeaders("X-Script-Name");
         assertEquals("Expected to find one X-Script-Name header.", 1, header.length);
-        assertEquals("/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/HEAD.selector-1.html",
+        assertEquals("/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/selector-1.HEAD.html",
                 header[0].getValue());
     }
 
@@ -70,31 +70,61 @@
     }
 
     @Test
+    public void testOPTIONSMethodSelectorMatching() throws Exception {
+        testHttpMethodScriptMatching("/content/srr/examples/script-matching.selector-1.html", HttpOptions.METHOD_NAME);
+    }
+
+    @Test
     public void testPOSTMethodMatching() throws Exception {
         testHttpMethodScriptMatching("/content/srr/examples/script-matching.html", HttpPost.METHOD_NAME);
     }
 
     @Test
+    public void testPOSTMethodSelectorMatching() throws Exception {
+        testHttpMethodScriptMatching("/content/srr/examples/script-matching.selector-1.html", HttpPost.METHOD_NAME);
+    }
+
+    @Test
     public void testPATCHMethodMatching() throws Exception {
         testHttpMethodScriptMatching("/content/srr/examples/script-matching.html", HttpPatch.METHOD_NAME);
     }
 
     @Test
+    public void testPATCHMethodSelectorMatching() throws Exception {
+        testHttpMethodScriptMatching("/content/srr/examples/script-matching.selector-1.html", HttpPatch.METHOD_NAME);
+    }
+
+    @Test
     public void testPUTMethodMatching() throws Exception {
         testHttpMethodScriptMatching("/content/srr/examples/script-matching.html", HttpPut.METHOD_NAME);
     }
 
     @Test
+    public void testPUTMethodSelectorMatching() throws Exception {
+        testHttpMethodScriptMatching("/content/srr/examples/script-matching.selector-1.html", HttpPut.METHOD_NAME);
+    }
+
+    @Test
     public void testDELETEMethodMatching() throws Exception {
         testHttpMethodScriptMatching("/content/srr/examples/script-matching.html", HttpDelete.METHOD_NAME);
     }
 
     @Test
+    public void testDELETEMethodSelectorMatching() throws Exception {
+        testHttpMethodScriptMatching("/content/srr/examples/script-matching.selector-1.html", HttpDelete.METHOD_NAME);
+    }
+
+    @Test
     public void testTRACEMethodMatching() throws Exception {
         testHttpMethodScriptMatching("/content/srr/examples/script-matching.html", HttpTrace.METHOD_NAME);
     }
 
     @Test
+    public void testTRACEMethodSelectorMatching() throws Exception {
+        testHttpMethodScriptMatching("/content/srr/examples/script-matching.selector-1.html", HttpTrace.METHOD_NAME);
+    }
+
+    @Test
     public void testSelectorMatching() throws Exception {
         Document document = getDocument("/content/srr/examples/script-matching.selector-2.html");
         assertTrue(document.select("div").html().contains("/javax.script/org.apache.sling.scripting.examplebundle" +
@@ -115,8 +145,8 @@
         } else {
             throw new IllegalArgumentException("The following URL doesn't seem to be correctly handled: " + url);
         }
-        String expectedScriptName = "/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/" + httpMethod +
-                (StringUtils.isNotEmpty(selectorString) ? "." + selectorString : "") + "." + extension;
+        String expectedScriptName = "/javax.script/org.apache.sling.scripting.examplebundle.scriptmatching/1.0.0/" +
+                (StringUtils.isNotEmpty(selectorString) ? selectorString + "." : "") + httpMethod + "." + extension;
         assertTrue(document.select("div").html().contains(expectedScriptName));
     }