Author: radu
Date: Thu Jun 30 13:10:36 2016
New Revision: 1750793

URL: http://svn.apache.org/viewvc?rev=1750793&view=rev
Log:
SLING-5812 - Add option to include attributes in request scope for Sightly 
data-sly-request and data-sly-include

* Added new option named requestAttributes to allow setting specific attributes 
on data-sly-request and data-sly-include
* Added tests
* cleaned testing pom file
(applied slightly modified patch from Vlad Băilescu; closes #149)

Added:
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/include.html
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.html
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.js
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.html
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.js
Modified:
    
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ExtensionUtils.java
    
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java
    
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java
    
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json
    sling/trunk/bundles/scripting/sightly/testing/pom.xml
    
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java

Modified: 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ExtensionUtils.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ExtensionUtils.java?rev=1750793&r1=1750792&r2=1750793&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ExtensionUtils.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ExtensionUtils.java
 Thu Jun 30 13:10:36 2016
@@ -18,6 +18,10 @@
  
******************************************************************************/
 package org.apache.sling.scripting.sightly.impl.engine.extension;
 
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.scripting.sightly.SightlyException;
 import org.apache.sling.scripting.sightly.extension.RuntimeExtension;
 
@@ -40,4 +44,28 @@ public class ExtensionUtils {
         }
     }
 
+    /**
+     * Helper method for setting specific attributes in a {@link 
SlingHttpServletRequest} scope
+     *
+     * @param request              the {@link SlingHttpServletRequest}
+     * @param newRequestAttributes the {@link Map} of attributes to set
+     * @return A {@link Map} of original attributes values for substituted keys
+     */
+    public static Map<String, Object> 
setRequestAttributes(SlingHttpServletRequest request, Map<String, Object> 
newRequestAttributes) {
+        Map<String, Object> originalRequestAttributes = new 
LinkedHashMap<String, Object>();
+        if (newRequestAttributes != null && request != null) {
+            for (Map.Entry<String, Object> attr : 
newRequestAttributes.entrySet()) {
+                String key = attr.getKey();
+                Object value = attr.getValue();
+                originalRequestAttributes.put(key, request.getAttribute(key));
+                if (value == null) {
+                    request.removeAttribute(key);
+                } else {
+                    request.setAttribute(key, value);
+                }
+            }
+        }
+        return originalRequestAttributes;
+    }
+
 }

Modified: 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java?rev=1750793&r1=1750792&r2=1750793&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java
 Thu Jun 30 13:10:36 2016
@@ -56,6 +56,7 @@ public class IncludeRuntimeExtension imp
     private static final String OPTION_FILE = "file";
     private static final String OPTION_PREPEND_PATH = "prependPath";
     private static final String OPTION_APPEND_PATH = "appendPath";
+    private static final String OPTION_REQUEST_ATTRIBUTES = 
"requestAttributes";
 
 
     @Override
@@ -67,7 +68,10 @@ public class IncludeRuntimeExtension imp
         String path = buildPath(originalPath, options);
         StringWriter output = new StringWriter();
         final Bindings bindings = renderContext.getBindings();
+        SlingHttpServletRequest request = BindingsUtils.getRequest(bindings);
+        Map originalAttributes = ExtensionUtils.setRequestAttributes(request, 
(Map)options.remove(OPTION_REQUEST_ATTRIBUTES));
         includeScript(bindings, path, new PrintWriter(output));
+        ExtensionUtils.setRequestAttributes(request, originalAttributes);
         return output.toString();
 
     }

Modified: 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java?rev=1750793&r1=1750792&r2=1750793&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java
 Thu Jun 30 13:10:36 2016
@@ -63,6 +63,7 @@ public class ResourceRuntimeExtension im
     private static final String OPTION_REMOVE_SELECTORS = "removeSelectors";
     private static final String OPTION_ADD_SELECTORS = "addSelectors";
     private static final String OPTION_REPLACE_SELECTORS = "replaceSelectors";
