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/02/17 04:57:21 UTC

svn commit: r910815 - in /sling/trunk/samples/inplace-integration-test: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sling/ src/main/java/org/apache/sling/samples/ src/main/java/org/apache/sling...

Author: justin
Date: Wed Feb 17 03:57:20 2010
New Revision: 910815

URL: http://svn.apache.org/viewvc?rev=910815&view=rev
Log:
adding sample project for SLING-1364

Added:
    sling/trunk/samples/inplace-integration-test/
    sling/trunk/samples/inplace-integration-test/.gitignore
    sling/trunk/samples/inplace-integration-test/README.txt
    sling/trunk/samples/inplace-integration-test/pom.xml
    sling/trunk/samples/inplace-integration-test/src/
    sling/trunk/samples/inplace-integration-test/src/main/
    sling/trunk/samples/inplace-integration-test/src/main/java/
    sling/trunk/samples/inplace-integration-test/src/main/java/org/
    sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/
    sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/
    sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/
    sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/itdemo/
    sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/itdemo/impl/
    sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/itdemo/impl/SimpleServlet.java
    sling/trunk/samples/inplace-integration-test/src/test/
    sling/trunk/samples/inplace-integration-test/src/test/java/
    sling/trunk/samples/inplace-integration-test/src/test/java/org/
    sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/
    sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/
    sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/
    sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/
    sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/InitialContentIT.java
    sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/SimpleServletIT.java

Added: sling/trunk/samples/inplace-integration-test/.gitignore
URL: http://svn.apache.org/viewvc/sling/trunk/samples/inplace-integration-test/.gitignore?rev=910815&view=auto
==============================================================================
--- sling/trunk/samples/inplace-integration-test/.gitignore (added)
+++ sling/trunk/samples/inplace-integration-test/.gitignore Wed Feb 17 03:57:20 2010
@@ -0,0 +1 @@
+/sling/

Added: sling/trunk/samples/inplace-integration-test/README.txt
URL: http://svn.apache.org/viewvc/sling/trunk/samples/inplace-integration-test/README.txt?rev=910815&view=auto
==============================================================================
--- sling/trunk/samples/inplace-integration-test/README.txt (added)
+++ sling/trunk/samples/inplace-integration-test/README.txt Wed Feb 17 03:57:20 2010
@@ -0,0 +1,28 @@
+Apache Sling Samples In-Place Integration Test
+
+Provide a sample bundle demonstrating the use of the Maven Launchpad Plugin's ability
+to do in-place integration testing.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can run the sample integration tests
+using the following command:
+
+    mvn verify
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+    svn checkout http://svn.apache.org/repos/asf/sling/trunk/samples/inplace-integration-test
+
+See the Subversion documentation for other source control features.
+

