vmassol     2002/10/08 06:51:26

  Added:       src/plugins-build/cactus/conf/containers/tomcat4x server.xml
                        tomcat-users.xml
               src/plugins-build/cactus/xdocs changes.xml .cvsignore
               src/plugins-build/cactus/conf web-13.xml web-12.xml
                        cactus.properties
               src/plugins-build/cactus plugin.properties
                        project.properties .cvsignore plugin.jelly
                        maven.xml project.xml
               src/plugins-build/cactus/conf/web jspRedirector.jsp
               src/plugins-build/cactus/scripts tomcat.4x.jelly
  Log:
  Creation of the Cactus plugin. Currently supports Tomcat 4.x only. Does not generate 
HTML reports yet. Has only been tested with the Servlet Redirector (still need to be 
tested with the Jsp and Filter redirectors).
  
  To use: 
  - simply define a maven.cactus.tomcat4x.home property in your build.properties that 
point to where your Tomcat 4.x is installed
  - put your cactus tests in a src/test-cactus directory structure
  - simply type: maven cactus:test-tomcat-4x
  
  Enjoy!
  
  Revision  Changes    Path
  1.1                  
jakarta-turbine-maven/src/plugins-build/cactus/conf/containers/tomcat4x/server.xml
  
  Index: server.xml
  ===================================================================
  <Server port="8005" shutdown="SHUTDOWN" debug="0">
  
    <Service name="Tomcat-Standalone">
  
      <Connector className="org.apache.catalina.connector.http.HttpConnector"
                 port="@maven.cactus.port@" minProcessors="5" maxProcessors="75"
                 acceptCount="10" debug="0"/>
  
      <Engine name="Standalone" defaultHost="localhost" debug="0">
  
        <Realm className="org.apache.catalina.realm.MemoryRealm" />
  
        <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true">
        </Host>
  
      </Engine>
  
    </Service>
  
  </Server>
  
  
  
  1.1                  
