vmassol     2002/10/16 04:45:26

  Modified:    src/plugins-build/cactus/conf/containers/tomcat4x server.xml
                        tomcat-users.xml
               src/plugins-build/cactus/xdocs tasks.xml
               src/plugins-build/cactus/scripts tomcat.4x.jelly
  Log:
  Added support for starting Tomcat container before running the tests, so that it can 
be left running while modifying code
  
  Revision  Changes    Path
  1.2       +6 -1      
jakarta-turbine-maven/src/plugins-build/cactus/conf/containers/tomcat4x/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/cactus/conf/containers/tomcat4x/server.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- server.xml        8 Oct 2002 13:51:25 -0000       1.1
  +++ server.xml        16 Oct 2002 11:45:26 -0000      1.2
  @@ -10,7 +10,12 @@
   
         <Realm className="org.apache.catalina.realm.MemoryRealm" />
   
  -      <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true">
  +      <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true"
  +        autoDeploy="true">
  +
  +        <Context path="/test" docBase="test" debug="0" reloadable="true" 
  +          crossContext="true"/>
  +
         </Host>
   
       </Engine>
  
  
  
  1.2       +1 -1      
jakarta-turbine-maven/src/plugins-build/cactus/conf/containers/tomcat4x/tomcat-users.xml
  
  Index: tomcat-users.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/cactus/conf/containers/tomcat4x/tomcat-users.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- tomcat-users.xml  8 Oct 2002 13:51:25 -0000       1.1
  +++ tomcat-users.xml  16 Oct 2002 11:45:26 -0000      1.2
  @@ -1,3 +1,3 @@
   <tomcat-users>
  -  <user name="testuser" password="testpassword" roles="test" />
  +  <user name="testuser" password="testpassword" roles="test"/>
   </tomcat-users>
  
  
  
  1.5       +0 -4      jakarta-turbine-maven/src/plugins-build/cactus/xdocs/tasks.xml
  
  Index: tasks.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/cactus/xdocs/tasks.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- tasks.xml 15 Oct 2002 20:37:34 -0000      1.4
  +++ tasks.xml 16 Oct 2002 11:45:26 -0000      1.5
  @@ -25,10 +25,6 @@
                 it. Ideally this means an XML merge of some sort (?).
               </li>
               <li>
  -              Support containers that are already started (same as the Cactus
  -              runservertests Ant task).
  -            </li>
  -            <li>
                 Improve the Jelly code to start the server in a separate thread.
                 Probably need to write a Jelly Tag (same as the Cactus Ant tags).
               </li>
  
  
  
  1.3       +77 -33    
jakarta-turbine-maven/src/plugins-build/cactus/scripts/tomcat.4x.jelly
  
  Index: tomcat.4x.jelly
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/cactus/scripts/tomcat.4x.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- tomcat.4x.jelly   12 Oct 2002 20:10:36 -0000      1.2
  +++ tomcat.4x.jelly   16 Oct 2002 11:45:26 -0000      1.3
  @@ -7,6 +7,8 @@
   -->
   <project xmlns:j="jelly:core">
   
  +  <j:set var="maven.cactus.webxml" value="${plugin.dir}/conf/web-13.xml"/>
  +
     <!--
        ========================================================================
          Run the Cactus tests in Tomcat 4.x
  @@ -22,8 +24,6 @@
         <j:when test="${home != 'X'}">
   
           <echo message="maven.cactus.tomcat4x.home = 
${maven.cactus.tomcat4x.home}"/>
  -
  -        <j:set var="maven.cactus.webxml" value="${plugin.dir}/conf/web-13.xml"/>
           
           <attainGoal name="cactus:tomcat-4x-run"/>            
   
  @@ -40,59 +40,104 @@
          Run the tests
        ========================================================================
     -->
  -  <goal name="cactus:tomcat-4x-run" prereqs="cactus:tomcat-4x-setup">
  +  <goal name="cactus:tomcat-4x-run">
   
       <!-- Start the servlet engine, wait for it to be started, run the
            unit tests, stop the servlet engine, wait for it to be stopped.
            The servlet engine is stopped if the tests fail for any reason -->
   
  -    <j:thread>
  -      <attainGoal name="cactus:tomcat-4x-start"/>
  -    </j:thread>
  +    <!-- Is Tomcat 4.x already started? -->
  +    <condition property="tomcat4xstarted">
  +      <socket server="localhost" port="${maven.cactus.port}"/>
  +    </condition>
  +    
  +    <j:choose>
  +      <j:when test="${tomcat4xstarted == null}">
  +        <j:thread>
  +          <attainGoal name="cactus:start-tomcat-4x"/>
  +        </j:thread>
  +      </j:when>
  +      <j:otherwise>
  +        <attainGoal name="cactus:redeploy-tomcat-4x"/>
  +      </j:otherwise>
  +    </j:choose>
   
       <waitfor checkevery="500">
         <http 
url="http://localhost:${maven.cactus.port}/test/ServletRedirector?Cactus_Service=RUN_TEST"/>

       </waitfor>
   
       <attainGoal name="cactus:test"/>         
  -    <attainGoal name="cactus:tomcat-4x-stop"/>       
   
  -    <waitfor checkevery="500">
  -      <not>
  -             <http 
