<?xml version="1.0"?>
<project default="cleanup" basedir=".">

  <target name="init">
    <mkdir dir="result" />
    <echo file="result/prepend.txt" message="this-should-be-the-first-line${line.separator}"/>
    <echo file="result/append.txt" message="this-should-be-the-last-line${line.separator}"/>
    <copy file="input/head-tail.test" tofile="input/concatfilter.test"/>
    <fixcrlf srcDir="input" includes="concatfilter.test"/>
    <!-- to be consistent on MacOS X.  fixcrlf uses CR while line.sep is LF -->
    <fixcrlf srcDir="result" includes="append.txt,prepend.txt"/>
  </target>

  <target name="cleanup">
    <delete dir="result"/>
    <delete>
      <fileset dir="input" includes="concatfilter.test"/>
    </delete>
  </target>


  <target name="testFilterReaderNoArgs" depends="init">
    <copy file="input/concatfilter.test"
          tofile="result/concat.FilterReaderNoArgs.test">
      <filterchain>
        <filterreader classname="org.apache.tools.ant.filters.ConcatFilter"/>
      </filterchain>
    </copy>
  </target>

  <target name="testFilterReaderPrepend" depends="init">
    <copy file="input/concatfilter.test"
          tofile="result/concat.FilterReaderPrepend.test">
      <filterchain>
        <filterreader classname="org.apache.tools.ant.filters.ConcatFilter">
          <param name="prepend" value="result/prepend.txt"/>
        </filterreader>
      </filterchain>
    </copy>
  </target>

  <target name="testFilterReaderAppend" depends="init">
    <copy file="input/concatfilter.test"
          tofile="result/concat.FilterReaderAppend.test">
      <filterchain>
        <filterreader classname="org.apache.tools.ant.filters.ConcatFilter">
          <param name="append" value="result/append.txt"/>
        </filterreader>
      </filterchain>
    </copy>
  </target>

  <target name="testFilterReaderPrependAppend" depends="init">
    <copy file="input/concatfilter.test"
          tofile="result/concat.FilterReaderPrependAppend.test">
      <filterchain>
        <filterreader classname="org.apache.tools.ant.filters.ConcatFilter">
          <param name="prepend" value="result/prepend.txt"/>
          <param name="append"  value="result/append.txt"/>
        </filterreader>
      </filterchain>
    </copy>
  </target>

  <target name="testConcatFilter" depends="init">
    <typedef name="concatfilter" classname="org.apache.tools.ant.filters.ConcatFilter"/>
    <copy file="input/concatfilter.test"
          tofile="result/concat.ConcatFilter.test">
      <filterchain>
        <concatfilter/>
      </filterchain>
    </copy>
  </target>

  <target name="testConcatFilterPrepend" depends="init">
    <typedef name="concatfilter" classname="org.apache.tools.ant.filters.ConcatFilter"/>
    <copy file="input/concatfilter.test"
          tofile="result/concat.ConcatFilterPrepend.test">
      <filterchain>
        <concatfilter prepend="result/prepend.txt"/>
      </filterchain>
    </copy>
  </target>

  <target name="testConcatFilterAppend" depends="init">
    <typedef name="concatfilter" classname="org.apache.tools.ant.filters.ConcatFilter"/>
    <copy file="input/concatfilter.test"
          tofile="result/concat.ConcatFilterAppend.test">
      <filterchain>
        <concatfilter append="result/append.txt"/>
      </filterchain>
    </copy>
  </target>

  <target name="testConcatFilterPrependAppend" depends="init">
    <typedef name="concatfilter" classname="org.apache.tools.ant.filters.ConcatFilter"/>
    <copy file="input/concatfilter.test"
          tofile="result/concat.ConcatFilterPrependAppend.test">
      <filterchain>
        <concatfilter prepend="result/prepend.txt" append="result/append.txt"/>
      </filterchain>
    </copy>
  </target>

</project>