| <?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 |
| |
| https://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> |