001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.tools.ant.taskdefs;
019:
020: import org.apache.tools.ant.BuildFileTest;
021:
022: /**
023: * @created 13 January 2002
024: */
025: public class ConditionTest extends BuildFileTest {
026:
027: /**
028: * Constructor for the ConditionTest object
029: *
030: * @param name we dont know
031: */
032: public ConditionTest(String name) {
033: super (name);
034: }
035:
036: /**
037: * The JUnit setup method
038: */
039: public void setUp() {
040: configureProject("src/etc/testcases/taskdefs/condition.xml");
041: }
042:
043: /**
044: * The teardown method for JUnit
045: */
046: public void tearDown() {
047: executeTarget("cleanup");
048: }
049:
050: public void testBasic() {
051: expectPropertySet("basic", "basic");
052: }
053:
054: public void testConditionIncomplete() {
055: expectSpecificBuildException("condition-incomplete",
056: "property attribute has been omitted",
057: "The property attribute is required.");
058: }
059:
060: public void testConditionEmpty() {
061: expectSpecificBuildException("condition-empty",
062: "no conditions",
063: "You must nest a condition into <condition>");
064: }
065:
066: public void testShortcut() {
067: expectPropertySet("shortcut", "shortcut", "set");
068: }
069:
070: public void testUnset() {
071: expectPropertyUnset("dontset", "dontset");
072: }
073:
074: public void testSetValue() {
075: expectPropertySet("setvalue", "setvalue", "woowoo");
076: }
077:
078: public void testNegation() {
079: expectPropertySet("negation", "negation");
080: }
081:
082: public void testNegationFalse() {
083: expectPropertyUnset("negationfalse", "negationfalse");
084: }
085:
086: public void testNegationIncomplete() {
087: expectSpecificBuildException("negationincomplete",
088: "no conditions in <not>",
089: "You must nest a condition into <not>");
090: }
091:
092: public void testAnd() {
093: expectPropertySet("and", "and");
094: }
095:
096: public void testAndFails() {
097: expectPropertyUnset("andfails", "andfails");
098: }
099:
100: public void testAndIncomplete() {
101: expectPropertyUnset("andincomplete", "andincomplete");
102: }
103:
104: public void testAndempty() {
105: expectPropertySet("andempty", "andempty");
106: }
107:
108: public void testOr() {
109: expectPropertySet("or", "or");
110: }
111:
112: public void testOrincomplete() {
113: expectPropertySet("or", "or");
114: }
115:
116: public void testOrFails() {
117: expectPropertyUnset("orfails", "orfails");
118: }
119:
120: public void testOrboth() {
121: expectPropertySet("orboth", "orboth");
122: }
123:
124: public void testFilesmatchIdentical() {
125: expectPropertySet("filesmatch-identical",
126: "filesmatch-identical");
127: }
128:
129: public void testFilesmatchIncomplete() {
130: expectSpecificBuildException("filesmatch-incomplete",
131: "Missing file2 attribute",
132: "both file1 and file2 are required in filesmatch");
133: }
134:
135: public void testFilesmatchOddsizes() {
136: expectPropertyUnset("filesmatch-oddsizes",
137: "filesmatch-oddsizes");
138: }
139:
140: public void testFilesmatchExistence() {
141: expectPropertyUnset("filesmatch-existence",
142: "filesmatch-existence");
143: }
144:
145: public void testFilesmatchDifferent() {
146: expectPropertyUnset("filesmatch-different",
147: "filesmatch-different");
148: }
149:
150: public void testFilesmatchMatch() {
151: expectPropertySet("filesmatch-match", "filesmatch-match");
152: }
153:
154: public void testFilesmatchDifferentSizes() {
155: expectPropertyUnset("filesmatch-different-sizes",
156: "filesmatch-different-sizes");
157: }
158:
159: public void testFilesmatchDifferentOnemissing() {
160: expectPropertyUnset("filesmatch-different-onemissing",
161: "filesmatch-different-onemissing");
162: }
163:
164: public void testFilesmatchDifferentEol() {
165: executeTarget("filesmatch-different-eol");
166: }
167:
168: public void testFilesmatchSameEol() {
169: executeTarget("filesmatch-same-eol");
170: }
171:
172: public void testFilesmatchNeitherExist() {
173: executeTarget("filesmatch-neitherexist");
174: }
175:
176: public void testContains() {
177: expectPropertySet("contains", "contains");
178: }
179:
180: public void testContainsDoesnt() {
181: expectPropertyUnset("contains-doesnt", "contains-doesnt");
182: }
183:
184: public void testContainsAnycase() {
185: expectPropertySet("contains-anycase", "contains-anycase");
186: }
187:
188: public void testContainsIncomplete1() {
189: expectSpecificBuildException("contains-incomplete1",
190: "Missing contains attribute",
191: "both string and substring are required in contains");
192: }
193:
194: public void testContainsIncomplete2() {
195: expectSpecificBuildException("contains-incomplete2",
196: "Missing contains attribute",
197: "both string and substring are required in contains");
198: }
199:
200: public void testIstrue() {
201: expectPropertySet("istrue", "istrue");
202: }
203:
204: public void testIstrueNot() {
205: expectPropertyUnset("istrue-not", "istrue-not");
206: }
207:
208: public void testIstrueFalse() {
209: expectPropertyUnset("istrue-false", "istrue-false");
210: }
211:
212: public void testIstrueIncomplete1() {
213: expectSpecificBuildException("istrue-incomplete",
214: "Missing attribute", "Nothing to test for truth");
215: }
216:
217: public void testIsfalseTrue() {
218: expectPropertyUnset("isfalse-true", "isfalse-true");
219: }
220:
221: public void testIsfalseNot() {
222: expectPropertySet("isfalse-not", "isfalse-not");
223: }
224:
225: public void testIsfalseFalse() {
226: expectPropertySet("isfalse-false", "isfalse-false");
227: }
228:
229: public void testIsfalseIncomplete1() {
230: expectSpecificBuildException("isfalse-incomplete",
231: "Missing attribute", "Nothing to test for falsehood");
232: }
233:
234: public void testElse() {
235: executeTarget("testElse");
236: }
237:
238: public void testResourcesmatchError() {
239: expectBuildException("resourcesmatch-error",
240: "should fail because no resources specified");
241: }
242:
243: public void testResourcesmatchEmpty() {
244: executeTarget("resourcesmatch-match-empty");
245: }
246:
247: public void testResourcesmatchOne() {
248: executeTarget("resourcesmatch-match-one");
249: }
250:
251: public void testResourcesmatchBinary() {
252: executeTarget("resourcesmatch-match-binary");
253: }
254:
255: public void testResourcesmatchMultipleBinary() {
256: executeTarget("resourcesmatch-match-multiple-binary");
257: }
258:
259: public void testResourcesmatchDiffer() {
260: executeTarget("resourcesmatch-differ");
261: }
262:
263: public void testResourcesmatchText() {
264: executeTarget("resourcesmatch-match-text");
265: }
266:
267: public void testResourcesmatchNoneExist() {
268: executeTarget("resourcesmatch-noneexist");
269: }
270: }
|