1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <project name="loadfile-test" basedir="." default="testLoadAFile">
|
---|
3 |
|
---|
4 |
|
---|
5 | <target name="init">
|
---|
6 | </target>
|
---|
7 |
|
---|
8 | <target name="testNoSourcefileDefined" depends="init">
|
---|
9 | <loadfile property="foo" />
|
---|
10 | </target>
|
---|
11 |
|
---|
12 | <target name="testNoPropertyDefined"
|
---|
13 | depends="init">
|
---|
14 | <loadfile srcFile="somefile" />
|
---|
15 | </target>
|
---|
16 |
|
---|
17 |
|
---|
18 | <target name="testNoSourcefilefound"
|
---|
19 | depends="init">
|
---|
20 | <loadfile property="missing" srcFile="somefile" />
|
---|
21 | </target>
|
---|
22 |
|
---|
23 | <target name="testFailOnError"
|
---|
24 | depends="init">
|
---|
25 | <loadfile
|
---|
26 | property="testFailOnError"
|
---|
27 | srcFile="somefile"
|
---|
28 | failonerror="false"/>
|
---|
29 | </target>
|
---|
30 |
|
---|
31 | <target name="testLoadAFile"
|
---|
32 | depends="init">
|
---|
33 | <echo
|
---|
34 | message="What's it going to be then, eh?"
|
---|
35 | file="loadfile1.tmp"
|
---|
36 | />
|
---|
37 | <loadfile property="testLoadAFile" srcFile="loadfile1.tmp" />
|
---|
38 | <echo>${testLoadAFile}</echo>
|
---|
39 | </target>
|
---|
40 |
|
---|
41 | <target name="testLoadAFileEnc"
|
---|
42 | depends="init">
|
---|
43 | <loadfile property="testLoadAFileEnc"
|
---|
44 | srcFile="loadfile.xml"
|
---|
45 | encoding="ISO-8859-1"/>
|
---|
46 | </target>
|
---|
47 |
|
---|
48 | <target name="testEvalProps"
|
---|
49 | depends="init">
|
---|
50 | <property name="weather" value="rain" />
|
---|
51 | <echo
|
---|
52 | message="All these moments will be lost in time, like teardrops in the ${weather}"
|
---|
53 | file="loadfile1.tmp"
|
---|
54 | />
|
---|
55 | <loadfile property="testEvalProps"
|
---|
56 | srcFile="loadfile1.tmp">
|
---|
57 | <filterchain>
|
---|
58 | <expandproperties/>
|
---|
59 | </filterchain>
|
---|
60 | </loadfile>
|
---|
61 | <echo>${testEvalProps}</echo>
|
---|
62 | </target>
|
---|
63 |
|
---|
64 | <target name="testFilterChain"
|
---|
65 | depends="init">
|
---|
66 | <echo file="loadfile1.tmp">#Line 1
|
---|
67 | REM Line 2
|
---|
68 | --Line 3
|
---|
69 | Line 4
|
---|
70 | Hello World!</echo>
|
---|
71 | <loadfile srcFile="loadfile1.tmp"
|
---|
72 | property="testFilterChain">
|
---|
73 | <filterchain>
|
---|
74 | <headfilter lines="5"/>
|
---|
75 | <striplinecomments>
|
---|
76 | <comment value="--"/>
|
---|
77 | <comment value="REM "/>
|
---|
78 | <comment value="#"/>
|
---|
79 | </striplinecomments>
|
---|
80 | <filterreader classname="org.apache.tools.ant.filters.TailFilter">
|
---|
81 | <param name="lines" value="1"/>
|
---|
82 | </filterreader>
|
---|
83 | <linecontains>
|
---|
84 | <contains value="World!"/>
|
---|
85 | </linecontains>
|
---|
86 | </filterchain>
|
---|
87 | </loadfile>
|
---|
88 | </target>
|
---|
89 |
|
---|
90 | <target name="testStripJavaComments"
|
---|
91 | depends="init">
|
---|
92 | <echo file="loadfile1.tmp">
|
---|
93 | /*
|
---|
94 | Comment "1"
|
---|
95 | */
|
---|
96 | public class test1 {
|
---|
97 | //Some comment
|
---|
98 | int x = 1/2;
|
---|
99 | private static final String GREETING="*/Hello/*";
|
---|
100 | private static final String GREETING1="/*Hello*/";
|
---|
101 |
|
---|
102 | public static void main( String args[] ) {
|
---|
103 | }
|
---|
104 | }</echo>
|
---|
105 | <echo file="nocomments.tmp">
|
---|
106 |
|
---|
107 | public class test1 {
|
---|
108 |
|
---|
109 | int x = 1/2;
|
---|
110 | private static final String GREETING="*/Hello/*";
|
---|
111 | private static final String GREETING1="/*Hello*/";
|
---|
112 |
|
---|
113 | public static void main( String args[] ) {
|
---|
114 | }
|
---|
115 | }</echo>
|
---|
116 | <loadfile srcFile="loadfile1.tmp"
|
---|
117 | property="testStripJavaComments">
|
---|
118 | <filterchain>
|
---|
119 | <stripjavacomments/>
|
---|
120 | </filterchain>
|
---|
121 | </loadfile>
|
---|
122 | <loadfile srcFile="nocomments.tmp"
|
---|
123 | property="expected"/>
|
---|
124 | </target>
|
---|
125 |
|
---|
126 | <target name="testOneLine"
|
---|
127 | depends="init">
|
---|
128 | <echo
|
---|
129 | message="1, 2, 3, 4"
|
---|
130 | file="loadfile1.tmp"
|
---|
131 | />
|
---|
132 | <loadfile property="testOneLine"
|
---|
133 | srcFile="loadfile1.tmp">
|
---|
134 | <filterchain>
|
---|
135 | <striplinebreaks/>
|
---|
136 | </filterchain>
|
---|
137 | </loadfile>
|
---|
138 | <echo>${testOneLine}</echo>
|
---|
139 | </target>
|
---|
140 |
|
---|
141 |
|
---|
142 | <target name="cleanup">
|
---|
143 | <delete file="loadfile1.tmp"/>
|
---|
144 | <delete file="nocomments.tmp"/>
|
---|
145 | </target>
|
---|
146 |
|
---|
147 | </project>
|
---|