<!-- Copyright 2004-2005 The Apache Software Foundation. -->
<project name="redirector" basedir=".">

  <target name="test1" description="create ref">
    <redirector id="test1" output="out" />
  </target>

  <target name="test2" depends="test1" description="fail">
    <redirector refid="test1" output="out" />
  </target>

  <target name="test3" depends="test1" description="fail">
    <redirector refid="test1">
      <outputmapper type="flatten" />
    </redirector>
  </target>

  <target name="test4" depends="test1" description="pass">
    <redirector>
      <outputmapper type="flatten" />
    </redirector>
  </target>

  <target name="testLogInputString" depends="cat-check" if="can-cat">
    <echo>
        testLogInputString can-cat
    </echo>
    <exec executable="cat">
      <redirector inputstring="foo" loginputstring="false" />
    </exec>
  </target>

  <target name="testRefid" depends="cat-check" if="can-cat">
    <fail message="Property testRefid.out is already set!">
      <condition>
        <isset property="testRefid.out" />
      </condition>
    </fail>
    <redirector id="r" outputproperty="testRefid.out" inputstring="foo" />
    <exec executable="cat">
      <redirector refid="r" />
    </exec>
    <fail>
      <condition>
        <not>
          <equals arg1="${testRefid.out}" arg2="foo" />
        </not>
      </condition>
    </fail>
  </target>

  <target name="cat-check">
    <property environment="env" />
    <condition property="can-cat">
      <or>
        <available file="cat" filepath="${env.PATH}" property="can-cat" />
        <available file="cat.exe" filepath="${env.PATH}" property="can-cat" />
        <available file="cat.exe" filepath="${env.Path}" property="can-cat" />
      </or>
    </condition>
  </target>

</project>
