You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:12:14 UTC
[sling-org-apache-sling-scripting-sightly-testing-content] 13/17:
SLING-4493 Sightly: Create performance tests
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.scripting.sightly.testing-content-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-testing-content.git
commit 8dd4cab118f2245e71bfc0449a1a45dc326d38eb
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Mar 12 16:40:13 2015 +0000
SLING-4493 Sightly: Create performance tests
* added Sightly performance testing content and scripts
* added test suite for JSP, JSP-EL, Sightly Java Use API and Sightly JS Use API
(applied patches sent by Vlad Băilescu - closes #70)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/sightly/testing-content@1666251 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 5 +-
.../SLING-INF/apps/sightlyperf/loop/loop.jsp | 7 +
.../SLING-INF/apps/sightlyperf/test/Test.java | 77 +++++++
.../SLING-INF/apps/sightlyperf/test/jsp-el.jsp | 17 ++
.../SLING-INF/apps/sightlyperf/test/mode.jsp | 1 +
.../SLING-INF/apps/sightlyperf/test/sly-java.html | 9 +
.../SLING-INF/apps/sightlyperf/test/sly-js.html | 9 +
.../SLING-INF/apps/sightlyperf/test/test.js | 16 ++
.../SLING-INF/apps/sightlyperf/test/test.jsp | 41 ++++
src/main/resources/SLING-INF/sightlyperf.json | 227 +++++++++++++++++++++
10 files changed, 407 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1c3f141..a529a91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,8 +40,9 @@
<name>Apache Sling Scripting Sightly Integration Tests Content</name>
<description>
- This bundle contains content adapted from the Adobe Sightly TCK meant to test the org.apache.sling.scripting.sightly
- implementations.
+ This bundle contains:
+ - Content adapted from the Adobe Sightly TCK meant to test the org.apache.sling.scripting.sightly implementations.
+ - Content meant to test performance of the org.apache.sling.scripting.sightly implementation.
</description>
<scm>
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/loop/loop.jsp b/src/main/resources/SLING-INF/apps/sightlyperf/loop/loop.jsp
new file mode 100644
index 0000000..7075ccb
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/loop/loop.jsp
@@ -0,0 +1,7 @@
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling"%>
+<p>selector: ${param.selector} [<strong>jsp</strong>, jsp-el, sly-java, sly-js]</p>
+<p>count: ${param.count} [1 - 20, <strong>20</strong>]</p>
+<c:forEach begin="1" end="${empty param.count || param.count < 1 || param.count > 20 ? 20 : param.count}">
+ <sling:include path="/sightlyperf/test" replaceSelectors="${param.selector == 'sly-java' || param.selector == 'sly-js' || param.selector == 'jsp-el' ? param.selector : 'jsp'}" />
+</c:forEach>
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/test/Test.java b/src/main/resources/SLING-INF/apps/sightlyperf/test/Test.java
new file mode 100644
index 0000000..cb826b1
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/test/Test.java
@@ -0,0 +1,77 @@
+package apps.sightlyperf.test;
+
+import java.util.Iterator;
+
+import javax.script.Bindings;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.scripting.sightly.pojo.Use;
+
+public class Test implements Use {
+
+ private String text = null;
+
+ private String tag = null;
+
+ private boolean includeChildren = false;
+
+ private Iterator<Resource> children = null;
+
+ public void init(Bindings bindings) {
+ Resource resource = (Resource)bindings.get("resource");
+ ValueMap properties = (ValueMap)bindings.get("properties");
+
+ if (properties != null) {
+ Object text = properties.get("text");
+ if (text != null) {
+ this.text = text.toString();
+ }
+
+ Object tag = properties.get("tag");
+ if (tag != null) {
+ this.tag = tag.toString();
+ }
+
+ Object includeChildren = properties.get("includeChildren");
+ if (includeChildren != null) {
+ this.includeChildren = Boolean.parseBoolean(includeChildren.toString());
+ this.children = resource.listChildren();
+ }
+ }
+
+ if (this.text == null) {
+ this.text = resource.getPath();
+ }
+ }
+
+ public String getText() {
+ return this.text;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public String getStartTag() {
+ if (tag == null) {
+ return null;
+ }
+ return "<" + tag + ">";
+ }
+
+ public String getEndTag() {
+ if (tag == null) {
+ return null;
+ }
+ return "</" + tag + ">";
+ }
+
+ public boolean getIncludeChildren() {
+ return includeChildren;
+ }
+
+ public Iterator<Resource> getChildren() {
+ return this.children;
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/test/jsp-el.jsp b/src/main/resources/SLING-INF/apps/sightlyperf/test/jsp-el.jsp
new file mode 100644
index 0000000..953b9dc
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/test/jsp-el.jsp
@@ -0,0 +1,17 @@
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
+<%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling"%>
+<sling:defineObjects />
+<c:set var="properties" value="${sling:adaptTo(resource,'org.apache.sling.api.resource.ValueMap')}" />
+<c:set var="tag" value="${sling:getValue(properties, 'tag', '')}" />
+<c:if test="${tag != ''}"><${tag}></c:if>
+${sling:encode(sling:getValue(properties, 'text', resource.path), 'HTML')}
+<c:if test="${tag != ''}"></${tag}></c:if>
+<sling:call script="mode.jsp" />
+<c:if test="${sling:getValue(properties, 'includeChildren', false)}">
+ <ul>
+ <c:forEach items="${sling:listChildren(resource)}" var="child">
+ <li><sling:include path="${child.path}" /></li>
+ </c:forEach>
+ </ul>
+</c:if>
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/test/mode.jsp b/src/main/resources/SLING-INF/apps/sightlyperf/test/mode.jsp
new file mode 100644
index 0000000..ad61611
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/test/mode.jsp
@@ -0,0 +1 @@
+<!-- <%="comment"%> -->
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java.html b/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java.html
new file mode 100644
index 0000000..6c3a1de
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-java.html
@@ -0,0 +1,9 @@
+<div data-sly-use.test="apps.sightlyperf.test.Test" data-sly-unwrap>
+ ${test.tag != null ? test.startTag : '' @ context = "unsafe"}
+ ${test.text @ context = "text"}
+ ${test.tag != null ? test.endTag : '' @ context = "unsafe"}
+ <div data-sly-include="mode.jsp" data-sly-unwrap=""></div>
+ <ul data-sly-test="${test.includeChildren}" data-sly-list.child="${test.children}">
+ <li data-sly-resource="${child.path}"></li>
+ </ul>
+</div>
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-js.html b/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-js.html
new file mode 100644
index 0000000..4b1c2e6
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/test/sly-js.html
@@ -0,0 +1,9 @@
+<div data-sly-use.test="test.js" data-sly-unwrap>
+ ${test.tag != null ? test.startTag : '' @ context = "unsafe"}
+ ${test.text @ context = "text"}
+ ${test.tag != null ? test.endTag : '' @ context = "unsafe"}
+ <div data-sly-include="mode.jsp" data-sly-unwrap=""></div>
+ <ul data-sly-test="${test.includeChildren}" data-sly-list.child="${test.children}">
+ <li data-sly-resource="${child.path}"></li>
+ </ul>
+</div>
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/test/test.js b/src/main/resources/SLING-INF/apps/sightlyperf/test/test.js
new file mode 100644
index 0000000..f256d30
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/test/test.js
@@ -0,0 +1,16 @@
+use(function () {
+ var test = {};
+
+ test.text = properties.get('text') || resource.getPath();
+ test.tag = properties.get('tag') || null;
+ if (test.tag != null) {
+ test.startTag = '<' + test.tag + '>';
+ test.endTag = '</' + test.tag + '>';
+ }
+ test.includeChildren = properties.get('includeChildren') || false;
+ if (test.includeChildren) {
+ test.children = sightly.resource.getChildren();
+ }
+
+ return test;
+});
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightlyperf/test/test.jsp b/src/main/resources/SLING-INF/apps/sightlyperf/test/test.jsp
new file mode 100644
index 0000000..3296710
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightlyperf/test/test.jsp
@@ -0,0 +1,41 @@
+<%@ page import="org.apache.sling.api.resource.Resource" %>
+<%@ page import="org.apache.sling.api.resource.ValueMap" %>
+<%@ page import="org.apache.sling.xss.XSSAPI" %>
+<%@ page import="java.util.Iterator" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
+<%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling"%>
+<sling:defineObjects />
+<%
+ ValueMap properties = resource.adaptTo(ValueMap.class);
+
+ String tag = properties.get("tag", null);
+ if (tag != null) {
+ out.println("<" + tag + ">");
+ }
+ XSSAPI xssAPI = sling.getService(XSSAPI.class);
+ out.println(xssAPI.encodeForHTML(properties.get("text", resource.getPath()).toString()));
+ if (tag != null) {
+ out.println("</" + tag + ">");
+ }
+
+%>
+ <sling:call script="mode.jsp" />
+<%
+
+ if (properties.get("includeChildren", false)) {
+ Iterator<Resource> iter = resource.listChildren();
+%>
+<ul>
+<%
+ while(iter.hasNext()) {
+ Resource child = iter.next();
+%>
+ <li><sling:include path="<%=child.getPath()%>" /></li>
+<%
+ }
+%>
+</ul>
+<%
+ }
+%>
diff --git a/src/main/resources/SLING-INF/sightlyperf.json b/src/main/resources/SLING-INF/sightlyperf.json
new file mode 100644
index 0000000..59cbae9
--- /dev/null
+++ b/src/main/resources/SLING-INF/sightlyperf.json
@@ -0,0 +1,227 @@
+{
+ "jcr:primaryType": "sling:Folder",
+ "test" : {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<page>",
+ "tag": "b",
+ "includeChildren": "true",
+ "head": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<head>",
+ "includeChildren": "true",
+ "title": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<title>"
+ },
+ "style": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<style>"
+ }
+ },
+ "body": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<body>",
+ "includeChildren": "true",
+ "topnav": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<topnav>",
+ "includeChildren": "true",
+ "logo": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<logo>"
+ },
+ "menu": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<menu>",
+ "includeChildren": "true",
+ "home": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<home>"
+ },
+ "products": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<products>"
+ },
+ "services": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<services>"
+ },
+ "about": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<about>"
+ },
+ "contact": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<contact>"
+ }
+ },
+ "breadcrumbs": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<breadcrumbs>",
+ "includeChildren": "true",
+ "home": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<home>"
+ },
+ "products": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<products>"
+ },
+ "productPage": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<productPage>"
+ }
+ }
+ },
+ "main": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<main>",
+ "includeChildren": "true",
+ "sidebar": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<sidebar>",
+ "includeChildren": "true",
+ "title": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<title>"
+ },
+ "links": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<links>",
+ "includeChildren": "true",
+ "home": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<home>"
+ },
+ "products": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<products>"
+ },
+ "services": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<services>"
+ },
+ "about": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<about>"
+ },
+ "contact": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<contact>"
+ }
+ }
+ },
+ "content": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<content>",
+ "includeChildren": "true",
+ "carousel": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<carousel>",
+ "tag": "blink",
+ "includeChildren": "true",
+ "image": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<image>"
+ },
+ "video": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<video>"
+ }
+ },
+ "title": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<title>"
+ },
+ "paragraph1": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<paragraph1>"
+ },
+ "paragraph2": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<paragraph2>"
+ },
+ "paragraph3": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<paragraph3>"
+ }
+ },
+ "bottomnav": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<bottomnav>",
+ "includeChildren": "true",
+ "links": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<links>",
+ "includeChildren": "true",
+ "home": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<home>"
+ },
+ "about": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<about>"
+ },
+ "contact": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<contact>"
+ }
+ },
+ "copyright": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<copyright>"
+ }
+ }
+ }
+ },
+ "foot": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/test",
+ "text": "<foot>"
+ }
+ },
+ "loop" : {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "/apps/sightlyperf/loop"
+ }
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.