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/17 18:59:02 UTC

[sling-org-apache-sling-scripting-bundle-tracker-it] branch master updated: SLING-9320 - Allow bundled render units to access objects from the same bundle through the Use API

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 ca11be8  SLING-9320 - Allow bundled render units to access objects from the same bundle through the Use API
ca11be8 is described below

commit ca11be84ce67fbbcd104e7999dcbc0b976a24431
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri Apr 17 20:24:02 2020 +0200

    SLING-9320 - Allow bundled render units to access objects from the same bundle through the Use API
    
    * added IT for inheriting resource typs with multiple providers
---
 .../pom.xml                                        |  3 ---
 .../pom.xml                                        |  4 +++-
 .../1.0.0/name-provider.js                         | 24 ++++++++++++++++++++++
 .../1.0.0/two.html                                 |  1 +
 .../pom.xml                                        |  1 -
 .../pom.xml                                        |  6 +++++-
 .../1.0.0/name-provider.js                         | 24 ++++++++++++++++++++++
 .../1.0.0/use-script.js                            | 23 +++++++++++++++++++++
 .../1.0.0/hello.html                               |  1 +
 .../pom.xml                                        |  3 ---
 it/pom.xml                                         |  2 +-
 .../bundle/tracker/it/ExampleBundleExtend2IT.java  | 12 +++++++++++
 .../it/ExampleBundleExtend2TeleportedIT.java       |  7 +++++--
 .../tracker/it/ExampleBundlePrecompiledIT.java     |  3 +++
 .../it/ExampleBundlePrecompiledTeleportedIT.java   | 10 +++++++--
 it/src/test/provisioning/it-model.txt              |  1 +
 16 files changed, 111 insertions(+), 14 deletions(-)

diff --git a/examples/org-apache-sling-scripting-examplebundle-extend1/pom.xml b/examples/org-apache-sling-scripting-examplebundle-extend1/pom.xml
index 6526aee..6de453e 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend1/pom.xml
+++ b/examples/org-apache-sling-scripting-examplebundle-extend1/pom.xml
@@ -45,9 +45,6 @@
                         <goals>
                             <goal>metadata</goal>
                         </goals>
-                        <configuration>
-                            <sourceDirectory>src/main/resources/javax.script</sourceDirectory>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml b/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
index a44d07e..9338145 100644
--- a/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/pom.xml
@@ -46,7 +46,9 @@
                             <goal>metadata</goal>
                         </goals>
                         <configuration>
-                            <sourceDirectory>src/main/resources/javax.script</sourceDirectory>
+                            <scriptEngineMappings>
+                                <js>rhino</js>
+                            </scriptEngineMappings>
                         </configuration>
                     </execution>
                 </executions>
diff --git a/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.one/1.0.0/name-provider.js b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.one/1.0.0/name-provider.js
new file mode 100644
index 0000000..5aad2c5
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-extend2/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.extend2.one/1.0.0/name-provider.js
@@ -0,0 +1,24 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/* global use */
+use(function() {
+    return {
+        name: 'Jack Black'
+    }
+});
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 e06a10d..ad48b9c 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
@@ -27,3 +27,4 @@
 <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>
+<div class="js-use" data-sly-use.js="use-script.js">${js}</div>
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled-jsp/pom.xml b/examples/org-apache-sling-scripting-examplebundle-precompiled-jsp/pom.xml
index 61f9422..9722d71 100644
--- a/examples/org-apache-sling-scripting-examplebundle-precompiled-jsp/pom.xml
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled-jsp/pom.xml
@@ -65,7 +65,6 @@
                         <Sling-Initial-Content>
                             SLING-INF/content;overwrite:=true;path:=/content/bundled-scripts/examplebundle-precompiled-jsp
                         </Sling-Initial-Content>
-                        <Sling-ResourceType-Precompiled>true</Sling-ResourceType-Precompiled>
                     </instructions>
                 </configuration>
             </plugin>
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml b/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml
index 1f88aed..d3f8305 100644
--- a/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml
@@ -39,6 +39,11 @@
                 <groupId>org.apache.sling</groupId>
                 <artifactId>scriptingbundle-maven-plugin</artifactId>
                 <version>0.1.1-SNAPSHOT</version>
+                <configuration>
+                    <scriptEngineMappings>
+                        <js>rhino</js>
+                    </scriptEngineMappings>
+                </configuration>
                 <executions>
                     <execution>
                         <phase>prepare-package</phase>
@@ -65,7 +70,6 @@
                         <Sling-Initial-Content>
                             SLING-INF/content;overwrite:=true;path:=/content/bundled-scripts/examplebundle-precompiled
                         </Sling-Initial-Content>
-                        <Sling-ResourceType-Precompiled>true</Sling-ResourceType-Precompiled>
                     </instructions>
                 </configuration>
             </plugin>
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/name-provider.js b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/name-provider.js
new file mode 100644
index 0000000..5361c14
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/name-provider.js
@@ -0,0 +1,24 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/* global use */
+use(function() {
+    return {
+        name: 'John Doe'
+    }
+});
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/use-script.js b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/use-script.js
new file mode 100644
index 0000000..83cd3a0
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/resources/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/use-script.js
@@ -0,0 +1,23 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/* global use */
+use(['name-provider.js'], function (nameProvider) {
+    'use strict';
+    return 'Hello, ' + nameProvider.name + '!';
+});
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/hello.html b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/hello.html
index ca61c06..3a9feff 100644
--- a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/hello.html
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/1.0.0/hello.html
@@ -18,3 +18,4 @@
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
 <h2 data-script="${javax_script_filename}">${resource.resourceType}</h2>
 <sly data-sly-include="h.html"/> <sly data-sly-include="w.html"/>