+    private static final String OPTION_REQUEST_ATTRIBUTES = 
"requestAttributes";
 
     @Override
     public Object call(final RenderContext renderContext, Object... arguments) 
{
@@ -73,10 +74,11 @@ public class ResourceRuntimeExtension im
     private String provideResource(final RenderContext renderContext, Object 
pathObj, Map<String, Object> options) {
         Map<String, Object> opts = new HashMap<>(options);
         final Bindings bindings = renderContext.getBindings();
+        SlingHttpServletRequest request = BindingsUtils.getRequest(bindings);
+        Map originalAttributes = ExtensionUtils.setRequestAttributes(request, 
(Map)options.remove(OPTION_REQUEST_ATTRIBUTES));
         String resourceType = coerceString(getAndRemoveOption(opts, 
OPTION_RESOURCE_TYPE));
         StringWriter writer = new StringWriter();
         PrintWriter printWriter = new PrintWriter(writer);
-
         if (pathObj instanceof Resource) {
             Resource includeRes = (Resource) pathObj;
             Map<String, String> dispatcherOptionsMap = 
handleSelectors(bindings, new LinkedHashSet<String>(), opts);
@@ -89,7 +91,7 @@ public class ResourceRuntimeExtension im
             String dispatcherOptions = 
createDispatcherOptions(dispatcherOptionsMap);
             includeResource(bindings, printWriter, finalPath, 
dispatcherOptions, resourceType);
         }
-
+        ExtensionUtils.setRequestAttributes(request, originalAttributes);
         return writer.toString();
     }
 

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/include.html
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/include.html?rev=1750793&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/include.html
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/include.html
 Thu Jun 30 13:10:36 2016
@@ -0,0 +1,22 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<sly data-sly-use.requestattributes="requestattributes.js">
+    <div id="attrs-set" data-sly-include="${'included.html' @ 
requestAttributes=requestattributes.attrs}"></div>
+    <div id="attrs-unset" data-sly-include="${'included.html'}"></div>
+</sly>
\ No newline at end of file

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.html
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.html?rev=1750793&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.html
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.html
 Thu Jun 30 13:10:36 2016
@@ -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.
+  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<sly data-sly-use.included="included.js">${included.attr}</sly>
\ No newline at end of file

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.js
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.js?rev=1750793&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.js
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/included.js
 Thu Jun 30 13:10:36 2016
@@ -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.
+ 
******************************************************************************/
+use(function () {
+    return {
+        attr: request.getAttribute("testAttribute")
+    }
+});
\ No newline at end of file

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.html
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.html?rev=1750793&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.html
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.html
 Thu Jun 30 13:10:36 2016
@@ -0,0 +1,22 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<sly data-sly-use.requestattributes="requestattributes.js">
+    <div id="attrs-set" data-sly-resource="${'/sightly/requestattributes' @ 
selectors='included',requestAttributes=requestattributes.attrs}"></div>
+    <div id="attrs-unset" data-sly-resource="${'/sightly/requestattributes' @ 
selectors='included'}"></div>
+</sly>
\ No newline at end of file

Added: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.js
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.js?rev=1750793&view=auto
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.js
 (added)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/apps/sightly/scripts/requestattributes/requestattributes.js
 Thu Jun 30 13:10:36 2016
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.
+ 
******************************************************************************/
+use(function () {
+    var attrs = new Packages.java.util.HashMap();
+    attrs.put("testAttribute", "testValue")
+    return {
+        attrs: attrs
+    }
+});
\ No newline at end of file

Modified: 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json?rev=1750793&r1=1750792&r2=1750793&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/testing-content/src/main/resources/SLING-INF/sightly.json
 Thu Jun 30 13:10:36 2016
