aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/types/resources/multirootfileset-test.xml
blob: 27b6193ea77f32a4aad01fa402d9578c9ba3f38d (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
<?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 xmlns:au="antlib:org.apache.ant.antunit" default="antunit">

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

  <target name="setUp">
    <property name="a" location="${input}/a"/>
    <property name="b" location="${input}/b"/>
    <touch mkdirs="true" file="${a}/1/1.txt"/>
    <touch mkdirs="true" file="${a}/1/2.txt"/>
    <touch mkdirs="true" file="${a}/1/3.txt"/>
    <touch mkdirs="true" file="${b}/2/3.txt"/>
    <touch mkdirs="true" file="${b}/2/4.txt"/>
    <mkdir dir="${output}"/>
  </target>

  <target name="test-count-in-simple-configuration" depends="setUp">
    <resourcecount property="files">
      <multirootfileset basedirs="${a},${b}"/>
    </resourcecount>
    <resourcecount property="dirs">
      <multirootfileset basedirs="${a},${b}" type="dir"/>
    </resourcecount>
    <resourcecount property="files-and-dirs">
      <multirootfileset basedirs="${a},${b}" type="both"/>
    </resourcecount>
    <au:assertPropertyEquals value="5" name="files"/>
    <au:assertPropertyEquals value="4" name="dirs"/>
    <au:assertPropertyEquals value="9" name="files-and-dirs"/>
  </target>

  <target name="test-count-nested-basedir-elements" depends="setUp">
    <resourcecount property="files">
      <multirootfileset>
        <basedir file="${a}"/>
        <basedir file="${b}"/>
      </multirootfileset>
    </resourcecount>
    <resourcecount property="dirs">
      <multirootfileset type="dir">
        <basedir file="${a}"/>
        <basedir file="${b}"/>
      </multirootfileset>
    </resourcecount>
    <resourcecount property="files-and-dirs">
      <multirootfileset type="both">
        <basedir file="${a}"/>
        <basedir file="${b}"/>
      </multirootfileset>
    </resourcecount>
    <au:assertPropertyEquals value="5" name="files"/>
    <au:assertPropertyEquals value="4" name="dirs"/>
    <au:assertPropertyEquals value="9" name="files-and-dirs"/>
  </target>

  <target name="test-copying" depends="setUp">
    <copy todir="${output}">
      <multirootfileset basedirs="${a},${b}"/>
    </copy>
    <au:assertFileExists file="${output}/1/1.txt"/>
    <au:assertFileExists file="${output}/1/2.txt"/>
    <au:assertFileExists file="${output}/1/3.txt"/>
    <au:assertFileExists file="${output}/2/3.txt"/>
    <au:assertFileExists file="${output}/2/4.txt"/>
  </target>

  <target name="test-dirs" depends="setUp">
    <pathconvert property="dirs" pathsep=":">
      <multirootfileset basedirs="${a},${b}" type="dir"/>
    </pathconvert>
    <au:assertPropertyEquals value="${a}:${a}${file.separator}1:${b}:${b}${file.separator}2"
                             name="dirs"/>
  </target>

  <target name="test-include-pattern" depends="setUp">
    <copy todir="${output}">
      <multirootfileset basedirs="${a},${b}">
        <include name="**/3.txt"/>
      </multirootfileset>
    </copy>
    <au:assertFileDoesntExist file="${output}/1/1.txt"/>
    <au:assertFileExists file="${output}/1/3.txt"/>
    <au:assertFileExists file="${output}/2/3.txt"/>
    <au:assertFileDoesntExist file="${output}/2/4.txt"/>
    <pathconvert property="dirs" pathsep=":">
      <multirootfileset basedirs="${a},${b}" type="dir">
        <include name="1/"/>
      </multirootfileset>
    </pathconvert>
    <au:assertPropertyEquals value="${a}${file.separator}1" name="dirs"/>
  </target>

  <target name="test-exclude-pattern" depends="setUp">
    <copy todir="${output}">
      <multirootfileset basedirs="${a},${b}">
        <exclude name="**/3.txt"/>
      </multirootfileset>
    </copy>
    <au:assertFileExists file="${output}/1/1.txt"/>
    <au:assertFileDoesntExist file="${output}/1/3.txt"/>
    <au:assertFileDoesntExist file="${output}/2/3.txt"/>
    <au:assertFileExists file="${output}/2/4.txt"/>
    <pathconvert property="dirs" pathsep=":">
      <multirootfileset basedirs="${a},${b}" type="dir">
        <exclude name="1/"/>
      </multirootfileset>
    </pathconvert>
    <au:assertPropertyEquals value="${a}:${b}:${b}${file.separator}2"
                             name="dirs"/>
  </target>

  <target name="test-selectors" depends="setUp">
    <copy todir="${output}">
      <multirootfileset basedirs="${a},${b}">
        <filename regex=".*3\.txt"/>
      </multirootfileset>
    </copy>
    <au:assertFileDoesntExist file="${output}/1/1.txt"/>
    <au:assertFileExists file="${output}/1/3.txt"/>
    <au:assertFileExists file="${output}/2/3.txt"/>
    <au:assertFileDoesntExist file="${output}/2/4.txt"/>
    <pathconvert property="dirs" pathsep=":">
      <multirootfileset basedirs="${a},${b}" type="dir">
        <filename regex="1"/>
      </multirootfileset>
    </pathconvert>
    <au:assertPropertyEquals value="${a}${file.separator}1" name="dirs"/>
  </target>

  <target name="test-cache-false" depends="setUp">
    <copy todir="${output}">
      <multirootfileset basedirs="${a},${b}" cache="false">
        <filename regex=".*3\.txt"/>
      </multirootfileset>
    </copy>
    <au:assertFileDoesntExist file="${output}/1/1.txt"/>
    <au:assertFileExists file="${output}/1/3.txt"/>
    <au:assertFileExists file="${output}/2/3.txt"/>
    <au:assertFileDoesntExist file="${output}/2/4.txt"/>
    <multirootfileset basedirs="${a},${b}" type="dir" cache="false"
                      id="the-one-dirs">
      <filename regex="1"/>
    </multirootfileset>
    <pathconvert property="dirs" pathsep=":" refid="the-one-dirs"/>
    <au:assertPropertyEquals value="${a}${file.separator}1" name="dirs"/>
    <resourcecount property="dir-count" refid="the-one-dirs" />
    <au:assertPropertyEquals value="1" name="dir-count"/>
  </target>

</project>