+<div class="js-use" data-sly-use.js="use-script.js">${js}</div>
diff --git a/examples/org-apache-sling-scripting-examplebundle/pom.xml b/examples/org-apache-sling-scripting-examplebundle/pom.xml
index 0cbc35f..5d2adea 100644
--- a/examples/org-apache-sling-scripting-examplebundle/pom.xml
+++ b/examples/org-apache-sling-scripting-examplebundle/pom.xml
@@ -45,9 +45,6 @@
                         <goals>
                             <goal>metadata</goal>
                         </goals>
-                        <configuration>
-                            <sourceDirectory>src/main/resources/javax.script</sourceDirectory>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>
diff --git a/it/pom.xml b/it/pom.xml
index a2c926e..7635080 100644
--- a/it/pom.xml
+++ b/it/pom.xml
@@ -225,7 +225,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.sightly.js.provider</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.1-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 70ccce4..51e3f8c 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
@@ -49,6 +49,9 @@ public class ExampleBundleExtend2IT extends AbstractEndpointTestBase {
                 , w.size());
         assertEquals("World", w.html());
         assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
+
+        Elements jsUse = document.select("div.js-use");
+        assertEquals("Expected a js-use script to have rendered content", "Hello, Jack Black!", jsUse.html());
     }
 
     @Test
@@ -71,6 +74,9 @@ public class ExampleBundleExtend2IT extends AbstractEndpointTestBase {
                 , w.size());
         assertEquals("World", w.html());
         assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
+
+        Elements jsUse = document.select("div.js-use");
+        assertEquals("Expected a js-use script to have rendered content", "Hello, Jack Black!", jsUse.html());
     }
 
     @Test
@@ -105,6 +111,9 @@ public class ExampleBundleExtend2IT extends AbstractEndpointTestBase {
 
         Elements absoluteTemplate2 = document.select("div.absolute-path-2 > div.exampledBundleAppsHello > p");
         assertEquals("Hello, Jack Schitt!", absoluteTemplate2.html());
+
+        Elements jsUse = document.select("div.js-use");
+        assertEquals("Expected a js-use script to have rendered content", "Hello, Jack Black!", jsUse.html());
     }
 
     @Test
@@ -127,6 +136,9 @@ public class ExampleBundleExtend2IT extends AbstractEndpointTestBase {
                 , w.size());
         assertEquals("World", w.html());
         assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
+
+        Elements jsUse = document.select("div.js-use");
+        assertEquals("Expected a js-use script to have rendered content", "Hello, Jack Black!", jsUse.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 31572db..f475038 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
@@ -41,13 +41,16 @@ public class ExampleBundleExtend2TeleportedIT extends AbstractTeleportedTestBase
             assertNotNull(main);
             assertEquals("org.apache.sling.scripting.examplebundle.extend1.hello/1.0.0", main.getResourceSuperType());
             Map<String, Resource> children = collectResourceChildren(main);
-            assertEquals(3, children.size());
+            assertEquals(6, children.size());
 
             Set<String> expectedChildren = getChildrenForServletResource(
                     "/apps/" + expectedRT,
                     "h.html",
                     "h.html.servlet",
-                    "html.servlet"
+                    "html.servlet",
+                    "name-provider.js",
+                    "name-provider.js.servlet",
+                    "name-provider.html.servlet"
             );
             assertEquals(expectedChildren, children.keySet());
 
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledIT.java
index 9332566..23e3e0c 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledIT.java
@@ -88,6 +88,9 @@ public class ExampleBundlePrecompiledIT extends AbstractEndpointTestBase {
         assertEquals("Resource based servlet resolution failed.", 1, w.size());
         assertEquals("World", w.html());
         assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
+
+        Elements jsUse = document.select("div.js-use");
+        assertEquals("Expected a js-use script to have rendered content", "Hello, John Doe!", jsUse.html());
     }
 
     @Test
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 8fb7250..b420ce1 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(9, children.size());
+            assertEquals(15, children.size());
 
             Set<String> expectedChildren = getChildrenForServletResource(
                     "/apps/" + expectedRT,
@@ -54,7 +54,13 @@ public class ExampleBundlePrecompiledTeleportedIT extends AbstractTeleportedTest
                     "hello.html.servlet",
                     "html.servlet",
                     "templates.html",
-                    "templates.html.servlet"
+                    "templates.html.servlet",
+                    "name-provider.js",
+                    "name-provider.js.servlet",
+                    "name-provider.html.servlet",
+                    "use-script.js",
+                    "use-script.js.servlet",
+                    "use-script.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 9936add..4201a4d 100644
--- a/it/src/test/provisioning/it-model.txt
+++ b/it/src/test/provisioning/it-model.txt
@@ -28,6 +28,7 @@
   org.apache.sling/org.apache.sling.scripting.sightly.runtime
   org.apache.sling/org.apache.sling.scripting.sightly.compiler
   org.apache.sling/org.apache.sling.scripting.sightly.compiler.java
+  org.apache.sling/org.apache.sling.scripting.sightly.js.provider
   org.apache.sling/org.apache.sling.commons.compiler
   org.apache.sling/org.apache.sling.scripting.bundle.tracker
   org.apache.sling/org.apache.sling.scripting.examplebundle