@@ -44,5 +44,9 @@
     "update": {
         "jcr:primaryType": "nt:unstructured",
         "sling:resourceType": "/apps/sightly/scripts/update"
+    },
+    "requestattributes": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "/apps/sightly/scripts/requestattributes"
     }
 }

Modified: sling/trunk/bundles/scripting/sightly/testing/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/pom.xml?rev=1750793&r1=1750792&r2=1750793&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing/pom.xml (original)
+++ sling/trunk/bundles/scripting/sightly/testing/pom.xml Thu Jun 30 13:10:36 
2016
@@ -71,9 +71,6 @@
         otherwise you can provide your own debug settings
         -->
         <debug.options/>
-
-        <slf4j.version>1.7.7</slf4j.version>
-        <logback.version>1.1.2</logback.version>
     </properties>
 
     <build>
@@ -113,10 +110,10 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-failsafe-plugin</artifactId>
-                <version>2.19</version>
-                <!-- Version newer than the one declared in the parent pom -->
+                <version>2.19.1</version>
                 <executions>
                     <execution>
+                        <id>integration-tests</id>
                         <goals>
                             <goal>integration-test</goal>
                             <goal>verify</goal>
@@ -213,7 +210,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.testing</artifactId>
-            <version>2.0.22</version>
+            <version>2.0.24</version>
             <exclusions>
                 <exclusion>
                     <groupId>junit</groupId>
@@ -227,49 +224,8 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>javax.jcr</groupId>
-            <artifactId>jcr</artifactId>
-            <version>2.0</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>${slf4j.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>log4j-over-slf4j</artifactId>
-            <version>${slf4j.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <version>${logback.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.11</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>4.4</version>
             <scope>test</scope>
         </dependency>
 

Modified: 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java?rev=1750793&r1=1750792&r2=1750793&view=diff
==============================================================================
--- 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
 (original)
+++ 
sling/trunk/bundles/scripting/sightly/testing/src/test/java/org/apache/sling/scripting/sightly/it/SlingSpecificsSightlyIT.java
 Thu Jun 30 13:10:36 2016
@@ -57,6 +57,8 @@ public class SlingSpecificsSightlyIT {
     private static final String SLING_CRLF_PKG = SLING_CRLF + ".pkg.html";
     private static final String SLING_CRLF_WRONGPKG = SLING_CRLF + 
".wrongpkg.html";
     private static final String SLING_SCRIPT_UPDATE = "/sightly/update.html";
+    private static final String SLING_REQUEST_ATTRIBUTES = 
"/sightly/requestattributes.html";
+    private static final String SLING_REQUEST_ATTRIBUTES_INCLUDE = 
"/sightly/requestattributes.include.html";
 
 
     @BeforeClass
@@ -241,6 +243,22 @@ public class SlingSpecificsSightlyIT {
         assertNotEquals(hash, path);
     }
 
+    @Test
+    public void testRequestAttributes() {
+        String url = launchpadURL + SLING_REQUEST_ATTRIBUTES;
+        String pageContent = client.getStringContent(url, 200);
+        assertEquals("testValue", HTMLExtractor.innerHTML(url, pageContent, 
"#attrs-set"));
+        assertEquals("", HTMLExtractor.innerHTML(url, pageContent, 
"#attrs-unset"));
+    }
+
+    @Test
+    public void testRequestAttributesInclude() {
+        String url = launchpadURL + SLING_REQUEST_ATTRIBUTES_INCLUDE;
+        String pageContent = client.getStringContent(url, 200);
+        assertEquals("testValue", HTMLExtractor.innerHTML(url, pageContent, 
"#attrs-set"));
+        assertEquals("", HTMLExtractor.innerHTML(url, pageContent, 
"#attrs-unset"));
+    }
+
     private void uploadFile(String fileName, String serverFileName, String 
url) throws IOException {
         HttpClient httpClient = HttpClientBuilder.create().build();
         HttpPost post = new HttpPost(launchpadURL + url);


Reply via email to