You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by cm...@apache.org on 2003/07/07 22:16:23 UTC

cvs commit: jakarta-cactus/samples/jetty/src/webapp/WEB-INF web.xml

cmlenz      2003/07/07 13:16:23

  Added:       samples/jetty/src/script build.properties build.xml
               samples/jetty/src/conf jetty.xml
               samples/jetty/src/webapp/WEB-INF web.xml
  Log:
  Cleanup the jetty sample. Note: this is not working yet, the tests fail miserably because of classpath problems... still investigating
  
  Revision  Changes    Path
  1.1                  jakarta-cactus/samples/jetty/src/script/build.properties
  
  Index: build.properties
  ===================================================================
  # -----------------------------------------------------------------------------
  # build.properties.sample
  #
  # Use this file to ajust the build of the Cactus Jetty Sample to your local
  # environment. Specifically, you might want to define the port on which Jetty
  # will be started.
  #
  # $Id: build.properties,v 1.1 2003/07/07 20:16:22 cmlenz Exp $
  # -----------------------------------------------------------------------------
  
  # NOTE: The relative paths below are relative to the directory where the
  # build.xml file is located.
  
  # -----------------------------------------------------------------------------
  # Mandatory properties
  # -----------------------------------------------------------------------------
  
  # The location of the Cactus framework jar
  cactus.jar = ../../lib/@cactus.jar.name@
  
  # The location of the Junit jar
junit.jar = ../../lib/@junit.jar.name@
  
  # The location of the Commons Logging jar
  commons.logging.jar = ../../lib/@commons.logging.jar.name@
  
  # The location of the Commons Httpclient jar
  commons.httpclient.jar = ../../lib/@commons.httpclient.jar.name@
  
  # The location of the AspectJ runtime jar
aspectjrt.jar = ../../lib/@aspectjrt.jar.name@
  
  # The location of the Httpunit jar
  httpunit.jar = ../../lib/@httpunit.jar.name@
  
  # The location of the Servlet API 2.3 jar
servlet.jar = ../../lib/@servlet.jar.name@
  
  # The location of the Jetty jar
  jetty.jar = lib/@jetty.jar.name@
  
  # The location of the Jasper compiler jar
jasperc.jar = lib/@jasperc.jar.name@
  
  # The location of the Jasper runtime jar
jasperr.jar = lib/@jasperr.jar.name@
  
  # -----------------------------------------------------------------------------
  # Optional properties
  # -----------------------------------------------------------------------------
  
  # The location of the log4j jar (optional). Only needed if you want Cactus to
