aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/echoxml-test.xml
blob: d461d3d8305a6e45e5118f36048ba97d7dee4f90 (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
<?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 default="antunit" xmlns:au="antlib:org.apache.ant.antunit">

  <!-- note relies on antunit 1.1 -->
  <import file="../antunit-base.xml"/>

  <target name="setUp">
    <property name="file" location="${output}/echoed.xml"/>
    <mkdir dir="${output}"/>
    <echoxml file="${file}">
      <project>
        <property name="foo" value="bar" />
        <fail message="$$$${foo}=$${foo}">
          <condition>
            <istrue value="${mustfail}" />
          </condition>
        </fail>
      </project>
    </echoxml>
  </target>
  
  <target name="testPass">
    <ant antfile="${file}"/>
  </target>
  
  <target name="testFail">
    <au:expectfailure expectedmessage="${foo}=bar" message="Should have thrown an exception">
      <ant antfile="${file}">
        <property name="mustfail" value="true" />
      </ant>
    </au:expectfailure>
  </target>
  
  <target name="testEmpty">
    <au:expectfailure expectedmessage="No nested XML specified" message="Should have thrown an exception">
      <echoxml />
    </au:expectfailure>
  </target>
  
 <!-- comment this and the next targets if you don't have the svn
      trunk of antunit -->
  <target name="test-ns-all">
    <echoxml file="${file}" xmlns:a="antlib:a"
             namespacepolicy="all">
      <a:something a:foo="bar"/>
    </echoxml>
    <au:assertResourceContains resource="${file}" value="a:something"/>
    <au:assertResourceContains resource="${file}" value="antlib:a"/>
  </target>

  <target name="test-ns-elementsOnly">
    <echoxml file="${file}" xmlns:a="antlib:a"
             namespacepolicy="elementsOnly">
      <a:something a:foo="bar"/>
    </echoxml>
    <au:assertResourceContains resource="${file}" value="a:something"/>
    <au:assertResourceContains resource="${file}" value="antlib:a"/>
  </target>

  <target name="test-ns-ignore">
    <echoxml file="${file}" xmlns:a="antlib:a"
             namespacepolicy="ignore">
      <a:something a:foo="bar"/>
    </echoxml>
    <au:assertResourceContains resource="${file}" value="a:something"/>
    <au:assertFalse message="Didn't expecte ${file} to contain antlib:a">
      <resourcecontains resource="${file}" substring="antlib:a"/>
    </au:assertFalse>
  </target>

</project>