1 17 18 package org.apache.tools.ant.taskdefs; 19 import org.apache.tools.ant.BuildFileTest; 20 import org.apache.tools.ant.util.FileUtils; 21 22 24 public class UnzipTest extends BuildFileTest { 25 26 public UnzipTest(String name) { 27 super(name); 28 } 29 30 public void setUp() { 31 configureProject("src/etc/testcases/taskdefs/unzip.xml"); 32 } 33 34 public void tearDown() { 35 executeTarget("cleanup"); 36 } 37 38 public void test1() { 39 expectBuildException("test1", "required argument not specified"); 40 } 41 42 public void test2() { 43 expectBuildException("test2", "required argument not specified"); 44 } 45 46 public void test3() { 47 expectBuildException("test3", "required argument not specified"); 48 } 49 50 51 public void testRealTest() throws java.io.IOException { 52 FileUtils fileUtils = FileUtils.newFileUtils(); 53 executeTarget("realTest"); 54 assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), 55 project.resolveFile("asf-logo.gif"))); 56 } 57 58 public void testTestZipTask() throws java.io.IOException { 59 FileUtils fileUtils = FileUtils.newFileUtils(); 60 executeTarget("testZipTask"); 61 assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), 62 project.resolveFile("asf-logo.gif"))); 63 } 64 65 public void testTestUncompressedZipTask() throws java.io.IOException { 66 FileUtils fileUtils = FileUtils.newFileUtils(); 67 executeTarget("testUncompressedZipTask"); 68 assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), 69 project.resolveFile("asf-logo.gif"))); 70 } 71 72 75 public void testPatternSetExcludeOnly() { 76 executeTarget("testPatternSetExcludeOnly"); 77 assertTrue("1/foo is excluded", 78 !getProject().resolveFile("unziptestout/1/foo").exists()); 79 assertTrue("2/bar is not excluded", 80 getProject().resolveFile("unziptestout/2/bar").exists()); 81 } 82 83 86 public void testPatternSetIncludeOnly() { 87 executeTarget("testPatternSetIncludeOnly"); 88 assertTrue("1/foo is not included", 89 !getProject().resolveFile("unziptestout/1/foo").exists()); 90 assertTrue("2/bar is included", 91 getProject().resolveFile("unziptestout/2/bar").exists()); 92 } 93 94 97 public void testPatternSetIncludeAndExclude() { 98 executeTarget("testPatternSetIncludeAndExclude"); 99 assertTrue("1/foo is not included", 100 !getProject().resolveFile("unziptestout/1/foo").exists()); 101 assertTrue("2/bar is excluded", 102 !getProject().resolveFile("unziptestout/2/bar").exists()); 103 } 104 105 108 public void testSelfExtractingArchive() { 109 executeTarget("selfExtractingArchive"); 110 } 111 112 113 116 public void testPatternSetSlashOnly() { 117 executeTarget("testPatternSetSlashOnly"); 118 assertTrue("1/foo is not included", 119 !getProject().resolveFile("unziptestout/1/foo").exists()); 120 assertTrue("2/bar is included", 121 getProject().resolveFile("unziptestout/2/bar").exists()); 122 } 123 124 127 public void testEncoding() { 128 executeTarget("encodingTest"); 129 assertTrue("foo has been properly named", 130 getProject().resolveFile("unziptestout/foo").exists()); 131 } 132 133 } 134 | Popular Tags |