aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/etc/testcases/types/selectors.xml
blob: 5a80d04a043f8f46f2a67c1dac05c8c33203e652 (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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<?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="selectors-test" basedir="." default="setupfiles">

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

  <target name="setUp">
    <mkdir dir="${output}"/>
  </target>
  <property name="etc.dir" value=".."/>
  <property name="test.dir"
          value="${output}/selectortest"/>
  <property name="testregexpsrc.dir"
          value="${output}/regexpseltestsrc"/>
  <property name="testregexpdest.dir"
          value="${output}/regexpseltestdest"/>
  <property name="mirror.dir"
          value="${output}/selectortest2"/>

  <target name="setupfiles">
    <mkdir dir="${test.dir}" />
    <mkdir dir="${test.dir}/zip" />
    <mkdir dir="${test.dir}/tar" />
    <mkdir dir="${test.dir}/tar/gz" />
    <mkdir dir="${test.dir}/tar/bz2" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo.gif.md5"
            tofile="${test.dir}/asf-logo.gif.md5" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo.gif.bz2"
            tofile="${test.dir}/asf-logo.gif.bz2" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo.gif.gz"
            tofile="${test.dir}/asf-logo.gif.gz" />
    <copy file="${etc.dir}/taskdefs/expected/copy.filterset.filtered"
            tofile="${test.dir}/copy.filterset.filtered" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo.gif.zip"
            tofile="${test.dir}/zip/asf-logo.gif.zip" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo.gif.tar"
            tofile="${test.dir}/tar/asf-logo.gif.tar" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo-huge.tar.gz"
            tofile="${test.dir}/tar/asf-logo-huge.tar.gz" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo.gif.tar.gz"
            tofile="${test.dir}/tar/gz/asf-logo.gif.tar.gz" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo.gif.tar.bz2"
            tofile="${test.dir}/tar/bz2/asf-logo.gif.tar.bz2" />
    <copy file="${etc.dir}/taskdefs/expected/asf-logo-huge.tar.bz2"
            tofile="${test.dir}/tar/bz2/asf-logo-huge.tar.bz2" />
    <!-- Make linefeeds consistent between platforms -->
    <fixcrlf srcdir="${test.dir}" includes="*.filtered" eol="lf"/>
    <!-- Set a known base time for all files -->
    <touch datetime="11/21/2001 4:55 AM">
        <fileset dir="${test.dir}">
            <include name="**/*"/>
        </fileset>
    </touch>
    <!-- Then adjust individual ones -->
    <touch file="${test.dir}/asf-logo.gif.bz2"
            datetime="01/01/2001 12:00 AM"/>
    <touch file="${test.dir}/asf-logo.gif.gz"
            datetime="04/15/2002 2:30 PM"/>
    <touch file="${test.dir}/zip/asf-logo.gif.zip"
            datetime="05/10/2002 2:30 PM"/>
    <touch file="${test.dir}/tar/asf-logo.gif.tar"
            datetime="05/10/2002 2:29 PM"/>
    <touch file="${test.dir}/tar/asf-logo-huge.tar.gz"
            datetime="05/10/2002 2:29 AM"/>
  </target>

  <target name="mirrorfiles">
    <mkdir dir="${mirror.dir}" />
    <mkdir dir="${mirror.dir}/zip" />
    <mkdir dir="${mirror.dir}/tar" />
    <mkdir dir="${mirror.dir}/tar/gz" />
    <mkdir dir="${mirror.dir}/tar/bz2" />
    <touch file="${mirror.dir}/asf-logo.gif.md5"/>
    <touch file="${mirror.dir}/asf-logo.gif.bz2"/>
    <touch file="${mirror.dir}/zip/asf-logo.gif.zip"/>
    <touch file="${mirror.dir}/tar/asf-logo.gif.tar"/>
    <touch file="${mirror.dir}/tar/asf-logo-huge.tar.gz"/>
    <touch file="${mirror.dir}/tar/gz/asf-logo.gif.tar.gz"/>
    <touch file="${mirror.dir}/tar/bz2/asf-logo.gif.tar.bz2"/>
    <touch file="${mirror.dir}/tar/bz2/asf-logo-huge.tar.bz2"/>
  </target>

  <target name="containsregexp">
    <mkdir dir="${testregexpsrc.dir}" />
    <mkdir dir="${testregexpdest.dir}" />
    <!-- Make two test files, shouldcopy.txt will get selected if everything works
         shouldnotcopy.txt will not get selected for copy.  The test looks to see
         that only one file is copied
    -->
    <echo message="Some testregexp text 2.0" file="${testregexpsrc.dir}/shouldcopy.txt" />
    <echo message="Some testregexp text 20" file="${testregexpsrc.dir}/shouldnotcopy.txt" />
    <copy todir="${testregexpdest.dir}">
      <fileset dir="${testregexpsrc.dir}">
        <include name="*.txt" />
        <containsregexp expression="[0-9]\.[0,1,2]" />
      </fileset>
    </copy>
  </target>

  <!-- ==========  Test for ModifiedSelector  ========== -->

  <target name="modifiedselectortest-makeDirty">
      <!-- Load propertyfile generated by SelectorTest-class -->
      <property file="ModifiedSelectorTest.properties"/>

      <!-- Modify only timestamp -->
      <touch file="${test.dir}/${f2name}" datetime="02/28/2003 9:55 AM"/>
      <!-- Change content but keep timestamp -->
      <echo file="${test.dir}/${f3name}" append="true" message="new content"/>
      <touch file="${test.dir}/${f3name}" datetime="11/21/2001 4:55 AM"/>
      <!-- Change content and timestamp -->
      <echo file="${test.dir}/${f4name}" append="true" message="new content"/>
  </target>

  <target name="modifiedselectortest-scenario-clean">
      <delete dir="${test.dir}"/>
  </target>

  <target name="modifiedselectortest-scenario-prepare">
      <mkdir dir="${test.dir}/src"/>
      <copy todir="${test.dir}/src">
          <fileset dir="${ant.home}/lib" includes="ant.jar">
              <type type="file"/>
          </fileset>
          <fileset dir="${ant.home}/bin">
                <type type="file"/>
          </fileset>
      </copy>
      <touch datetime="12/24/2002 4:00 pm">
          <fileset dir="${test.dir}"/>
      </touch>
      <mkdir dir="${test.dir}/to-1"/>
      <mkdir dir="${test.dir}/to-2"/>
      <mkdir dir="${test.dir}/to-3"/>
  </target>

  <target name="modifiedselectortest-scenario-makeDirty">
      <touch file="${test.dir}/src/ant.jar"/>
      <echo file="${test.dir}/src/ant.bat" append="true" message="new-content"/>
      <echo file="${test.dir}/src/antRun.pl" append="true" message="new-content"/>
      <touch file="${test.dir}/src/antRun.pl" datetime="12/24/2002 4:00 pm"/>
  </target>

  <target name="modifiedselectortest-scenario-coreselector-defaults" depends="modifiedselectortest-scenario-prepare">
      <!-- copy first time and create cachefile -->
      <copy todir="${test.dir}/to-1">
          <fileset dir="${test.dir}/src">
              <modified/>
          </fileset>
      </copy>
      <!-- copy second time: nothing should be copied -->
      <copy todir="${test.dir}/to-2">
          <fileset dir="${test.dir}/src">
              <modified/>
          </fileset>
      </copy>
      <!-- 'modify' the source files -->
      <antcall target="modifiedselectortest-scenario-makeDirty"/>
      <!-- copy third time: only the files with new CONTENT should be copied -->
      <copy todir="${test.dir}/to-3">
          <fileset dir="${test.dir}/src">
              <modified/>
          </fileset>
      </copy>
  </target>

  <target name="modifiedselectortest-scenario-coreselector-settings" depends="modifiedselectortest-scenario-prepare">
      <!-- copy first time and create cachefile -->
      <copy todir="${test.dir}/to-1">
          <fileset dir="${test.dir}/src">
              <modified cache="propertyfile" algorithm="hashvalue" update="true">
                  <param name="cache.cachefile" value="core.cache.properties" />
              </modified>
          </fileset>
      </copy>
      <!-- copy second time: nothing should be copied -->
      <copy todir="${test.dir}/to-2">
          <fileset dir="${test.dir}/src">
              <modified cache="propertyfile" algorithm="hashvalue" update="true">
                  <param name="cache.cachefile" value="core.cache.properties" />
              </modified>
          </fileset>
      </copy>
      <!-- 'modify' the source files -->
      <antcall target="modifiedselectortest-scenario-makeDirty"/>
      <!-- copy third time: only the files with new CONTENT should be copied -->
      <copy todir="${test.dir}/to-3">
          <fileset dir="${test.dir}/src">
              <modified cache="propertyfile" algorithm="hashvalue" update="true">
                  <param name="cache.cachefile" value="core.cache.properties" />
              </modified>
          </fileset>
      </copy>
  </target>

  <target name="modifiedselectortest-scenario-customselector-settings" depends="modifiedselectortest-scenario-prepare">
      <!-- copy first time and create cachefile -->
      <copy todir="${test.dir}/to-1">
          <fileset dir="${test.dir}/src">
              <custom classname="org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector">
                  <param name="cache"      value="propertyfile"/>
                  <param name="algorithm"  value="hashvalue"/>
                  <param name="update"     value="true"/>
                  <param name="cache.cachefile" value="core.cache.properties"/>
              </custom>
          </fileset>
      </copy>
      <!-- copy second time: nothing should be copied -->
      <copy todir="${test.dir}/to-2">
          <fileset dir="${test.dir}/src">
              <custom classname="org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector">
                  <param name="cache"      value="propertyfile"/>
                  <param name="algorithm"  value="hashvalue"/>
                  <param name="update"     value="true"/>
                  <param name="cache.cachefile" value="core.cache.properties"/>
              </custom>
          </fileset>
      </copy>
      <!-- 'modify' the source files -->
      <antcall target="modifiedselectortest-scenario-makeDirty"/>
      <!-- copy third time: only the files with new CONTENT should be copied -->
      <copy todir="${test.dir}/to-3">
          <fileset dir="${test.dir}/src">
              <custom classname="org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector">
                  <param name="cache"      value="propertyfile"/>
                  <param name="algorithm"  value="hashvalue"/>
                  <param name="update"     value="true"/>
                  <param name="cache.cachefile" value="core.cache.properties"/>
              </custom>
          </fileset>
      </copy>
  </target>

  <target name="modifiedselectortest-customClasses" depends="modifiedselectortest-scenario-prepare">
      <property name="pkg.live" value="org.apache.tools.ant.types.selectors.modifiedselector"/>
      <property name="pkg.test" value="org.apache.tools.ant.types.selectors"/>
      <fileset id="fs.mod" dir="${test.dir}/src">
          <modified
              algorithmclass="${pkg.test}.MockAlgorithm"
              cacheclass="${pkg.test}.MockCache"
              comparatorclass="${pkg.test}.MockComparator"
          >
              <classpath>
                  <pathelement location="${build.tests.value}"/>
              </classpath>
          </modified>
      </fileset>
      <fileset id="fs.full" dir="${test.dir}/src"/>
      <property name="fs.mod.value"  refid="fs.mod"/>
      <property name="fs.full.value" refid="fs.full"/>
  </target>

  <target name="modifiedselectortest-ResourceSimple">
    <fail message="Didnt get the required numbers of Resources.">
      <condition>
        <not>
          <resourcecount when="equal" count="3">
            <restrict>
              <resources>
                <file file="foo" />
                <resource name="foo" />
                <file file="foo" basedir="${basedir}" />
              </resources>
              <modified selres="true" xmlns="antlib:org.apache.tools.ant.types.resources.selectors"/>
            </restrict>
          </resourcecount>
        </not>
      </condition>
    </fail>
  </target>

  <target name="modifiedselectortest-ResourceSelresTrue">
    <fail message="Got the Resource, but should.">
      <condition>
        <not>
          <resourcecount when="equal" count="1">
            <restrict>
              <resources>
                <resource name="notExisting" />
              </resources>
              <modified selres="true" xmlns="antlib:org.apache.tools.ant.types.resources.selectors"/>
            </restrict>
          </resourcecount>
        </not>
      </condition>
    </fail>
  </target>

  <target name="modifiedselectortest-ResourceSelresFalse">
    <fail message="Got the Resource, but should not.">
      <condition>
        <not>
          <resourcecount when="equal" count="0">
            <restrict>
              <resources>
                <resource name="notExisting" />
              </resources>
              <modified selres="false" xmlns="antlib:org.apache.tools.ant.types.resources.selectors"/>
            </restrict>
          </resourcecount>
        </not>
      </condition>
    </fail>
  </target>

  <target name="modifiedselectortest-scenario-resourceSimple" depends="modifiedselectortest-scenario-prepare">
    <macrodef name="check">
      <attribute name="count"/>
      <attribute name="message"/>
      <sequential>
        <fail message="@{message}">
          <condition>
            <not>
              <resourcecount when="equal" count="@{count}">
                <restrict>
                  <resources>
                    <fileset dir="${test.dir}/src"/>
                  </resources>
                  <modified selres="false" xmlns="antlib:org.apache.tools.ant.types.resources.selectors"/>
                </restrict>
              </resourcecount>
            </not>
          </condition>
        </fail>	
      </sequential>
    </macrodef>
    <!-- select first time and create cachefile -->
    <check count="14" message="Initial set of files not ok."/>

    <!-- check second time: nothing should be selected -->
    <check count="0" message="Selected files but shouldnt."/>

    <!-- 'modify' the source files -->
    <antcall target="modifiedselectortest-scenario-makeDirty"/>

    <!-- copy third time: only the files with new CONTENT should be copied -->
    <check count="2" message="Didnt select the 2 modified files."/>
  </target>	

</project>