url="http://localhost:${maven.cactus.port}/test/ServletRedirector?Cactus_Service=RUN_TEST"/>

  -      </not>
  -    </waitfor>
  +    <!-- Only stop if the container was not already started -->
  +    <j:if test="${tomcat4xstarted == null}">
  +      <attainGoal name="cactus:stop-tomcat-4x"/>
  +      <waitfor checkevery="500">
  +        <not>
  +          <http 
url="http://localhost:${maven.cactus.port}/test/ServletRedirector?Cactus_Service=RUN_TEST"/>

  +        </not>
  +      </waitfor>
  +    </j:if>
  +
  +  </goal>
  +
  +  <!--
  +     ========================================================================
  +       Deploy the test webapp in Tomcat
  +     ========================================================================
  +  -->
  +  <goal name="cactus:deploy-tomcat-4x" prereqs="cactus:war">
  +
  +    <!-- Unwar our war so that Tomcat can dynamically pick up changes without
  +         having to stop/restart it -->
  +    <unwar src="${maven.war.build.dir}/${pom.id}.war"
  +      dest="${maven.cactus.build.dir}/tomcat4x/webapps/test">      
  +    </unwar>
   
     </goal>
   
     <!--
        ========================================================================
  -       Prepare directories and variables for running the tests
  +       Redeploy the test webapp in Tomcat by only deploying the files in
  +       WEB-INF/classes (it is faster)
  +     ========================================================================
  +  -->
  +  <goal name="cactus:redeploy-tomcat-4x" prereqs="cactus:war">
  +
  +    <!-- Unwar our war so that Tomcat can dynamically pick up changes without
  +         having to stop/restart it -->
  +    <unwar src="${maven.war.build.dir}/${pom.id}.war"
  +      dest="${maven.cactus.build.dir}/tomcat4x/webapps/test">      
  +      <patternset>
  +        <include name="WEB-INF/classes/**"/>
  +      </patternset>
  +    </unwar>
  +
  +    <!-- Ideally we would need to wait until Tomcat has finished reloading
  +         the changes. But apart from using the new Manager in Tomcat 4.1.x
  +         I don't know how to do that ... Thus ATM there is a risk that
  +         Tomcat will not have picked up the changes when the tests 
  +         run... -->
  +         
  +  </goal>
  +     
  +  <!--
  +     ========================================================================
  +       Set up a Tomcat directory structure
        ========================================================================
     -->
  -  <goal name="cactus:tomcat-4x-setup" prereqs="cactus:war">
  +  <goal name="cactus:setup-tomcat-4x">
   
       <!-- Create work and conf directories and copy configuration files -->
       <mkdir dir="${maven.cactus.build.dir}/tomcat4x/conf"/>
       <mkdir dir="${maven.cactus.build.dir}/tomcat4x/webapps"/>
   
  -    <!-- We delete the work directory as Tomcat may have saved some 
  -         serialized sessions or other stuff -->
  -    <delete dir="${maven.cactus.build.dir}/tomcat4x/work" failonerror="false"/>
  -    <mkdir dir="${maven.cactus.build.dir}/tomcat4x/work"/>
  -
  -    <!-- Delete some config file so that they will be copied every time -->
  -    <delete file="${maven.cactus.build.dir}/tomcat4x/conf/server.xml"/>
  -
  -    <!-- Remove the auto deployed webapp so that it is redeployed every
  -         time -->
  -    <delete dir="${maven.cactus.build.dir}/tomcat4x/webapps/test"/>
  -
       <!-- Copy Tomcat configuration files, replacing filter tokens -->
       <copy todir="${maven.cactus.build.dir}/tomcat4x/conf" filtering="on">
         <fileset dir="${maven.cactus.conf.containers.dir}/tomcat4x"/>
         <filterset>
           <filter token="maven.cactus.port" value="${maven.cactus.port}"/>
  +        <filter token="maven.cactus.tomcat4x.home" 
  +          value="${maven.cactus.tomcat4x.home}"/>
         </filterset>
       </copy>
   
  @@ -102,18 +147,16 @@
       <copy file="${maven.cactus.tomcat4x.home}/conf/web.xml"
         todir="${maven.cactus.build.dir}/tomcat4x/conf"/>
   
  -    <!-- Copy the war file -->
  -    <copy file="${maven.war.build.dir}/${pom.id}.war"
  -      tofile="${maven.cactus.build.dir}/tomcat4x/webapps/test.war"/>
  -
     </goal>
  -     
  +
     <!--
        ========================================================================
          Start Tomcat 4.x
        ========================================================================
     -->
  -  <goal name="cactus:tomcat-4x-start">
  +  <goal name="cactus:start-tomcat-4x" 
  +    prereqs="cactus:setup-tomcat-4x,cactus:deploy-tomcat-4x"
  +    description="Starts Tomcat 4.x">
   
       <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
   
  @@ -136,7 +179,8 @@
          Stop Tomcat 4.x
        ========================================================================
     -->
  -  <goal name="cactus:tomcat-4x-stop">
  +  <goal name="cactus:stop-tomcat-4x"
  +    description="Stops a running Tomcat 4.x">
   
       <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to