jakarta-turbine-maven/src/plugins-build/cactus/conf/containers/tomcat4x/tomcat-users.xml
  
  Index: tomcat-users.xml
  ===================================================================
  <tomcat-users>
    <user name="testuser" password="testpassword" roles="test" />
  </tomcat-users>
  
  
  
  1.1                  jakarta-turbine-maven/src/plugins-build/cactus/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  <?xml version="1.0"?>
  <document>
    <properties>
      <title>Changes</title>
      <author email="[EMAIL PROTECTED]">Vincent Massol</author>
    </properties>
  
    <body>
      <release version="1.0" date="in CVS">
        <action dev="vmassol" type="add">
          Creation of the Cactus plugin. Currently supports Tomcat 4.x
          only. Does not generate HTML reports yet. Has only been tested 
          with the Servlet Redirector (still need to be tested with the 
          Jsp and Filter redirectors).
        </action>
      </release>
    </body>
  </document>
  
  
  
  
  1.3       +0 -0      jakarta-turbine-maven/src/plugins-build/cactus/xdocs/.cvsignore
  
  
  
  
  1.1                  jakarta-turbine-maven/src/plugins-build/cactus/conf/web-13.xml
  
  Index: web-13.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd";>
  
  <web-app>
  
      <filter>
          <filter-name>FilterRedirector</filter-name>
          <filter-class>org.apache.cactus.server.FilterTestRedirector</filter-class>
      </filter>
  
      <filter-mapping>
          <filter-name>FilterRedirector</filter-name>
          <url-pattern>/FilterRedirector</url-pattern>
      </filter-mapping>
  
      <servlet>
          <servlet-name>ServletRedirector</servlet-name>
          <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
      </servlet>
  
      <servlet>
          <servlet-name>ServletRedirectorSecure</servlet-name>
          <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
      </servlet>
  
      <servlet>
          <servlet-name>JspRedirector</servlet-name>
          <jsp-file>/jspRedirector.jsp</jsp-file>
      </servlet>
  
      <servlet-mapping>
          <servlet-name>ServletRedirector</servlet-name>
          <url-pattern>/ServletRedirector</url-pattern>
      </servlet-mapping>
  
      <servlet-mapping>
          <servlet-name>ServletRedirectorSecure</servlet-name>
          <url-pattern>/ServletRedirectorSecure</url-pattern>
      </servlet-mapping>
  
      <servlet-mapping>
          <servlet-name>JspRedirector</servlet-name>
          <url-pattern>/JspRedirector</url-pattern>
      </servlet-mapping>
  
        <!-- Authentication -->
  
        <security-constraint>
        <web-resource-collection>
                <web-resource-name>SecurityRestriction</web-resource-name>
                <description>Protect the Cactus redirector servlet.</description>
                <url-pattern>/ServletRedirectorSecure</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
                <description>Authorized Users Group</description>
                <role-name>test</role-name>
        </auth-constraint>
        <user-data-constraint>
                <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
        </security-constraint>
  
      <login-config>
        <auth-method>BASIC</auth-method>
        </login-config>
  
        <security-role>
                <description>Test role</description>
                <role-name>test</role-name>
        </security-role>
  
        <!-- End Authentication -->
  
  </web-app>
  
  
  
  1.1                  jakarta-turbine-maven/src/plugins-build/cactus/conf/web-12.xml
  
  Index: web-12.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd";>
  
  <web-app>
  
      <servlet>
          <servlet-name>ServletRedirector</servlet-name>
          <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
      </servlet>
  
      <servlet>
          <servlet-name>ServletRedirectorSecure</servlet-name>
          <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
      </servlet>
  
      <servlet>
          <servlet-name>JspRedirector</servlet-name>
          <jsp-file>/jspRedirector.jsp</jsp-file>
      </servlet>
  
      <servlet-mapping>
          <servlet-name>ServletRedirector</servlet-name>
          <url-pattern>/ServletRedirector</url-pattern>
      </servlet-mapping>
  
      <servlet-mapping>
          <servlet-name>ServletRedirectorSecure</servlet-name>
          <url-pattern>/ServletRedirectorSecure</url-pattern>
      </servlet-mapping>
  
      <servlet-mapping>
          <servlet-name>JspRedirector</servlet-name>
          <url-pattern>/JspRedirector</url-pattern>
      </servlet-mapping>
  
        <!-- Authentication -->
  
        <security-constraint>
        <web-resource-collection>
                <web-resource-name>SecurityRestriction</web-resource-name>
                <description>Protect the Cactus redirector servlet.</description>
                <url-pattern>/ServletRedirectorSecure</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
                <description>Authorized Users Group</description>
                <role-name>test</role-name>
        </auth-constraint>
        <user-data-constraint>
                <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
        </security-constraint>
  
      <login-config>
        <auth-method>BASIC</auth-method>
        </login-config>
  
        <security-role>
                <description>Test role</description>
                <role-name>test</role-name>
        </security-role>
  
        <!-- End Authentication -->
  
  </web-app>
  
  
  
  1.1                  
