You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jv...@apache.org on 2009/06/09 21:40:11 UTC
svn commit: r783107 - in /incubator/sling/whiteboard/jvazquez/testing: ./
src/test/java/org/apache/sling/itest/
src/test/java/org/apache/sling/launchpad/webapp/integrationtest/
src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManag...
Author: jvazquez
Date: Tue Jun 9 19:40:10 2009
New Revision: 783107
URL: http://svn.apache.org/viewvc?rev=783107&view=rev
Log:
CreateNodeTest using Pax Exam
Added:
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/CreateNodeTest.java
- copied, changed from r782910, incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/HttpTestBase.java
Removed:
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/FileUploadTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ForwardTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/GeneratedNodeNameTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/GeneratedNodeNameTestStar.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/GetStarTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/GetWithSuffixTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpPingTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/IncludeTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/InitialContentTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JavascriptWrappersTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JsonQueryServletTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JsonRenderingTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/MkdirTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/PostRedirectTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/PropertyRenderingTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RenderingTestBase.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RequestAttributeTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ScriptBuiltinObjectsTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/SlingResourceTypeRenderingTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/StaticContentTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/StreamServletTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/SyntheticResourceTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/UploadFileTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ValueFromTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/WebdavUploadTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/issues/
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/package.html
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/
Modified:
incubator/sling/whiteboard/jvazquez/testing/pom.xml
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/DummyPaxExamTest.java
incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/PaxExamTestBase.java
Modified: incubator/sling/whiteboard/jvazquez/testing/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/testing/pom.xml?rev=783107&r1=783106&r2=783107&view=diff
==============================================================================
--- incubator/sling/whiteboard/jvazquez/testing/pom.xml (original)
+++ incubator/sling/whiteboard/jvazquez/testing/pom.xml Tue Jun 9 19:40:10 2009
@@ -28,8 +28,8 @@
</parent>
<artifactId>org.apache.sling.launchpad.testing.paxbased</artifactId>
- <packaging>war</packaging>
- <version>4-incubator-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <version>6-incubator-SNAPSHOT</version>
<name>Apache Sling Launchpad Testing</name>
<description>
@@ -42,12 +42,12 @@
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/testing</developerConnection>
<url>http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing</url>
</scm>
-
- <properties>
+
+ <properties>
<!--
- Jetty default port (override with -D)
+ HTTP OSGi service default port (override with -D)
-->
- <http.port>8888</http.port>
+ <http.port>8080</http.port>
<!-- path suffix for HTTP access to Sling -->
<http.base.path />
@@ -58,221 +58,24 @@
<!-- hostname for integration tests -->
<test.host>localhost</test.host>
- <!--
- Disable Jetty webapp rescan (override with -D)
- -->
- <jetty.scan.interval.seconds>0</jetty.scan.interval.seconds>
-
- <!--
- Sling home directory when starting with jetty:run
- -->
- <jetty.sling.home>target/sling</jetty.sling.home>
-
<!--
Defines which tests are for the "integration-testing" phase
-->
<integration.test.code.path>
**/launchpad/webapp/integrationtest
</integration.test.code.path>
-
- <!--
- 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>
- <resources.bundles.path>${project.build.directory}/launchpad-bundles/resources/bundles</resources.bundles.path>
</properties>
-
+
<build>
- <plugins>
-
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.2</version>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}</directory>
- <includes>
- <include>derby.log</include>
- <include>cachedir</include>
- <include>sling</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>delete-sling-folder</id>
- <phase>package</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <echo>SLING-845 - delete parent sling folder before integration tests</echo>
- <delete dir="../../sling"/>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <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>
-
- <!--
- Use target/... as the webapp source, as we unpack stuff there from the
- Sling launcher modules
- -->
- <webAppSourceDirectory>
- target/${artifactId}-${pom.version}
- </webAppSourceDirectory>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <!-- Unpack the sling-app launcher for inclusion in the web app -->
- <id>unpack-dependencies</id>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeArtifactIds>
- org.apache.sling.launchpad.bundles
- </includeArtifactIds>
- <includes>
- resources/**
- </includes>
- <excludeTransitive>true</excludeTransitive>
- <outputDirectory>
- ${project.build.directory}/launchpad-bundles
- </outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>
- true
- </overWriteSnapshots>
- </configuration>
- </execution>
- <!-- Launcher Jar -->
- <execution>
- <id>copy-launcher-jar</id>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad.base</artifactId>
- <version>2.0.3-incubator-SNAPSHOT</version>
- </artifactItem>
- </artifactItems>
- <stripVersion>true</stripVersion>
- <excludeTransitive>true</excludeTransitive>
- <outputDirectory>
- ${project.build.directory}/launchpad-bundles/resources
- </outputDirectory>
- </configuration>
- </execution>
-
- <execution>
- <!--
- Copy additional bundles that must be initially installed to
- WEB-INF/resources/bundles/N where N = desired
- start level
- -->
- <id>copy-bundles-dependencies</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>
- ${resources.bundles.path}/0
- </outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- <includeArtifactIds>
- org.apache.sling.launchpad.test-services
- </includeArtifactIds>
- <includeScope>
- provided
- </includeScope>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <!--
- Include sling-app launcher classes and resources, but no Sling
- bundles (we want to specify our own versions)
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webResources>
- <!-- the configuration resources -->
- <resource>
- <directory>
- ${project.build.directory}/launchpad-bundles
- </directory>
- <targetPath>WEB-INF</targetPath>
- </resource>
- <!-- Legal stuff -->
- <resource>
- <directory>${basedir}</directory>
- <targetPath>META-INF</targetPath>
- <includes>
- <include>LICENSE*</include>
- <include>NOTICE*</include>
- <include>DISCLAIMER</include>
- </includes>
- </resource>
- </webResources>
- </configuration>
- </plugin>
-
- <plugin>
+
+ <plugins>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
- <!--
- WARNING: make sure these URLs are consistent with the
- cargo-maven2-plugin settings: AFAIK Maven does not
- expand variables in the <value> element.
- And WARNING: these properties are duplicated somewhere in this
- POM with slightly different values...there must be a better way.
- -->
<property>
<name>launchpad.http.server.url</name>
<value>
@@ -288,141 +91,31 @@
</systemProperties>
</configuration>
</plugin>
-
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/bin.xml</descriptor>
- </descriptors>
- </configuration>
- </plugin>
- </plugins>
+
+ </plugins>
+
</build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!-- No javadocs -->
- <excludePackageNames>
- org.apache.sling
- </excludePackageNames>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
+
+ <repositories>
+ <repository>
+ <id>ops4j.releases</id>
+ <url>http://repository.ops4j.org/maven2</url>
+ </repository>
+ <repository>
+ <id>ops4j.profiles</id>
+ <url>http://scm.ops4j.org/repos/ops4j/projects/pax/runner-repository</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>ops4j.releases</id>
+ <url>http://repository.ops4j.org/maven2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
<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-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>surefire-integration-test</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <excludes>
- <exclude>none</exclude>
- </excludes>
- <includes>
- <include>
- ${integration.test.code.path}/**/*Test.java
- </include>
- </includes>
- <systemProperties>
- <!--
- WARNING: make sure these URLs are consistent with the
- cargo-maven2-plugin settings: AFAIK Maven does not
- expand variables in the <value> element.
- And WARNING: these properties are duplicated somewhere in this
- POM with slightly different values...there must be a better way.
- -->
- <property>
- <name>
- launchpad.http.server.url
- </name>
- <value>
- http://${test.host}:${http.port}/${project.build.finalName}
- </value>
- </property>
- <property>
- <name>
- launchpad.webdav.server.url
- </name>
- <value>
- http://${test.host}:${http.port}/${project.build.finalName}/${webdav.workspace.path}
- </value>
- </property>
-
- </systemProperties>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.cargo</groupId>
- <artifactId>cargo-maven2-plugin</artifactId>
- <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>
- </configuration>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
+
+ <profile>
<!--
By default, do not run the integration tests in the test phase, as they have
no Sling instance to talk to.
@@ -450,50 +143,319 @@
</plugin>
</plugins>
</build>
- </profile>
+ </profile>
+
</profiles>
-
- <dependencies>
- <!-- The basic Sling WebApp -->
+ <dependencies>
+
+ <!-- Http Service -->
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-service</artifactId>
+ <version>0.6.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Dependencies for Start Level 1 -->
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad.base</artifactId>
- <version>2.0.3-incubator-SNAPSHOT</version>
- <classifier>webapp</classifier>
- <type>war</type>
- <scope>runtime</scope>
+ <artifactId>org.apache.sling.commons.log</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
</dependency>
- <!-- The basic Sling Bundles -->
+ <!-- Dependencies for Start Level 5 -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.webconsole</artifactId>
+ <version>1.2.10</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad.bundles</artifactId>
- <version>4-incubator-SNAPSHOT</version>
+ <artifactId>org.apache.sling.commons.json</artifactId>
+ <version>2.0.4-incubator</version>
<scope>provided</scope>
- <optional>true</optional>
</dependency>
-
- <!-- JCR Install - needs to be in a profile -->
+ <!--
<dependency>
<groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>test</scope>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ <version>1.4.0</version>
+ <scope>provided</scope>
</dependency>
+ -->
<dependency>
- <groupId>biz.aQute</groupId>
- <artifactId>bnd</artifactId>
- <version>0.0.169</version>
- <scope>test</scope>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.extensions.threaddump</artifactId>
+ <version>0.1.2-incubator</version>
+ <scope>provided</scope>
</dependency>
-
+
+ <!-- Dependencies for Start Level 10 -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.eventadmin</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr</artifactId>
+ <version>1.0.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.0.10</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.metatype</artifactId>
+ <version>1.0.2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Dependencies for Start Level 15 -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.api</artifactId>
+ <version>2.0.2-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.base</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-api</artifactId>
+ <version>1.5.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.jackrabbit.server</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.jackrabbit.usermanager</artifactId>
+ <version>2.0.2-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.jackrabbit.accessmanager</artifactId>
+ <version>2.0.2-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-commons</artifactId>
+ <version>1.5.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.webdav</artifactId>
+ <version>2.0.6-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!--
+ Commons Dependencies
+ -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.osgi</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.1.0-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Dependencies for Default Start Level -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.0.5-incubator-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.engine</artifactId>
+ <version>2.0.5-incubator-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.httpauth</artifactId>
+ <version>2.0.5-incubator-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.openidauth</artifactId>
+ <version>0.9.0-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.adapter</artifactId>
+ <version>2.0.2-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.servlets.resolver</artifactId>
+ <version>2.0.6-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.servlets.get</artifactId>
+ <version>2.0.5-incubator-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.servlets.post</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.contentloader</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.resource</artifactId>
+ <version>2.0.5-incubator-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.ocm</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.classloader</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.bundleresource.impl</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.fsresource</artifactId>
+ <version>0.9.2-incubator</version>
+ </dependency>
+
+ <!-- Launchpad initial content -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.launchpad.content</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- scripting -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.api</artifactId>
+ <version>2.0.2-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.core</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.javascript</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.jsp</artifactId>
+ <version>2.0.6-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
+ <version>2.0.4-incubator</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.6.0</version>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Dependencies for the Test Build and Run -->
+
+ <!-- Needed for HttpTestBase class -->
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.commons-httpclient</artifactId>
+ <version>3.1_1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.commons-codec</artifactId>
+ <version>1.2_1</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.testing</artifactId>
- <version>2.0.3-incubator-SNAPSHOT</version>
- <scope>test</scope>
+ <version>2.0.5-incubator-SNAPSHOT</version>
+ <scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlets.post</artifactId>
@@ -503,7 +465,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.launchpad.test-services</artifactId>
- <version>2.0.3-incubator-SNAPSHOT</version>
+ <version>2.0.6-incubator</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -526,54 +488,25 @@
<!-- Pax Exam tests based dependencies -->
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- <version>1.2.1</version>
- </dependency>
-
- <dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
- <version>0.5.0</version>
+ <version>0.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit</artifactId>
- <version>0.5.0</version>
+ <version>0.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-default</artifactId>
- <version>0.5.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit-extender-impl</artifactId>
- <version>0.5.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.runner.profiles</groupId>
- <artifactId>log</artifactId>
- <version>1.3.0</version>
- <type>composite</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.runner.profiles</groupId>
- <artifactId>felix.config</artifactId>
- <version>1.0.10</version>
- <type>composite</type>
+ <version>0.6.0</version>
<scope>test</scope>
</dependency>
+
+ <!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -583,21 +516,4 @@
</dependencies>
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <url>http://repository.ops4j.org/maven2</url>
- </repository>
- <repository>
- <id>ops4j.profiles</id>
- <url>http://scm.ops4j.org/repos/ops4j/projects/pax/runner-repository</url>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>ops4j.releases</id>
- <url>http://repository.ops4j.org/maven2</url>
- </pluginRepository>
- </pluginRepositories>
-
-</project>
+</project>
\ No newline at end of file
Copied: incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/CreateNodeTest.java (from r782910, incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java)
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/CreateNodeTest.java?p2=incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/CreateNodeTest.java&p1=incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java&r1=782910&r2=783107&rev=783107&view=diff
==============================================================================
--- incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java (original)
+++ incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/CreateNodeTest.java Tue Jun 9 19:40:10 2009
@@ -14,18 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.launchpad.webapp.integrationtest;
+package org.apache.sling.itest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import junit.framework.Assert;
+
import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.sling.commons.testing.integration.HttpTestBase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
/** Test creating a Node using the MicroslingIntegrationTestClient */
+@RunWith(JUnit4TestRunner.class)
public class CreateNodeTest extends HttpTestBase {
-
+
+ @Test
public void testCreateNode() throws IOException {
final String url = HTTP_BASE_URL + "/CreateNodeTest_1_" + System.currentTimeMillis();
@@ -39,16 +45,16 @@
try {
urlOfNewNode = testClient.createNode(url, props);
} catch(IOException ioe) {
- fail("createNode failed: " + ioe);
+ Assert.fail("createNode failed: " + ioe);
}
// get and check URL of created node
final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
final int status = httpClient.executeMethod(get);
- assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
+ Assert.assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
final String responseBodyStr = get.getResponseBodyAsString();
- assertTrue(responseBodyStr.contains("value1"));
- assertTrue(responseBodyStr.contains("value2"));
+ Assert.assertTrue(responseBodyStr.contains("value1"));
+ Assert.assertTrue(responseBodyStr.contains("value2"));
// test default txt and html renderings
getContent(urlOfNewNode + DEFAULT_EXT, CONTENT_TYPE_PLAIN);
@@ -61,7 +67,8 @@
assertHttpStatus(urlOfNewNode + ".pdf", 403);
assertHttpStatus(urlOfNewNode + ".someWeirdExtension", 403);
}
-
+
+ @Test
public void testCreateNodeMultipart() throws IOException {
final String url = HTTP_BASE_URL + "/CreateNodeTest_2_" + System.currentTimeMillis();
@@ -75,19 +82,20 @@
try {
urlOfNewNode = testClient.createNode(url, props, null, true);
} catch(IOException ioe) {
- fail("createNode failed: " + ioe);
+ Assert.fail("createNode failed: " + ioe);
}
// check node contents (not all renderings - those are tested above)
final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
final int status = httpClient.executeMethod(get);
- assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
+ Assert.assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
final String responseBodyStr = get.getResponseBodyAsString();
- assertTrue(responseBodyStr.contains("value1B"));
- assertTrue(responseBodyStr.contains("value2B"));
+ Assert.assertTrue(responseBodyStr.contains("value1B"));
+ Assert.assertTrue(responseBodyStr.contains("value2B"));
}
-
- public void testCreateNodeWithNodeType() throws IOException {
+
+ @Test
+ public void testCreateNodeWithNodeType() throws IOException {
final String url = HTTP_BASE_URL + "/CreateNodeTest_3_" + System.currentTimeMillis();
// add node type param
@@ -99,13 +107,14 @@
try {
urlOfNewNode = testClient.createNode(url, props);
} catch(IOException ioe) {
- fail("createNode failed: " + ioe);
+ Assert.fail("createNode failed: " + ioe);
}
String content = getContent(urlOfNewNode + ".json", CONTENT_TYPE_JSON);
assertJavascript("nt:folder", content, "out.println(data['jcr:primaryType'])");
}
-
+
+ @Test
public void testCreateNewNodeWithNodeType() throws IOException {
final String url = HTTP_BASE_URL + "/CreateNodeTest_4_" + System.currentTimeMillis() + "/*";
@@ -118,13 +127,14 @@
try {
urlOfNewNode = testClient.createNode(url, props);
} catch(IOException ioe) {
- fail("createNode failed: " + ioe);
+ Assert.fail("createNode failed: " + ioe);
}
String content = getContent(urlOfNewNode + ".json", CONTENT_TYPE_JSON);
assertJavascript("nt:folder", content, "out.println(data['jcr:primaryType'])");
}
-
+
+ @Test
public void testDeepCreateNodeWithNodeType() throws IOException {
final String url = HTTP_BASE_URL + "/CreateNodeTest_5_" + System.currentTimeMillis();
@@ -139,7 +149,7 @@
try {
urlOfNewNode = testClient.createNode(url, props);
} catch(IOException ioe) {
- fail("createNode failed: " + ioe);
+ Assert.fail("createNode failed: " + ioe);
}
String content = getContent(urlOfNewNode + ".3.json", CONTENT_TYPE_JSON);
@@ -147,7 +157,8 @@
assertJavascript("nt:folder", content, "out.println(data.foo['jcr:primaryType'])");
assertJavascript("nt:folder", content, "out.println(data.foo.bar['jcr:primaryType'])");
}
-
+
+ @Test
public void testCreateEmptyNode() throws IOException {
final String url = HTTP_BASE_URL + "/CreateNodeTest_6_" + System.currentTimeMillis();
@@ -159,12 +170,12 @@
try {
urlOfNewNode = testClient.createNode(url, props);
} catch(IOException ioe) {
- fail("createNode failed: " + ioe);
+ Assert.fail("createNode failed: " + ioe);
}
// get and check URL of created node
final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
final int status = httpClient.executeMethod(get);
- assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
+ Assert.assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
}
}
\ No newline at end of file
Modified: incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/DummyPaxExamTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/DummyPaxExamTest.java?rev=783107&r1=783106&r2=783107&view=diff
==============================================================================
--- incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/DummyPaxExamTest.java (original)
+++ incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/DummyPaxExamTest.java Tue Jun 9 19:40:10 2009
@@ -37,5 +37,5 @@
logger.info( "Bundle " + b.getBundleId() + " : " + b.getSymbolicName() );
}
}
-
+
}
Added: incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/HttpTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/HttpTestBase.java?rev=783107&view=auto
==============================================================================
--- incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/HttpTestBase.java (added)
+++ incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/HttpTestBase.java Tue Jun 9 19:40:10 2009
@@ -0,0 +1,391 @@
+/*
+ * 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.itest;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.Assert;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.sling.commons.testing.integration.HttpAnyMethod;
+import org.apache.sling.commons.testing.integration.HttpStatusCodeException;
+import org.apache.sling.commons.testing.integration.SlingIntegrationTestClient;
+import org.junit.After;
+import org.junit.Before;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ScriptableObject;
+
+/** Base class for HTTP-based Sling Launchpad integration tests */
+public class HttpTestBase extends PaxExamTestBase {
+ public static final String HTTP_BASE_URL = removeEndingSlash(System.getProperty("launchpad.http.server.url", "http://localhost:8888"));
+ public static final String WEBDAV_BASE_URL = removeEndingSlash(System.getProperty("launchpad.webdav.server.url", "http://localhost:8888"));
+
+ /** base path for test files */
+ public static final String TEST_PATH = "/launchpad-integration-tests";
+
+ public static final String CONTENT_TYPE_HTML = "text/html";
+ public static final String CONTENT_TYPE_XML = "application/xml";
+ public static final String CONTENT_TYPE_PLAIN = "text/plain";
+ public static final String CONTENT_TYPE_JSON = "application/json";
+ public static final String CONTENT_TYPE_JS = "application/javascript";
+ public static final String CONTENT_TYPE_CSS = "text/css";
+
+ public static final String SLING_RESOURCE_TYPE = "sling:resourceType";
+
+ public static final String SLING_POST_SERVLET_CREATE_SUFFIX = "/";
+ public static final String DEFAULT_EXT = ".txt";
+
+ protected SlingIntegrationTestClient testClient;
+ protected HttpClient httpClient;
+
+ private static Boolean slingStartupOk;
+
+ /** Means "don't care about Content-Type" in getContent(...) methods */
+ public static final String CONTENT_TYPE_DONTCARE = "*";
+
+ /** URLs stored here are deleted in tearDown */
+ protected final List<String> urlsToDelete = new LinkedList<String>();
+
+ /** Class that creates a test node under the given parentPath, and
+ * stores useful values for testing. Created for JspScriptingTest,
+ * older test classes do not use it, but it might simplify them.
+ */
+ protected class TestNode {
+ public final String testText;
+ public final String nodeUrl;
+ public final String resourceType;
+ public final String scriptPath;
+
+ public TestNode(String parentPath, Map<String, String> properties) throws IOException {
+ if(properties == null) {
+ properties = new HashMap<String, String>();
+ }
+ testText = "This is a test node " + System.currentTimeMillis();
+ properties.put("text", testText);
+ nodeUrl = testClient.createNode(parentPath + SLING_POST_SERVLET_CREATE_SUFFIX, properties);
+ resourceType = properties.get(SLING_RESOURCE_TYPE);
+ scriptPath = "/apps/" + (resourceType == null ? "nt/unstructured" : resourceType);
+ testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+ }
+
+ public void delete() throws IOException {
+ testClient.delete(nodeUrl);
+ }
+ };
+
+ protected static String removeEndingSlash(String str) {
+ if(str != null && str.endsWith("/")) {
+ return str.substring(0, str.length() - 1);
+ }
+ return str;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+
+ // assume http and webdav are on the same host + port
+ URL url = null;
+ try {
+ url = new URL(HTTP_BASE_URL);
+ } catch(MalformedURLException mfe) {
+ // MalformedURLException doesn't tell us the URL by default
+ throw new IOException("MalformedURLException: " + HTTP_BASE_URL);
+ }
+
+ // setup HTTP client, with authentication (using default Jackrabbit credentials)
+ httpClient = new HttpClient();
+ httpClient.getParams().setAuthenticationPreemptive(true);
+ Credentials defaultcreds = new UsernamePasswordCredentials("admin", "admin");
+ httpClient.getState().setCredentials(new AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), defaultcreds);
+
+ testClient = new SlingIntegrationTestClient(httpClient);
+
+ waitForSlingStartup();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ for(String url : urlsToDelete) {
+ testClient.delete(url);
+ }
+ }
+
+ /** On the server side, initialization of Sling bundles is done
+ * asynchronously once the webapp is started. This method checks
+ * that everything's ready on the server side, by calling an URL
+ * that requires the SlingPostServlet and the JCR repository to
+ * work correctly.
+ */
+ protected void waitForSlingStartup() throws Exception {
+ // Use a static flag to make sure this runs only once in our test suite
+ if (slingStartupOk != null) {
+ if(slingStartupOk) {
+ return;
+ }
+ Assert.fail("Sling services not available. Already checked in earlier tests.");
+ }
+ slingStartupOk = false;
+
+ System.err.println("Checking if the required Sling services are started...");
+ System.err.println("(base URLs=" + HTTP_BASE_URL + " and " + WEBDAV_BASE_URL + ")");
+
+ // Try creating a node on server, every 500msec, until ok, with timeout
+ final List<String> exceptionMessages = new LinkedList<String>();
+ final long maxMsecToWait = 60 * 1000L;
+ final long startupTime = System.currentTimeMillis();
+
+ while(!slingStartupOk && (System.currentTimeMillis() < startupTime + maxMsecToWait) ) {
+ try {
+ slingStartupOk = slingServerReady();
+ } catch(Exception e) {
+ exceptionMessages.add(e.toString());
+ Thread.sleep(500L);
+ }
+ }
+
+ if(!slingStartupOk) {
+ StringBuffer msg = new StringBuffer("Server does not seem to be ready, after ");
+ msg.append(maxMsecToWait).append(" msec, got the following ").append(exceptionMessages.size()).append(" Exceptions:");
+ for (String e: exceptionMessages) {
+ msg.append(e).append("\n");
+ }
+ System.err.println(msg);
+ Assert.fail(msg.toString());
+ }
+
+ System.err.println("Sling services seem to be started, continuing with integration tests.");
+ }
+
+ /** Return true if able to create and retrieve a node on server */
+ protected boolean slingServerReady() throws Exception {
+ // create a node on the server
+ final String time = String.valueOf(System.currentTimeMillis());
+ final String url = HTTP_BASE_URL + "/WaitForSlingStartup/" + time;
+
+ // add some properties to the node
+ final Map<String,String> props = new HashMap<String,String>();
+ props.put("time", time);
+
+ // POST, get URL of created node and get content
+ {
+ final String urlOfNewNode = testClient.createNode(url, props, null, true);
+ final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
+ final int status = httpClient.executeMethod(get);
+ if(status!=200) {
+ throw new HttpStatusCodeException(200, status, "GET", urlOfNewNode);
+ }
+
+ final Header h = get.getResponseHeader("Content-Type");
+ final String contentType = h==null ? "" : h.getValue();
+ if(!contentType.startsWith("text/plain")) {
+ throw new IOException("Expected Content-Type=text/plain but got '" + contentType + "' for URL=" + urlOfNewNode);
+ }
+
+ final String content = get.getResponseBodyAsString();
+ if(!content.contains(time)) {
+ throw new IOException("Content does not contain '" + time + "' (" + content + ") at URL=" + urlOfNewNode);
+ }
+ }
+
+ // Also check that the WebDAV root is ready
+ {
+ // need the trailing slash in case the base URL is the context root
+ final String webDavUrl = WEBDAV_BASE_URL + "/";
+ final HttpAnyMethod options = new HttpAnyMethod("OPTIONS",webDavUrl);
+ final int status = httpClient.executeMethod(options);
+ if(status!=200) {
+ throw new HttpStatusCodeException(200, status, "OPTIONS", webDavUrl);
+ }
+
+ // The Allow header tells us that we're talking to a WebDAV server
+ final Header h = options.getResponseHeader("Allow");
+ if(h == null) {
+ throw new IOException("Response does not contain Allow header, at URL=" + webDavUrl);
+ } else if(h.getValue() == null) {
+ throw new IOException("Allow header has null value at URL=" + webDavUrl);
+ } else if(!h.getValue().contains("PROPFIND")) {
+ throw new IOException("Allow header (" + h.getValue() + " does not contain PROPFIND, at URL=" + webDavUrl);
+ }
+ }
+
+
+ return true;
+ }
+
+ /** Verify that given URL returns expectedStatusCode
+ * @throws IOException */
+ protected void assertHttpStatus(String urlString, int expectedStatusCode, String assertMessage) throws IOException {
+ final int status = httpClient.executeMethod(new GetMethod(urlString));
+ if(assertMessage == null) {
+ Assert.assertEquals(urlString,expectedStatusCode, status);
+ } else {
+ Assert.assertEquals(assertMessage, expectedStatusCode, status);
+ }
+ }
+
+ /** Verify that given URL returns expectedStatusCode
+ * @throws IOException */
+ protected void assertHttpStatus(String urlString, int expectedStatusCode) throws IOException {
+ assertHttpStatus(urlString, expectedStatusCode, null);
+ }
+
+ /** Execute a POST request and check status */
+ protected void assertPostStatus(String url, int expectedStatusCode, List<NameValuePair> postParams, String assertMessage)
+ throws IOException {
+ final PostMethod post = new PostMethod(url);
+ post.setFollowRedirects(false);
+
+ if(postParams!=null) {
+ final NameValuePair [] nvp = {};
+ post.setRequestBody(postParams.toArray(nvp));
+ }
+
+ final int status = httpClient.executeMethod(post);
+ if(assertMessage == null) {
+ Assert.assertEquals(expectedStatusCode, status);
+ } else {
+ Assert.assertEquals(assertMessage, expectedStatusCode, status);
+ }
+ }
+
+ /** retrieve the contents of given URL and assert its content type */
+ protected String getContent(String url, String expectedContentType) throws IOException {
+ return getContent(url, expectedContentType, null);
+ }
+
+ protected String getContent(String url, String expectedContentType, List<NameValuePair> params) throws IOException {
+ return getContent(url, expectedContentType, params, HttpServletResponse.SC_OK);
+ }
+
+ /** retrieve the contents of given URL and assert its content type
+ * @param expectedContentType use CONTENT_TYPE_DONTCARE if must not be checked
+ * @throws IOException
+ * @throws HttpException */
+ protected String getContent(String url, String expectedContentType, List<NameValuePair> params, int expectedStatusCode) throws IOException {
+ final GetMethod get = new GetMethod(url);
+ if(params != null) {
+ final NameValuePair [] nvp = new NameValuePair[0];
+ get.setQueryString(params.toArray(nvp));
+ }
+ final int status = httpClient.executeMethod(get);
+ final InputStream is = get.getResponseBodyAsStream();
+ final StringBuffer content = new StringBuffer();
+ final String charset = get.getResponseCharSet();
+ final byte [] buffer = new byte[16384];
+ int n = 0;
+ while( (n = is.read(buffer, 0, buffer.length)) > 0) {
+ content.append(new String(buffer, 0, n, charset));
+ }
+ Assert.assertEquals("Expected status " + expectedStatusCode + " for " + url + " (content=" + content + ")",
+ expectedStatusCode,status);
+ final Header h = get.getResponseHeader("Content-Type");
+ if(expectedContentType == null) {
+ if(h!=null) {
+ Assert.fail("Expected null Content-Type, got " + h.getValue());
+ }
+ } else if(CONTENT_TYPE_DONTCARE.equals(expectedContentType)) {
+ // no check
+ } else if(h==null) {
+ Assert.fail(
+ "Expected Content-Type that starts with '" + expectedContentType
+ +" but got no Content-Type header at " + url
+ );
+ } else {
+ Assert.assertTrue(
+ "Expected Content-Type that starts with '" + expectedContentType
+ + "' for " + url + ", got '" + h.getValue() + "'",
+ h.getValue().startsWith(expectedContentType)
+ );
+ }
+ return content.toString();
+ }
+
+ /** upload rendering test script, and return its URL for future deletion */
+ protected String uploadTestScript(String scriptPath, String localFilename,String filenameOnServer) throws IOException {
+ final String url = WEBDAV_BASE_URL + scriptPath + "/" + filenameOnServer;
+ final String testFile = "/integration-test/" + localFilename;
+ final InputStream data = getClass().getResourceAsStream(testFile);
+ if(data==null) {
+ Assert.fail("Test file not found:" + testFile);
+ }
+ try {
+ testClient.upload(url, data);
+ } finally {
+ if(data!=null) {
+ data.close();
+ }
+ }
+ return url;
+ }
+
+ protected void assertJavascript(String expectedOutput, String jsonData, String code) throws IOException {
+ assertJavascript(expectedOutput, jsonData, code, null);
+ }
+
+ /** Evaluate given code using given jsonData as the "data" object */
+ protected void assertJavascript(String expectedOutput, String jsonData, String code, String testInfo) throws IOException {
+ // build the code, something like
+ // data = <jsonData> ;
+ // <code>
+ final String jsCode = "data=" + jsonData + ";\n" + code;
+ final Context rhinoContext = Context.enter();
+ final ScriptableObject scope = rhinoContext.initStandardObjects();
+
+ // execute the script, out script variable maps to sw
+ final StringWriter sw = new StringWriter();
+ final PrintWriter pw = new PrintWriter(sw, true);
+ ScriptableObject.putProperty(scope, "out", Context.javaToJS(pw, scope));
+ final int lineNumber = 1;
+ final Object securityDomain = null;
+ rhinoContext.evaluateString(scope, jsCode, getClass().getSimpleName(),
+ lineNumber, securityDomain);
+
+ // check script output
+ pw.flush();
+ final String result = sw.toString().trim();
+ if(!result.equals(expectedOutput)) {
+ Assert.fail(
+ "Expected '" + expectedOutput
+ + "' but got '" + result
+ + "' for script='" + jsCode + "'"
+ + (testInfo==null ? "" : ", test info=" + testInfo)
+ );
+ }
+ }
+}
Modified: incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/PaxExamTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/PaxExamTestBase.java?rev=783107&r1=783106&r2=783107&view=diff
==============================================================================
--- incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/PaxExamTestBase.java (original)
+++ incubator/sling/whiteboard/jvazquez/testing/src/test/java/org/apache/sling/itest/PaxExamTestBase.java Tue Jun 9 19:40:10 2009
@@ -20,8 +20,11 @@
import static org.ops4j.pax.exam.CoreOptions.felix;
import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.*;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.*;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
@@ -35,45 +38,80 @@
@Configuration
public static Option[] configuration() {
+
+ String vmOpt = "";
+
+ // This runs in the VM that runs the build, but the tests run in another one.
+ // Make all system properties available to OSGi framework VM
+ for(Object o : System.getProperties().keySet()) {
+ final String key = (String)o;
+ if(key.startsWith("launchpad.")) {
+ vmOpt += " -D" + key + "=" + System.getProperty(key);
+ }
+ }
+
+ // optional debugging
+ final String paxDebugPort = System.getProperty("pax.exam.debug.port");
+ if(paxDebugPort != null && paxDebugPort.length() > 0) {
+ vmOpt += " -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=" + paxDebugPort;
+ }
+
Option[] options = options(
- // install log service using pax runners profile abstraction (there are more profiles, like DS)
- logProfile(),
- // this is how you set the default log level when using pax logging (logProfile)
- systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
-
- /**
- * Bundles
- */
-
- // Level 1
- mavenBundle("org.ops4j.pax.web", "pax-web-service", "0.6.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "2.0.3-incubator-SNAPSHOT"),
-
- // Level 5
- mavenBundle("org.apache.felix", "org.apache.felix.webconsole", "1.2.8"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.json", "2.0.3-incubator-SNAPSHOT"),
- mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository", "1.4.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.extensions.threaddump", "0.1.0-incubator-SNAPSHOT"),
-
- // Level 10
- mavenBundle("org.apache.felix", "org.apache.felix.eventadmin", "1.0.0"),
- mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.0.7-SNAPSHOT"),
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.0.10"),
- mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.0.2"),
-
- // Level 15
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.api", "2.0.2-incubator"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.base", "2.0.3-incubator-SNAPSHOT"),
- mavenBundle("org.apache.jackrabbit", "jackrabbit-api", "1.5.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.jackrabbit.server", "2.0.3-incubator-SNAPSHOT"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.jackrabbit.usermanager", "2.0.0-incubator-SNAPSHOT"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.jackrabbit.accessmanager", "2.0.0-incubator-SNAPSHOT"),
- mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-commons", "1.5.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.webdav", "2.0.3-incubator-SNAPSHOT"),
-
- felix()
+ felix(),
+ vmOption(vmOpt),
+ waitForFrameworkStartup(),
+ provision(
+
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-httpclient"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-codec"),
+ wrappedBundle(mavenBundle("org.apache.sling", "org.apache.sling.commons.testing")),
+
+ mavenBundle("org.ops4j.pax.web", "pax-web-service"),
+ mavenBundle("commons-io", "commons-io"),
+ mavenBundle("commons-collections", "commons-collections"),
+ mavenBundle("commons-lang", "commons-lang"),
+ mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-commons"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.webdav"),
+ mavenBundle("org.apache.sling", "org.apache.sling.commons.osgi"),
+ mavenBundle("org.apache.sling", "org.apache.sling.commons.mime"),
+ mavenBundle("org.apache.sling", "org.apache.sling.commons.log"),
+ mavenBundle("org.apache.felix", "org.apache.felix.webconsole"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.api"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.base"),
+ mavenBundle("org.apache.jackrabbit", "jackrabbit-api"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.jackrabbit.server"),
+ mavenBundle("org.apache.sling", "org.apache.sling.commons.json"),
+ mavenBundle("org.apache.sling", "org.apache.sling.extensions.threaddump"),
+ mavenBundle("org.apache.felix", "org.apache.felix.eventadmin"),
+ mavenBundle("org.apache.felix", "org.apache.felix.scr"),
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+ mavenBundle("org.apache.felix", "org.apache.felix.metatype"),
+ mavenBundle("org.apache.sling", "org.apache.sling.api"),
+ mavenBundle("org.apache.sling", "org.apache.sling.adapter"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.resource"),
+ mavenBundle("org.apache.sling", "org.apache.sling.servlets.get"),
+ mavenBundle("org.apache.sling", "org.apache.sling.servlets.post"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.jackrabbit.usermanager"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.jackrabbit.accessmanager"),
+ mavenBundle("org.apache.sling", "org.apache.sling.engine"),
+ mavenBundle("org.apache.sling", "org.apache.sling.httpauth"),
+ mavenBundle("org.apache.sling", "org.apache.sling.openidauth"),
+ mavenBundle("org.apache.sling", "org.apache.sling.servlets.resolver"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.contentloader"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.ocm"),
+ mavenBundle("org.apache.sling", "org.apache.sling.jcr.classloader"),
+ mavenBundle("org.apache.sling", "org.apache.sling.bundleresource.impl"),
+ mavenBundle("org.apache.sling", "org.apache.sling.fsresource"),
+ mavenBundle("org.apache.sling", "org.apache.sling.launchpad.content"),
+ mavenBundle("org.apache.sling", "org.apache.sling.scripting.api"),
+ mavenBundle("org.apache.sling", "org.apache.sling.scripting.core"),
+ mavenBundle("org.apache.sling", "org.apache.sling.scripting.javascript"),
+ mavenBundle("org.apache.sling", "org.apache.sling.scripting.jsp"),
+ mavenBundle("org.apache.sling", "org.apache.sling.scripting.jsp.taglib"),
+ mavenBundle("org.codehaus.groovy", "groovy-all")
+ )
);
return options;
}
-}
+}
\ No newline at end of file