configuration.setProperty(GeneralPropertySet.HOSTNAME, hostname);
configuration.setProperty(ServletPropertySet.PORT, port);
Deployable war = new WAR(System.getProperty("cargo.war"));
configuration = new Tomcat5xStandaloneLocalConfiguration(
new File("target/tomcat5x"));
configuration.setProperty("cargo.servlet.port", System.getProperty("cargo.servlet.port"));
configuration.addDeployable(war);
container = new Tomcat5xInstalledLocalContainer(configuration);
container.setHome(new File(System.getProperty("cargo.tomcat5x.home")));
container.start();
container.stop();
Deployable war = new DefaultDeployableFactory().createDeployable(
"tomcat5x", System.getProperty("cargo.war"), DeployableType.WAR);
ConfigurationFactory configurationFactory = new DefaultConfigurationFactory();
LocalConfiguration configuration =
(LocalConfiguration) configurationFactory.createConfiguration(
"tomcat5x", ConfigurationType.STANDALONE);
configuration.setProperty("cargo.servlet.port", System.getProperty("cargo.servlet.port"));
configuration.addDeployable(war);
container = (InstalledLocalContainer)
new DefaultContainerFactory().createContainer(
"tomcat5x", ContainerType.INSTALLED, configuration);
container.setHome(new File(System.getProperty("cargo.tomcat5x.home")));
container.start();
container.stop();
Better: Move the integration tests to a separate module. This works:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>2.4-SNAPSHOT</version>
</parent>
<groupId>com.example</groupId>
<artifactId>myproject-it</artifactId>
<packaging>pom</packaging>
<name>My Project - Integration Tests</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compiler-it</id>
<phase>pre-integration-test</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>contextName</name>
<value>${pom.build.finalName}</value>
</property>
<!-- configure the path to the war file in the sibling module -->
<property>
<name>cargo.war</name>
<value>${basedir}/../webapp/target/${pom.build.finalName}.war</value>
</property>
<!-- cargo.tomcat5x.home MUST be defined in settings.xml -->
<property>
<name>cargo.tomcat5x.home</name>
<value>${cargo.tomcat5x.home}</value>
</property>
<property>
<name>cargo.resin3x.home</name>
<value>${cargo.resin3x.home}</value>
</property>
<property>
<name>cargo.servlet.port</name>
<value>80</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The Connector in Tomcat 4.1.31 looks like this:
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector?"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true"
acceptCount="100" debug="0" scheme="https" secure="true"
useURIValidationHack?="false" disableUploadTimeout?="true">
<Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory?"
clientAuth="false" protocol="TLS" />
</Connector?>
So change the one in Cargo...
<Connector className="org.apache.catalina.connector.http.HttpConnector?"
port="@cargo.servlet.port@" minProcessors="5" maxProcessors="75"
scheme="@cargo.protocol@" secure="@catalina.secure@"
acceptCount="10" debug="@catalina.logging.level@">
@catalina.coyote.factory@
</Connector?>
cargo.protocol and catalina.secure are already taken care of by CARGO-284, just need to add catalina.coyote.factory to... not AbstractTomcatStandalone? (or whatever it's called) but one level down, only for Tomcat 4.x
Some classes could use good toString methods:
[DEBUG] cargo-core-container-geronimo: using locally installed snapshot
[DEBUG] cargo-core-container-orion: using locally installed snapshot
[DEBUG] Configuring mojo 'org.codehaus.cargo:cargo-maven2-plugin:0.3-SNAPSHOT:st
art' -->
[DEBUG] (s) home = c:\svn\irm\current\benweb\webapp\target\tomcat
[DEBUG] (f) properties = {cargo.client.auth=null, cargo.hostname=xxx.example.com, cargo.protocol=https, cargo.secure=true, cargo.servlet.port=443, cargo.s
sl.protocol=null}
[DEBUG] (f) configuration = org.codehaus.cargo.maven2.Configuration@1e7c5cb
[DEBUG] (s) containerId = tomcat5x
[DEBUG] (s) home = c:\java\apache-tomcat-5.5.15
[DEBUG] (s) log = c:\temp\tomcat5x.log
[DEBUG] (s) container = org.codehaus.cargo.maven2.Container@1961581
[DEBUG] (f) localRepository = [local] -> file://C:\\java\\m2-repository
[DEBUG] (f) project = org.apache.maven.project.MavenProject@89b5af79
[DEBUG] (f) repositories = [[Apache Snapshots] -> http://cvs.apache.org/maven-
snapshot-repository/, [irm-repo] -> file://\\irmfs1\files\irm\irmapps\projects\r
epository, [central] -> http://repo1.maven.org/maven2]
[DEBUG] (f) wait = true
[DEBUG] -- end configuration --
[INFO] [cargo:start]
[DEBUG] No container log will be generated. Configure the plugin using the <outp
ut> element under <container> to generate container logs
[INFO] ------------------------------------------------------------------------
The second parameter of createDeployable changed from String to File
Deployable war = new DefaultDeployableFactory().createDeployable(
"tomcat5x",
- System.getProperty("localRepository")+System.getProperty("cargo.war"),
+ new File(System.getProperty("localRepository")+System.getProperty("cargo.war")),
DeployableType.WAR);