<?xml version="1.0"?>

<project name="test-cactifywar" basedir="." default="help">

  <property name="work.dir" location="${basedir}/work"/>

  <target name="setUp">
    <mkdir dir="${work.dir}"/>
  </target>

  <target name="testNeitherSrcFileNorVersionSet">
    <cactifywar destfile="destfile.war"/>
  </target>

  <target name="testDestFileNotSet">
    <cactifywar srcfile="empty.war"/>
  </target>

  <target name="testSrcFileWithoutWebXml">
    <cactifywar srcfile="nowebxml.war"
        destfile="${work.dir}/destfile.war"/>
  </target>

  <target name="testSrcFileWithoutWebXmlNewWebXml22">
    <cactifywar srcfile="nowebxml.war" version="2.2"
        destfile="${work.dir}/destfile.war"/>
  </target>
  
  <target name="testSrcFileWithoutWebXmlNewWebXml23">
    <cactifywar srcfile="nowebxml.war" version="2.3"
        destfile="${work.dir}/destfile.war"/>
  </target>
  
  <target name="testDefaultRedirectorsNoDoctype">
    <cactifywar srcfile="empty.war"
        destfile="${work.dir}/destfile.war"/>
  </target>

  <target name="testDefaultRedirectors22Doctype">
    <cactifywar srcfile="empty-2_2.war"
        destfile="${work.dir}/destfile.war"/>
  </target>

  <target name="testDefaultRedirectors23Doctype">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war"/>
  </target>

  <target name="testDefaultRedirectorsNewWar22">
    <cactifywar version="2.2"
        destfile="${work.dir}/destfile.war"/>
  </target>

  <target name="testDefaultRedirectorsNewWar23">
    <cactifywar version="2.3"
        destfile="${work.dir}/destfile.war"/>
  </target>

  <target name="testCustomServletRedirectorMapping">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war">
      <servletredirector mapping="/test/servletRedirector"/>
    </cactifywar>
  </target>

  <target name="testCustomJspRedirectorMapping">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war">
      <jspredirector mapping="/test/jspRedirector"/>
    </cactifywar>
  </target>

  <target name="testCustomFilterRedirectorMapping">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war">
      <filterredirector mapping="/test/filterRedirector"/>
    </cactifywar>
  </target>

  <target name="testCustomFilterRedirectorMappingIgnored">
    <cactifywar srcfile="empty-2_2.war"
        destfile="${work.dir}/destfile.war">
      <filterredirector mapping="/test/filterRedirector"/>
    </cactifywar>
  </target>

  <target name="testMultipleNamedServletRedirectors">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war">
      <servletredirector name="ServletRedirector"
          mapping="/test/ServletRedirector"/>
      <servletredirector name="ServletRedirectorSecure"
          mapping="/test/ServletRedirectorSecure"/>
    </cactifywar>
  </target>

  <target name="testMultipleNamedJspRedirectors">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war">
      <jspredirector name="JspRedirector"
          mapping="/test/JspRedirector"/>
      <jspredirector name="JspRedirectorSecure"
          mapping="/test/JspRedirectorSecure"/>
    </cactifywar>
  </target>

  <target name="testMultipleNamedFilterRedirectors">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war">
      <filterredirector name="FilterRedirector"
          mapping="/test/FilterRedirector"/>
      <filterredirector name="FilterRedirectorSecure"
          mapping="/test/FilterRedirectorSecure"/>
    </cactifywar>
  </target>

  <target name="testSecuredServletRedirector">
    <cactifywar srcfile="empty-2_3.war"
        destfile="${work.dir}/destfile.war">
      <servletredirector name="ServletRedirectorSecure"
          mapping="/ServletRedirectorSecure"
          roles="test, cactus"/>
    </cactifywar>
  </target>

  <target name="testLoginConfigNotOverwritten">
    <cactifywar srcfile="formloginconfig.war"
        destfile="${work.dir}/destfile.war">
      <servletredirector name="ServletRedirectorSecure"
          mapping="/ServletRedirectorSecure"
          roles="test"/>
    </cactifywar>
  </target>

  <target name="testNoDuplicateJars">
    <cactifywar srcfile="containscactusjars.war"
        destfile="${work.dir}/destfile.war"/>
  </target>

  <target name="testAddWeblogicEjbRefs">
    <cactifywar srcfile="weblogic.war"
        destfile="${work.dir}/destfile.war">
        <ejbref name="MyEjb" 
                localInterface="com.wombat.MyEjb" 
                localHomeInterface="com.wombat.MyEjbHome"
                jndiName="/wombat/MyEjb"
                type="Session"/>
    </cactifywar>
  </target>

  <target name="tearDown">
    <delete dir="${work.dir}"/>
  </target>

</project>
