SLING-9571 - Nested selector scripts do not have a path-based registered servlet
* added a nested selector and ITs
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html
index cd588dc..4785e96 100644
--- a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html
@@ -21,3 +21,4 @@
<div data-sly-use.slingSettings="org.apache.sling.settings.SlingSettingsService"
data-sly-test.slingId="${slingSettings.slingId}"
id="sling-id">${slingId}</div>
+<sly data-sly-include="nested/selector.html"/>
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/nested/selector.html b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/nested/selector.html
new file mode 100644
index 0000000..d8d4f1c
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/nested/selector.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="nested-selector-2" data-rt="${resource.resourceType}">Nested Selector</span>
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 bd77f9d..09b7e4b 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
@@ -67,6 +67,11 @@
assertEquals("Resource based servlet resolution failed.", 1, w.size());
assertEquals("World", w.html());
assertEquals(expectedRT, w.attr(DATA_RT_ATTRIBUTE));
+
+ Elements ns = document.select("#nested-selector-2");
+ assertEquals("Resource based servlet resolution failed.", 1, ns.size());
+ assertEquals("Nested Selector", ns.html());
+ assertEquals(expectedRT, ns.attr(DATA_RT_ATTRIBUTE));
}
@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 6356f85..840d22c 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
@@ -68,20 +68,24 @@
assertNotNull(main);
assertTrue(main.getValueMap().isEmpty());
Map<String, Resource> children = collectResourceChildren(main);
- assertEquals(4, children.size());
+ assertEquals(5, children.size());
Set<String> expectedChildren = getChildrenForServletResource(
"/apps/" + expectedRT,
"h.html",
"w.html",
"hello.html",
- "2.0.0.servlet"
+ "2.0.0.servlet",
+ "nested"
);
+ assertNotNull(resolver.getResource("/apps/" + expectedRT + "/nested/selector.html"));
assertEquals(expectedChildren, children.values().stream().map(Resource::getPath).collect(Collectors.toSet()));
for (Resource child : children.values()) {
- assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
- child.getResourceSuperType());
+ if (!"nested".equals(child.getName())) {
+ assertEquals(child.getPath() + " does not have the expected resource super type", "sling/bundle/resource",
+ child.getResourceSuperType());
+ }
}
}
}