Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB35198CB for ; Wed, 21 Dec 2011 01:04:36 +0000 (UTC) Received: (qmail 37284 invoked by uid 500); 21 Dec 2011 01:04:36 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 37245 invoked by uid 500); 21 Dec 2011 01:04:36 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 37237 invoked by uid 99); 21 Dec 2011 01:04:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2011 01:04:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2011 01:04:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E6B4723889E1; Wed, 21 Dec 2011 01:04:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1221548 - in /sling/trunk/maven/archetypes/servlet: ./ src/main/resources/META-INF/maven/ src/main/resources/archetype-resources/src/test/java/ src/test/ src/test/resources/ src/test/resources/projects/ src/test/resources/projects/normal/ ... Date: Wed, 21 Dec 2011 01:04:08 -0000 To: commits@sling.apache.org From: justin@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111221010408.E6B4723889E1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: justin Date: Wed Dec 21 01:04:07 2011 New Revision: 1221548 URL: http://svn.apache.org/viewvc?rev=1221548&view=rev Log: SLING-2338 - adding integration test for servlet archetype Added: sling/trunk/maven/archetypes/servlet/src/test/ sling/trunk/maven/archetypes/servlet/src/test/resources/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/archetype.properties sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/goal.txt sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/pom.xml sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByPathServlet.java sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByResourceTypeServlet.java sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/SimpleFilter.java sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/servlet/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/servlet/testing/ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/servlet/testing/ByPathServletTest.java Removed: sling/trunk/maven/archetypes/servlet/src/main/resources/META-INF/maven/archetype.xml Modified: sling/trunk/maven/archetypes/servlet/pom.xml sling/trunk/maven/archetypes/servlet/src/main/resources/archetype-resources/src/test/java/ByPathServletTest.java Modified: sling/trunk/maven/archetypes/servlet/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/pom.xml?rev=1221548&r1=1221547&r2=1221548&view=diff ============================================================================== --- sling/trunk/maven/archetypes/servlet/pom.xml (original) +++ sling/trunk/maven/archetypes/servlet/pom.xml Wed Dec 21 01:04:07 2011 @@ -17,7 +17,8 @@ specific language governing permissions and limitations under the License. --> - + 4.0.0 org.apache.sling @@ -41,39 +42,51 @@ + + + src/test/resources + + **/.settings + **/.settings/** + **/.project + **/.classpath + **/target/** + + + org.apache.maven.archetype archetype-packaging - 2.0-alpha-4 + 2.2 maven-archetype-plugin - 2.0-alpha-4 + 2.2 true - - - - org.apache.maven.plugins - maven-plugin-plugin - 2.5.1 - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - org.apache.sling - - - - - + + + + org.apache.maven.plugins + maven-plugin-plugin + 2.5.1 + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.apache.sling + + + + + Modified: sling/trunk/maven/archetypes/servlet/src/main/resources/archetype-resources/src/test/java/ByPathServletTest.java URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/main/resources/archetype-resources/src/test/java/ByPathServletTest.java?rev=1221548&r1=1221547&r2=1221548&view=diff ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/main/resources/archetype-resources/src/test/java/ByPathServletTest.java (original) +++ sling/trunk/maven/archetypes/servlet/src/main/resources/archetype-resources/src/test/java/ByPathServletTest.java Wed Dec 21 01:04:07 2011 @@ -1,3 +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. + */ package ${package}; import junit.framework.TestCase; Added: sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/archetype.properties URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/archetype.properties?rev=1221548&view=auto ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/archetype.properties (added) +++ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/archetype.properties Wed Dec 21 01:04:07 2011 @@ -0,0 +1,4 @@ +groupId=org.apache.sling +artifactId=test-servlet-archetype-project +version=0.0.1-SNAPSHOT +package=org.apache.sling.archetype.servlet.testing \ No newline at end of file Added: sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/goal.txt URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/goal.txt?rev=1221548&view=auto ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/goal.txt (added) +++ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/goal.txt Wed Dec 21 01:04:07 2011 @@ -0,0 +1 @@ +package \ No newline at end of file Added: sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/pom.xml?rev=1221548&view=auto ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/pom.xml (added) +++ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/pom.xml Wed Dec 21 01:04:07 2011 @@ -0,0 +1,134 @@ + + + + 4.0.0 + org.apache.sling + test-servlet-archetype-project + bundle + 0.0.1-SNAPSHOT + test-servlet-archetype-project + org.apache.sling - test-servlet-archetype-project + + + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-descriptor + + scr + + + + + + org.apache.felix + maven-bundle-plugin + true + 2.0.1 + + + org.apache.maven.plugins + maven-compiler-plugin + + 2.3.2 + + + + + + javax.servlet + servlet-api + 2.5 + provided + + + org.osgi + org.osgi.compendium + 4.2.0 + provided + + + org.osgi + org.osgi.core + 4.2.0 + provided + + + javax.jcr + jcr + 2.0 + provided + + + org.apache.sling + org.apache.sling.api + 2.2.0 + provided + + + org.slf4j + slf4j-api + 1.5.10 + provided + + + org.apache.felix + org.apache.felix.scr.annotations + 1.6.0 + provided + + + junit + junit + 3.8.1 + test + + + + + autoInstallBundle + + + + org.apache.sling + maven-sling-plugin + 2.0.4-incubator + + + install-bundle + + install + + + http://localhost:8888/system/console + admin + admin + + + + + + + + + Added: sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByPathServlet.java URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByPathServlet.java?rev=1221548&view=auto ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByPathServlet.java (added) +++ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByPathServlet.java Wed Dec 21 01:04:07 2011 @@ -0,0 +1,79 @@ +/* + * 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.archetype.servlet.testing; + +import java.io.IOException; +import java.io.Writer; + +import javax.servlet.ServletException; + +import org.apache.felix.scr.annotations.Properties; +import org.apache.felix.scr.annotations.Property; +import org.apache.felix.scr.annotations.sling.SlingServlet; +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.SlingHttpServletResponse; +import org.apache.sling.api.servlets.SlingSafeMethodsServlet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Hello World Servlet registered by path + * + * Annotations below are short version of: + * + * @Component + * @Service(Servlet.class) + * @Properties({ + * @Property(name="service.description", value="Hello World Path Servlet"), + * @Property(name="service.vendor", value="The Apache Software Foundation"), + * @Property(name="sling.servlet.paths", value="/hello-world-servlet") + * }) + */ +@SlingServlet(paths="/hello-world-servlet") +@Properties({ + @Property(name="service.description", value="Hello World Path Servlet"), + @Property(name="service.vendor", value="The Apache Software Foundation") +}) +@SuppressWarnings("serial") +public class ByPathServlet extends SlingSafeMethodsServlet { + + private final Logger log = LoggerFactory.getLogger(ByPathServlet.class); + + @Override + protected void doGet(SlingHttpServletRequest request, + SlingHttpServletResponse response) throws ServletException, + IOException { + + Writer w = response.getWriter(); + w.write(""); + w.write(""); + w.write(""); + w.write("Hello World Servlet"); + w.write(""); + w.write(""); + w.write("

