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/09 20:39:30 UTC

[sling-org-apache-sling-scripting-bundle-tracker-it] branch master updated: SLING-9328 - Allow loading template libraries from bundles

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 ae39991  SLING-9328 - Allow loading template libraries from bundles
ae39991 is described below

commit ae399916b4471f3c1e8e0f7f4eafd4b62bb5b14d
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Apr 9 22:38:08 2020 +0200

    SLING-9328 - Allow loading template libraries from bundles
    
    * added some IT here, since the functionality depends on the
    o.a.s.scripting.bundle.tracker API; the setup of the example bundles
    also makes testing this functionality here easier
---
 .../org-apache-sling-scripting-examplebundle-extend2/pom.xml |  1 +
 .../1.0.0/requires                                           |  1 +
 .../1.0.0/{two.html => two-templates.html}                   |  9 +++++----
 .../1.0.0/two.html                                           |  9 +++++++++
 .../1.0.0/templates.html}                                    | 11 +++++++----
 .../apps/sling/scripting/examplebundle/hello/templates.html} | 11 +++++++----
 it/pom.xml                                                   |  8 +++++++-
 .../scripting/bundle/tracker/it/ExampleBundleExtend2IT.java  | 12 ++++++++++++
 .../bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java  |  6 ++++--
 .../tracker/it/ExampleBundlePrecompiledTeleportedIT.java     |  6 ++++--
 .../bundle/tracker/it/ExampleBundleTeleportedIT.java         |  6 ++++--
 it/src/test/provisioning/it-model.txt                        |  1 +
 12 files changed, 62 insertions(+), 19 deletions(-)

diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml b/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
index 07312e0..a44d07e 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
@@ -76,6 +76,7 @@
                 <configuration>
                     <excludes>
                         <exclude>**/extends</exclude>
+                        <exclude>**/requires</exclude>
                     </excludes>
                 </configuration>
             </plugin>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/requires b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/requires
new file mode 100644
index 0000000..f23567e
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/requires
@@ -0,0 +1 @@
+/apps/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.two/1.0.0/two.html b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two-templates.html
similarity index 80%
copy from examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
copy to examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two-templates.html
index ca61c06..8850f76 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two-templates.html
@@ -1,4 +1,4 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ~ 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
@@ -15,6 +15,7 @@
   ~ KIND, either express or implied.  See the License for the
   ~ specific language governing permissions and limitations
   ~ under the License.
-  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-<h2 data-script="${javax_script_filename}">${resource.resourceType}</h2>
-<sly data-sly-include="h.html"/> <sly data-sly-include="w.html"/>
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<template data-sly-template.two>
+    <div class="template two">two</div>
+</template>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
index ca61c06..e06a10d 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
@@ -18,3 +18,12 @@
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
 <h2 data-script="${javax_script_filename}">${resource.resourceType}</h2>
 <sly data-sly-include="h.html"/> <sly data-sly-include="w.html"/>
+<sly data-sly-use.twoTemplates="two-templates.html" data-sly-call="${twoTemplates.two}"></sly>
+<div class="inherited" data-sly-use.inheritedTemplates="templates.html"
+       data-sly-call="${inheritedTemplates.precompiled1Template @ name ='John Doe'}"></div>
+<div class="absolute-path-1"
+     data-sly-use.absolutePathTemplates1="/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/templates.html"
+     data-sly-call="${absolutePathTemplates1.precompiled1Template @ name ='John Doe'}"></div>
+<div class="absolute-path-2"
+     data-sly-use.absolutePathTemplates2="/apps/sling/scripting/examplebundle/hello/templates.html"
+     data-sly-call="${absolutePathTemplates2.exampledBundleAppsHello @ name = 'Jack Schitt'}"></div>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/templates.html
similarity index 77%
copy from examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
copy to examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/templates.html
index ca61c06..1cfd082 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/templates.html
@@ -1,4 +1,4 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ~ 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
@@ -15,6 +15,9 @@
   ~ KIND, either express or implied.  See the License for the
   ~ specific language governing permissions and limitations
   ~ under the License.
-  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-<h2 data-script="${javax_script_filename}">${resource.resourceType}</h2>
-<sly data-sly-include="h.html"/> <sly data-sly-include="w.html"/>
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<template data-sly-template.precompiled1Template="${ @ name='the name to display'}">
+    <div class="precompiled1Template">
+        <p>Hello, ${name}!</p>
+    </div>
+</template>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/apps/sling/scripting/examplebundle/hello/templates.html
similarity index 77%
copy from examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
copy to examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/apps/sling/scripting/examplebundle/hello/templates.html
index ca61c06..c025678 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.two/1.0.0/two.html
+++ b/examples/org-apache-sling-scripting-examplebundle/src/main/resources/javax.script/apps/sling/scripting/examplebundle/hello/templates.html
@@ -1,4 +1,4 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ~ 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
@@ -15,6 +15,9 @@
   ~ KIND, either express or implied.  See the License for the
   ~ specific language governing permissions and limitations
   ~ under the License.
