1 | /*
|
---|
2 | * Copyright 2003-2005 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 |
|
---|
18 | package org.apache.tools.ant.taskdefs;
|
---|
19 |
|
---|
20 | import org.apache.tools.ant.BuildFileTest;
|
---|
21 | import org.apache.tools.ant.Project;
|
---|
22 | import org.apache.tools.ant.Task;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | */
|
---|
26 | public class MacroDefTest extends BuildFileTest {
|
---|
27 | public MacroDefTest(String name) {
|
---|
28 | super(name);
|
---|
29 | }
|
---|
30 |
|
---|
31 | public void setUp() {
|
---|
32 | configureProject("src/etc/testcases/taskdefs/macrodef.xml");
|
---|
33 | }
|
---|
34 |
|
---|
35 | public void testSimple() {
|
---|
36 | expectLog("simple", "Hello World");
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void testText() {
|
---|
40 | expectLog("text", "Inner Text");
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void testDuplicateAttribute() {
|
---|
44 | expectBuildException(
|
---|
45 | "duplicate.attribute",
|
---|
46 | "the attribute text has already been specified");
|
---|
47 | }
|
---|
48 |
|
---|
49 | public void testDuplicateElement() {
|
---|
50 | expectBuildException(
|
---|
51 | "duplicate.element",
|
---|
52 | "the element text has already been specified");
|
---|
53 | }
|
---|
54 |
|
---|
55 | public void testUri() {
|
---|
56 | expectLog("uri", "Hello World");
|
---|
57 | }
|
---|
58 |
|
---|
59 | public void testNested() {
|
---|
60 | expectLog("nested", "A nested element");
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void testDouble() {
|
---|
64 | expectLog(
|
---|
65 | "double",
|
---|
66 | "@{prop} is 'property', value of ${property} is 'A property value'");
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void testIgnoreCase() {
|
---|
70 | expectLog(
|
---|
71 | "ignorecase",
|
---|
72 | "a is ab is b");
|
---|
73 | }
|
---|
74 |
|
---|
75 | public void testIgnoreElementCase() {
|
---|
76 | expectLog(
|
---|
77 | "ignore-element-case",
|
---|
78 | "nested elementnested element");
|
---|
79 | }
|
---|
80 |
|
---|
81 | public void testTextElement() {
|
---|
82 | expectLogContaining(
|
---|
83 | "textelement", "Hello world");
|
---|
84 | }
|
---|
85 |
|
---|
86 | public void testTextTrim() {
|
---|
87 | expectLogContaining(
|
---|
88 | "text.trim", "[Hello world]");
|
---|
89 | }
|
---|
90 |
|
---|
91 | public void testDuplicateTextName() {
|
---|
92 | expectBuildException(
|
---|
93 | "duplicatetextname",
|
---|
94 | "the name \"text\" is already used as an attribute");
|
---|
95 | }
|
---|
96 | public void testDuplicateTextName2() {
|
---|
97 | expectBuildException(
|
---|
98 | "duplicatetextname2",
|
---|
99 | "the attribute name \"text\" has already been used by the text element");
|
---|
100 | }
|
---|
101 | public void testEscape() {
|
---|
102 | expectLog(
|
---|
103 | "escape",
|
---|
104 | "a@b or a@b is avalue@bvalue");
|
---|
105 | }
|
---|
106 | public void testAttributeDescription() {
|
---|
107 | expectLog(
|
---|
108 | "attribute.description",
|
---|
109 | "description is hello world");
|
---|
110 | }
|
---|
111 | public void testOverrideDefault() {
|
---|
112 | expectLog(
|
---|
113 | "override.default",
|
---|
114 | "value is new");
|
---|
115 | }
|
---|
116 | public void testImplicit() {
|
---|
117 | expectLog(
|
---|
118 | "implicit", "Before implicitIn implicitAfter implicit");
|
---|
119 | }
|
---|
120 | public void testImplicitNotOptional() {
|
---|
121 | expectSpecificBuildException(
|
---|
122 | "implicit.notoptional",
|
---|
123 | "Missing nested elements for implicit element implicit",
|
---|
124 | "Missing nested elements for implicit element implicit");
|
---|
125 | }
|
---|
126 | public void testImplicitOptional() {
|
---|
127 | expectLog(
|
---|
128 | "implicit.optional", "Before implicitAfter implicit");
|
---|
129 | }
|
---|
130 | public void testImplicitExplicit() {
|
---|
131 | expectSpecificBuildException(
|
---|
132 | "implicit.explicit",
|
---|
133 | "Only one element allowed when using implicit elements",
|
---|
134 | "Only one element allowed when using implicit elements");
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|