# generate logs
log4j.jar = ../../lib/log4j-1.2.7.jar
  
  # The port to use for starting the servers during unit testing. If not
  # sepcified, it defaults to port 8080.
  #test.port = 8081
  
  
  
  1.1                  jakarta-cactus/samples/jetty/src/script/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
    =============================================================================
      Build file for the Cactus Jetty Sample subproject (it shows how to use
      Cactus and Jelly in an integrated way for unit testing the Servlet API : 
      Servlets, Fitlers, Taglibs).
  
      The following Ant tasks need to be available in your ant installation (i.e.
      the Ant task themselves and their dependent jars need to be put in
      ANT_HOME/lib) :
  
          junit                  [REQUIRED] JUnit Ant task
  
      The mandatory and optional Ant properties are defined in
      build.properties.sample. Please read and edit that file.
  
      This script should be started with the following command line :
  
          ant <target>
  
      Run "ant -projecthelp" to get a list of available targets. The default
      target is "dist"
    =============================================================================
  -->
  <project name="Cactus Jetty Sample" default="test" basedir=".">
  
    <!-- Give user a chance to override without editing this file
         (and without typing -D each time it compiles it) -->
    <property file="build.properties" />
    <property file="${user.home}/build.properties" />
  
    <!-- Global project properties -->
    <property name="project.name.text" value="Cactus Jetty Sample"/>
    <property name="project.name.file" value="sample-jetty"/>
    <property name="project.version" value="@version@"/>
  
    <!-- Prefix to add to all distributable files -->
    <property name="project.prefix" value="jakarta-"/>
  
    <!-- Generic properties -->
    <property name="year" value="@year@"/>
    <property name="debug" value="on"/>
    <property name="optimize" value="off"/>
    <property name="deprecation" value="off"/>
  
    <!-- Properties for the Cactus tests -->
    <property name="cactus.port" value="8080"/>
  
    <!--
       ========================================================================
         Set the properties related to the source tree.
       ========================================================================
    -->
    <property name="src.dir" location="src"/>
    <property name="src.java.dir" location="${src.dir}/java"/>
    <property name="src.conf.dir" location="${src.dir}/conf"/>
    <property name="src.cactus.dir" location="${src.dir}/test-cactus"/>
    <property name="src.webapp.dir" location="${src.dir}/webapp"/>
  
    <!--
       ========================================================================
         Set the properties related to the target area
       ========================================================================
    -->
    <!-- Destination locations for the build -->
    <property name="target.dir" location="target"/>
    <property name="target.classes.dir" location="${target.dir}/classes"/>
    <property name="target.classes.java.dir"
        location="${target.classes.dir}/java"/>
    <property name="target.classes.cactus.dir"
        location="${target.classes.dir}/cactus"/>
    <property name="target.testreports.dir"
        location="${target.dir}/test-reports"/>
  
    <!-- Distribution directory, i.e. where the expanded distibutable files
         are located -->
    <property name="dist.dir" location="dist"/>
  
    <!--
       ========================================================================
         Set the properties related to the required libraries
       ========================================================================
    -->
  
    <!-- Libraries required for the sample project -->
    <property name="servlet.jar"
        location="../../lib/@servlet.jar.name@"/>
    <path id="project.classpath">
      <pathelement location="${servlet.jar}"/>
    </path>
  
    <!-- Libraries required for the Cactus tests -->
    <property name="aspectjrt.jar"
        location="../../lib/@aspectjrt.jar.name@"/>
    <property name="cactus.jar"
        location="../../lib/@cactus.jar.name@"/>
    <property name="commons.httpclient.jar"
        location="../../lib/@commons.httpclient.jar.name@"/>
    <property name="commons.logging.jar"
        location="../../lib/@commons.logging.jar.name@"/>
    <property name="jasperc.jar"
        location="lib/@jetty.jar.name@"/>
    <property name="jasperr.jar"
        location="lib/@jetty.jar.name@"/>
    <property name="jetty.jar"
        location="../../lib/@jetty.jar.name@"/>
    <property name="junit.jar"
        location="../../lib/@junit.jar.name@"/>
    <path id="cactus.classpath">
      <path refid="project.classpath"/>
      <pathelement location="${aspectjrt.jar}"/>
      <pathelement location="${cactus.jar}"/>
      <pathelement location="${commons.httpclient.jar}"/>
      <pathelement location="${commons.logging.jar}"/>
      <pathelement location="${jasperc.jar}"/>
      <pathelement location="${jasperr.jar}"/>
      <pathelement location="${jetty.jar}"/>
      <pathelement location="${junit.jar}"/>
    </path>
  
    <!--
       ========================================================================
         Initialize the build. Must be called by all targets
       ========================================================================
    -->
    <target name="init">
  
      <condition property="properties.ok">
        <and>
          <available file="${servlet.jar}"/>
        </and>
      </condition>
      <fail unless="properties.ok">Missing property or property pointing to an invalid file
  (check your build.properties file)</fail>
  
      <taskdef resource="cactus.tasks" classpathref="cactus.classpath"/>
  
      <tstamp/>
  
    </target>
  
    <!--
       ========================================================================
         Compiles the sources
       ========================================================================
    -->
    <!-- Compiles the java sources -->
    <target name="compile.java" depends="init">
  
      <mkdir dir="${target.classes.java.dir}"/>
      <javac destdir="${target.classes.java.dir}"
          deprecation="${deprecation}" optimize="${optimize}">
        <src path="${src.java.dir}"/>
        <classpath>
          <path refid="project.classpath"/>
        </classpath>
      </javac>
  
    </target>
  
    <!-- Compiles the Cactus test sources -->
    <target name="compile.cactus" depends="compile.java">
  
      <mkdir dir="${target.classes.cactus.dir}"/>
      <javac destdir="${target.classes.cactus.dir}"
          deprecation="${deprecation}" optimize="${optimize}">
        <src path="${src.cactus.dir}"/>
        <classpath>
          <path refid="cactus.classpath"/>
          <pathelement location="${httpunit.jar}"/>
          <pathelement location="${nekohtml.jar}"/>
          <pathelement location="${target.classes.java.dir}"/>
        </classpath>
      </javac>
  
    </target>
  
    <target name="compile" depends="compile.java, compile.cactus"
        description="Compile the sources"/>
  
    <!--
       ========================================================================
         Create the runtime war file
       ========================================================================
    -->
    <target name="war" depends="compile.java"
        description="Generate the runtime war">
  
      <war warfile="${target.dir}/${project.name.file}.war"
           webxml="${src.webapp.dir}/WEB-INF/web.xml">
        <classes dir="${target.classes.java.dir}"/>
      </war>
  
    </target>
  
    <!--
       ========================================================================
         Generate the distributable files
       ========================================================================
    -->
    <target name="dist" depends="clean, war, test"
        description="Generate the distributable files">
  
      <copy todir="${dist.dir}"
          file="${target.dir}/${project.name.file}.war"/>
  
    </target>
  
    <!--
       ========================================================================
         Clean generated files (including distributables)
       ========================================================================
    -->
    <target name="clean" depends="init" description="Clean all generated files">
  
      <delete dir="${target.dir}"/>
      <delete dir="${dist.dir}"/>
  
    </target>
  
    <!--
       ========================================================================
         Run the tests on Jetty.
       ========================================================================
    -->
    <target name="test" depends="compile">
  
      <mkdir dir="${target.testreports.dir}"/>
  
      <junit fork="no" failureproperty="tests.failed">
        <sysproperty key="cactus.contextURL"
            value="http://localhost:${cactus.port}/test"/>
        <sysproperty key="cactus.jetty.resourceDir" file="${src.webapp.dir}"/>
        <sysproperty key="cactus.initializer"
            value="org.apache.cactus.extension.jetty.JettyInitializer"/>
        <sysproperty key="cactus.jetty.config" file="${src.conf.dir}/jetty.xml"/>
        <classpath>
          <path refid="cactus.classpath"/>
          <pathelement location="${target.classes.java.dir}"/>
          <pathelement location="${target.classes.cactus.dir}"/>
        </classpath>
        <formatter type="brief" usefile="false"/>
        <formatter type="xml"/>
        <batchtest todir="${target.testreports.dir}">
          <fileset dir="${src.cactus.dir}">
            <include name="**/sample/Test*.java"/>
          </fileset>
        </batchtest>
      </junit>
  
      <junitreport todir="${target.testreports.dir}">
        <fileset dir="${target.testreports.dir}" includes="TEST-*.xml"/>
        <report todir="${target.testreports.dir}" format="frames"/>
      </junitreport>
  
      <fail if="tests.failed">At least one test failed!</fail>
  
    </target>
  
  </project>
  
  
  
  1.1                  jakarta-cactus/samples/jetty/src/conf/jetty.xml
  
  Index: jetty.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.1//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
  
  <Configure class="org.mortbay.jetty.Server">
  
    <Call name="getContext">
      <Arg>/test</Arg>
  
      <Call name="getWebApplicationHandler">
        <Call name="getServletHolder">
        	<Arg>ServletRedirector</Arg>
          <Call name="setInitParameter">
            <Arg>param1</Arg>
            <Arg>value1 used for testing</Arg>
          </Call>
        </Call>
      </Call>
  
      <Call name="getWebApplicationHandler">
        <Call name="getServletHolder">
          <Arg>JspRedirector</Arg>
          <Call name="setInitParameter">
            <Arg>param1</Arg>
            <Arg>value1 used for testing</Arg>
          </Call>
        </Call>
      </Call>
  
      <Call name="getServletHandler">
        <Call name="newServletHolder">
          <Arg>TestJsp</Arg>
          <Arg>org.apache.jasper.servlet.JspServlet</Arg>
          <Arg>/test/test.jsp</Arg>
        </Call>
      </Call>
  
      <Call name="addServlet">
        <Arg>/ServletRedirectorOverride</Arg>
        <Arg>org.apache.cactus.server.ServletTestRedirector</Arg>
        <Call name="setInitParameter">
        	<Arg>param2</Arg>
        	<Arg>value2 used for testing</Arg>
        </Call>
      </Call>
      
      <Call name="addServlet">
        <Arg>/ServletRedirectorSecure</Arg>
        <Arg>org.apache.cactus.server.ServletTestRedirector</Arg>
      </Call>
    
      <Call name="setRealm">
        <Arg>
          <New class="org.mortbay.http.HashUserRealm"/>
        </Arg>
      </Call>
      
      <Call name="getRealm">
        <Call name="put">
          <Arg>testuser</Arg>
          <Arg>testpassword</Arg>
        </Call>
        <Call name="addUserToRole">
          <Arg>testuser</Arg>
          <Arg>test</Arg>
        </Call>
      </Call>
    </Call>
  </Configure>
   
    
    
  
  
  1.1                  jakarta-cactus/samples/jetty/src/webapp/WEB-INF/web.xml
  
  Index: web.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>
  
    <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>
      <realm-name>Sample Cactus Servlet Application</realm-name>
    </login-config>
  
    <security-role>
      <description>Test role</description>
      <role-name>test</role-name>
    </security-role>
  
  </web-app>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org