You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ws...@apache.org on 2006/04/28 08:27:30 UTC

svn commit: r397781 - in /struts/action/trunk/integration: ./ apps-it/ apps-it/src/ apps-it/src/test/ apps-it/src/test/java/ apps-it/src/test/java/org/ apps-it/src/test/java/org/apache/ apps-it/src/test/java/org/apache/struts/ apps-it/src/test/java/org...

Author: wsmoak
Date: Thu Apr 27 23:27:27 2006
New Revision: 397781

URL: http://svn.apache.org/viewcvs?rev=397781&view=rev
Log:
Added automated tests to confirm that each example app starts and displays its default page.
Use 'mvn -P perform-itest' to run the tests.
Issue: STR-2850

Added:
    struts/action/trunk/integration/apps-it/
    struts/action/trunk/integration/apps-it/pom.xml   (with props)
    struts/action/trunk/integration/apps-it/src/
    struts/action/trunk/integration/apps-it/src/test/
    struts/action/trunk/integration/apps-it/src/test/java/
    struts/action/trunk/integration/apps-it/src/test/java/org/
    struts/action/trunk/integration/apps-it/src/test/java/org/apache/
    struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/
    struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/
    struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java   (with props)
    struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java   (with props)
Modified:
    struts/action/trunk/integration/pom.xml

Added: struts/action/trunk/integration/apps-it/pom.xml
URL: http://svn.apache.org/viewcvs/struts/action/trunk/integration/apps-it/pom.xml?rev=397781&view=auto
==============================================================================
--- struts/action/trunk/integration/apps-it/pom.xml (added)
+++ struts/action/trunk/integration/apps-it/pom.xml Thu Apr 27 23:27:27 2006
@@ -0,0 +1,121 @@
+<?xml version="1.0"?>
+<!--
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Id$
+ */
+-->
+
+<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">
+
+   <parent>
+      <groupId>org.apache.struts.action</groupId>
+      <artifactId>struts-action-it</artifactId>
+      <version>1.3.3-SNAPSHOT</version>
+   </parent>
+
+   <modelVersion>4.0.0</modelVersion>
+   <groupId>org.apache.struts.action</groupId>
+   <artifactId>struts-action-it-apps</artifactId>
+   <packaging>pom</packaging>
+   <name>Struts Action - Integration - Apps Tests</name>
+   <url>http://struts.apache.org</url>
+
+   <dependencies>
+      <dependency>
+         <groupId>junit</groupId>
+         <artifactId>junit</artifactId>
+         <version>3.8.1</version>
+      </dependency>
+      <dependency>
+         <groupId>htmlunit</groupId>
+         <artifactId>htmlunit</artifactId>
+         <version>1.8</version>
+         <exclusions>
+            <exclusion>
+               <groupId>javax.xml</groupId>
+               <artifactId>jsr173</artifactId>
+            </exclusion>
+         </exclusions>
+      </dependency>
+      <dependency>
+         <groupId>org.codehaus.cargo</groupId>
+         <artifactId>cargo-core-uberjar</artifactId>
+         <version>0.8</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.codehaus.cargo</groupId>
+         <artifactId>cargo-ant</artifactId>
+         <version>0.8</version>
+         <scope>test</scope>
+      </dependency>
+   </dependencies>
+
+   <profiles>
+      <profile>
+         <id>perform-itest</id>
+         <build>
+            <plugins>
+               <plugin>
+                  <groupId>org.apache.maven.plugins</groupId>
+                  <artifactId>maven-compiler-plugin</artifactId>
+                  <executions>
+                     <execution>
+                        <id>compiler-for-tests</id>
+                        <phase>test-compile</phase>
+                        <goals>
+                           <goal>testCompile</goal>
+                        </goals>
+                     </execution>
+                  </executions>
+               </plugin>
+               <plugin>
+                  <groupId>org.apache.maven.plugins</groupId>
+                  <artifactId>maven-surefire-plugin</artifactId>
+                  <configuration>
+                     <systemProperties>
+                        <property>
+                           <name>cargo.tomcat5x.home</name>
+                           <value>${cargo.tomcat5x.home}</value>
+                        </property>
+                        <property>
+                           <name>cargo.servlet.port</name>
+                           <value>8080</value>
+                        </property>
+                        <property>
+                           <name>version</name>
+                           <value>${version}</value>
+                        </property>
+                     </systemProperties>
+                  </configuration>
+                  <executions>
+                     <execution>
+                        <id>surefire-it</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                           <goal>test</goal>
+                        </goals>
+                     </execution>
+                  </executions>
+               </plugin>
+            </plugins>
+         </build>
+      </profile>
+   </profiles>
+
+</project>

