must not set file and dir in <fileset>
[ant.git] / src / tests / antunit / types / fileset-test.xml
1 <?xml version="1.0"?>
2 <!--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18 <project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
19
20 <import file="../antunit-base.xml"/>
21
22 <target name="test-fileset-missing-dir">
23 <path id="missing.path.id">
24 <fileset id="missing.dir.fs" dir="not present"
25 erroronmissingdir="false"/>
26 </path>
27 <au:assertTrue>
28 <and>
29 <equals arg1="" arg2="${toString:missing.path.id}"/>
30 <resourcecount count="0" refid="missing.dir.fs" />
31 </and>
32 </au:assertTrue>
33 </target>
34
35 <target name="test-fileset-missing-dir-exception">
36 <mkdir dir="${output}"/>
37 <au:expectfailure expectedmessage="not present does not exist">
38 <copy todir="${output}">
39 <fileset dir="not present" />
40 </copy>
41 </au:expectfailure>
42 </target>
43
44 <target name="test-fileset-with-if">
45 <fileset id="this.xml" dir=".">
46 <include if="trigger.include" name="fileset-test.xml"/>
47 </fileset>
48 <pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/>
49 <au:assertTrue message="fileset this.xml should not contain anything but contains ${this.xml.prop}">
50 <not>
51 <isset property="this.xml.prop"/>
52 </not>
53 </au:assertTrue>
54 </target>
55
56 <target name="test-fileset-with-if-property-set">
57 <property name="trigger.include" value="true"/>
58 <fileset id="this.xml" dir=".">
59 <include if="trigger.include" name="fileset-test.xml"/>
60 </fileset>
61 <pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/>
62 <au:assertPropertySet name="this.xml.prop" message="fileset should contain one file"/>
63 <echo>${this.xml.prop}</echo>
64 <au:assertLogContains text="fileset-test.xml"/>
65 </target>
66
67 <target name="test-fileset-dir-and-file-exception">
68 <mkdir dir="${output}"/>
69 <au:expectfailure expectedmessage="you can only specify one of the dir and file attributes">
70 <copy todir="${output}">
71 <fileset dir="foo" file="bar" />
72 </copy>
73 </au:expectfailure>
74 </target>
75
76 <target name="test-fileset-file-and-dir-exception">
77 <mkdir dir="${output}"/>
78 <au:expectfailure expectedmessage="you can only specify one of the dir and file attributes">
79 <copy todir="${output}">
80 <fileset file="bar" dir="foo"/>
81 </copy>
82 </au:expectfailure>
83 </target>
84
85 </project>