Hello World!

"); + w.write(""); + w.write(""); + + log.info("Hello World Servlet"); + + } + +} + Added: sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByResourceTypeServlet.java URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByResourceTypeServlet.java?rev=1221548&view=auto ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByResourceTypeServlet.java (added) +++ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/ByResourceTypeServlet.java Wed Dec 21 01:04:07 2011 @@ -0,0 +1,85 @@ +/* + * 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.archetype.servlet.testing; + +import java.io.IOException; +import java.io.Writer; + +import javax.servlet.ServletException; + +import org.apache.felix.scr.annotations.Properties; +import org.apache.felix.scr.annotations.Property; +import org.apache.felix.scr.annotations.sling.SlingServlet; +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.SlingHttpServletResponse; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.servlets.SlingSafeMethodsServlet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Hello World Servlet registered by resource type + * + * Annotations below are short version of: + * + * @Component + * @Service(Servlet.class) + * @Properties({ + * @Property(name="service.description", value="Hello World Type Servlet"), + * @Property(name="service.vendor", value="The Apache Software Foundation"), + * @Property(name="sling.servlet.resourceTypes", value="sling/servlet/default"), + * @Property(name="sling.servlet.selectors", value="hello"), + * @Property(name="sling.servlet.extensions", value="html") + * }) + */ +@SlingServlet(resourceTypes="sling/servlet/default", selectors="hello", extensions="html") +@Properties({ + @Property(name="service.description", value="Hello World Type Servlet"), + @Property(name="service.vendor", value="The Apache Software Foundation") +}) +@SuppressWarnings("serial") +public class ByResourceTypeServlet extends SlingSafeMethodsServlet { + + private final Logger log = LoggerFactory.getLogger(ByResourceTypeServlet.class); + + @Override + protected void doGet(SlingHttpServletRequest request, + SlingHttpServletResponse response) throws ServletException, + IOException { + Resource resource = request.getResource(); + + Writer w = response.getWriter(); + w.write(""); + w.write(""); + w.write(""); + w.write("Hello World Servlet"); + w.write(""); + w.write(""); + w.write("

