Hi,

I setup such a config for one of my projects a few weeks ago.

There are different profiles "run-server" and "integrationtest". The main
difference is that in "integrationtest" antrun is used to start a ranorex
testsuite (Flex UI Frontend-Test) and shutdown the server after the tests
are finished.

In this setup I call an init-script to initialize my mySQL database (in my
case clear the schema),
then the desired container is downloaded and installed, the application is
deployed and the containert is started.

Hope this was what you were looking for.

Chris

PS: Here comes my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>de.cware.cweb</artifactId>
        <groupId>parent</groupId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>de.cware.cweb</artifactId>
    <artifactId>de.upw.cweb.testing.integrationtest</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <name>de.upw.cweb.testing.integrationtest</name>

    <!-- Properties common to all profiles -->
    <properties>
        <port>8082</port>
        <installDir>${java.io.tmpdir}/cargo/installs</installDir>

        <cweb.database.driver>com.mysql.jdbc.Driver</cweb.database.driver>

 
<cweb.database.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</cweb.database.dialect>

 <cweb.database.url>jdbc:mysql://localhost:3306/cwebtest</cweb.database.url>
        <cweb.database.user>username</cweb.database.user>
        <cweb.database.password>password</cweb.database.password>
    </properties>

    <dependencies>
        <dependency>
            <groupId>de.cware.cweb</groupId>
            <artifactId>de.cware.cweb.webapp</artifactId>
            <version>1.0.0-SNAPSHOT</version>
            <type>war</type>
        </dependency>
    </dependencies>

    <!-- Container-specific profiles -->
    <profiles>
        <profile>
            <id>tomcat5x</id>
            <properties>
                <containerId>tomcat5x</containerId>
                <downloadUrl>
http://apache.imsam.info//tomcat/tomcat-5/v5.5.31/bin/apache-tomcat-5.5.31.zip
                </downloadUrl>
            </properties>
        </profile>
        <profile>
            <id>tomcat6x</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <containerId>tomcat6x</containerId>
                <downloadUrl>
http://apache.easy-webs.de//tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.zip
                </downloadUrl>
            </properties>
        </profile>
        <profile>
            <id>tomcat7x</id>
            <properties>
                <containerId>tomcat7x</containerId>
                <downloadUrl>
http://apache.mirror.clusters.cc//tomcat/tomcat-7/v7.0.4-beta/bin/apache-tomcat-7.0.4.zip
                </downloadUrl>
            </properties>
        </profile>
        <profile>
            <id>resin3x</id>
            <properties>
                <containerId>resin3x</containerId>
                <downloadUrl>http://www.caucho.com/download/resin-3.0.18.zip
</downloadUrl>
            </properties>
        </profile>
        <profile>
            <id>jboss3x</id>
            <properties>
                <containerId>jboss3x</containerId>
                <downloadUrl>
http://ovh.dl.sourceforge.net/sourceforge/jboss/jboss-3.2.8.zip
</downloadUrl>
            </properties>
        </profile>
        <profile>
            <id>jboss4x</id>
            <properties>
                <containerId>jboss4x</containerId>
                <downloadUrl>
http://downloads.sourceforge.net/jboss/jboss-4.0.5.GA.zip?big_mirror=1
</downloadUrl>
            </properties>
        </profile>

        <profile>
            <id>run-server</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.3</version>
                        <executions>
                            <execution>
                                <id>clear-database</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks name="Call mysql to drop the
database.">
                                        <exec dir="${basedir}"
executable="cmd">
                                            <arg value="/c" />
                                            <arg value="mysql.exe
--user=${cweb.database.user} --password=${cweb.database.password} &lt;
clear_schema.sql" />
                                        </exec>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>1.0.3</version>
                        <configuration>
                            <container>
                                <containerId>${containerId}</containerId>

 <log>${project.build.directory}/${containerId}/container.log</log>
                                <zipUrlInstaller>
                                    <url>${downloadUrl}</url>
                                    <installDir>${installDir}</installDir>
                                </zipUrlInstaller>
                                <!-- 3 Minutes -->
                                <timeout>180000</timeout>
                                <systemProperties>
                                    <pgm.password>s3cr3t</pgm.password>

 <de.upw.cweb.default-namespace>de.cware.cweb</de.upw.cweb.default-namespace>

 <cweb.home>${project.build.directory}${file.separator}cweb-home</cweb.home>
                                    <cweb.base-url>http://localhost:
${port}/CWebTest/</cweb.base-url>


 <cweb.database.driver>${cweb.database.driver}</cweb.database.driver>

 <cweb.database.dialect>${cweb.database.dialect}</cweb.database.dialect>

 <cweb.database.url>${cweb.database.url}</cweb.database.url>

 <cweb.database.user>${cweb.database.user}</cweb.database.user>

 <cweb.database.password>${cweb.database.password}</cweb.database.password>
                                </systemProperties>
                            </container>
                            <configuration>
                                <type>standalone</type>

 <home>${project.build.directory}/${containerId}/container</home>
                                <properties>
                                    <cargo.jvmargs>-Xmx1024m -Xms1024m