Propchange: struts/action/trunk/integration/apps-it/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/action/trunk/integration/apps-it/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: struts/action/trunk/integration/apps-it/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java?rev=397781&view=auto
==============================================================================
--- struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java (added)
+++ struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java Thu Apr 27 23:27:27 2006
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Id$
+ */
+package org.apache.struts.apps;
+
+import java.net.URL;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.WebClient;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Verify that each of the example apps starts and displays its
+ * default page.
+ */
+public class AppsTest extends TestCase {
+
+    private String version;
+    private String port;
+
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppsTest(String testName) {
+        super(testName);
+    }
+
+    public void setUp() throws Exception {
+        super.setUp();
+        version = System.getProperty("version");
+        port = System.getProperty("cargo.servlet.port");
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(AppsTest.class);
+        return new Tomcat5xTestSetup(suite);
+    }
+
+    /**
+     * Verify that the Struts Blank app has started
+     */
+    public void testStrutsBlank() throws Exception {
+        WebClient webClient = new WebClient();
+        URL url = new URL("http://localhost:"
+                + port + "/struts-blank-" + version);
+        HtmlPage page = (HtmlPage) webClient.getPage(url);
+
+        assertEquals("Struts Blank Application", page.getTitleText());
+    }
+
+    /**
+     * Verify that the Struts Cookbook app has started
+     */
+    public void testStrutsCookbook() throws Exception {
+        WebClient webClient = new WebClient();
+        URL url = new URL("http://localhost:"
+                + port + "/struts-cookbook-" + version);
+        HtmlPage page = (HtmlPage) webClient.getPage(url);
+
+        assertEquals("Struts Cookbook", page.getTitleText());
+    }
+
+    /**
+     * Verify that the Struts Examples app has started
+     */
+    public void testStrutsExamples() throws Exception {
+        WebClient webClient = new WebClient();
+        URL url = new URL("http://localhost:"
+                + port + "/struts-examples-" + version);
+        HtmlPage page = (HtmlPage) webClient.getPage(url);
+
+        assertEquals("Struts Examples", page.getTitleText());
+    }
+
+
+    /**
+     * Verify that the Struts Mailreader app has started
+     */
+    public void testStrutsMailreader() throws Exception {
+        WebClient webClient = new WebClient();
+        URL url = new URL("http://localhost:"
+                + port + "/struts-mailreader-" + version);
+        HtmlPage page = (HtmlPage) webClient.getPage(url);
+
+        assertEquals("MailReader Demonstration Application",
+                page.getTitleText());
+    }
+
+    /**
+     * Verify that the Struts Scripting Mailreader app has started
+     */
+    public void testStrutsScriptingMailreader() throws Exception {
+        WebClient webClient = new WebClient();
+        URL url = new URL("http://localhost:" + port
+                + "/struts-scripting-mailreader-" + version);
+        HtmlPage page = (HtmlPage) webClient.getPage(url);
+
+        assertEquals("MailReader Demonstration Application",
+                page.getTitleText());
+    }
+
+    /**
+     * Verify that the Struts EL Exercise Taglib app has started
+     */
+    public void testStrutsELExcerciseTaglib() throws Exception {
+        WebClient webClient = new WebClient();
+        URL url = new URL("http://localhost:" + port
+                + "/strutsel-exercise-taglib-" + version);
+        HtmlPage page = (HtmlPage) webClient.getPage(url);
+
+        assertEquals("Struts-EL Test Application", page.getTitleText());
+    }
+
+}

