You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2015/05/22 17:41:58 UTC
svn commit: r1681152 - in /sling/trunk/contrib/extensions/bgservlets: ./
core/ core/src/ src/ testing/ testing/src/ testing/src/main/
testing/src/main/provisioning/ testing/src/test/ testing/src/test/java/
testing/src/test/java/org/ testing/src/test/ja...
Author: bdelacretaz
Date: Fri May 22 15:41:58 2015
New Revision: 1681152
URL: http://svn.apache.org/r1681152
Log:
SLING-4740 - add integration tests
Added:
sling/trunk/contrib/extensions/bgservlets/core/ (with props)
sling/trunk/contrib/extensions/bgservlets/core/pom.xml
- copied unchanged from r1681148, sling/trunk/contrib/extensions/bgservlets/pom.xml
sling/trunk/contrib/extensions/bgservlets/core/src/
- copied from r1681148, sling/trunk/contrib/extensions/bgservlets/src/
sling/trunk/contrib/extensions/bgservlets/pom.xml
sling/trunk/contrib/extensions/bgservlets/testing/ (with props)
sling/trunk/contrib/extensions/bgservlets/testing/pom.xml
sling/trunk/contrib/extensions/bgservlets/testing/src/
sling/trunk/contrib/extensions/bgservlets/testing/src/main/
sling/trunk/contrib/extensions/bgservlets/testing/src/main/provisioning/
sling/trunk/contrib/extensions/bgservlets/testing/src/main/provisioning/test-model.txt
sling/trunk/contrib/extensions/bgservlets/testing/src/test/
sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/
sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/
sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/
sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/
sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/bgservlets/
sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/bgservlets/it/
sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/bgservlets/it/BackgroundRequestIT.java
Removed:
sling/trunk/contrib/extensions/bgservlets/src/
Propchange: sling/trunk/contrib/extensions/bgservlets/core/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri May 22 15:41:58 2015
@@ -0,0 +1,14 @@
+target
+bin
+derby.log
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+
+
+
Added: sling/trunk/contrib/extensions/bgservlets/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/pom.xml?rev=1681152&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/pom.xml (added)
+++ sling/trunk/contrib/extensions/bgservlets/pom.xml Fri May 22 15:41:58 2015
@@ -0,0 +1,38 @@
+<?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.
+ -->
+<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>
+ <artifactId>sling</artifactId>
+ <version>16</version>
+ <relativePath/>
+ </parent>
+
+ <artifactId>org.apache.sling.bgservlets.reactor</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>Apache Sling Background Servlets Reactor</name>
+
+ <modules>
+ <module>core</module>
+ <module>testing</module>
+ </modules>
+</project>
Propchange: sling/trunk/contrib/extensions/bgservlets/testing/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri May 22 15:41:58 2015
@@ -0,0 +1,14 @@
+target
+bin
+derby.log
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+
+
+
Added: sling/trunk/contrib/extensions/bgservlets/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/testing/pom.xml?rev=1681152&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/testing/pom.xml (added)
+++ sling/trunk/contrib/extensions/bgservlets/testing/pom.xml Fri May 22 15:41:58 2015
@@ -0,0 +1,226 @@
+<?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.
+ -->
+<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>
+ <artifactId>sling</artifactId>
+ <version>16</version>
+ <relativePath/>
+ </parent>
+
+ <artifactId>org.apache.sling.bgservlets.testing</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>slingstart</packaging>
+
+ <name>Apache Sling Background Servlets Integration Tests</name>
+
+ <properties>
+ <!-- Timeout when checking for Sling readyness before starting tests -->
+ <HttpTestBase.readyTimeoutSeconds>62</HttpTestBase.readyTimeoutSeconds>
+
+ <!-- path suffix for HTTP access to Sling -->
+ <http.base.path/>
+
+ <!-- path suffix for WebDAV access to the repository -->
+ <webdav.workspace.path/>
+
+ <!-- hostname for integration tests -->
+ <test.host>localhost</test.host>
+
+ <!--
+ Set this to true to stop mvn once the integration test Jetty instance is
+ started. Useful to manually test the integration testing webapp.
+ -->
+ <integration.test.wait>false</integration.test.wait>
+
+ <!--
+ if set to "true" this will start the launchpad with the following debug options:
+ -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
+
+ otherwise you can provide your own debug settings
+ -->
+ <debug.options/>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>reserve-network-port</id>
+ <goals>
+ <goal>reserve-network-port</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <portNames>
+ <portName>http.port</portName>
+ <portName>sling.control.port</portName>
+ </portNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <runOrder>alphabetical</runOrder>
+ <systemPropertyVariables>
+ <launchpad.http.server.url>http://${test.host}:${http.port}/</launchpad.http.server.url>
+ <launchpad.webdav.server.url>http://${test.host}:${http.port}/${webdav.workspace.path}</launchpad.webdav.server.url>
+ <HttpTestBase.readyTimeoutSeconds>${HttpTestBase.readyTimeoutSeconds}</HttpTestBase.readyTimeoutSeconds>
+ <launchpad.ready.1>GET:/index.html:200:.*Welcome to the Sling Launchpad.*</launchpad.ready.1>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>slingstart-maven-plugin</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <goals>
+ <goal>start</goal>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <servers>
+ <server>
+ <port>${http.port}</port>
+ <controlPort>${sling.control.port}</controlPort>
+ <runmode>jackrabbit</runmode>
+ <contextPath>${http.base.path}</contextPath>
+ <debug>${debug.options}</debug>
+ </server>
+ </servers>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.engine</artifactId>
+ <version>2.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.testing</artifactId>
+ <version>2.0.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.json</artifactId>
+ <version>2.0.4-incubator</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.api</artifactId>
+ <version>2.0.6</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.webconsole</artifactId>
+ <version>3.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.testing</artifactId>
+ <version>2.0.18</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: sling/trunk/contrib/extensions/bgservlets/testing/src/main/provisioning/test-model.txt
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/testing/src/main/provisioning/test-model.txt?rev=1681152&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/testing/src/main/provisioning/test-model.txt (added)
+++ sling/trunk/contrib/extensions/bgservlets/testing/src/main/provisioning/test-model.txt Fri May 22 15:41:58 2015
@@ -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.
+#
+[feature name=launchpad-testing]
+# Dependencies
+[artifacts]
+ org.apache.sling/org.apache.sling.launchpad/8-SNAPSHOT/slingstart
+ org.apache.sling/org.apache.sling.bgservlets/0.0.1-SNAPSHOT
+
+# additional configuration for testing
+[configurations]
+
+ org.apache.sling.servlets.resolver.SlingServletResolver
+ # Set the servlet resolver's cache size to zero for testing
+ servletresolver.cacheSize=I"0"
+
+[settings]
+ sling.system.packages.class.com.vladium.emma.rt.RT=com.vladium.emma.rt
+ org.apache.sling.commons.log.julenabled=true
Added: sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/bgservlets/it/BackgroundRequestIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/bgservlets/it/BackgroundRequestIT.java?rev=1681152&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/bgservlets/it/BackgroundRequestIT.java (added)
+++ sling/trunk/contrib/extensions/bgservlets/testing/src/test/java/org/apache/sling/bgservlets/it/BackgroundRequestIT.java Fri May 22 15:41:58 2015
@@ -0,0 +1,82 @@
+/*
+ * 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.bgservlets.it;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+
+import junit.framework.AssertionFailedError;
+
+import org.apache.sling.commons.testing.integration.HttpTest;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BackgroundRequestIT {
+ private final HttpTest T = new HttpTest();
+
+ @Before
+ public void setup() throws Exception {
+ T.setUp();
+ }
+
+ /** Find out how many job state nodes are present */
+ private int countStoredJobs() throws IOException {
+ int jobs = 0;
+ String content = "";
+ try {
+ content = T.getContent(HttpTest.HTTP_BASE_URL + "/var/bg.tidy.20.json", "application/json");
+ } catch(AssertionFailedError ignore) {
+ // Expected if no jobs have ever been created
+ }
+ final BufferedReader r = new BufferedReader(new StringReader(content));
+ String line = null;
+ while((line = r.readLine()) != null) {
+ if(line.contains("sling:resourceType") && line.contains("sling/bg/job")) {
+ jobs++;
+ }
+ }
+ return jobs;
+ }
+
+ @Test
+ public void testTmpRequestCreatesJob() throws IOException,InterruptedException {
+ final int initialJobs = countStoredJobs();
+ T.getContent(HttpTest.HTTP_BASE_URL + "/tmp.json?sling:bg=true", "application/json");
+
+ // Request must have created a job
+ final long timeout = System.currentTimeMillis() + 10000L;
+ while(true) {
+ if(countStoredJobs() >= initialJobs + 1) {
+ break;
+ }
+ if(System.currentTimeMillis() > timeout) {
+ fail("Timeout waiting for background job creation");
+ }
+ Thread.sleep(50L);
+ }
+
+ // Wait a bit - no more jobs should be created
+ Thread.sleep(2000L);
+ assertEquals("Expecting no extra jobs", initialJobs + 1, countStoredJobs());
+ }
+}