Maven cargo plugin embedded tomcat 7 configuration

2.8k views Asked by At

i was wondering what is the minimum configuration needed for maven cargo plugin to run embedded tomcat 7 for integration testing, please advise, thanks.

1

There are 1 answers

1
dermoritz On

that should be enough (specifying the port is optional, change the url to get a different version of tomcat7):

        <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.2.0</version>
    <!-- minimal configuration to let adb run (mvn package org.codehaus.cargo:cargo-maven2-plugin:run) in a local tomcat -->
    <configuration>
      <container>
        <containerId>tomcat7x</containerId>
        <zipUrlInstaller>
          <url>http://a-inet01:8100/apache-tomcat-7.0.25.zip</url>
        </zipUrlInstaller>
      </container>
      <configuration>
        <properties>
          <cargo.servlet.port>1718</cargo.servlet.port>
        </properties>
      </configuration>
    </configuration>
  </plugin>

than mvn package org.codehaus.cargo:cargo-maven2-plugin:run (on a mavenproject with packaging "war") will create the war, download the tomcat from given url, start it and deploy the war. if you use start the container is stopped if maven is finished (this one u will use in integration test): if you want to start cargo automatically than complement:

            <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>
                [Cargo plugin configuration goes in here]
            </configuration>
        </plugin>

just copied from cargo maven docu (http://cargo.codehaus.org/Starting+and+stopping+a+container). this will start the container before "integration-test" and stop it after the tests.