Propchange: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/AppsTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java?rev=397781&view=auto
==============================================================================
--- struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java (added)
+++ struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java Thu Apr 27 23:27:27 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Id$
+ */
+package org.apache.struts.apps;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.codehaus.cargo.container.ContainerType;
+import org.codehaus.cargo.container.InstalledLocalContainer;
+import org.codehaus.cargo.container.installer.Installer;
+import org.codehaus.cargo.container.installer.ZipURLInstaller;
+import org.codehaus.cargo.container.configuration.ConfigurationType;
+import org.codehaus.cargo.container.configuration.LocalConfiguration;
+import org.codehaus.cargo.container.deployable.WAR;
+import org.codehaus.cargo.container.property.ServletPropertySet;
+import org.codehaus.cargo.generic.DefaultContainerFactory;
+import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
+
+/**
+ * Set up to run tests with Tomcat 5.x.  If the 'cargo.tomcat5x.home'
+ * System property is not set, Tomcat 5.0.30 will be downloaded from ibiblio.
+ */
+public class Tomcat5xTestSetup extends TestSetup {
+
+    InstalledLocalContainer container;
+    String version;
+    String port;
+    String localRepository;
+
+    public Tomcat5xTestSetup(Test test) {
+        super(test);
+    }
+
+    protected void setUp() throws Exception {
+        version = System.getProperty("version");
+        port = System.getProperty("cargo.servlet.port");
+        localRepository = System.getProperty("localRepository");
+
+        // (1) Find the locally installed container.  This System property may
+        //     be set in settings.xml, or on the command line with
+        //     -Dcargo.tomcat5x.home=c:/java/apache-tomcat-5.5.17
+        String tomcat5x = System.getProperty("cargo.tomcat5x.home");
+
+        File tomcatHome;
+        if (tomcat5x == null || tomcat5x.startsWith("$")) {
+            //System.out.println("INFO: Downloading Tomcat 5.0 from a mirror");
+            Installer installer = new ZipURLInstaller(
+                    new URL("http://mirrors.ibiblio.org/pub/mirrors/apache"
+                            + "/tomcat/tomcat-5/v5.0.30/bin/jakarta-tomcat-5.0.30.zip"));
+            installer.install();
+            tomcatHome = installer.getHome();
+        } else {
+            tomcatHome = new File(tomcat5x);
+        }
+        //System.out.println("INFO: Tomcat home is " + tomcatHome);
+
+        // (2) Create the Cargo Container instance wrapping our physical container
+        LocalConfiguration configuration = (LocalConfiguration)
+                new DefaultConfigurationFactory().createConfiguration(
+                        "tomcat5x", ConfigurationType.STANDALONE);
+        container = (InstalledLocalContainer)
+                new DefaultContainerFactory().createContainer(
+                        "tomcat5x", ContainerType.INSTALLED, configuration);
+        container.setHome(tomcatHome);
+
+        // (3) Statically deploy WAR(s)
+        configuration.addDeployable(getWAR("struts-blank"));
+        configuration.addDeployable(getWAR("struts-cookbook"));
+        configuration.addDeployable(getWAR("struts-examples"));
+        configuration.addDeployable(getWAR("struts-mailreader"));
+        configuration.addDeployable(getWAR("struts-scripting-mailreader"));
+        configuration.addDeployable(getWAR("strutsel-exercise-taglib"));
+
+        configuration.setProperty(ServletPropertySet.PORT, port);
+
+        // (4) Start the container
+        container.start();
+    }
+
+    protected void tearDown() throws Exception {
+        // (6) Stop the container
+        container.stop();
+    }
+
+    private WAR getWAR(String context) {
+        return new WAR(localRepository + "/org/apache/struts/action/"
+                + context + "/" + version + "/"
+                + context + "-" + version + ".war");
+    }
+
+}
\ No newline at end of file

Propchange: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: struts/action/trunk/integration/apps-it/src/test/java/org/apache/struts/apps/Tomcat5xTestSetup.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: struts/action/trunk/integration/pom.xml
URL: http://svn.apache.org/viewcvs/struts/action/trunk/integration/pom.xml?rev=397781&r1=397780&r2=397781&view=diff
==============================================================================
--- struts/action/trunk/integration/pom.xml (original)
+++ struts/action/trunk/integration/pom.xml Thu Apr 27 23:27:27 2006
@@ -19,18 +19,6 @@
  */
 -->
 
-<!-- 
-             Experimental Maven 2 Build for Apache Struts
-             ============================================
-
-To build and install this module into your local repo:
-
-   $ mvn install
-   
-For more information, see:  http://wiki.apache.org/struts/StrutsMaven2Plan
-
--->
-
 <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">
 
@@ -48,6 +36,7 @@
 
    <modules>
       <module>taglib-it</module>
+      <module>apps-it</module>
    </modules>
 
 </project>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org