You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2022/02/21 10:41:04 UTC
[sling-org-apache-sling-scripting-bundle-tracker-it] branch master updated: SLING-11155 - Bundled scripts should be registered by path for the main script when overriding (#4)
This is an automated email from the ASF dual-hosted git repository.
pauls 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 3af8bcd SLING-11155 - Bundled scripts should be registered by path for the main script when overriding (#4)
3af8bcd is described below
commit 3af8bcde8dbe965a3639b0d70470d011b1056159
Author: Karl Pauls <ka...@gmail.com>
AuthorDate: Mon Feb 21 11:38:32 2022 +0100
SLING-11155 - Bundled scripts should be registered by path for the main script when overriding (#4)
* SLING-11155: add a test case for SLING-11155 to make sure we don't override the default GET servlet for proxies
* Update to latest scripting.core
---
.../main/resources/SLING-INF/content/examplebundle.xml | 9 +++++++++
it/pom.xml | 2 +-
.../scripting/bundle/tracker/it/ScriptMatchIT.java | 17 +++++++++++++++++
.../scripting/bundle/tracker/it/ScriptMatchPostIT.java | 13 -------------
4 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/SLING-INF/content/examplebundle.xml b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/SLING-INF/content/examplebundle.xml
index 4d33f5f..f00925c 100644
--- a/examples/org-apache-sling-scripting-examplebundle/src/main/resources/SLING-INF/content/examplebundle.xml
+++ b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/SLING-INF/content/examplebundle.xml
@@ -89,4 +89,13 @@
<type>String</type>
</property>
</node>
+<node>
+<name>script-matching-no-version-rtsuper</name>
+<primaryNodeType>nt:unstructured</primaryNodeType>
+<property>
+ <name>sling:resourceType</name>
+ <value>rtsuper</value>
+ <type>String</type>
+</property>
+</node>
diff --git a/it/pom.xml b/it/pom.xml
index 8b0fce8..5221057 100644
--- a/it/pom.xml
+++ b/it/pom.xml
@@ -182,7 +182,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.scripting.core</artifactId>
- <version>2.4.3-SNAPSHOT</version>
+ <version>2.4.4</version>
<scope>test</scope>
</dependency>
<dependency>
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 88ee053..014cd68 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
@@ -133,6 +133,23 @@ public class ScriptMatchIT extends AbstractEndpointTestBase {
".scriptmatching/1.0.0/selector-2.html"));
}
+ /*
+ * We need to test that we don't override the default GET servlet for resource types without a script
+ * This scenario can happen when we extend a resource type without providing a script ourself
+ * in this case, the registration should not override the default servlets for the none default extension.
+ * In other words, in this case, only the default extension should be handled by the resource super type -
+ * all other extensions should be handled by the default servlet.
+ */
+ @Test
+ public void testDefaultGETServlet() throws Exception {
+ // First test that the default extension is handled by the super type
+ Document document = getDocument(SCRIPT_MATCHING_BASE + "-no-version-rtsuper.html");
+ assertTrue(document.html().contains("/libs/rtsuper"));
+ // and now test that the none default json extension is not handled by it
+ document = getDocument(SCRIPT_MATCHING_BASE + "-no-version-rtsuper.json");
+ assertTrue(!document.html().contains("/libs/rtsuper"));
+ }
+
private void testHttpMethodScriptMatching(String url, String httpMethod) throws Exception {
Document document = getDocument(url, httpMethod);
String path = url.substring(url.lastIndexOf('/'));
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchPostIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchPostIT.java
index cf3e78b..637cfbb 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchPostIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ScriptMatchPostIT.java
@@ -18,22 +18,9 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package org.apache.sling.scripting.bundle.tracker.it;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpOptions;
-import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpTrace;
import org.jsoup.nodes.Document;
import org.junit.Test;
-
-import static junit.framework.TestCase.assertFalse;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ScriptMatchPostIT extends AbstractEndpointTestBase {