1 | /*
|
---|
2 | * Copyright 2000-2001,2003-2004 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
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 | /**
|
---|
23 | */
|
---|
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 | /*
|
---|
73 | * PR 11100
|
---|
74 | */
|
---|
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 | /*
|
---|
84 | * PR 11100
|
---|
85 | */
|
---|
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 | /*
|
---|
95 | * PR 11100
|
---|
96 | */
|
---|
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 | /*
|
---|
106 | * PR 16213
|
---|
107 | */
|
---|
108 | public void testSelfExtractingArchive() {
|
---|
109 | executeTarget("selfExtractingArchive");
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | /*
|
---|
114 | * PR 20969
|
---|
115 | */
|
---|
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 | /*
|
---|
125 | * PR 10504
|
---|
126 | */
|
---|
127 | public void testEncoding() {
|
---|
128 | executeTarget("encodingTest");
|
---|
129 | assertTrue("foo has been properly named",
|
---|
130 | getProject().resolveFile("unziptestout/foo").exists());
|
---|
131 | }
|
---|
132 |
|
---|
133 | }
|
---|