You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2020/03/19 20:53:29 UTC
[sling-org-apache-sling-scripting-bundle-tracker-it] branch master
updated: SLING-9203 - Perform script / class lookup using the Sling script
naming conventions
This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-bundle-tracker-it.git
The following commit(s) were added to refs/heads/master by this push:
new 36c76c6 SLING-9203 - Perform script / class lookup using the Sling script naming conventions
36c76c6 is described below
commit 36c76c612e324bac652eb379127cf3c8770d54c5
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Mar 19 21:52:50 2020 +0100
SLING-9203 - Perform script / class lookup using the Sling script naming conventions
---
...{GET.selector-1.html => selector-1.DELETE.html} | 0
.../{GET.selector-1.html => selector-1.GET.html} | 0
.../{HEAD.selector-1.html => selector-1.HEAD.html} | 0
...GET.selector-1.html => selector-1.OPTIONS.html} | 0
.../{GET.selector-1.html => selector-1.PATCH.html} | 0
.../{GET.selector-1.html => selector-1.POST.html} | 0
.../{GET.selector-1.html => selector-1.PUT.html} | 0
.../{GET.selector-1.html => selector-1.TRACE.html} | 0
.../scripting/bundle/tracker/it/ScriptMatchIT.java | 36 ++++++++++++++++++++--
9 files changed, 33 insertions(+), 3 deletions(-)
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%
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.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%
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.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 @@ public class ScriptMatchIT extends AbstractEndpointIT {
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 @@ public class ScriptMatchIT extends AbstractEndpointIT {
}
@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 @@ public class ScriptMatchIT extends AbstractEndpointIT {
} 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));
}