jakarta-turbine-maven/src/plugins-build/cactus/conf/cactus.properties
  
  Index: cactus.properties
  ===================================================================
  # Configuration file for Cactus.
  
  # Each project using Cactus need to have such a file put in the client side
  # CLASSPATH (Meaning the directory containgin this file should be in the client
  # side CLASSPATH, not the file itself of course ... :) )
  
  # Defines the URLs that will be used by Cactus to call it's redirectors.
  # You need to specify in these URLs the webapp context that you use for your
  # application. In the example below, the context is "test".
  
  # Web app Context under which our application to test runs
  cactus.contextURL = http://localhost:@maven.cactus.port@/test
  
  # Default Servlet Redirector Name. Used by ServletTestCase test cases.
  cactus.servletRedirectorName = ServletRedirector
  
  # Default JSP Redirector Name. Used by JspTestCase test cases.
  cactus.jspRedirectorName = JspRedirector
  
  # Default Filter Redirector Name. Used by FilterTestCase test cases.
  cactus.filterRedirectorName = FilterRedirector
  
  
  
  1.1                  jakarta-turbine-maven/src/plugins-build/cactus/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  # -------------------------------------------------------------------
  # Default properties for the Cactus Plugin
  # -------------------------------------------------------------------
  
  # Location of containers. These properties need to be put in your
  # local build.properties as they depend on where you installed
  # your containers on your local machine.
  #
  # Examples:
  #
  # maven.cactus.tomcat4x.home = c:/apps/tomcat-4.1.10
  
  # Location of Cactus JSP Redirector
  maven.cactus.jspRedirector = ${plugin.dir}/conf/web/jspRedirector.jsp
  
  # Location of cactus.properties Cactus configuration file
  maven.cactus.configFile = ${plugin.dir}/conf/cactus.properties
  
  # Location of Cactus tests in project sources
  maven.cactus.src.dir = src/test-cactus
  
  # Location of scripts for the different containers
  maven.cactus.scripts.dir = ${plugin.dir}/scripts
  
  # Location of container configuration files
  maven.cactus.conf.containers.dir = ${plugin.dir}/conf/containers
  
  # Location where the cactus plugin puts its generateds stuff in
  # the project build directory.
  maven.cactus.build.dir = ${maven.build.dir}/cactus
  
  # Location where the cactus plugin puts the compiled cactus test classes
  maven.cactus.classes.dir = ${maven.cactus.build.dir}/classes
  
  # Location where the cactus plugin puts resources that need to be in the
  # Cactus client side classpath.
  maven.cactus.build.resources.dir = ${maven.cactus.build.dir}/resources
  
  # Port under which the container will be started
  maven.cactus.port = 8080
  
  # If true, the junit task used to run the Cactus tests will output the
  # test result to a file
  maven.cactus.junit.usefile = true
  
  # Location of generated raw test reports
  maven.cactus.test.reportsDirectory = ${maven.cactus.build.dir}/test-reports
  
  
  
  1.5       +0 -2      
jakarta-turbine-maven/src/plugins-build/cactus/project.properties
  
  
  
  
  1.5       +1 -1      jakarta-turbine-maven/src/plugins-build/cactus/.cvsignore
  
  
  
  
  1.1                  jakarta-turbine-maven/src/plugins-build/cactus/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    =============================================================================
      Cactus plugin for Maven.
    =============================================================================
  -->
  <project xmlns:j="jelly:core">
  
    <!-- Import all the jelly scripts found in the maven.cactus.conf.dir 
           directory. They are jelly scripts to start/stop the different
           containers. -->
    <fileScanner var="scanner">
      <fileset dir="${maven.cactus.scripts.dir}" includes="*.jelly"/>
    </fileScanner>
  
    <j:forEach var="script" items="${scanner.iterator()}">
      <j:import inherit="true" uri="${script.toURL().toString()}"/>
    </j:forEach>
  
    <taskdef name="runservertests"
      classname="org.apache.cactus.ant.RunServerTestsTask">
      <classpath>
        <pathelement location="${plugin.getDependencyPath('cactus:cactus-ant')}"/>
      </classpath>
    </taskdef>
  
    <!--
       ========================================================================
         Compile Cactus tests.
       ========================================================================
    -->
    <goal name="cactus:compile" prereqs="java:compile">
  
      <mkdir dir="${maven.cactus.build.dir}"/>
      <mkdir dir="${maven.cactus.classes.dir}"/>
  
      <javac 
        destdir="${maven.cactus.classes.dir}"
        excludes="**/package.html"
        debug="${maven.compile.debug}"
        deprecation="${maven.compile.deprecation}"
        optimize="${maven.compile.optimize}">
        <classpath>
          <pathelement path="${maven.build.dest}"/>
          <path refid="maven.dependency.classpath"/>
          <pathelement path="${plugin.getDependencyPath('cactus:cactus')}"/>
          <pathelement path="${plugin.getDependencyPath('junit')}"/>
        </classpath>
        <src>
          <path location="${maven.cactus.src.dir}"/>
        </src>
      </javac>
  
    </goal>
  
    <!--
       ========================================================================
         Generate a Cactus WAR file.
         
         Call the War goal from the War plugin and then update the war to
         add Cactus specific stuff: modified web.xml, Cactus related jars
         and Cactus tests.
         
         Note: ${maven.cactus.webxml} need to be set and point to a valid
         web.xml prior to calling this goal.
       ========================================================================
    -->
    <goal name="cactus:war" prereqs="cactus:compile,war:war">
  
      <copy tofile="${maven.cactus.build.dir}/jspRedirector.jsp" 
        file="${maven.cactus.jspRedirector}"/>
      
      <war update="true" webxml="${maven.cactus.webxml}"
        warfile="${maven.war.build.dir}/${pom.id}.war">
  
        <!-- Cactus framework -->
        <lib 
