aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/etc/testcases/taskdefs/loadfile.xml
blob: 66c9ce4feabe69cd9a6880055f72cd602dc1326d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  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

      http://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 name="loadfile-test" basedir="." default="testLoadAFile">


  <target name="init">
  </target>

  <target name="testNoSourcefileDefined" depends="init">
    <loadfile property="foo" />
  </target>

  <target name="testNoPropertyDefined"
    depends="init">
    <loadfile srcFile="somefile" />
  </target>


  <target name="testNoSourcefilefound"
    depends="init">
    <loadfile property="missing" srcFile="somefile" />
  </target>

  <target name="testFailOnError"
    depends="init">
    <loadfile
      property="testFailOnError"
      srcFile="somefile"
      failonerror="false"/>
  </target>

  <target name="testLoadAFile"
    depends="init">
    <echo
      message="What's it going to be then, eh?"
      file="loadfile1.tmp"
      />
    <loadfile property="testLoadAFile" srcFile="loadfile1.tmp" />
    <echo>${testLoadAFile}</echo>
  </target>

  <target name="testLoadAFileEnc"
    depends="init">
    <loadfile property="testLoadAFileEnc"
      srcFile="loadfile.xml"
      encoding="ISO-8859-1"/>
  </target>

  <target name="testEvalProps"
    depends="init">
    <property name="weather" value="rain" />
    <echo
      message="All these moments will be lost in time, like teardrops in the ${weather}"
      file="loadfile1.tmp"
      />
    <loadfile property="testEvalProps"
        srcFile="loadfile1.tmp">
        <filterchain>
          <expandproperties/>
        </filterchain>
    </loadfile>
    <echo>${testEvalProps}</echo>
  </target>

  <target name="testFilterChain"
    depends="init">
      <echo file="loadfile1.tmp">#Line 1
REM Line 2
--Line 3
Line 4
Hello World!</echo>
      <loadfile srcFile="loadfile1.tmp" 
        property="testFilterChain">
        <filterchain>
          <headfilter lines="5"/>
          <striplinecomments>
            <comment value="--"/>
            <comment value="REM "/>
            <comment value="#"/>
          </striplinecomments>
          <filterreader classname="org.apache.tools.ant.filters.TailFilter">
            <param name="lines" value="1"/>
          </filterreader>
          <linecontains>
            <contains value="World!"/>
          </linecontains>
        </filterchain>
      </loadfile>
  </target>

  <target name="testStripJavaComments"
    depends="init">
      <echo file="loadfile1.tmp">
/*
Comment "1"
*/
public class test1 {
    //Some comment
    int x = 1/2;
    private static final String GREETING="*/Hello/*";
    private static final String GREETING1="/*Hello*/";

    public static void main( String args[] ) {
    }
}</echo>
      <echo file="nocomments.tmp">

public class test1 {
    
    int x = 1/2;
    private static final String GREETING="*/Hello/*";
    private static final String GREETING1="/*Hello*/";

    public static void main( String args[] ) {
    }
}</echo>
      <loadfile srcFile="loadfile1.tmp" 
        property="testStripJavaComments">
        <filterchain>
          <stripjavacomments/>
        </filterchain>
      </loadfile>
      <loadfile srcFile="nocomments.tmp" 
        property="expected"/>
  </target>

  <target name="testOneLine"
    depends="init">
    <echo
      message="1,&#10;2,&#13;3,&#13;&#10;4"
      file="loadfile1.tmp"
      />
    <loadfile property="testOneLine"
        srcFile="loadfile1.tmp">
      <filterchain>
        <striplinebreaks/>
      </filterchain>
    </loadfile>
    <echo>${testOneLine}</echo>
  </target>


  <target name="cleanup">
    <delete file="loadfile1.tmp"/>
    <delete file="nocomments.tmp"/>
  </target>

  </project>