Added: sling/trunk/samples/inplace-integration-test/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/samples/inplace-integration-test/pom.xml?rev=910815&view=auto
==============================================================================
--- sling/trunk/samples/inplace-integration-test/pom.xml (added)
+++ sling/trunk/samples/inplace-integration-test/pom.xml Wed Feb 17 03:57:20 2010
@@ -0,0 +1,298 @@
+<?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.samples</groupId>
+    <artifactId>inplace-integration-test</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>Sample In-Place Integration Test</name>
+    <description>Sling Integration Test Demo Project</description>
+    <properties>
+        <http.port>8888</http.port>
+        <jetty.scan.interval.seconds>0</jetty.scan.interval.seconds>
+        <jetty.sling.home>target/sling</jetty.sling.home>
+        <test.host>localhost</test.host>
+        <integration.test.wait>false</integration.test.wait>
+        <http.base.path />
+        <webdav.workspace.path />
+        <test.webapp.classifier>testwebapp</test.webapp.classifier>
+        <test.webapp.war>${project.build.directory}/${project.build.finalName}-${test.webapp.classifier}.war</test.webapp.war>
+    </properties>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/samples/inplace-integration-test</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/samples/inplace-integration-test</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/samples/inplace-integration-test</url>
+    </scm>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.0.1</version>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <version>1.4.0</version>
+                <executions>
+                    <execution>
+                        <id>generate-scr-descriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>maven-launchpad-plugin</artifactId>
+                <version>2.0.5-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <id>prepare-test-webapp</id>
+                        <goals>
+                            <goal>prepare-test-webapp</goal>
+                        </goals>
+                        <configuration>
+                            <defaultBundleList>
+                                <version>6-SNAPSHOT</version>
+                            </defaultBundleList>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-war-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>create-test-war</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>war</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>${test.webapp.classifier}</classifier>
+                            <failOnMissingWebXml>false</failOnMissingWebXml>
+                            <primaryArtifact>false</primaryArtifact>
+                            <overlays>
+                                <overlay>
+                                    <groupId>org.apache.sling</groupId>
+                                    <artifactId>org.apache.sling.launchpad.base</artifactId>
+                                    <classifier>webapp</classifier>
+                                    <type>war</type>
+                                </overlay>
+                            </overlays>
+                            <webResources>
+                                <resource>
+                                    <directory>${project.build.directory}/launchpad-bundles</directory>
+                                    <targetPath>WEB-INF</targetPath>
+                                </resource>
+                            </webResources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <!--
+                This isn't necessary to run integration tests, but it is helpful to be able to run $ mvn jetty:run
+            -->
+            <plugin>
+                <groupId>org.mortbay.jetty</groupId>
+                <artifactId>maven-jetty-plugin</artifactId>
+                <version>6.1.22</version>
+                <configuration>
+                    <contextPath>/</contextPath>
+                    <scanIntervalSeconds>
+                        ${jetty.scan.interval.seconds}
+                    </scanIntervalSeconds>
+
+                    <systemProperties>
+                        <systemProperty>
+                            <name>sling.home</name>
+                            <value>${jetty.sling.home}</value>
+                        </systemProperty>
+                    </systemProperties>
+
+                    <connectors>
+                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+                            <port>${http.port}</port>
+                            <maxIdleTime>60000</maxIdleTime>
+                        </connector>
+                    </connectors>
+
+                    <webApp>${test.webapp.war}</webApp>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <!--
+                Run the cargo-based integration tests.
+            -->
+            <id>cargoIntegrationTesting</id>
+            <activation>
+                <property>
+                    <name>!maven.test.skip</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <version>2.5</version>
+                        <executions>
+                            <execution>
+                                <id>integration-test</id>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>verify</id>
+                                <goals>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <systemProperties>
+                                <property>
+                                    <name>launchpad.http.server.url</name>
+                                    <value>http://${test.host}:${http.port}/${project.build.finalName}-${test.webapp.classifier}</value>
+                                </property>
+                                <property>
+                                    <name>launchpad.webdav.server.url</name>
+                                    <value>http://${test.host}:${http.port}/${project.build.finalName}-${test.webapp.classifier}/${webdav.workspace.path}</value>
+                                </property>
+                            </systemProperties>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.codehaus.cargo</groupId>
+                        <artifactId>cargo-maven2-plugin</artifactId>
+                        <version>1.0</version>
+                        <executions>
+                            <execution>
+                                <id>start-container</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>start</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>stop-container</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>stop</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <wait>${integration.test.wait}</wait>
+                            <container>
+                                <containerId>jetty6x</containerId>
+                                <type>embedded</type>
+                                <systemProperties>
+                                    <sling.home>${basedir}/target/it/sling</sling.home>
+                                </systemProperties>
+                            </container>
+                            <configuration>
+                                <home>${project.build.directory}/cargo</home>
+                                <properties>
+                                    <cargo.servlet.port>${http.port}</cargo.servlet.port>
+                                    <!--
+                                        <cargo.jvmargs>-Xdebug -Xnoagent
+                                        -Xrunjdwp:transport=dt_socket,address=30333,server=y,suspend=y</cargo.jvmargs>
+                                    -->
+                                </properties>
+                                <deployables>
+                                    <deployable>
+                                        <location>${test.webapp.war}</location>
+                                        <type>war</type>
+                                    </deployable>
+                                </deployables>
+                            </configuration>
+
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+    <dependencies>
+        <!-- These dependencies cover our sample servlet. -->
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.0.8</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+
+        <!-- These dependencies cover our sample servlet. -->
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.testing</artifactId>
+            <version>2.0.5-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1.1</version>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- We need the base webapp for integration tests -->
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.launchpad.base</artifactId>
+            <version>2.1.1-SNAPSHOT</version>
+            <classifier>webapp</classifier>
+            <type>war</type>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

