Author: wsmoak Date: Wed Jun 7 20:18:28 2006 New Revision: 412639 URL: http://svn.apache.org/viewvc?rev=412639&view=rev Log: Use the Cargo Java API to start and stop Tomcat for the integration tests. To run the tests, enable the 'itest' profile with -Pitest on the command line. Remove the Cargo plugin config, which was conflicting with the config inherited from the shale-apps parent pom.
Modified: struts/shale/branches/mvn_reorg/shale-apps/shale-blank/pom.xml struts/shale/branches/mvn_reorg/shale-apps/shale-blank/src/test/java/org/apache/shale/blank/systest/WelcomeTestCase.java Modified: struts/shale/branches/mvn_reorg/shale-apps/shale-blank/pom.xml URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-apps/shale-blank/pom.xml?rev=412639&r1=412638&r2=412639&view=diff ============================================================================== --- struts/shale/branches/mvn_reorg/shale-apps/shale-blank/pom.xml (original) +++ struts/shale/branches/mvn_reorg/shale-apps/shale-blank/pom.xml Wed Jun 7 20:18:28 2006 @@ -88,6 +88,19 @@ </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> <build> @@ -109,39 +122,6 @@ <build> <plugins> <plugin> - <groupId>org.codehaus.cargo</groupId> - <artifactId>cargo-maven2-plugin</artifactId> - <version>0.2</version> - <executions> - <execution> - <id>cargo-start</id> - <phase>pre-integration-test</phase> - <goals> - <goal>start</goal> - </goals> - <configuration> - <wait>false</wait> - <container> - <containerId>tomcat5x</containerId> - <home>${cargo.tomcat5x.home}</home> - <log>${project.build.directory}/tomcat5x.log</log> - <output>${project.build.directory}/tomcat5x.out</output> - </container> - <configuration> - <home>${project.build.directory}/tomcat5x</home> - </configuration> - </configuration> - </execution> - <execution> - <id>cargo-stop</id> - <phase>post-integration-test</phase> - <goals> - <goal>stop</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> @@ -162,6 +142,11 @@ <property> <name>url</name> <value>http://localhost:8080/shale-blank</value> + </property> + <!-- Define cargo.tomcat5x.home ~/.m2/settings.xml or with -D on the command line --> + <property> + <name>cargo.tomcat5x.home</name> + <value>${cargo.tomcat5x.home}</value> </property> </systemProperties> </configuration> Modified: struts/shale/branches/mvn_reorg/shale-apps/shale-blank/src/test/java/org/apache/shale/blank/systest/WelcomeTestCase.java URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-apps/shale-blank/src/test/java/org/apache/shale/blank/systest/WelcomeTestCase.java?rev=412639&r1=412638&r2=412639&view=diff ============================================================================== --- struts/shale/branches/mvn_reorg/shale-apps/shale-blank/src/test/java/org/apache/shale/blank/systest/WelcomeTestCase.java (original) +++ struts/shale/branches/mvn_reorg/shale-apps/shale-blank/src/test/java/org/apache/shale/blank/systest/WelcomeTestCase.java Wed Jun 7 20:18:28 2006 @@ -18,10 +18,21 @@ package org.apache.shale.blank.systest; +import java.io.File; import java.util.ResourceBundle; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.shale.test.htmlunit.AbstractHtmlUnitTestCase; +import org.codehaus.cargo.generic.DefaultContainerFactory; +import org.codehaus.cargo.generic.deployable.DefaultDeployableFactory; +import org.codehaus.cargo.generic.configuration.ConfigurationFactory; +import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory; +import org.codehaus.cargo.container.ContainerType; +import org.codehaus.cargo.container.InstalledLocalContainer; +import org.codehaus.cargo.container.deployable.DeployableType; +import org.codehaus.cargo.container.deployable.Deployable; +import org.codehaus.cargo.container.configuration.LocalConfiguration; +import org.codehaus.cargo.container.configuration.ConfigurationType; /** * <p>System test case for the <code>/welcome.jsp</code> page.</p> @@ -51,6 +62,8 @@ ResourceBundle.getBundle("org.apache.shale.blank.Bundle"); + private InstalledLocalContainer container; + // ------------------------------------------------------ Test Setup Methods @@ -59,6 +72,28 @@ */ public void setUp() throws Exception { + Deployable war = new DefaultDeployableFactory().createDeployable( + "tomcat5x", + System.getProperty("basedir")+"/target/shale-blank.war", + DeployableType.WAR); + + ConfigurationFactory configurationFactory = new DefaultConfigurationFactory(); + + LocalConfiguration configuration = + (LocalConfiguration) configurationFactory.createConfiguration( + "tomcat5x", ConfigurationType.STANDALONE); + + configuration.addDeployable(war); + + container = (InstalledLocalContainer) + new DefaultContainerFactory().createContainer( + "tomcat5x", ContainerType.INSTALLED, configuration); + + container.setHome(new File(System.getProperty("cargo.tomcat5x.home"))); + container.setOutput(new File( System.getProperty("basedir") + "/target/tomcat5x.out")); + + container.start(); + super.setUp(); page("/"); @@ -81,6 +116,7 @@ public void tearDown() { super.tearDown(); + container.stop(); }