incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
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 GMT
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.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.sling</groupId>
@@ -41,39 +42,51 @@
     </scm>
 
     <build>
+        <testResources>
+            <testResource>
+                <directory>src/test/resources</directory>
+                <excludes>
+                    <exclude>**/.settings</exclude>
+                    <exclude>**/.settings/**</exclude>
+                    <exclude>**/.project</exclude>
+                    <exclude>**/.classpath</exclude>
+                    <exclude>**/target/**</exclude>
+                </excludes>
+            </testResource>
+        </testResources>
         <extensions>
             <extension>
                 <groupId>org.apache.maven.archetype</groupId>
                 <artifactId>archetype-packaging</artifactId>
-                <version>2.0-alpha-4</version>
+                <version>2.2</version>
             </extension>
         </extensions>
         <plugins>
             <plugin>
                 <artifactId>maven-archetype-plugin</artifactId>
-                <version>2.0-alpha-4</version>
+                <version>2.2</version>
                 <extensions>true</extensions>
             </plugin>
         </plugins>
     </build>
 
-        <reporting>
-            <plugins>
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-plugin-plugin</artifactId>
-                    <version>2.5.1</version>
-                </plugin>
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-javadoc-plugin</artifactId>
-                    <configuration>
-                        <!-- No javadocs -->
-                        <excludePackageNames>
-                            org.apache.sling
-                        </excludePackageNames>
-                    </configuration>
-                </plugin>
-            </plugins>
-        </reporting>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <version>2.5.1</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <!-- No javadocs -->
+                    <excludePackageNames>
+                        org.apache.sling
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
 </project>

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 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.sling</groupId>
+    <artifactId>test-servlet-archetype-project</artifactId>
+    <packaging>bundle</packaging>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>test-servlet-archetype-project</name>
+    <description>org.apache.sling - test-servlet-archetype-project</description>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <version>1.7.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-scr-descriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <version>2.0.1</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <!-- use version 2.3.2 to have java 1.5 as the default -->
+                <version>2.3.2</version>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.5.10</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.6.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <profiles>
+        <profile>
+            <id>autoInstallBundle</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.sling</groupId>
+                        <artifactId>maven-sling-plugin</artifactId>
+                        <version>2.0.4-incubator</version>
+                        <executions>
+                            <execution>
+                                <id>install-bundle</id>
+                                <goals>
+                                    <goal>install</goal>
+                                </goals>
+                                <configuration>
+                                    <slingUrl>http://localhost:8888/system/console</slingUrl>
+                                    <user>admin</user>
+                                    <password>admin</password>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

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("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 2.0//EN\">");
+        w.write("<html>");
+        w.write("<head>");
+        w.write("<title>Hello World Servlet</title>");
+        w.write("</head>");
+        w.write("<body>");
+        w.write("<h1>Hello World!</h1>");
+        w.write("</body>");
+        w.write("</html>");
+        
+        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("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 2.0//EN\">");
+        w.write("<html>");
+        w.write("<head>");
+        w.write("<title>Hello World Servlet</title>");
+        w.write("</head>");
+        w.write("<body>");
+        w.write("<h1>Hello ");
+        w.write(resource.getPath());
+        w.write("</h1>");
+        w.write("</body>");
+        w.write("</html>");
+        
+        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);
+    }
+    
+}



Mime
View raw message