Added: sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/itdemo/impl/SimpleServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/itdemo/impl/SimpleServlet.java?rev=910815&view=auto
==============================================================================
--- sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/itdemo/impl/SimpleServlet.java (added)
+++ sling/trunk/samples/inplace-integration-test/src/main/java/org/apache/sling/samples/itdemo/impl/SimpleServlet.java Wed Feb 17 03:57:20 2010
@@ -0,0 +1,46 @@
+/*
+ * 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.samples.itdemo.impl;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
+
+/**
+ * A simple test servlet.
+ */
+@Component(metatype=false)
+@Service
+@Property(name="sling.servlet.paths", value={"/test/from/this/bundle.txt"})
+public class SimpleServlet extends SlingSafeMethodsServlet {
+
+    @Override
+    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
+            IOException {
+        response.setContentType("text/plain");
+        response.getWriter().println("Hello World!");
+        response.getWriter().flush();
+    }
+
+}

Added: sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/InitialContentIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/InitialContentIT.java?rev=910815&view=auto
==============================================================================
--- sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/InitialContentIT.java (added)
+++ sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/InitialContentIT.java Wed Feb 17 03:57:20 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.samples.itdemo;
+
+import java.io.IOException;
+
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+
+/**
+ * A test to ensure that the Initial Content bundle has loaded.
+ */
+public class InitialContentIT extends HttpTestBase {
+
+    public void testIndex() throws IOException {
+        final String expected = "Do not remove this comment, used for Launchpad integration tests";
+        final String content = getContent(HTTP_BASE_URL + "/index.html", CONTENT_TYPE_HTML);
+        assertTrue("Content contains expected marker (" + content + ")", content.contains(expected));
+    }
+
+    public void testRootRedirectProperty() throws IOException {
+        final String expected = "\"sling:resourceType\":\"sling:redirect\"";
+        final String content = getContent(HTTP_BASE_URL + "/.json", CONTENT_TYPE_JSON);
+        assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
+    }
+
+    public void testInitialContentA() throws IOException {
+        final String expected = "42";
+        final String content = getContent(HTTP_BASE_URL + "/sling-test/sling/initial-content-test/marker.txt",
+                CONTENT_TYPE_PLAIN);
+        assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
+    }
+
+    public void testInitialContentB() throws IOException {
+        final String expected = "46";
+        final String content = getContent(HTTP_BASE_URL
+                + "/sling-test/initial-content-folder/folder-content-test/marker.txt", CONTENT_TYPE_PLAIN);
+        assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
+    }
+}

Added: sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/SimpleServletIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/SimpleServletIT.java?rev=910815&view=auto
==============================================================================
--- sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/SimpleServletIT.java (added)
+++ sling/trunk/samples/inplace-integration-test/src/test/java/org/apache/sling/samples/itdemo/SimpleServletIT.java Wed Feb 17 03:57:20 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.samples.itdemo;
+
+import java.io.IOException;
+
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+
+/**
+ * A test of our simple servlet.
+ */
+public class SimpleServletIT extends HttpTestBase {
+
+    public void testSimpleServlet() throws IOException {
+        final String expected = "Hello World!";
+        final String content = getContent(HTTP_BASE_URL + "/test/from/this/bundle.txt", CONTENT_TYPE_PLAIN);
+        assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
+    }
+
+}