dir="${maven.repo.local}/${plugin.getDependency('cactus:cactus').getProjectId()}/jars/">

          <include name="${plugin.getDependency('cactus:cactus').getArtifact()}"/>
        </lib>    
  
        <!-- AspectJ runtime -->
        <lib 
dir="${maven.repo.local}/${plugin.getDependency('aspectj:aspectjrt').getProjectId()}/jars/">

          <include name="${plugin.getDependency('aspectj:aspectjrt').getArtifact()}"/>
        </lib>    
  
        <!-- Commons Logging -->
        <lib 
dir="${maven.repo.local}/${plugin.getDependency('commons-logging').getProjectId()}/jars/">

          <include name="${plugin.getDependency('commons-logging').getArtifact()}"/>
        </lib>    
  
        <!-- JUnit -->
        <lib 
dir="${maven.repo.local}/${plugin.getDependency('junit').getProjectId()}/jars/">
          <include name="${plugin.getDependency('junit').getArtifact()}"/>
        </lib>    
  
        <!-- Add the Cactus Jsp Redirector -->
        <fileset dir="${maven.cactus.build.dir}">
          <include name="jspRedirector.jsp"/>
        </fileset>
  
        <!-- Add Cactus tests -->
        <classes dir="${maven.cactus.classes.dir}"/>
              
      </war>
  
    </goal>
     
    <!--
       ========================================================================
         Start the Cactus tests using the <junit> Ant task.
       ========================================================================
    -->
    <goal name="cactus:test">
  
      <mkdir dir="${maven.cactus.test.reportsDirectory}"/>
      <mkdir dir="${maven.cactus.build.resources.dir}"/>
  
      <copy todir="${maven.cactus.build.resources.dir}"
        file="${maven.cactus.configFile}" filtering="on">
        <filterset>
          <filter token="maven.cactus.port" value="${maven.cactus.port}"/>
        </filterset>
      </copy>
  
      <junit printSummary="yes" fork="true" dir="${basedir}"
        failureProperty="maven.cactus.test.failure">
  
        <formatter type="xml"/>
        <formatter type="plain" usefile="${maven.cactus.junit.usefile}"/>
        <classpath>
          <path refid="maven.dependency.classpath"/>
          <pathelement location="${maven.build.dest}"/>
          <pathelement location="${maven.cactus.classes.dir}"/>
          <pathelement location="${maven.cactus.build.resources.dir}"/>
          <pathelement path="${plugin.getDependencyPath('junit')}"/>
          <pathelement path="${plugin.getDependencyPath('cactus:cactus')}"/>
          <pathelement path="${plugin.getDependencyPath('commons-httpclient')}"/>
          <pathelement path="${plugin.getDependencyPath('commons-logging')}"/>
          <pathelement path="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
          <!-- These 2 jars should not be needed but it won't work without 
                 them -->
          <pathelement path="${plugin.getDependencyPath('xml-apis')}"/>
          <pathelement path="${plugin.getDependencyPath('xerces')}"/>
        </classpath>
        <batchtest todir="${maven.cactus.test.reportsDirectory}">
          <fileset dir="${maven.cactus.src.dir}"/>
        </batchtest>
  
      </junit>
  
      <j:if test="${maven.cactus.test.failure}">
        <j:set var="cactusignore__" value="${maven.cactus.test.failure.ignore}X"/>
        <j:if test="${cactusignore__ == 'X'}">
          <fail message="There were test failures."/>
        </j:if>
      </j:if>
  
    </goal>
  
  </project>
  
  
  1.10      +0 -0      jakarta-turbine-maven/src/plugins-build/cactus/maven.xml
  
  
  
  
  1.9       +82 -46    jakarta-turbine-maven/src/plugins-build/cactus/project.xml
  
  
  
  
  1.1                  