-XX:MaxPermSize=128m

 
-javaagent:"${settings.localRepository}/org/springframework/org.springframework.instrument/${spring.version}/org.springframework.instrument-${spring.version}.jar"
                                    </cargo.jvmargs>

 <cargo.servlet.port>${port}</cargo.servlet.port>
                                    <cargo.logging>high</cargo.logging>

 <cargo.servlet.users>admin::manager</cargo.servlet.users>
                                </properties>
                                <deployables>
                                    <deployable>
                                        <groupId>de.cware.cweb</groupId>

 <artifactId>de.cware.cweb.webapp</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>CWebTest</context>
                                        </properties>
                                        <pingURL>http://localhost:
${port}/CWebTest/index.html</pingURL>
                                        <pingTimeout>180000</pingTimeout>
                                    </deployable>
                                </deployables>
                            </configuration>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>integrationtest</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.3</version>
                        <executions>
                            <execution>
                                <id>clear-database</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks name="Call mysql to drop the
database.">
                                        <exec dir="${basedir}"
executable="cmd">
                                            <arg value="/c" />
                                            <arg value="mysql.exe
--user=${cweb.database.user} --password=${cweb.database.password} &lt;
clear_schema.sql" />
                                        </exec>
                                    </tasks>
                                </configuration>
                            </execution>
                            <execution>
                                <id>integration-test</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks name="Call Ranorex to execute the
test.">
                                        <exec dir="${basedir}"
executable="execute-integrationtest.bat" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>1.0.3</version>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                    <goal>deploy</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <wait>false</wait>
                            <container>
                                <containerId>${containerId}</containerId>

 <log>${project.build.directory}/${containerId}/container.log</log>
                                <zipUrlInstaller>
                                    <url>${downloadUrl}</url>
                                    <installDir>${installDir}</installDir>
                                </zipUrlInstaller>
                                <!-- 3 Minutes -->
                                <timeout>180000</timeout>
                                <systemProperties>
                                    <pgm.password>s3cr3t</pgm.password>

 <de.upw.cweb.default-namespace>de.cware.cweb</de.upw.cweb.default-namespace>

 <cweb.home>${project.build.directory}${file.separator}cweb-home</cweb.home>
                                    <cweb.base-url>http://localhost:
${port}/UPWComplianceGuard/</cweb.base-url>


 <cweb.database.driver>${cweb.database.driver}</cweb.database.driver>

 <cweb.database.dialect>${cweb.database.dialect}</cweb.database.dialect>

 <cweb.database.url>${cweb.database.url}</cweb.database.url>

 <cweb.database.user>${cweb.database.user}</cweb.database.user>

 <cweb.database.password>${cweb.database.password}</cweb.database.password>
                                </systemProperties>
                            </container>
                            <configuration>
                                <type>standalone</type>

 <home>${project.build.directory}/${containerId}/container</home>
                                <properties>
                                    <cargo.jvmargs>-Xmx1024m -Xms1024m
-XX:MaxPermSize=128m

 
-javaagent:"${settings.localRepository}/org/springframework/org.springframework.instrument/${spring.version}/org.springframework.instrument-${spring.version}.jar"
                                    </cargo.jvmargs>

 <cargo.servlet.port>${port}</cargo.servlet.port>
                                    <cargo.logging>high</cargo.logging>

 <cargo.servlet.users>admin::manager</cargo.servlet.users>
                                </properties>
                            </configuration>
                            <deployer>
                                <deployables>
                                    <!--deployable>
                                        <pingURL>http://localhost:
${port}/${project.artifactId}-${version}/index.jsp</pingURL>
                                    </deployable-->
                                    <deployable>
                                        <groupId>de.cware.cweb</groupId>

 <artifactId>de.cware.cweb.webapp.blazeds.server</artifactId>
                                        <type>war</type>
                                        <properties>

 <context>UPWComplianceGuard</context>
                                        </properties>
                                        <pingURL>http://localhost:
${port}/UPWComplianceGuard/index.html</pingURL>
                                        <pingTimeout>180000</pingTimeout>
                                    </deployable>
                                </deployables>
                            </deployer>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>


2011/3/8 François Le Droff <[email protected]>

> James,
>
> You may try out the jetty plugin cf.
> http://maven.apache.org/plugins/maven-war-plugin/examples/rapid-testing-jetty6-plugin.html
> it you are in tomcat specific need try out cargo cf.
> http://cargo.codehaus.org/Deploying+to+a+running+container
>
> and if you only need to do this during dev, what I do is :
> * use M2Eclipse for the java project and have it deplying the war as
> exploded war in my tomcat/jboss folder
> * have Flashbuilder compile the swf in the deployed exploded war (using
> linked resource)
>
> Cheers,
> François
>
>
>
> On Tue, Mar 8, 2011 at 8:24 AM, James Ward <[email protected]> wrote:
>
>> Hi,
>>
>> I want to run some FlexUnit integration tests from Maven, but to do so I
>> need to startup a Tomcat server and deploy out the contents of my Java
>> subproject.  It seems like I should be able to automate this from Maven,
>> but I can't figure out how.  Any ideas or pointers?
>>
>> Thanks!
>>
>> -James
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Flex Mojos" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/flex-mojos
>>
>> http://flexmojos.sonatype.org/
>>
>
>
>
> --
>
> François Le Droff
> http://www.droff.com
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Flex Mojos" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/flex-mojos
>
> http://flexmojos.sonatype.org/
>

-- 
You received this message because you are subscribed to the Google
Groups "Flex Mojos" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex-mojos

http://flexmojos.sonatype.org/

Reply via email to