incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r588244 - in /incubator/sling/whiteboard/microsling: ./ src/test/java/org/apache/sling/microsling/integration/
Date Thu, 25 Oct 2007 14:42:26 GMT
Author: bdelacretaz
Date: Thu Oct 25 07:42:26 2007
New Revision: 588244

URL: http://svn.apache.org/viewvc?rev=588244&view=rev
Log:
SLING-82 - activate integration tests using the cargo-maven2-plugin

Added:
    incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/
    incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java
  (with props)
    incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/package.html
  (with props)
Modified:
    incubator/sling/whiteboard/microsling/pom.xml

Modified: incubator/sling/whiteboard/microsling/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/pom.xml?rev=588244&r1=588243&r2=588244&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/pom.xml (original)
+++ incubator/sling/whiteboard/microsling/pom.xml Thu Oct 25 07:42:26 2007
@@ -26,8 +26,12 @@
   <groupId>org.apache.sling</groupId>
   <artifactId>microsling</artifactId>
   <packaging>war</packaging>
-  <version>1.0-SNAPSHOT</version>
   <name>microsling</name>
+  <!--
+    WARNING: if changing this, change microsling.http.server.url below as well 
+   -->
+  <version>1.0-SNAPSHOT</version>
+  
   <url>http://incubator.apache.org/sling</url>
 
   <properties>
@@ -37,6 +41,17 @@
       jackrabbit-webapp module.
     -->
     <jackrabbit.version>1.4-SNAPSHOT</jackrabbit.version>
+    
+    <!-- 
+      Defines which tests are for the "integration-testing" phase
+     -->
+    <integration.test.code.pattern>**/microsling/integration/**.java</integration.test.code.pattern>
+    
+    <!-- 
+      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>
   </properties>
 
   <dependencies>
@@ -122,7 +137,104 @@
           </connectors>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>${integration.test.code.pattern}</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
+
+  <profiles>
+    <profile>
+      <!--
+        Run the cargo-based integration tests.
+        This profile is active by default, to deactivate it activate another
+        one, for example " mvn -P nullProfile".
+        
+        TODO there must be a way to control this with "mvn.test.skip", but I haven't
+        found it. 
+       -->
+      <id>cargoIntegrationTesting</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </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.pattern}</include>
+                  </includes>
+                  <systemProperties>
+                    <property>
+                      <name>microsling.http.server.url</name>
+                      <!-- 
+                        WARNING: make sure this URL is consistent with the
+                        cargo-maven2-plugin settings: AFAIK Maven does not
+                        expand variables in the <value> element.  
+                      -->
+                      <value>http://localhost:8080/microsling-1.0-SNAPSHOT</value>
+                    </property>
+                  </systemProperties>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.cargo</groupId>
+            <artifactId>cargo-maven2-plugin</artifactId>
+            <version>0.3.1</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>
+              </container>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <!-- 
+        Useful to deactivate other profiles from the command-line
+        Is there a better way? mvn doesn't have a "deactivate profile" option. 
+       -->
+      <id>nullProfile</id>
+    </profile>
+  </profiles>
 
 </project>

Added: incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java?rev=588244&view=auto
==============================================================================
--- incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java
(added)
+++ incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java
Thu Oct 25 07:42:26 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.microsling.integration;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/** Ping the microsling server to verify that our integration test
+ *  setup is ok (SLING-82).
+ */
+public class HttpPingTest extends TestCase {
+    public static final String BASE_URL = System.getProperty("microsling.http.server.url");
+    
+    public void testWebServerRoot() throws Exception
+    {
+        URL url = new URL(BASE_URL + "/");
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        try {
+            connection.connect();
+            assertEquals(200, connection.getResponseCode());
+        } finally {
+            if(connection!=null) {
+                connection.disconnect();
+            }
+        }
+    }
+    
+    public void test404() throws Exception
+    {
+        URL url = new URL(BASE_URL + "/someNonExistentUrl." + System.currentTimeMillis());
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        try {
+            connection.connect();
+            assertEquals(404, connection.getResponseCode());
+        } finally {
+            if(connection!=null) {
+                connection.disconnect();
+            }
+        }
+    }
+    
+}
\ No newline at end of file

Propchange: incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/HttpPingTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/package.html
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/package.html?rev=588244&view=auto
==============================================================================
--- incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/package.html
(added)
+++ incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/package.html
Thu Oct 25 07:42:26 2007
@@ -0,0 +1,7 @@
+<html>
+<body>
+The tests found in and under this package are used in the 
+"integration-test" build phase (SLING-82), they are not run 
+as part of the normal "test" build phase. 
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/sling/whiteboard/microsling/src/test/java/org/apache/sling/microsling/integration/package.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message