aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/types/propertyset-test.xml
blob: 0b7e236c9ed01367a4abaa986a9f8e875a0659ac (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
<?xml version="1.0"?>
<!--
 *   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="test-propertyset" basedir="." default="antunit"
         xmlns:au="antlib:org.apache.ant.antunit">

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

  <property name="fooA" value="FooA"/>
  <property name="barB" value="BarB"/>

  <propertyset id="properties-starting-with-foo">
    <propertyref prefix="foo"/>
  </propertyset>
  <propertyset id="properties-starting-with-bar">
    <propertyref prefix="bar"/>
  </propertyset>
  <propertyset id="my-set">
    <propertyset refid="properties-starting-with-foo"/>
    <propertyset refid="properties-starting-with-bar"/>
  </propertyset>
  
  <macrodef name="expect.equals">
    <attribute name="test"/>
    <attribute name="exp"/>
    <attribute name="got"/>
    <sequential>
      <fail message=
          "@{test} failed: expected &quot;@{exp}&quot; got &quot;@{got}&quot;">
        <condition>
          <not>
            <equals arg1="@{exp}" arg2="@{got}"/>
          </not>
        </condition>
      </fail>
    </sequential>
  </macrodef>

  <target name="test-reference-to-two-references">
    <expect.equals
      test="reference to two references"
      exp="barB=BarB, fooA=FooA"
      got="${toString:my-set}"/>
  </target>

  <target name="test-nested-mapped">
    <propertyset id="nested-mapped">
      <propertyset>
        <propertyset refid="properties-starting-with-foo"/>
        <globmapper from="foo*" to="boo*" />
      </propertyset>
      <propertyset>
        <propertyset refid="properties-starting-with-bar"/>
        <globmapper from="bar*" to="far*" />
      </propertyset>
    </propertyset>
    <expect.equals
      test="nested mapped propertysets"
      exp="booA=FooA, farB=BarB"
      got="${toString:nested-mapped}"/>
  </target>

  <target name="test-nested-mapped-mapped">
    <propertyset id="nested-mapped-mapped">
      <propertyset>
        <propertyset refid="properties-starting-with-foo"/>
        <globmapper from="foo*" to="boo*" />
      </propertyset>
      <propertyset>
        <propertyset refid="properties-starting-with-bar"/>
        <globmapper from="bar*" to="far*" />
      </propertyset>
      <mapper>
        <globmapper from="boo*" to="hoo*" />
        <globmapper from="far*" to="near*" />
      </mapper>
    </propertyset>
    <expect.equals
      test="nested mapped propertysets"
      exp="hooA=FooA, nearB=BarB"
      got="${toString:nested-mapped-mapped}"/>
  </target>

  <target name="testResources">
    <au:assertTrue>
      <resourcecount count="2">
        <restrict>
          <exists />
          <resources refid="my-set" />
        </restrict>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testMappedResources">
    <au:assertTrue>
      <resourcecount count="2">
        <restrict>
          <exists />
          <propertyset>
            <propertyset refid="my-set" />
            <globmapper from="bar*" to="far*" />
          </propertyset>
        </restrict>
      </resourcecount>
    </au:assertTrue>
  </target>

</project>