-  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-<h2 data-script="${javax_script_filename}">${resource.resourceType}</h2>
-<sly data-sly-include="h.html"/> <sly data-sly-include="w.html"/>
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<template data-sly-template.exampledBundleAppsHello="${ @ name='the name to display'}">
+    <div class="exampledBundleAppsHello">
+        <p>Hello, ${name}!</p>
+    </div>
+</template>
diff --git a/it/pom.xml b/it/pom.xml
index a69b87a..afc430d 100644
--- a/it/pom.xml
+++ b/it/pom.xml
@@ -176,6 +176,12 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.scripting.core</artifactId>
+            <version>2.2.1-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.bundle.tracker</artifactId>
             <version>0.1.1-SNAPSHOT</version>
             <scope>test</scope>
@@ -195,7 +201,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.sightly</artifactId>
-            <version>1.3.3-1.4.0-SNAPSHOT</version>
+            <version>1.4.0-1.4.0-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
         <dependency>
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 41f8c96..70ccce4 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
@@ -93,6 +93,18 @@ public class ExampleBundleExtend2IT extends AbstractEndpointTestBase {
                 , w.size());
         assertEquals("World", w.html());
         assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
+
+        Elements localTemplate = document.select("div.template.two");
+        assertEquals("two", localTemplate.html());
+
+        Elements inheritedTemplate = document.select("div.inherited > div.precompiled1Template > p");
+        assertEquals("Hello, John Doe!", inheritedTemplate.html());
+
+        Elements absoluteTemplate1 = document.select("div.absolute-path-1 > div.precompiled1Template > p");
+        assertEquals("Hello, John Doe!", absoluteTemplate1.html());
+
+        Elements absoluteTemplate2 = document.select("div.absolute-path-2 > div.exampledBundleAppsHello > p");
+        assertEquals("Hello, Jack Schitt!", absoluteTemplate2.html());
     }
 
     @Test
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
index e71d5d2..31572db 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleExtend2TeleportedIT.java
@@ -65,13 +65,15 @@ public class ExampleBundleExtend2TeleportedIT extends AbstractTeleportedTestBase
             assertNotNull(main);
             assertEquals("org.apache.sling.scripting.examplebundle.extend2.one/1.0.0", main.getResourceSuperType());
             Map<String, Resource> children = collectResourceChildren(main);
-            assertEquals(3, children.size());
+            assertEquals(5, children.size());
 
             Set<String> expectedChildren = getChildrenForServletResource(
                     "/apps/" + expectedRT,
                     "html.servlet",
                     "two.html",
-                    "two.html.servlet"
+                    "two.html.servlet",
+                    "two-templates.html",
+                    "two-templates.html.servlet"
             );
             assertEquals(expectedChildren, children.keySet());
 
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
index 80436c1..8fb7250 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
@@ -42,7 +42,7 @@ public class ExampleBundlePrecompiledTeleportedIT extends AbstractTeleportedTest
             assertNotNull(main);
             assertTrue(main.getValueMap().isEmpty());
             Map<String, Resource> children = collectResourceChildren(main);
-            assertEquals(7, children.size());
+            assertEquals(9, children.size());
 
             Set<String> expectedChildren = getChildrenForServletResource(
                     "/apps/" + expectedRT,
@@ -52,7 +52,9 @@ public class ExampleBundlePrecompiledTeleportedIT extends AbstractTeleportedTest
                     "w.html.servlet",
                     "hello.html",
                     "hello.html.servlet",
-                    "html.servlet"
+                    "html.servlet",
+                    "templates.html",
+                    "templates.html.servlet"
             );
             assertEquals(expectedChildren, children.keySet());
 
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleTeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleTeleportedIT.java
index 6e5f506..5286c97 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleTeleportedIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundleTeleportedIT.java
@@ -102,7 +102,7 @@ public class ExampleBundleTeleportedIT extends AbstractTeleportedTestBase {
             assertNotNull(main);
             assertTrue(main.getValueMap().isEmpty());
             Map<String, Resource> children = collectResourceChildren(main);
-            assertEquals(7, children.size());
+            assertEquals(9, children.size());
 
             Set<String> expectedChildren = getChildrenForServletResource(
                     "/apps/" + expectedRT,
@@ -112,7 +112,9 @@ public class ExampleBundleTeleportedIT extends AbstractTeleportedTestBase {
                     "w.html.servlet",
                     "hello.html",
                     "hello.html.servlet",
-                    "html.servlet"
+                    "html.servlet",
+                    "templates.html",
+                    "templates.html.servlet"
             );
             assertEquals(expectedChildren, children.keySet());
 
diff --git a/it/src/test/provisioning/it-model.txt b/it/src/test/provisioning/it-model.txt
index 46d445b..9936add 100644
--- a/it/src/test/provisioning/it-model.txt
+++ b/it/src/test/provisioning/it-model.txt
@@ -22,6 +22,7 @@
 # Dependencies
 [artifacts]
   org.apache.sling/org.apache.sling.starter/12-SNAPSHOT/slingstart
+  org.apache.sling/org.apache.sling.scripting.core
   org.apache.sling/org.apache.sling.scripting.jsp
   org.apache.sling/org.apache.sling.scripting.sightly
   org.apache.sling/org.apache.sling.scripting.sightly.runtime