aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/condition/resourcecontains-test.xml
blob: 11c6a9ed44fd889616060713c2901b1bac3a962f (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
<?xml version="1.0" encoding="utf-8"?>
<!--
  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="resourcecontains-test" default="antunit" xmlns:au="antlib:org.apache.ant.antunit">

  <import file="../../antunit-base.xml"/>

  <target name="setUp">
    <mkdir dir="${output}"/>
    <property name="file" location="${output}/test-resource.txt"/>
    <echo file="${file}" message="loads of text!"/>
  </target>

  <target name="testcontains">
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains resource="${file}" substring="text"/>
    </au:assertTrue>
  </target>

  <target name="testContainsLowerNonCS">
    <echo file="${file}" message="LOADS OF TEXT!"/>
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains resource="${file}" substring="text"
                        casesensitive="false"/>
    </au:assertTrue>
  </target>

  <target name="testContainsUpperNonCS">
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains resource="${file}" substring="TEXT"
                        casesensitive="false"/>
    </au:assertTrue>
  </target>

  <target name="testContainsEmptyString">
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains resource="${file}" substring="" />
    </au:assertTrue>
  </target>

  <target name="testContainsEmptyProperty">
    <property name="testContainsEmptyProperty" value="" />
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains resource="${file}"
                        substring="${testContainsEmptyProperty}" />
    </au:assertTrue>
  </target>

  <target name="testwithemptyfile">
    <truncate file="${file}"/>
    <au:assertFalse message="Should have found nothing as file is empty">
      <resourcecontains resource="${file}" substring="text"/>
    </au:assertFalse>
  </target>

  <target name="testWithEmptyFileAndSubstring">
    <truncate file="${file}"/>
    <au:assertTrue message="Empty resource should contain empty string">
      <resourcecontains resource="${file}" substring=""/>
    </au:assertTrue>
  </target>

  <target name="testdoesntcontain">
    <au:assertFalse message="Should have found nothing as file is empty">
      <resourcecontains resource="${file}" substring="futurama"/>
    </au:assertFalse>
  </target>

  <target name="testFileRefContains">
    <file id="file" file="${file}" />
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains refid="file" substring="text"/>
    </au:assertTrue>
  </target>

  <target name="testStringRefContains">
    <string id="string">loads of text!</string>
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains refid="string" substring="text"/>
    </au:assertTrue>
  </target>

  <target name="testTextConcatRefContains">
    <resources id="concat">
      <concat>loads of text!</concat>
    </resources>
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains refid="concat" substring="text"/>
    </au:assertTrue>
  </target>

  <target name="testFileConcatRefContains">
    <resources id="concat">
      <concat><file file="${file}" /></concat>
    </resources>
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains refid="concat" substring="text"/>
    </au:assertTrue>
  </target>

  <target name="testMultiConcatRefContains">
    <resources id="concat">
      <concat>
        <header>HEADER</header>
        <footer>FOOTER</footer>
        <string>foo</string>
        <file file="${file}" />
        <string>bar</string>
      </concat>
    </resources>
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains refid="concat" substring="text"/>
    </au:assertTrue>
  </target>

  <target name="testFirstRefContains">
    <first id="first">
      <fileset dir="${basedir}" includes="*-test.xml" />
    </first>
    <au:assertTrue message="Should have found the text in the resource">
      <resourcecontains refid="first" substring="project"/>
    </au:assertTrue>
  </target>

</project>