<!--

 Copyright 2002,2004 The Apache Software Foundation.
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

-->


<project name="Struts-Faces System Integration Test Client" default="compile" basedir=".">


  <!-- ===================== Initialize Property Values =================== -->


  <!-- Initialize property values -->
  <property file="build.properties"/>
  <property file="../../build.properties"/>
  <property file="../../../build.properties"/>
  <property file="${user.home}/build.properties"/>


  <!-- Dependency home directory defaults -->
  <property name="htmlunit.home"    value="/usr/local/htmlunit-1.2.3"/>
  <property name="jsf.home"         value="/usr/local/jsf-1_1"/>
  <property name="jstl.home"        value="/usr/local/standard-1.0.3"/>
  <property name="server.home"      value="/usr/local/jakarta-tomcat-5.0.25"/>
  <property name="struts.home"      value="/usr/local/jakarta-struts-1.1"/>


  <!-- Dependency library defaults -->
  <property name="commons-beanutils.jar"
                                    value="${struts.home}/lib/commons-beanutils.jar"/>
  <property name="commons-collections.jar"
                                    value="${struts.home}/lib/commons-collections.jar"/>
  <property name="commons-digester.jar"
                                    value="${struts.home}/lib/commons-digester.jar"/>
  <property name="commons-fileupload.jar"
                                    value="${struts.home}/lib/commons-fileupload.jar"/>
  <property name="commons-logging.jar"
                                    value="${struts.home}/lib/commons-logging.jar"/>
  <property name="commons-validator.jar"
                                    value="${struts.home}/lib/commons-validator.jar"/>
  <property name="jakarta-oro.jar"  value="${struts.home}/lib/jakarta-oro.jar"/>
  <property name="jsf-api.jar"      value="${jsf.home}/lib/jsf-api.jar"/>
  <property name="jsf-impl.jar"     value="${jsf.home}/lib/jsf-impl.jar"/>
  <property name="jsp-api.jar"      value="${server.home}/common/lib/jsp-api.jar"/>
  <property name="jstl.jar"         value="${jstl.home}/lib/jstl.jar"/>
  <property name="servlet.jar"      value="${server.home}/common/lib/servlet.jar"/>
  <property name="standard.jar"     value="${jstl.home}/lib/standard.jar"/>
  <property name="struts.jar"       value="${struts.home}/lib/struts.jar"/>


  <!-- Conditional Processing Flags -->
  <available                     property="jsfri.present"
                                classname="com.sun.faces.RIConstants"
                                classpath="${jsf-impl.jar}"/>
  <available                     property="myfaces.present"
                                classname="net.sourceforge.myfaces.config.MyfacesConfig"
                                classpath="${jsf-impl.jar}"/>

  <!-- Build Defaults -->
  <property name="build.home"      value="${basedir}/target"/>
  <property name="project.name"    value="Struts-Faces System Integration Test Client"/>
  <property name="project.package" value="org.apache.struts.faces"/>
  <property name="project.version" value="1.0-dev"/>


  <!-- Compile Defaults -->
  <property name="compile.debug"           value="true"/>
  <property name="compile.deprecation"     value="false"/>
  <property name="compile.optimize"        value="true"/>


  <!-- Construct Classpath -->
  <path id="classpath">
    <pathelement location="${commons-beanutils.jar}"/>
    <pathelement location="${commons-collections.jar}"/>
    <pathelement location="${commons-digester.jar}"/>
    <pathelement location="${commons-logging.jar}"/>
    <pathelement location="${commons-validator.jar}"/>
    <pathelement location="${jsf-api.jar}"/>
    <pathelement location="${jsp-api.jar}"/>
    <pathelement location="${jstl.jar}"/>
    <pathelement location="${servlet.jar}"/>
    <pathelement location="${struts.jar}"/>
    <pathelement location="${build.home}/classes"/>
  </path>

  <!-- System Integration Test Client Classpath -->
  <path id="sysclient.classpath">
    <pathelement location="${junit.jar}"/>
    <fileset          dir="${htmlunit.home}/lib"
                 includes="*.jar"/>
    <pathelement location="${build.home}/classes"/>
  </path>

  <property name="systest.path"         value="/struts-faces-systest1"/>


  <!-- System Integration Test Settings -->
  <property name="systest.state.saving" value="server"/>
  <property name="systest.url"          value="http://localhost:8080${systest.path}"/>



  <!-- ===================== Maintenance Targets ========================= -->


  <target name="clean"
   description="Clean all build directories">
    <delete dir="${build.home}"/>
    <delete dir="${dist.home}"/>
  </target>


  <target name="init">
    <echo message="---------- ${project.name} ${project.version} ----------"/>
    <filter token="name"     value="${project.name}"/>
    <filter token="package"  value="${project.package}"/>
    <filter token="state"    value="${systest.state.saving}"/>
    <filter token="version"  value="${project.version}"/>
    <echo message="jsf-api.jar =    ${jsf-api.jar}"/>
    <echo message="jsf-impl.jar =   ${jsf-impl.jar}"/>
    <echo message="struts-jar =     ${struts.jar}"/>
    <echo message="jsfri.present =  ${jsfri.present}"/>
    <echo message="myfaces.present= ${myfaces.present}"/>
  </target>


  <target name="static" depends="init">
    <mkdir    dir="${build.home}"/>
    <mkdir    dir="${build.home}/classes"/>
  </target>


  <!-- ======================= Test Client Execution ======================= -->


  <target name="compile" depends="static"
   description="Prepare system integration test client">

    <!-- Compile Java Sources -->
    <javac      srcdir="src/java"
               destdir="${build.home}/classes"
                 debug="${compile.debug}"
           deprecation="${compile.deprecation}"
              optimize="${compile.optimize}">
      <classpath refid="sysclient.classpath"/>
    </javac>

    <!-- Copy non-Java Sources -->
    <copy        todir="${build.home}/src/java">
      <fileset     dir="src/java">
        <exclude  name="**/*.java"/>
      </fileset>
    </copy>

  </target>


  <target name="test" depends="compile"
   description="Execute system integration test client">

    <junit         fork="yes"
           printSummary="yes"
            haltonerror="yes"
          haltonfailure="yes">

      <classpath  refid="sysclient.classpath"/>
      <formatter   type="plain"
                usefile="false"/>
      <sysproperty  key="systest"
                  value="${systest.url}"/>

      <batchtest>
        <fileset    dir="${build.home}/classes"
               excludes="**/AbstractTestCase.class"
               includes="**/*TestCase.class"/>
      </batchtest>

    </junit>

  </target>


</project>
