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/04/01 15:33:31 UTC

[sling-org-apache-sling-scripting-bundle-tracker-it] branch master updated: SLING-9306 - Provide a path capability for scripts which are not part of a resource type

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 14e9a1e  SLING-9306 - Provide a path capability for scripts which are not part of a resource type
14e9a1e is described below

commit 14e9a1e71e286c8dda51d6a8d242fbb2459375a4
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Wed Apr 1 17:32:56 2020 +0200

    SLING-9306 - Provide a path capability for scripts which are not part of a resource type
    
    * added a test for resource types extending non-versioned resource types
---
 .../SLING-INF/content/examplebundle-extend2.xml       |  9 +++++++++
 .../extends                                           |  1 +
 .../h.html                                            | 19 +++++++++++++++++++
 .../bundle/tracker/it/ExampleBundleExtend2IT.java     | 18 ++++++++++++++++++
 4 files changed, 47 insertions(+)

diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/SLING-INF/content/examplebundle-extend2.xml b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/SLING-INF/content/examplebundle-extend2.xml
index 8b371cd..e6c014a 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/SLING-INF/content/examplebundle-extend2.xml
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/SLING-INF/content/examplebundle-extend2.xml
@@ -53,3 +53,12 @@
         <type>String</type>
     </property>
 </node>
+<node>
+<name>three</name>
+<primaryNodeType>nt:unstructured</primaryNodeType>
+<property>
+    <name>sling:resourceType</name>
+    <value>org.apache.sling.scripting.examplebundle.extend2.three</value>
+    <type>String</type>
+</property>
+</node>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.three/extends b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.three/extends
new file mode 100644
index 0000000..a0fbfb5
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.three/extends
@@ -0,0 +1 @@
+sling/scripting/examplebundle/hello
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.three/h.html b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.three/h.html
new file mode 100644
index 0000000..021c02c
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.three/h.html
@@ -0,0 +1,19 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<span id="h-extend2-three" data-rt="${resource.resourceType}">Hello</span>
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java
index b747f56..4df7fe5 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2IT.java
@@ -103,4 +103,22 @@ public class ExampleBundleExtend2IT extends AbstractEndpointTestBase {
         assertEquals("World", w.html());
         assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
     }
+
+    @Test
+    public void testThree() throws Exception {
+        final String expectedRT = "org.apache.sling.scripting.examplebundle.extend2.three";
+
+        Document document = getDocument(ROOT + "/three.html");
+        assertEquals(expectedRT, document.select("h2").html());
+
+        Elements h = document.select("#h-extend2-three");
+        assertEquals("Resource based servlet resolution failed.", 1, h.size());
+        assertEquals("Hello", h.html());
+        assertEquals(expectedRT, h.attr(DATA_RT_ATTRIBUTE));
+
+        Elements w = document.select("#w-examplebundle-hello");
+        assertEquals("The w.html script should have been provided by sling/scripting/examplebundle/hello", 1, w.size());
+        assertEquals("World", w.html());
+        assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
+    }
 }