git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@306519 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -14,9 +14,17 @@ | |||||
| <p><a href="../CoreTypes/patternset.html">PatternSet</a>s are used to select files to extract | <p><a href="../CoreTypes/patternset.html">PatternSet</a>s are used to select files to extract | ||||
| <I>from</I> the archive. If no patternset is used, all files are extracted. | <I>from</I> the archive. If no patternset is used, all files are extracted. | ||||
| </p> | </p> | ||||
| <p><a href="../CoreTypes/fileset.html">FileSet</a>s may be used to select archived files | |||||
| to perform unarchival upon. | |||||
| </p> | |||||
| <p><a href="../CoreTypes/resources.html#collection">Resource | |||||
| Collection</a>s may be used to select archived files to perform | |||||
| unarchival upon. Only file system based resource collections are | |||||
| supported by Unjar/Unwar/Unzip, this includes <a | |||||
| href="../CoreTypes/fileset.html">fileset</a>s, <a | |||||
| href="../CoreTypes/filelist.html">filelist</a> and <a | |||||
| href="../using.html#path">path</a>. Untar supports arbitrary resource | |||||
| collections. Prior to Ant 1.7 only fileset has been supported as a | |||||
| nested element.</p> | |||||
| <p>You can define filename transformations by using a nested <a href="../CoreTypes/mapper.html">mapper</a> element. The default mapper is the | <p>You can define filename transformations by using a nested <a href="../CoreTypes/mapper.html">mapper</a> element. The default mapper is the | ||||
| <a href="../CoreTypes/mapper.html#identity-mapper">identity mapper</a>. | <a href="../CoreTypes/mapper.html#identity-mapper">identity mapper</a>. | ||||
| </p> | </p> | ||||
| @@ -4,6 +4,7 @@ | |||||
| <target name="cleanup"> | <target name="cleanup"> | ||||
| <delete file="asf-logo.gif" /> | <delete file="asf-logo.gif" /> | ||||
| <delete dir="untartestout"/> | |||||
| </target> | </target> | ||||
| <target name="testTarTask"> | <target name="testTarTask"> | ||||
| @@ -44,4 +45,18 @@ | |||||
| <target name="encoding"> | <target name="encoding"> | ||||
| <untar src="expected/asf-logo.gif.tar" dest="." encoding="foo"/> | <untar src="expected/asf-logo.gif.tar" dest="." encoding="foo"/> | ||||
| </target> | </target> | ||||
| <target name="resourceCollection"> | |||||
| <mkdir dir="untartestout"/> | |||||
| <zip destfile="untartestout/test.zip"> | |||||
| <fileset dir="expected"> | |||||
| <include name="asf-logo.gif.tar"/> | |||||
| </fileset> | |||||
| </zip> | |||||
| <untar dest="."> | |||||
| <zipfileset src="untartestout/test.zip"> | |||||
| <include name="*.tar"/> | |||||
| </zipfileset> | |||||
| </untar> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -122,4 +122,16 @@ | |||||
| <mapper type="flatten"/> | <mapper type="flatten"/> | ||||
| </unzip> | </unzip> | ||||
| </target> | </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> | |||||
| </project> | </project> | ||||
| @@ -39,39 +39,27 @@ public class UntarTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testRealTest() throws java.io.IOException { | public void testRealTest() throws java.io.IOException { | ||||
| executeTarget("realTest"); | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | |||||
| testLogoExtraction("realTest"); | |||||
| } | } | ||||
| public void testRealGzipTest() throws java.io.IOException { | public void testRealGzipTest() throws java.io.IOException { | ||||
| executeTarget("realGzipTest"); | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | |||||
| testLogoExtraction("realGzipTest"); | |||||
| } | } | ||||
| public void testRealBzip2Test() throws java.io.IOException { | public void testRealBzip2Test() throws java.io.IOException { | ||||
| executeTarget("realBzip2Test"); | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | |||||
| testLogoExtraction("realBzip2Test"); | |||||
| } | } | ||||
| public void testTestTarTask() throws java.io.IOException { | public void testTestTarTask() throws java.io.IOException { | ||||
| executeTarget("testTarTask"); | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | |||||
| testLogoExtraction("testTarTask"); | |||||
| } | } | ||||
| public void testTestGzipTarTask() throws java.io.IOException { | public void testTestGzipTarTask() throws java.io.IOException { | ||||
| executeTarget("testGzipTarTask"); | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | |||||
| testLogoExtraction("testGzipTarTask"); | |||||
| } | } | ||||
| public void testTestBzip2TarTask() throws java.io.IOException { | public void testTestBzip2TarTask() throws java.io.IOException { | ||||
| executeTarget("testBzip2TarTask"); | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | |||||
| testLogoExtraction("testBzip2TarTask"); | |||||
| } | } | ||||
| public void testSrcDirTest() { | public void testSrcDirTest() { | ||||
| @@ -85,4 +73,13 @@ public class UntarTest extends BuildFileTest { | |||||
| + "encoding attribute"); | + "encoding attribute"); | ||||
| } | } | ||||
| public void testResourceCollection() throws java.io.IOException { | |||||
| testLogoExtraction("resourceCollection"); | |||||
| } | |||||
| private void testLogoExtraction(String target) throws java.io.IOException { | |||||
| executeTarget(target); | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | |||||
| } | |||||
| } | } | ||||
| @@ -173,4 +173,9 @@ public class UnzipTest extends BuildFileTest { | |||||
| expectBuildException("testTwoMappers",Expand.ERROR_MULTIPLE_MAPPERS); | expectBuildException("testTwoMappers",Expand.ERROR_MULTIPLE_MAPPERS); | ||||
| } | } | ||||
| public void testResourceCollections() { | |||||
| executeTarget("testResourceCollection"); | |||||
| assertFileExists("junit.jar has been extracted", | |||||
| "unziptestout/junit/framework/Assert.class"); | |||||
| } | |||||
| } | } | ||||