aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/etc/testcases/taskdefs/zip.xml
blob: 4fa6de6c75c19fcc527d7f080746ff522a192641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

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

  <import file="../buildfiletest-base.xml"/>

  <target name="setUp">
    <mkdir dir="${output}"/>
  </target>

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

  <target name="test2">
    <zip destFile="${output}/zip.tmp"/>
  </target>

  <!-- Test when the zip file includes itself
  when target file exists before the zip task is run -->
  <target name="test3">
    <touch file="${output}/test3.zip"/>
    <zip destFile="${output}/test3.zip"
         basedir="${output}/"/>
  </target>

  <!-- Test when the zip file includes itself
  when target file does not exist before the zip task is run
  <target name="test4">
     <zip destFile="${output}/test4.zip"
         basedir="."/>
  </target>
  -->

  <target name="test5">
    <zip zipfile="${output}/test5.zip" basedir="." >
      <exclude name="test5.zip" />
    </zip>
  </target>

  <target name="test6">
    <zip destFile="${output}/test6.zip" basedir=".">
      <include name="*.xml" />
      <exclude name="zip.*" />
    </zip>
  </target>

  <target name="test7">
    <copy todir="${output}">
      <fileset dir="."/>
    </copy>
    <zip destFile="${output}/inner7.zip" basedir="${output}" >
      <exclude name="inner7.zip" />
    </zip>
    <zip destFile="${output}/test7.zip" basedir=".">
      <exclude name="**/*.*" />
      <zipfileset src="${output}/inner7.zip" />
    </zip>
  </target>

  <target name="feather">
    <zip destFile="${output}/asf-logo.gif.zip"
         basedir=".."
         includes="asf-logo.gif" />
  </target>

  <target name="uncompressed-feather">
    <zip destFile="${output}/asf-logo.gif.zip"
         basedir=".."
         includes="asf-logo.gif" compress="false"/>
  </target>

  <!-- legacy attribute support -->
  <target name="test8">
    <zip zipfile="${output}/test8.zip" basedir="." >
      <exclude name="test8.zip" />
    </zip>
  </target>

  <target name="testZipgroupfileset">

    <zip zipfile="${output}/zipgroupfileset.zip" basedir=".">
      <zipgroupfileset dir="zip" 
        includes="zipgroupfileset*.zip" 
        excludes="zipgroupfileset3.zip" />
      <include name="zip/zipgroupfileset3.zip" />
    </zip>
  </target>

  <target name="testDuplicateFail">

    <zip zipfile="${output}/duplicateFail.zip" basedir="." duplicate="fail">
      <zipgroupfileset dir="duplicate" includes="duplicate*.zip" />
    </zip>
  </target>

  <target name="testUpdateNotNecessary" depends="feather">
    <zip destFile="${output}/asf-logo.gif.zip"
         basedir=".."
         includes="asf-logo.gif"
         update="true" />
  </target>

  <target name="testUpdateIsNecessary" depends="feather">
    <touch file="${output}/dummyfile" />
    <copy file="../asf-logo.gif" todir="${output}"/>
    <zip destFile="${output}/asf-logo.gif.zip"
         basedir="${output}"
         includes="asf-logo.gif,dummyfile"
         update="true" />
  </target>

  <!-- Bugzilla Report 18403 -->
  <target name="testPrefixAddsDir">
    <zip destFile="${output}/test3.zip" filesonly="false">
      <zipfileset dir="." prefix="test" includes="zip.xml"/>
    </zip>
  </target>

  <!-- Bugzilla Report 19449 -->
  <target name="testFilesOnlyDoesntCauseRecreateSetup">
    <mkdir dir="${output}/ziptest"/>
    <touch file="${output}/ziptest/ziptest"/>
    <zip destFile="${output}/test3.zip" basedir="${output}"
         includes="ziptest/**" filesonly="true"/>
  </target>

  <!-- Bugzilla Report 19449 -->
  <target name="testFilesOnlyDoesntCauseRecreate">
    <zip destFile="${output}/test3.zip" basedir="."
         includes="ziptest/**" filesonly="true"/>
  </target>

  <!-- Bugzilla Report 22865 -->
  <target name="testEmptySkip">
    <mkdir dir="${output}/ziptest"/>
    <zip destFile="${output}/test3.zip" basedir="${output}/ziptest" whenempty="skip"/>
    <fail message="archive should get skipped">
      <condition>
        <available file="${output}/test3.zip" />
      </condition>
    </fail>
  </target>

  <!-- Bugzilla Report 30365 -->
  <target name="zipEmptyDir">
    <mkdir dir="${output}/empty/empty2"/>
    <zip destFile="${output}/test3.zip" basedir="${output}/empty" update="true"/>
    <fail message="single-directory archive should be created">
      <condition>
        <or>
          <not>
            <available file="${output}/test3.zip" />
          </not>
          <resourcecount when="gt" count="0">
            <zipfileset src="${output}/test3.zip" />
          </resourcecount>
          <resourcecount when="ne" count="1">
            <restrict>
              <exists xmlns="antlib:org.apache.tools.ant.types.resources.selectors" />
              <zipentry zipfile="${output}/test3.zip" name="empty2/" />
            </restrict>
          </resourcecount>
        </or>
      </condition>
    </fail>
  </target>

  <!-- Bugzilla Report 40258 -->
  <target name="zipEmptyDirFilesOnly">
    <mkdir dir="${output}/empty/empty2" />
    <zip destFile="${output}/test3.zip" basedir="${output}/empty" update="true" filesonly="true" />
    <fail message="archive should get skipped">
      <condition>
        <available file="${output}/test3.zip" />
      </condition>
    </fail>
  </target>

  <target name="zipEmptyCreate">
    <mkdir dir="${output}/empty"/>
    <zip destFile="${output}/test3.zip" basedir="${output}/empty" whenempty="create" includes="*.xyz"/>
    <fail message="empty archive should be created">
      <condition>
        <or>
          <not>
           <available file="${output}/test3.zip" />
          </not>
          <resourcecount when="gt" count="0">
            <zipfileset src="${output}/test3.zip" />
          </resourcecount>
        </or>
      </condition>
    </fail>
  </target>

  <target name="testCompressionLevel" depends="test6">
    <length property="test6.length" file="${output}/test6.zip" />
    <copy todir="${output}">
      <fileset dir=".">
        <include name="*.xml"/>
      </fileset>
    </copy>
    <zip destFile="${output}/testLevel.zip" basedir="${output}" level="9">
      <include name="*.xml" />
      <exclude name="zip.*" />
    </zip>
    <fail>
      <condition>
        <not>
          <isfileselected file="${output}/testLevel.zip">
            <size when="less" value="${test6.length}" />
          </isfileselected>
        </not>
      </condition>
    </fail>
  </target>

  <!-- Bugzilla Report 33412 -->
  <target name="testDefaultExcludesAndUpdate">
    <mkdir dir="${output}/ziptest"/>
    <touch file="${output}/ziptest/ziptest~"/>
    <zip destFile="${output}/test3.zip" basedir="${output}/ziptest"
         defaultexcludes="false"/>
    <touch file="${output}/ziptest/ziptest2"/>
    <zip destFile="${output}/test3.zip" basedir="${output}/ziptest"
      defaultexcludes="false"
      update="true"/>
  </target>

  <target name="testFileResource">
    <zip destFile="${output}/test3.zip">
      <file file="zip.xml"/>
    </zip>
  </target>

  <target name="testNonFileResource">
    <zip destFile="${output}/test3.zip">
      <javaresource name="META-INF/MANIFEST.MF"/>
    </zip>
  </target>

  <target name="testTarFileSet">
    <ant antfile="tar.xml" target="feather"/>
    <zip destFile="${output}/test3.zip">
      <tarfileset src="${output}/asf-logo.gif.tar" filemode="446"/>
    </zip>
  </target>

  <target name="rewriteZeroPermissions">
    <zip destFile="${output}/test3.zip">
      <zipfileset src="nopermissions.zip"/>
    </zip>
  </target>

  <target name="acceptZeroPermissions">
    <zip destFile="${output}/test3.zip" preserve0permissions="true">
      <zipfileset src="nopermissions.zip"/>
    </zip>
  </target>

  <target name="testForBugzilla34764">
    <mkdir dir="${output}/ziptest"/>
    <touch file="${output}/ziptest/file1"/>
    <zip destFile="${output}/test3.zip" basedir="${output}/ziptest"/>
    <touch file="${output}/ziptest/file2"/>
    <zip destFile="${output}/test3.zip" basedir="${output}/ziptest" update="true"/>
  </target>


</project>