source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/etc/testcases/filters/tokenfilter.xml@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 8.3 KB
Line 
1<?xml version="1.0"?>
2<project default="cleanup" basedir=".">
3
4 <target name="init">
5 <mkdir dir="result" />
6 </target>
7
8 <target name="cleanup">
9 <delete dir="result"/>
10 </target>
11
12 <target name="tokenfilter">
13 <copy file="input/linecontains.test" tofile="result/file1">
14 <filterchain>
15 <tokenfilter/>
16 </filterchain>
17 </copy>
18 </target>
19
20 <target name="trimignore">
21 <concat destfile="result/input">
22 Hello
23
24 World
25 </concat>
26 <copy file="result/input" tofile="result/output" overwrite="yes">
27 <filterchain>
28 <tokenfilter delimoutput="-">
29 <trim/>
30 <ignoreblank/>
31 </tokenfilter>
32 </filterchain>
33 </copy>
34 <concat>
35 <filelist dir="." files="result/output"/>
36 </concat>
37 </target>
38
39 <target name="trimfile">
40 <concat destfile="result/trimfile">
41 This is the contents of the trimmed file.
42 This is the second line.
43 <filterchain>
44 <trim byline="no"/>
45 </filterchain>
46 </concat>
47 </target>
48
49 <target name="trimfilebyline">
50 <concat destfile="result/trimfilebyline">
51 This is the contents of the trimmed file.
52 This is the second line.
53 <filterchain>
54 <trim/>
55 <tokenfilter delimoutput="\n"/>
56 </filterchain>
57 </concat>
58 </target>
59
60 <target name="filterreplacestring">
61 <concat destfile="result/filterreplacestring">
62 This is foo bar
63 <filterchain>
64 <replacestring from="foo" to="the"/>
65 <replacestring from="bar" to="moon"/>
66 </filterchain>
67 </concat>
68 </target>
69
70 <target name="filterreplacestrings">
71 <concat>
72 foo foo foo
73 <filterchain>
74 <replacestring from="foo" to="bar"/>
75 </filterchain>
76 </concat>
77 </target>
78
79 <target name="stringtokenizer">
80 <concat destfile="result/input">
81 This is a number
82 of words
83 </concat>
84 <copy file="result/input" tofile="result/output" overwrite="yes">
85 <filterchain>
86 <tokenfilter delimoutput="#">
87 <stringtokenizer/>
88 </tokenfilter>
89 </filterchain>
90 </copy>
91 <concat>
92 <filelist dir="." files="result/output"/>
93 </concat>
94 </target>
95
96 <target name="unixlineoutput">
97 <concat destfile="result/unixlineoutput">
98 This is a number
99 of words
100 <filterchain>
101 <tokenfilter delimoutput="\n">
102 <stringtokenizer/>
103 </tokenfilter>
104 </filterchain>
105 </concat>
106 </target>
107
108 <target name="doslineoutput">
109 <concat destfile="result/doslineoutput">
110 This is a number
111 of words
112 <filterchain>
113 <tokenfilter delimoutput="\r\n">
114 <stringtokenizer/>
115 </tokenfilter>
116 </filterchain>
117 </concat>
118 </target>
119
120 <target name="filetokenizer">
121 <concat destfile="result/input">
122 This is a number
123 of words
124 </concat>
125 <copy file="result/input" tofile="result/filetokenizer">
126 <filterchain>
127 <tokenfilter>
128 <filetokenizer/>
129 <trim/>
130 </tokenfilter>
131 </filterchain>
132 </copy>
133 </target>
134
135 <target name="replacestring">
136 <concat destfile="result/replacestring">
137 this is the sun
138 <filterchain>
139 <tokenfilter>
140 <replacestring from="sun" to="moon"/>
141 </tokenfilter>
142 </filterchain>
143 </concat>
144 </target>
145
146 <target name="replacestrings">
147 <concat>
148 foo foo foo
149 <filterchain>
150 <tokenfilter>
151 <replacestring from="foo" to="bar"/>
152 </tokenfilter>
153 </filterchain>
154 </concat>
155 </target>
156
157 <target name="containsstring">
158 <concat destfile="result/input">
159 this is a line contains foo
160 this line does not
161 </concat>
162 <copy file="result/input" tofile="result/containsstring">
163 <filterchain>
164 <tokenfilter>
165 <containsstring contains="foo"/>
166 </tokenfilter>
167 </filterchain>
168 </copy>
169 </target>
170
171 <!-- need to check for existance of regex -->
172 <target name="replaceregex">
173 <concat destfile="result/input">
174 hello Hello HELLO hello
175 cat Cat cat
176 Sun Sun Sun
177 WhiteSpace tab
178 This is a line with digits - 1234 -- there
179 </concat>
180 <copy file="result/input" tofile="result/replaceregex">
181 <filterchain>
182 <tokenfilter>
183 <replaceregex pattern="hello" replace="world" flags="gi"/>
184 <replaceregex pattern="cat" replace="dog" flags="g"/>
185 <replaceregex pattern="sun" replace="moon" flags="i"/>
186 <replaceregex pattern="WhiteSpace[ \t]+tab"
187 replace="found WhiteSpace"/>
188 <replaceregex pattern="This is a line with dig.* ([0-9]+).*"
189 replace="Found digits [\1]"/>
190 </tokenfilter>
191 </filterchain>
192 </copy>
193 </target>
194
195 <target name="filterreplaceregex">
196 <concat destfile="result/filterreplaceregex">
197 hello Hello HELLO hello
198 <filterchain>
199 <replaceregex pattern="hello" replace="world" flags="gi"/>
200 </filterchain>
201 </concat>
202 </target>
203
204 <target name="dollermatch">
205 <concat>
206 @hello@
207 <filterchain>
208 <replaceregex pattern="@([^@]*)@" replace="${\1}"/>
209 </filterchain>
210 </concat>
211 </target>
212
213 <!-- need to check for existance of regex -->
214 <target name="containsregex">
215 <concat destfile="result/input">
216 hello world
217 this is the moon
218 World here
219 </concat>
220 <copy file="result/input" tofile="result/containsregex">
221 <filterchain>
222 <tokenfilter>
223 <containsregex pattern="(hello|world)" flags="i"/>
224 </tokenfilter>
225 </filterchain>
226 </copy>
227 </target>
228
229 <target name="filtercontainsregex">
230 <concat destfile="result/filtercontainsregex">
231 hello world
232 this is the moon
233 World here
234 <filterchain>
235 <tokenfilter>
236 <containsregex pattern="(hello|world)" flags="i"/>
237 </tokenfilter>
238 </filterchain>
239 </concat>
240 </target>
241
242
243 <!-- need to check for existance of regex -->
244 <target name="containsregex2">
245 <concat destfile="result/input">
246 SUITE(TestSuite, bits);
247 here
248 </concat>
249 <copy file="result/input" tofile="result/containsregex2">
250 <filterchain>
251 <tokenfilter>
252 <containsregex
253 pattern="^ *SUITE\(.*,\s*(.*)\s*\).*"
254 replace="void register_\1();"/>
255 </tokenfilter>
256 </filterchain>
257 </copy>
258 </target>
259
260 <target name="deletecharacters">
261 <concat destfile="result/deletechars">
262 This is some ### s
263 some ****
264 <filterchain>
265 <tokenfilter>
266 <deletecharacters chars="#"/>
267 </tokenfilter>
268 <deletecharacters chars="*"/>
269 </filterchain>
270 </concat>
271 </target>
272
273 <target name="scriptfilter">
274 <concat destfile="result/input">
275 hello world
276 </concat>
277 <copy file="result/input" tofile="result/scriptfilter">
278 <filterchain>
279 <tokenfilter>
280 <scriptfilter language="javascript">
281 self.setToken(self.getToken().toUpperCase());
282 </scriptfilter>
283 </tokenfilter>
284 </filterchain>
285 </copy>
286 </target>
287
288 <target name="scriptfilter2">
289 <concat destfile="result/input">
290 hello moon
291 </concat>
292 <copy file="result/input" tofile="result/scriptfilter2">
293 <filterchain>
294 <scriptfilter language="javascript">
295 self.setToken(self.getToken().toUpperCase());
296 </scriptfilter>
297 </filterchain>
298 </copy>
299 </target>
300
301 <target name="customtokenfilter">
302 <path id="test-classes">
303 <pathelement location="../../../../build/testcases" />
304 <pathelement path="${java.class.path}" />
305 </path>
306
307
308 <typedef
309 name="capitalize"
310 classname="org.apache.tools.ant.filters.TokenFilterTest$Capitalize">
311 <classpath refid="test-classes"/>
312 </typedef>
313
314 <concat destfile="result/input">
315 hello world
316 </concat>
317
318 <copy file="result/input" tofile="result/custom">
319 <filterchain>
320 <tokenfilter>
321 <stringtokenizer/>
322 <capitalize/>
323 </tokenfilter>
324 </filterchain>
325 </copy>
326 </target>
327
328 <target name="hasscript">
329 <script language="javascript">
330 i = 1;
331 </script>
332 </target>
333
334 <target name="hasregex">
335 <concat destfile="result/replaceregexp">
336 hello world
337 </concat>
338 <replaceregexp file="result/replaceregexp"
339 match="hello( )world"
340 replace="bye\1world"/>
341 </target>
342
343</project>
Note: See TracBrowser for help on using the repository browser.