KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > ConditionTest


1 /*
2  * Copyright 2002, 2004-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 package org.apache.tools.ant.taskdefs;
18
19 import org.apache.tools.ant.Project;
20 import org.apache.tools.ant.BuildException;
21 import org.apache.tools.ant.BuildFileTest;
22 import java.lang.reflect.InvocationTargetException JavaDoc;
23
24 /**
25  * @created 13 January 2002
26  */

27 public class ConditionTest extends BuildFileTest {
28
29     /**
30      * Constructor for the ConditionTest object
31      *
32      * @param name we dont know
33      */

34     public ConditionTest(String JavaDoc name) {
35         super(name);
36     }
37
38
39     /**
40      * The JUnit setup method
41      */

42     public void setUp() {
43         configureProject("src/etc/testcases/taskdefs/condition.xml");
44     }
45
46
47     /**
48      * The teardown method for JUnit
49      */

50     public void tearDown() {
51         executeTarget("cleanup");
52     }
53
54     public void testBasic() {
55        expectPropertySet("basic","basic");
56     }
57
58     public void testConditionIncomplete() {
59         expectSpecificBuildException("condition-incomplete",
60                                      "property attribute has been omitted",
61                                      "The property attribute is required.");
62     }
63
64     public void testConditionEmpty() {
65         expectSpecificBuildException("condition-empty",
66                                      "no conditions",
67                                      "You must nest a condition into <condition>");
68     }
69
70     public void testShortcut() {
71         expectPropertySet("shortcut","shortcut","set");
72     }
73
74     public void testUnset() {
75         expectPropertyUnset("dontset","dontset");
76     }
77
78     public void testSetValue() {
79         expectPropertySet("setvalue","setvalue","woowoo");
80     }
81
82     public void testNegation() {
83         expectPropertySet("negation","negation");
84     }
85
86     public void testNegationFalse() {
87         expectPropertyUnset("negationfalse","negationfalse");
88     }
89
90     public void testNegationIncomplete() {
91         expectSpecificBuildException("negationincomplete",
92                                      "no conditions in <not>",
93                                      "You must nest a condition into <not>");
94     }
95
96     public void testAnd() {
97         expectPropertySet("and","and");
98     }
99
100     public void testAndFails() {
101         expectPropertyUnset("andfails","andfails");
102     }
103
104     public void testAndIncomplete() {
105         expectPropertyUnset("andincomplete","andincomplete");
106     }
107
108     public void testAndempty() {
109         expectPropertySet("andempty","andempty");
110     }
111
112     public void testOr() {
113         expectPropertySet("or","or");
114     }
115
116     public void testOrincomplete() {
117         expectPropertySet("or","or");
118     }
119
120     public void testOrFails() {
121         expectPropertyUnset("orfails","orfails");
122     }
123
124     public void testOrboth() {
125         expectPropertySet("orboth","orboth");
126     }
127
128     public void testFilesmatchIdentical() {
129         expectPropertySet("filesmatch-identical","filesmatch-identical");
130     }
131
132
133     public void testFilesmatchIncomplete() {
134         expectSpecificBuildException("filesmatch-incomplete",
135                                      "Missing file2 attribute",
136                                      "both file1 and file2 are required in filesmatch");
137     }
138
139     public void testFilesmatchOddsizes() {
140         expectPropertyUnset("filesmatch-oddsizes","filesmatch-oddsizes");
141     }
142
143     public void testFilesmatchExistence() {
144         expectPropertyUnset("filesmatch-existence", "filesmatch-existence");
145     }
146
147     public void testFilesmatchDifferent() {
148         expectPropertyUnset("filesmatch-different","filesmatch-different");
149     }
150
151     public void testFilesmatchMatch() {
152         expectPropertySet("filesmatch-match","filesmatch-match");
153     }
154
155     public void testFilesmatchDifferentSizes() {
156         expectPropertyUnset("filesmatch-different-sizes",
157             "filesmatch-different-sizes");
158     }
159
160     public void testFilesmatchDifferentOnemissing() {
161         expectPropertyUnset("filesmatch-different-onemissing",
162             "filesmatch-different-onemissing");
163     }
164
165     public void testContains() {
166         expectPropertySet("contains","contains");
167     }
168
169
170     public void testContainsDoesnt() {
171         expectPropertyUnset("contains-doesnt","contains-doesnt");
172     }
173
174     public void testContainsAnycase() {
175         expectPropertySet("contains-anycase","contains-anycase");
176     }
177
178
179     public void testContainsIncomplete1() {
180         expectSpecificBuildException("contains-incomplete1",
181                     "Missing contains attribute",
182                     "both string and substring are required in contains");
183     }
184
185     public void testContainsIncomplete2() {
186         expectSpecificBuildException("contains-incomplete2",
187                     "Missing contains attribute",
188                     "both string and substring are required in contains");
189     }
190
191     public void testIstrue() {
192         expectPropertySet("istrue","istrue");
193     }
194
195     public void testIstrueNot() {
196         expectPropertyUnset("istrue-not","istrue-not");
197     }
198
199     public void testIstrueFalse() {
200         expectPropertyUnset("istrue-false","istrue-false");
201     }
202
203
204     public void testIstrueIncomplete1() {
205         expectSpecificBuildException("istrue-incomplete",
206                     "Missing attribute",
207                     "Nothing to test for truth");
208     }
209
210     public void testIsfalseTrue() {
211         expectPropertyUnset("isfalse-true","isfalse-true");
212     }
213
214     public void testIsfalseNot() {
215         expectPropertySet("isfalse-not","isfalse-not");
216     }
217
218     public void testIsfalseFalse() {
219         expectPropertySet("isfalse-false","isfalse-false");
220     }
221
222
223     public void testIsfalseIncomplete1() {
224         expectSpecificBuildException("isfalse-incomplete",
225                     "Missing attribute",
226                     "Nothing to test for falsehood");
227     }
228
229     public void testElse() {
230         executeTarget("testElse");
231     }
232 }
233
234
Popular Tags