dwinterfeldt    01/07/06 22:31:18

  Added:       contrib/validator INSTALL LICENSE README build.xml
                        build.properties build-test.xml
  Log:
  Adding Struts Validator to cvs.
  
  Revision  Changes    Path
  1.1                  jakarta-struts/contrib/validator/INSTALL
  
  Index: INSTALL
  ===================================================================
  Struts Validator
  ==================
  The Struts Validator Jar (dist/Struts_Validator-{date}.jar) and version 1.2 of the 
  Jakarta Regular Expression Package (http://jakarta.apache.org/regexp) needs to be 
  added to /WEB-INF/lib.
  
       This needs to be added to the web.xml file to load the ValidatorServlet. 
       <servlet> 
          <servlet-name>validator</servlet-name> 
          <servlet-class>com.wintecinc.struts.action.ValidatorServlet</servlet-class> 
          <init-param> 
            <param-name>config</param-name> 
            <param-value>/WEB-INF/validation.xml</param-value> 
          </init-param> 
          <init-param> 
            <param-name>debug</param-name> 
            <param-value>2</param-value> 
          </init-param> 
          <load-on-startup>2</load-on-startup> 
       </servlet> 
  
  Add the error messages to your ApplicationResources.properties file for the 
pluggable validators that you
  are using in your project. Make sure that you have errors.header & errors.footer in 
it if you are going to use
  the Struts' html:errors tag. If you use the Validator errors tag then the header and 
the footer are optional and
  configurable as to what message resource key is used to create the header and the 
footer. The message
  resource key a pluggable validator uses to create an error message is configurable 
in the validation.xml file by
  modifying the pluggable validator's msg attribute. 
     Example Error Messages:
        errors.required=<li>{0} is required.</li>
        errors.invalid=<li>{0} is invalid.</li>
  
  Copy the validators that you want to use from the validation.xml file in 
/web/example/WEB-INF or make
  your own. 
  
  
  1.1                  jakarta-struts/contrib/validator/LICENSE
  
  Index: LICENSE
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  
  
  
  
  
  
  
  1.1                  jakarta-struts/contrib/validator/README
  
  Index: README
  ===================================================================
  Struts Validator
  ==================
  You must do the following to have the build script work.
  
  1. Edit the build.properties file.
  2. Add the follwing to the lib directory.
       Struts - struts.jar (http://jakarta.apache.org/struts/)
       Jakarata Regexp - jakarta-regexp.jar (http://jakarta.apache.org/regexp/)
       JDBC 2.0 Optonal Package - jdbc2_0-stdext.jar 
(http://java.sun.com/products/jdbc/download.html#spec)
  3. Place the following Struts tlds from the Struts download in 'struts/WEB-INF/tlds'.
      (struts-bean.tld  struts-html.tld  struts-logic.tld  struts-template.tld)
  
  Overview
  ---------
  The Validation Framework was made to work with Struts. It can perform basic 
validations to check if a field
  is required, matches a regular expression, email, credit card, and server side type 
checking and date
  validation. Different validation rules can be defined for different locales. The 
framework has basic support for
  user defined constants which can be used in some field attributes. The validation 
routines are modifiable in
  the validation.xml file so custom validation routines can be created and added to 
the framework. 
  
  
  
  1.1                  jakarta-struts/contrib/validator/build.xml
  
  Index: build.xml
  ===================================================================
  <!--
     You will need Ant setup properly and have the commons-cactus-ant.jar in the 
classpath.  The build.properties file 
     will need to be edited to point to some jar files, java.home, and the application 
servers you want to 
     run the tests on.
  -->
  <project name="Struts Validator" default="javadocs" basedir=".">
    <!-- set global properties for this build -->
    <property file="build.properties"/>
    
    <property name="title" value="Struts Validator" />
    <property name="name" value="Struts_Validator" />
    <property name="src" value="src" />
    <property name="share" value="share" />
    <property name="example" value="example" />
    <property name="jdbc.example" value="jdbc-example" />
    <property name="web"  value="web" />
    <property name="webapps"  value="webapps" />
    <property name="build" value="build" />
    <property name="build.javadocs" value="docs/api" />
    <property name="dist"  value="dist" />
    <property name="package.root" value="com/wintecinc/struts"/>
    <property name="package" value="com/wintecinc/struts/action"/>
    <property name="package.example" value="com/wintecinc/struts/example/validator"/>
    <property name="package.jdbc.example" 
value="com/wintecinc/struts/example/validator/jdbc"/>
    <property name="package.test" value="com/wintecinc/test"/>
                                                          
    <target name="prepare">
      <!-- Create the time stamp -->
      <tstamp/>
      <!-- Create the build directory structure used by compile -->
      <mkdir dir="${build}" />
    </target>
  
    <target name="compile" depends="prepare">
      <!-- Compile the java code from ${src} into ${build} -->
      <javac srcdir="${src}/${share}" 
             destdir="${build}"
             excludes="${package.example}/**">
         <classpath>
            <pathelement path="${servlet.jar}"/>
            <fileset dir="lib">
               <include name="**/*.jar" />
            </fileset>
         </classpath>      
      </javac>
    </target>
  
    <target name="dist" depends="compile">
      <!-- Create the ${dist}/lib directory -->
      <mkdir dir="${dist}" />
  
      <!-- Put everything in ${build} into the Editor-${DSTAMP}.jar file -->
      <!-- <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}" /> 
-->
      <jar jarfile="${dist}/${name}-${DSTAMP}.jar" 
           basedir="${build}" 
           includes="${package.root}/**"
           excludes="${package.example}/**,${package.test}/"/>
    </target>
  
    <target name="compile_example" depends="dist">
      <!-- Compile the java code from ${src}/${example} into ${build} -->
      <javac srcdir="${src}/${example}" 
             destdir="${build}">
         <classpath>
            <pathelement path="${servlet.jar}"/>
            <pathelement location="${cactus.jar}"/>
            <pathelement path="${dist}/${name}-${DSTAMP}.jar" />
            <fileset dir="lib">
               <include name="**/*.jar" />
            </fileset>
         </classpath>      
      </javac>
  
      <!-- Compile the java code from ${src}/${jdbc.example} into ${build} -->
      <javac srcdir="${src}/${jdbc.example}" 
             destdir="${build}">
         <classpath>
            <pathelement path="${servlet.jar}"/>
            <pathelement path="${dist}/${name}-${DSTAMP}.jar" />
            <fileset dir="lib">
               <include name="**/*.jar" />
            </fileset>
         </classpath>      
      </javac>
  
    </target>
  
    <target name="copy_example" depends="compile_example">
       <copy todir="${build}" >
         <fileset dir="${src}/${example}" 
                  includes="cactus.properties,${package.example}/*,${package.test}/" 
                  excludes="**/*.java" 
         />
       </copy>
  
       <copy todir="${build}" >
         <fileset dir="${src}/${jdbc.example}" 
                  includes="${package.jdbc.example}/*" 
                  excludes="**/*.java" 
         />
       </copy>
  
       <copy todir="${web}/${example}/WEB-INF/tlds" >
         <fileset dir="${dist}" 
                  includes="struts-validator.tld"/>
       </copy>
  
       <copy todir="${web}/${jdbc.example}/WEB-INF/tlds" >
         <fileset dir="${dist}" 
                  includes="struts-validator.tld"/>
       </copy>
  
    </target>
      
    <target name="war" depends="copy_example">
      
      <war warfile="${webapps}/validator.war" 
webxml="${web}/${example}/WEB-INF/web.xml">
        <fileset dir="${web}/${example}">
           <include name="**/**" />
           <exclude name="WEB-INF/web.xml" />
        </fileset>
        <fileset dir="struts">
           <include name="**/**" />
        </fileset>
        <lib dir="lib">
          <exclude name="jdbc2_0-stdext.jar" />
        </lib>
        <lib dir="${dist}">
           <include name="${name}-${DSTAMP}.jar" />
        </lib>
        <classes dir="${build}">
           <include name="${package.example}/**" />
           <include name="${package.test}/" />
        </classes>
      </war>
  
      <war warfile="${webapps}/jdbc-validator.war" 
webxml="${web}/${jdbc.example}/WEB-INF/web.xml">
        <fileset dir="${web}/${jdbc.example}">
           <include name="**/**" />
           <exclude name="WEB-INF/web.xml" />
        </fileset>
        <fileset dir="struts">
           <include name="**/**" />
        </fileset>
        <lib dir="lib">
          <exclude name="jdbc2_0-stdext.jar" />
        </lib>
        <lib dir="${dist}">
           <include name="${name}-${DSTAMP}.jar" />
        </lib>
        <classes dir="${build}">
           <include name="${package.jdbc.example}/**" />
        </classes>
      </war>
      
    </target>
  
    <target name="javadocs" depends="war" description="Creates the API documentation">
      <mkdir dir="${build.javadocs}"/>
      <javadoc packagenames="com.wintecinc.struts.action.*, 
                             com.wintecinc.struts.taglib.html.*,
                             com.wintecinc.struts.validation.*"
             sourcepath="${src}/${share}"
               destdir="${build.javadocs}"
               author="true"
               version="true"
               windowtitle="${title} API"
               doctitle="${title}">
         <classpath>
            <pathelement path="${servlet.jar}"/>
            <fileset dir="lib">
               <include name="**/*.jar" />
            </fileset>
         </classpath>    
      </javadoc>
    </target>
  
  <!--
          Run tests on all servers not commented out in the build.properties file.
  -->
      <target name="test.all" depends="tests_tomcat_32,tests_tomcat_40">
      </target>
  
      <!-- 
         ========================================================================
           Display a warning message if the needed servlet engine home property
           is not set
         ========================================================================
      -->
      <target name="check_tests_tomcat_32" depends="war" unless="tomcat.home.32">
  
          <echo message=""/>
          <echo message="*********************************************************"/>
          <echo message="WARNING : The 'tomcat.home.32' property has not been set."/>
          <echo message="          No test will be run on that servlet engine."/>
          <echo message="*********************************************************"/>
          <echo message=""/>
  
      </target>
      
      <target name="tests_tomcat_32" depends="check_tests_tomcat_32" 
if="tomcat.home.32">
  
          <echo message="tomcat.home.32 = ${tomcat.home.32}"/>
          
          <ant antfile="build-test.xml" target="tests_tomcat_32"/>
      
      </target>
  
      <!-- 
         ========================================================================
           Display a warning message if the needed servlet engine home property
           is not set
         ========================================================================
      -->
      <target name="check_tests_tomcat_40" depends="war" unless="tomcat.home.40">
  
          <echo message=""/>
          <echo message="*********************************************************"/>
          <echo message="WARNING : The 'tomcat.home.40' property has not been set."/>
          <echo message="          No test will be run on that servlet engine."/>
          <echo message="*********************************************************"/>
          <echo message=""/>
  
      </target>
      
      <target name="tests_tomcat_40" depends="check_tests_tomcat_40" 
if="tomcat.home.40">
  
          <echo message="tomcat.home.40 = ${tomcat.home.40}"/>
          
          <ant antfile="build-test.xml" target="tests_tomcat_40"/>
      
      </target>
    
  </project>
  
  
  
  
  1.1                  jakarta-struts/contrib/validator/build.properties
  
  Index: build.properties
  ===================================================================
  # Properties related to the user's environment. This file should be provided
  # for building the Cactus Sample or the properties need to be specified on
  # the command line when starting Ant with the -D switch
  
  java.home=d:/jdk1.3
  servlet.jar=e:/tomcat3/lib/servlet.jar
  cactus.jar=e:/software/cactus/lib/commons-cactus.jar
  cactus.ant.jar=e:/software/cactus/lib/commons-cactus-ant.jar
  junit.jar=e:/software/junit3.5/junit.jar
  struts.jar=lib/struts_1_0.jar
  
  # Shouldn't be necessary, there is a problem with my ant setup
  ant.jar=e:/software/ant/lib/ant.jar
  ant.optional.jar=e:/software/ant/lib/optional.jar
  
  # Servlet engine locations for the tests
  
  # Note: If you don't want to run the test on a given servlet engine, just
  #       comment it's home property. For example, if you don't want to run the
  #       tests on the Resin 1.3, comment the "resin.home.13" property.
  #resin.home.13 = f:/applis/resin-1.3.s010125
  tomcat.home.32 = e:/tomcat3
  tomcat.home.40 = e:/tomcat
  
  
  
  
  1.1                  jakarta-struts/contrib/validator/build-test.xml
  
  Index: build-test.xml
  ===================================================================
  <project name="Struts Unit Tests" default="compile" basedir=".">
  
      <!-- Global test initialization - independent of Server type -->
      <target name="init">
          <property name="struts.jar" value="${build.home}/library/${app.name}.jar" />
          <property name="server.root" value="${basedir}/test" />
          <property name="test.conf" value="conf/test/tomcat" />
          <property name="test.root" value="test" />
  
          <!-- Filters -->
          <filter token="server.root" value="${server.root}"/>
          
          <!--
          <mkdir dir="dist/conf"/>
          <delete dir="${test.root}"/>
          <mkdir dir="${test.root}/webapps/test"/>
          -->
          
          <taskdef name="startserver" 
classname="org.apache.commons.cactus.ant.StartServerTask"/>
          <taskdef name="stopserver" 
classname="org.apache.commons.cactus.ant.StopServerTask"/>
          <taskdef name="runservertests" 
classname="org.apache.commons.cactus.ant.RunServerTestsTask"/>
          <taskdef name="junit" 
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
      </target>
  
      <target name="prepare_tests" depends="init">
         <property name="test.webapp.dir" value="${test.root}/webapps/validator" />
         
         <!-- <delete dir="${test.webapp.dir}"/> -->
         
         <unzip src="webapps/validator.war" dest="${test.webapp.dir}" />
         
         <copy file="${cactus.jar}" todir="${test.webapp.dir}/WEB-INF/lib"/>
      
      </target>
      
  
      <!-- =================================================================== -->
      <!-- Tomcat 3.2                                                          -->
      <!-- =================================================================== -->
      <target name="prepare_tests_tomcat_32" depends="prepare_tests" 
if="tomcat.home.32">
  
          <echo message="tomcat.home.32 = ${tomcat.home.32}"/>
  
          <delete file="test/conf/testserver-32.xml"/>
          <copy file="${test.conf}/testserver-32.xml" todir="test/conf" 
filtering="on"/>
          
          <!-- <delete dir="dist/webapps/struts-example"/> -->
      
      </target>
  
      <!-- Run Tomcat 3.2 tests -->
      <target name="tests_tomcat_32" depends="prepare_tests_tomcat_32">
  
          <!-- 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.-->
  
          <runservertests testURL="http://localhost:8080";
              startTarget="start_tomcat_32"
              stopTarget="stop_tomcat_32"
              testTarget="tests"/>
  
      </target>
         
      <!-- Generic Start Tomcat for Tomcat 3.2 -->
      <target name="start_tomcat_32">
  
          <java classname="org.apache.tomcat.startup.Tomcat" fork="yes">
              <arg value="-config"/>
              <arg value="test/conf/testserver-32.xml"/>
              <classpath>
                <pathelement location="${java.home}/lib/tools.jar"/>
                <pathelement location="${junit.jar}"/>
                <fileset dir="${tomcat.home.32}/lib">
                    <include name="*.jar"/>
                </fileset>
              </classpath>
          </java>
  
      </target>
   
  
      <!-- Generic Stop Tomcat for Tomcat 3.2 -->
      <target name="stop_tomcat_32">
  
          <java classname="org.apache.tomcat.startup.Tomcat" fork="yes">
              <jvmarg value="-Dtomcat.home=${tomcat.home.32}"/>
              <arg value="-stop"/>
              <classpath>
                <pathelement location="${junit.jar}"/>
                <fileset dir="${tomcat.home.32}/lib">
                    <include name="*.jar"/>
                </fileset>
              </classpath>
          </java>
  
      </target>
  
      
      <!-- =================================================================== -->
      <!-- Tomcat 4.0                                                          -->
      <!-- =================================================================== -->
      <target name="prepare_tests_tomcat_40" depends="prepare_tests" 
if="tomcat.home.40">
  
          <echo message="tomcat.home.40 = ${tomcat.home.40}"/>
  
          <delete file="test/conf/testserver-40.xml"/>
          <copy file="${test.conf}/testserver-40.xml" todir="test/conf" 
filtering="on"/>
      
      </target>
      
      <target name="tests_tomcat_40" depends="prepare_tests_tomcat_40">
  
          <!-- 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 -->
  
          <runservertests testURL="http://localhost:8080";
              startTarget="start_tomcat_40"
              stopTarget="stop_tomcat_40"
              testTarget="tests"/>
  
      </target>
  
      <target name="start_tomcat_40">
  
          <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
              <jvmarg value="-Dcatalina.home=${tomcat.home.40}"/>
              <arg value="-config"/>
              <arg value="${basedir}/test/conf/testserver-40.xml"/>
              <arg value="start"/>
              <classpath>
                <pathelement location="${java.home}/lib/tools.jar"/>
                <pathelement location="${junit.jar}"/>
                <fileset dir="${tomcat.home.40}">
                    <include name="bin/bootstrap.jar"/>
                    <include name="server/catalina.jar"/>
                </fileset>
              </classpath>
          </java>
  
      </target>
  
      <target name="stop_tomcat_40">
  
          <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
              <jvmarg value="-Dcatalina.home=${tomcat.home.40}"/>
              <arg value="stop"/>
              <classpath>
                <fileset dir="${tomcat.home.40}">
                    <include name="bin/bootstrap.jar"/>
                    <include name="server/catalina.jar"/>
                </fileset>
              </classpath>
          </java>
  
      </target>
  
  
      <target name="tests" depends="">
  
          <junit printsummary="yes" haltonfailure="yes" fork="yes">
              <classpath>
                  <pathelement location="${servlet.jar}"/>
                  <pathelement location="${struts.jar}"/>
                  <pathelement location="${junit.jar}"/>
                  <pathelement location="${cactus.jar}"/>
                  <pathelement location="${build}"/>
                  
                  <!-- For cactus.properties -->
                  <pathelement location="conf/test"/>
                  
                  <!-- Why do I need Ant here? -->
                  <pathelement location="${ant.jar}"/>
                  <pathelement location="${ant.optional.jar}"/>
              </classpath>
  
              <formatter type="plain" usefile="false"/>
  
              <!-- Cactus J2EEUnit unit tests requiring servlet engine -->
              <test name="com.wintecinc.test.TestLoad"/>
              <test name="com.wintecinc.test.TestValidator"/>
              
              <!-- 
              <test name="org.apache.struts.action.TestConfigActionServlet"/> 
              -->
          </junit>
          
     </target>
  
  </project>
  
  
  

Reply via email to