1 | <?xml version="1.0"?>
|
---|
2 | <project name="test" basedir=".">
|
---|
3 | <path id="testclasses">
|
---|
4 | <pathelement location="../../../../build/testcases" />
|
---|
5 | <pathelement path="${java.class.path}" />
|
---|
6 | </path>
|
---|
7 |
|
---|
8 | <mapper id="testmapper"
|
---|
9 | classname="org.apache.tools.ant.taskdefs.MultiMapTest$TestMapper"
|
---|
10 | classpathref="testclasses"/>
|
---|
11 |
|
---|
12 | <property name="map.ext" value=".copy2"/>
|
---|
13 | <property name="rootScratchDir" value="test_multi_mapper_scratch_area"/>
|
---|
14 | <property name="baseScratchSrc" value="${rootScratchDir}/src"/>
|
---|
15 | <property name="baseScratchDest" value="${rootScratchDir}/dest"/>
|
---|
16 |
|
---|
17 | <target name="setup">
|
---|
18 | <delete dir="${baseScratchSrc}"/>
|
---|
19 | <mkdir dir="${baseScratchSrc}"/>
|
---|
20 | <delete dir="${baseScratchDest}"/>
|
---|
21 | <mkdir dir="${baseScratchDest}"/>
|
---|
22 | <touch file="${baseScratchSrc}/somefile.txt"/>
|
---|
23 | </target>
|
---|
24 |
|
---|
25 | <!-- test simple single file to multiple file move -->
|
---|
26 | <target name="multicopy" depends="setup">
|
---|
27 | <copy todir="${baseScratchDest}" enablemultiplemappings="true">
|
---|
28 | <fileset dir="${baseScratchSrc}" includes="somefile.txt"/>
|
---|
29 | <mapper refid="testmapper"/>
|
---|
30 | </copy>
|
---|
31 | <condition property="multicopy.outcome">
|
---|
32 | <and>
|
---|
33 | <available file="${baseScratchDest}/somefile.txt"/>
|
---|
34 | <available file="${baseScratchDest}/somefile.txt${map.ext}"/>
|
---|
35 | </and>
|
---|
36 | </condition>
|
---|
37 | <fail unless="multicopy.outcome">multicopy failed</fail>
|
---|
38 | </target>
|
---|
39 |
|
---|
40 | <target name="multimove" depends="setup">
|
---|
41 | <move todir="${baseScratchDest}" enablemultiplemappings="true">
|
---|
42 | <fileset dir="${baseScratchSrc}" includes="somefile.txt"/>
|
---|
43 | <mapper refid="testmapper"/>
|
---|
44 | </move>
|
---|
45 | <condition property="test2.outcome">
|
---|
46 | <and>
|
---|
47 | <available file="${baseScratchDest}/somefile.txt"/>
|
---|
48 | <available file="${baseScratchDest}/somefile.txt${map.ext}"/>
|
---|
49 | <not>
|
---|
50 | <available file="${baseScratchSrc}/somefile.txt"/>
|
---|
51 | </not>
|
---|
52 | <not>
|
---|
53 | <available file="${baseScratchSrc}/somefile.txt${map.ext}"/>
|
---|
54 | </not>
|
---|
55 | </and>
|
---|
56 | </condition>
|
---|
57 | <fail unless="test2.outcome">mulitmove failed</fail>
|
---|
58 | </target>
|
---|
59 |
|
---|
60 | <!--
|
---|
61 | test traditional single file to single file copy explicitly telling
|
---|
62 | task to ignore multiple mappings
|
---|
63 | -->
|
---|
64 |
|
---|
65 | <target name="singlecopy" depends="setup">
|
---|
66 | <copy todir="${baseScratchDest}" enablemultiplemappings="false">
|
---|
67 | <fileset dir="${baseScratchSrc}" includes="somefile.txt"/>
|
---|
68 | <mapper refid="testmapper"/>
|
---|
69 | </copy>
|
---|
70 | <condition property="singlecopy.outcome">
|
---|
71 | <and>
|
---|
72 | <available file="${baseScratchDest}/somefile.txt"/>
|
---|
73 | <not>
|
---|
74 | <available file="${baseScratchDest}/somefile.txt${map.ext}"/>
|
---|
75 | </not>
|
---|
76 | <available file="${baseScratchSrc}/somefile.txt"/>
|
---|
77 | </and>
|
---|
78 | </condition>
|
---|
79 | <fail unless="singlecopy.outcome">singlecopy failed</fail>
|
---|
80 | </target>
|
---|
81 |
|
---|
82 | <target name="singlemove" depends="setup">
|
---|
83 | <move todir="${baseScratchDest}" enablemultiplemappings="false">
|
---|
84 | <fileset dir="${baseScratchSrc}" includes="somefile.txt"/>
|
---|
85 | <mapper refid="testmapper"/>
|
---|
86 | </move>
|
---|
87 | <condition property="singlemove.outcome">
|
---|
88 | <and>
|
---|
89 | <available file="${baseScratchDest}/somefile.txt"/>
|
---|
90 | <not>
|
---|
91 | <available file="${baseScratchDest}/somefile.txt${map.ext}"/>
|
---|
92 | </not>
|
---|
93 | <not>
|
---|
94 | <available file="${baseScratchSrc}/somefile.txt"/>
|
---|
95 | </not>
|
---|
96 | </and>
|
---|
97 | </condition>
|
---|
98 | <fail unless="singlemove.outcome">singlemove failed</fail>
|
---|
99 | </target>
|
---|
100 |
|
---|
101 | <!-- test dir w/ file + empty dir multimap copy -->
|
---|
102 | <target name="copywithempty">
|
---|
103 | <delete dir="${baseScratchSrc}"/>
|
---|
104 | <mkdir dir="${baseScratchSrc}/dirwithfile"/>
|
---|
105 | <mkdir dir="${baseScratchSrc}/emptydir"/>
|
---|
106 | <touch file="${baseScratchSrc}/dirwithfile/somefile.txt"/>
|
---|
107 |
|
---|
108 | <delete dir="${baseScratchDest}"/>
|
---|
109 | <mkdir dir="${baseScratchDest}"/>
|
---|
110 |
|
---|
111 | <copy todir="${baseScratchDest}" enablemultiplemappings="true">
|
---|
112 | <fileset dir="${baseScratchSrc}" includes="**/*"/>
|
---|
113 | <mapper refid="testmapper"/>
|
---|
114 | </copy>
|
---|
115 | <condition property="copywithempty.outcome">
|
---|
116 | <and>
|
---|
117 | <available file="${baseScratchDest}/dirwithfile"/>
|
---|
118 | <available file="${baseScratchDest}/dirwithfile${map.ext}"/>
|
---|
119 | <available file="${baseScratchDest}/dirwithfile/somefile.txt"/>
|
---|
120 | <available file="${baseScratchDest}/dirwithfile/somefile.txt${map.ext}"/>
|
---|
121 | <not>
|
---|
122 | <available file="${baseScratchDest}/dirwithfile${map.ext}/somefile.txt"/>
|
---|
123 | </not>
|
---|
124 | <not>
|
---|
125 | <available file="${baseScratchDest}/dirwithfile${map.ext}/somefile.txt${map.ext}"/>
|
---|
126 | </not>
|
---|
127 | <available file="${baseScratchDest}/emptydir"/>
|
---|
128 | <available file="${baseScratchDest}/emptydir${map.ext}"/>
|
---|
129 | </and>
|
---|
130 | </condition>
|
---|
131 | <fail unless="copywithempty.outcome">copywithempty failed</fail>
|
---|
132 | </target>
|
---|
133 | <!-- test dir w/ file + empty dir multimap move -->
|
---|
134 | <target name="movewithempty">
|
---|
135 | <delete dir="${baseScratchSrc}"/>
|
---|
136 | <mkdir dir="${baseScratchSrc}/dirwithfile"/>
|
---|
137 | <mkdir dir="${baseScratchSrc}/emptydir"/>
|
---|
138 | <touch file="${baseScratchSrc}/dirwithfile/somefile.txt"/>
|
---|
139 |
|
---|
140 | <delete dir="${baseScratchDest}"/>
|
---|
141 | <mkdir dir="${baseScratchDest}"/>
|
---|
142 |
|
---|
143 | <move todir="${baseScratchDest}" enablemultiplemappings="true">
|
---|
144 | <fileset dir="${baseScratchSrc}" includes="**/*"/>
|
---|
145 | <mapper refid="testmapper"/>
|
---|
146 | </move>
|
---|
147 | <condition property="movewithempty.outcome">
|
---|
148 | <and>
|
---|
149 | <available file="${baseScratchDest}/dirwithfile"/>
|
---|
150 | <available file="${baseScratchDest}/dirwithfile${map.ext}"/>
|
---|
151 | <available file="${baseScratchDest}/dirwithfile/somefile.txt"/>
|
---|
152 | <available file="${baseScratchDest}/dirwithfile/somefile.txt${map.ext}"/>
|
---|
153 | <not>
|
---|
154 | <available file="${baseScratchDest}/dirwithfile${map.ext}/somefile.txt"/>
|
---|
155 | </not>
|
---|
156 | <not>
|
---|
157 | <available file="${baseScratchDest}/dirwithfile${map.ext}/somefile.txt${map.ext}"/>
|
---|
158 | </not>
|
---|
159 | <available file="${baseScratchDest}/emptydir"/>
|
---|
160 | <available file="${baseScratchDest}/emptydir${map.ext}"/>
|
---|
161 | <not>
|
---|
162 | <available file="${baseScratchSrc}/dirwithfile"/>
|
---|
163 | </not>
|
---|
164 | <not>
|
---|
165 | <available file="${baseScratchSrc}/emptydir"/>
|
---|
166 | </not>
|
---|
167 | </and>
|
---|
168 | </condition>
|
---|
169 | <fail unless="movewithempty.outcome">movewithempty failed</fail>
|
---|
170 | </target>
|
---|
171 |
|
---|
172 | <target name="cleanup">
|
---|
173 | <delete dir="${rootScratchDir}"/>
|
---|
174 | </target>
|
---|
175 |
|
---|
176 | </project>
|
---|