<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- $Revision: 1.1 $ $Date: 2005/03/14 02:57:53 $ -->

<project default="default"
    xmlns:j="jelly:core"
    xmlns:ant="jelly:ant"
    xmlns:maven="jelly:maven"
    xmlns:u="jelly:util"
    xmlns:deploy="geronimo:deploy"
    xmlns:velocity="jelly:velocity"
    >

    <goal name="default" prereqs="jar:install"/>

    <postGoal name="jar:install">
        <attainGoal name="itest"/>
    </postGoal>

    <preGoal name="itest:setup">

    <j:if test="${context.getVariable('enable.debug') == 'true'}">
        <j:set var="geronimo.server.debug.options" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"/>
    </j:if>

    <ant:mkdir dir="${basedir}/target/plan"/>
    <velocity:merge
            basedir="${basedir}/src/plan"
            template="activemq-itests-ear.ear.xml"
            name="${basedir}/target/plan/activemq-itests-ear.ear.xml"/>

        <delete dir="${maven.build.dir}/geronimo"/>
        <deploy:unpackServer
            geronimoVersion="1.0-SNAPSHOT"
            />
        <deploy:startRemoteServer
            geronimoTarget="${maven.build.dir}/geronimo"
        vmArgs="-ea ${geronimo.server.debug.options} -Xms512m -Xmx768m -Djava.rmi.server.RMIClassLoaderSpi=org.apache.geronimo.system.rmi.RMIClassLoaderSpiImpl ${geronimo.server.options}"
            configs="org/apache/geronimo/ActiveMQServer org/apache/geronimo/RuntimeDeployer"/>
        <ant:echo message="Waiting for server"/>
        <deploy:waitForStarted
            uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
            username="system"
            password="manager"
            id="org/apache/geronimo/RuntimeDeployer"/>
        <echo message="server has started"/>
        <deploy:distribute
            uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
            username="system"
            password="manager"
        module="${maven.repo.local}/${pom.groupId}/ears/activemq-itest-ear-${pom.currentVersion}.ear"
        plan="${basedir}/target/plan/activemq-itests-ear.ear.xml"
            />
        <deploy:start
            uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
            username="system"
            password="manager"
            id="org/activemq/itest/ServerEar"/>

        <j:if test="${context.getVariable('enable.debug') == 'true'}">
            <input message="Connect your debugger and then press any key to start the tests."/>
        </j:if>
    </preGoal>

    <postGoal name="itest:teardown">
        <deploy:stopRemoteServer
            uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
            username="system"
            password="manager"/>
        <sleep seconds="2"/>
        <echo message="server has stopped"/>
    </postGoal>

</project>
