<?xml version="1.0"?>

<project name="xxx-test" basedir="." default="test1">

  <target name="cleanup">
    <delete file="asf-logo.gif" />
    <delete file="unziptest.zip"/>
    <delete dir="unziptestin"/>
    <delete dir="unziptestout"/>
  </target>

  <target name="test1">
    <unzip/>
  </target>

  <target name="test2">
    <unzip src=""/>
  </target>

  <target name="test3">
    <unzip dest=""/>
  </target>

  <target name="testZipTask">
    <ant antfile="zip.xml" target="feather" />
    <unzip src="asf-logo.gif.zip" dest="." />
    <ant antfile="zip.xml" target="cleanup" />
  </target>

  <target name="testUncompressedZipTask">
    <ant antfile="zip.xml" target="uncompressed-feather" />
    <unzip src="asf-logo.gif.zip" dest="." />
    <ant antfile="zip.xml" target="cleanup" />
  </target>

  <target name="realTest">
    <unzip src="expected/asf-logo.gif.zip" dest="." />
  </target>

  <target name="prepareTestZip">
    <mkdir dir="unziptestin/1"/>
    <mkdir dir="unziptestin/2"/>
    <touch file="unziptestin/1/foo"/>
    <touch file="unziptestin/2/bar"/>
    <zip destfile="unziptest.zip" basedir="unziptestin"/>
  </target>

  <target name="testPatternSetExcludeOnly" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <exclude name="1/**"/>
      </patternset>
    </unzip>
  </target>

  <target name="testPatternSetIncludeOnly" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="2/**"/>
      </patternset>
    </unzip>
  </target>

  <target name="testPatternSetIncludeAndExclude" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="2/**"/>
        <exclude name="2/**"/>
      </patternset>
    </unzip>
  </target>

  <target name="testTwoPatternSets" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="2/**"/>
      </patternset>
      <patternset>
        <include name="3/**"/>
      </patternset>
    </unzip>
  </target>

  <target name="testTwoPatternSetsWithExcludes" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="2/**"/>
      </patternset>
      <patternset>
        <exclude name="1/**"/>
        <exclude name="2/**"/>
      </patternset>
    </unzip>
  </target>

  <target name="selfExtractingArchive">
    <mkdir dir="unziptestout"/>
    <unzip dest="unziptestout" src="zip/test.exe"/>
  </target>

  <!-- Bugzilla Report 20969 -->
  <target name="testPatternSetSlashOnly" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="2/"/>
      </patternset>
    </unzip>
  </target>

  <!-- Bugzilla Report 10504 -->
  <target name="encodingTest">
    <mkdir dir="unziptestin"/>
    <touch file="unziptestin/foo"/>
    <zip zipfile="unziptest.zip" basedir="unziptestin" encoding="UnicodeBig"/>
    <mkdir dir="unziptestout"/>
    <unzip src="unziptest.zip" dest="unziptestout" encoding="UnicodeBig"/>
  </target>

  <!-- Bugzilla Report 21996 -->
  <target name="testFlattenMapper" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="1/**"/>
      </patternset>
      <mapper type="flatten"/>
    </unzip>
  </target>

  <!-- Bugzilla Report 21996 -->
  <target name="testGlobMapper" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="1/**"/>
      </patternset>
      <mapper type="glob" from="*" to="*.txt"/>
    </unzip>
  </target>

  <target name="testTwoMappers" depends="prepareTestZip">
    <unzip dest="unziptestout" src="unziptest.zip">
      <patternset>
        <include name="1/**"/>
      </patternset>
      <mapper type="glob" from="*" to="*.txt"/>
      <mapper type="flatten"/>      
    </unzip>
  </target>

  <target name="testResourceCollection">
    <unzip dest="unziptestout">
      <patternset>
        <include name="junit/**"/>
      </patternset>
      <restrict>
        <path path="${java.class.path}"/>
        <type type="file" xmlns="antlib:org.apache.tools.ant.types.resources.selectors"/>
      </restrict>
    </unzip>
  </target>

  <target name="testDocumentationClaimsOnCopy" depends="prepareTestZip">
    <copy todir="unziptestout" preservelastmodified="true"> 
      <zipfileset src="unziptest.zip">
        <patternset>
          <include name="2/"/>
        </patternset>
      </zipfileset>
    </copy>
  </target>
</project>
