You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2010/01/25 20:33:03 UTC

svn commit: r902951 - in /sling/trunk/launchpad: test-services/src/main/java/org/apache/sling/launchpad/testservices/scripting/ testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ testing/src/test/resources/integration-test/

Author: justin
Date: Mon Jan 25 19:33:01 2010
New Revision: 902951

URL: http://svn.apache.org/viewvc?rev=902951&view=rev
Log:
SLING-1303 - adding JSP test case

Added:
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java
    sling/trunk/launchpad/testing/src/test/resources/integration-test/bindingsprovided.jsp
Modified:
    sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ScriptBindingsValuesProviderTest.java

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java?rev=902951&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java (added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/scripting/JSPBindingsValuesProvider.java Mon Jan 25 19:33:01 2010
@@ -0,0 +1,39 @@
+package org.apache.sling.launchpad.testservices.scripting;
+
+/*
+ * 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.
+ */
+
+import javax.script.Bindings;
+
+import org.apache.sling.scripting.api.BindingsValuesProvider;
+/** Example/test BindingsValuesProvider targeting JSP scripts.
+*
+* @scr.component immediate="true" metatype="no"
+* @scr.service
+*
+* @scr.property name="service.description" value="JSP BindingsValuesProvider"
+* @scr.property name="service.vendor" value="The Apache Software Foundation"
+*
+* @scr.property name="javax.script.name" value="JSP"
+*/
+public class JSPBindingsValuesProvider implements BindingsValuesProvider {
+
+    public void addBindings(Bindings bindings) {
+       bindings.put("jspHelloWorld", "Hello World from JSP!");
+    }
+
+}

Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ScriptBindingsValuesProviderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ScriptBindingsValuesProviderTest.java?rev=902951&r1=902950&r2=902951&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ScriptBindingsValuesProviderTest.java (original)
+++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ScriptBindingsValuesProviderTest.java Mon Jan 25 19:33:01 2010
@@ -70,4 +70,17 @@
         }
     }
 
+    public void testJSPProvider() throws IOException {
+        final String toDelete = uploadTestScript("bindingsprovided.jsp","html.jsp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes JSP marker (" + content + ")",content.contains("bindingsprovided.jsp"));
+            assertTrue("Content includes test text (" + content + ")", content.contains("Hello World!"));
+            assertTrue("Content includes JSP-specific test text (" + content + ")", content.contains("Hello World from JSP!"));
+            assertFalse("Content doesn't includes Groovy-specific test text (" + content + ")", content.contains("Hello World from Groovy!"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
 }

Added: sling/trunk/launchpad/testing/src/test/resources/integration-test/bindingsprovided.jsp
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/resources/integration-test/bindingsprovided.jsp?rev=902951&view=auto
==============================================================================
--- sling/trunk/launchpad/testing/src/test/resources/integration-test/bindingsprovided.jsp (added)
+++ sling/trunk/launchpad/testing/src/test/resources/integration-test/bindingsprovided.jsp Mon Jan 25 19:33:01 2010
@@ -0,0 +1,31 @@
+<!--
+/*
+ * 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.
+-->
+<!-- simple JSP rendering test -->
+<%@page session="false"%>
+<%@page import="org.apache.sling.api.scripting.SlingBindings"%>
+<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
+<sling:defineObjects/>
+
+<h1>bindingsprovided.jsp</h1>
+<% SlingBindings bindings = (SlingBindings) request.getAttribute("org.apache.sling.api.scripting.SlingBindings"); %>
+<%= bindings %>
+<p>helloWorld:<%= bindings.get("helloWorld") %></p>
+<p>jspHelloWorld:<%= bindings.get("jspHelloWorld") %></p>
+<p>groovyHelloWorld:<%= bindings.get("groovyHelloWorld") %></p>