jakarta-turbine-maven/src/plugins-build/cactus/conf/web/jspRedirector.jsp
  
  Index: jspRedirector.jsp
  ===================================================================
  <%@page import="org.apache.cactus.server.*" session="true" %><%
  
      /**                                                
       * Note:
       * It is very important not to put any character between the end
       * of the page tag and the beginning of the java code expression, otherwise,
       * the generated servlet containss a 'out.println("\r\n");' and this breaks
       * our mechanism !
       */
  
      /**
       * This JSP is used as a proxy to call your server-side unit tests. We use
       * a JSP rather than a servlet because for testing custom JSP tags for
       * example we need access to JSP implicit objects (PageContext and
       * JspWriter).
       */
  
      JspImplicitObjects objects = new JspImplicitObjects();
      objects.setHttpServletRequest(request);
      objects.setHttpServletResponse(response);
      objects.setServletConfig(config);
      objects.setServletContext(application);
      objects.setJspWriter(out);
      objects.setPageContext(pageContext);
  
      JspTestRedirector redirector = new JspTestRedirector();
      redirector.doGet(objects);
  %>
  
  
  1.1                  
jakarta-turbine-maven/src/plugins-build/cactus/scripts/tomcat.4x.jelly
  
  Index: tomcat.4x.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    =============================================================================
      Script for running Cactus tests in Tomcat 4.x
    =============================================================================
  -->
  <project xmlns:j="jelly:core">
  
    <!--
       ========================================================================
         Run the Cactus tests in Tomcat 4.x
       ========================================================================
    -->
    <goal name="cactus:test-tomcat-4x"
      description="Run the Cactus tests in Tomcat 4.x">
  
      <j:set var="home" value="${maven.cactus.tomcat4x.home}X"/>
  
      <!-- Verify Tomcat home is defined -->
      <j:choose>
        <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"/>             
  
        </j:when>
        <j:otherwise>
                <echo>Property maven.cactus.tomcat4x.home is not defined</echo>
        </j:otherwise>
      </j:choose>
  
    </goal>
  
    <!--
       ========================================================================
         Run the tests
       ========================================================================
    -->
    <goal name="cactus:tomcat-4x-run" prereqs="cactus:tomcat-4x-setup">
  
      <!-- 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>
  
      <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>
  
    </goal>
  
    <!--
       ========================================================================
         Prepare directories and variables for running the tests
       ========================================================================
    -->
    <goal name="cactus:tomcat-4x-setup" prereqs="cactus:war">
  
      <!-- 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}"/>
        </filterset>
      </copy>
  
      <!-- Copy the Tomcat web.xml - We need to copy this file as it has
           changed between Tomcat 4.x versions and one version of it doesn't
           work with another version of Tomcat 4 -->
      <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.0
       ========================================================================
    -->
    <goal name="cactus:tomcat-4x-start">
  
      <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
  
        <jvmarg value="-Dcatalina.home=${maven.cactus.tomcat4x.home}"/>
        <jvmarg value="-Dcatalina.base=${maven.cactus.build.dir}/tomcat4x"/>
  
        <arg value="start"/>
        <classpath>
          <pathelement path="${java.home}/../lib/tools.jar"/>
          <fileset dir="${maven.cactus.tomcat4x.home}">
            <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
      </java>
  
    </goal>
  
    <!--
       ========================================================================
         Stop Tomcat 4.0
       ========================================================================
    -->
    <goal name="cactus:tomcat-4x-stop">
  
      <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
  
        <jvmarg value="-Dcatalina.home=${maven.cactus.tomcat4x.home}"/>
        <jvmarg value="-Dcatalina.base=${maven.cactus.build.dir}/tomcat4x"/>
  
        <arg value="stop"/>
  
        <classpath>
          <fileset dir="${maven.cactus.tomcat4x.home}">
            <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
      </java>
  
    </goal>
  
  </project>
  
  

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

Reply via email to