Author: rombert Date: Thu Aug 17 14:07:51 2017 New Revision: 1805288 URL: http://svn.apache.org/viewvc?rev=1805288&view=rev Log: SLING-7048 - Add an integration test for scripted tag files
Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/jsp/ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/jsp/TagFileTest.java sling/trunk/launchpad/test-services/src/main/resources/META-INF/ sling/trunk/launchpad/test-services/src/main/resources/META-INF/slingtest.tld sling/trunk/launchpad/test-services/src/main/resources/META-INF/tags/ sling/trunk/launchpad/test-services/src/main/resources/META-INF/tags/slingtest/ sling/trunk/launchpad/test-services/src/main/resources/META-INF/tags/slingtest/test.tag Modified: sling/trunk/launchpad/integration-tests/pom.xml sling/trunk/launchpad/test-services/pom.xml Modified: sling/trunk/launchpad/integration-tests/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/pom.xml?rev=1805288&r1=1805287&r2=1805288&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/pom.xml (original) +++ sling/trunk/launchpad/integration-tests/pom.xml Thu Aug 17 14:07:51 2017 @@ -184,7 +184,7 @@ <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.testing</artifactId> - <version>2.0.24</version> + <version>2.1.1-SNAPSHOT</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> @@ -235,11 +235,13 @@ </dependency> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> + <artifactId>osgi.core</artifactId> + <version>6.0.0</version> </dependency> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.compendium</artifactId> + <artifactId>osgi.cmpn</artifactId> + <version>6.0.0</version> </dependency> <dependency> <groupId>junit</groupId> Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/jsp/TagFileTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/jsp/TagFileTest.java?rev=1805288&view=auto ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/jsp/TagFileTest.java (added) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/jsp/TagFileTest.java Thu Aug 17 14:07:51 2017 @@ -0,0 +1,63 @@ +/* + * 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. + */ +package org.apache.sling.launchpad.webapp.jsp; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Collections; + +import org.apache.sling.commons.testing.integration.HttpTestBase; + +/** + * Verifies that JSP Tag files function correctly + * + */ +public class TagFileTest extends HttpTestBase { + + private static String TAG_FILE_SCRIPT = + "<%@ taglib prefix=\"t\" uri=\"https://sling.apache.org/tags/test/1.0\" %>\n" + + "\n" + + "<t:test/>"; + + /** + * Tests a tag file packaged in a jar file is properly executed + */ + public void testTagFileDeployedInBundle() throws IOException { + + if ( !isBundleVersionAtLeast("org.apache.sling.scripting.jsp", "2.3.1") ) { + System.out.println("Bundle version is too old, skipping"); + return; + } + + testClient.createNode(HTTP_BASE_URL + "/content/tagtest", Collections.singletonMap("sling:resourceType", "sling/test/tagfile")); + testClient.mkdirs(HTTP_BASE_URL, "/apps/sling/test/tagfile"); + testClient.upload(HTTP_BASE_URL + "/apps/sling/test/tagfile/html.jsp", new ByteArrayInputStream(TAG_FILE_SCRIPT.getBytes(Charset.forName("UTF-8")))); + + String content = getContent(HTTP_BASE_URL + "/content/tagtest.html", CONTENT_TYPE_DONTCARE, null, 200); + assertEquals("Incorrect output from rendering script", "TEST OUTPUT", content.trim()); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + + testClient.delete(HTTP_BASE_URL + "/content/tagtest"); + testClient.delete(HTTP_BASE_URL + "/apps/sling/test/tagfile"); + } + +} Modified: sling/trunk/launchpad/test-services/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/pom.xml?rev=1805288&r1=1805287&r2=1805288&view=diff ============================================================================== --- sling/trunk/launchpad/test-services/pom.xml (original) +++ sling/trunk/launchpad/test-services/pom.xml Thu Aug 17 14:07:51 2017 @@ -135,6 +135,12 @@ <artifactId>servlet-api</artifactId> </dependency> <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jsp-api</artifactId> + <version>2.0</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.jcr.jackrabbit.server</artifactId> <version>2.1.0</version> Added: sling/trunk/launchpad/test-services/src/main/resources/META-INF/slingtest.tld URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/resources/META-INF/slingtest.tld?rev=1805288&view=auto ============================================================================== --- sling/trunk/launchpad/test-services/src/main/resources/META-INF/slingtest.tld (added) +++ sling/trunk/launchpad/test-services/src/main/resources/META-INF/slingtest.tld Thu Aug 17 14:07:51 2017 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<taglib xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web- +jsptaglibrary_2_0.xsd" + version="2.0"> + + <tlib-version>1.0</tlib-version> + <uri>https://sling.apache.org/tags/test/1.0</uri> + + <tag-file> + <name>test</name> + <path>/META-INF/tags/slingtest/test.tag</path> + </tag-file> +</taglib> \ No newline at end of file Added: sling/trunk/launchpad/test-services/src/main/resources/META-INF/tags/slingtest/test.tag URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/resources/META-INF/tags/slingtest/test.tag?rev=1805288&view=auto ============================================================================== --- sling/trunk/launchpad/test-services/src/main/resources/META-INF/tags/slingtest/test.tag (added) +++ sling/trunk/launchpad/test-services/src/main/resources/META-INF/tags/slingtest/test.tag Thu Aug 17 14:07:51 2017 @@ -0,0 +1,21 @@ +<%-- +/* + * 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. +--%> +<%@ tag body-content="empty" %> +TEST OUTPUT \ No newline at end of file