Hello "); + w.write(resource.getPath()); + w.write("

"); + w.write(""); + w.write(""); + + log.info("Hello World Servlet"); + + } + +} + Added: sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/SimpleFilter.java URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/SimpleFilter.java?rev=1221548&view=auto ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/SimpleFilter.java (added) +++ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/main/java/org/apache/sling/archetype/servlet/testing/SimpleFilter.java Wed Dec 21 01:04:07 2011 @@ -0,0 +1,71 @@ +/* + * 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.archetype.servlet.testing; + +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Properties; +import org.apache.felix.scr.annotations.Property; +import org.apache.felix.scr.annotations.Service; +import org.apache.felix.scr.annotations.sling.SlingFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A Simple Filter + * + * Annotations below are short version of: + * + * @Component + * @Service(Filter.class) + * @Properties({ + * @Property(name="service.description", value="A Simple Filter"), + * @Property(name="service.vendor", value="The Apache Software Foundation"), + * @Property(name="sling.filter.scope", value="REQUEST"), + * @Property(name="service.ranking", intValue=1) + * }) + */ +@SlingFilter(order=1, description="A Simple Filter") +@Property(name="service.vendor", value="The Apache Software Foundation") +public class SimpleFilter implements Filter { + + private final Logger log = LoggerFactory.getLogger(SimpleFilter.class); + + public void init(FilterConfig filterConfig) throws ServletException { + } + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, + ServletException { + log.info("filter invoked - start"); + chain.doFilter(request, response); + log.info("filter invoked - end"); + } + + public void destroy() { + } + +} Added: sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/servlet/testing/ByPathServletTest.java URL: http://svn.apache.org/viewvc/sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/servlet/testing/ByPathServletTest.java?rev=1221548&view=auto ============================================================================== --- sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/servlet/testing/ByPathServletTest.java (added) +++ sling/trunk/maven/archetypes/servlet/src/test/resources/projects/normal/reference/src/test/java/org/apache/sling/archetype/servlet/testing/ByPathServletTest.java Wed Dec 21 01:04:07 2011 @@ -0,0 +1,33 @@ +/* + * 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.archetype.servlet.testing; + +import junit.framework.TestCase; + +/** + * Unit test for By Path Servlet. + */ +public class ByPathServletTest extends TestCase { + + /** + * Rigourous Test :-) + */ + public void testByPathServlet() { + assertTrue(true); + } + +}