KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > flowcontrol > tests > OnceTaskTest


1 /**
2  * $Id: OnceTaskTest.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2004 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your option) any
9  * later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.flowcontrol.tests;
30
31 import junit.framework.TestSuite;
32
33 import com.idaremedia.antx.ut.HTCUtils;
34
35 /**
36  * Class test for {@linkplain com.idaremedia.antx.flowcontrol.call.OnceTask OnceTask}.
37  *
38  * @since JWare/AntX 0.1
39  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
40  * @version 0.5
41  * @.safety single
42  * @.group impl,test
43  **/

44
45 public final class OnceTaskTest extends StepCallerTestSkeleton
46 {
47     /** <i>PET</i> Test Category. **/
48     public static final String JavaDoc TEST_CATEGORY="CLASS";
49
50
51     /**
52      * Create new OnceTaskTest testcase.
53      **/

54     public OnceTaskTest(String JavaDoc methodName)
55     {
56         super("OnceTask::",methodName);
57     }
58
59
60     /**
61      * Create full test suite for OnceTask.
62      **/

63     public static TestSuite suite()
64     {
65         return new TestSuite(OnceTaskTest.class);
66     }
67
68
69     /**
70      * Create baseline test suite for OnceTask (same as full).
71      **/

72     public static TestSuite baseline()
73     {
74         return suite();//new BaselineSuite(OnceTaskTest.class);
75
}
76
77
78     /**
79      * Make this test (standalone) self-running.
80      **/

81     public static void main(String JavaDoc[] argv)
82     {
83         HTCUtils.quickCheck(suite());
84     }
85
86
87 // ---------------------------------------------------------------------------------------------------------
88
// ---------------------------------------- [ Misc Setup Methods ] -----------------------------------------
89
// ---------------------------------------------------------------------------------------------------------
90

91     protected String JavaDoc getDefaultConfigureXMLFileName()
92     {
93         return "once.xml";
94     }
95
96 // ---------------------------------------------------------------------------------------------------------
97
// ------------------------------------------- [ The Test Cases ] ------------------------------------------
98
// ---------------------------------------------------------------------------------------------------------
99

100     public void testFailEmptyElement()
101     {
102         expectBuildException("testOnceFailEmpty", "Empty definition");
103     }
104
105     public void testRequireEitherStepsOrTargetsNotBoth()
106     {
107         expectBuildException("testOnceRequiresEitherStepsOrTargets",
108                              "Either 'steps' or 'targets' not both");
109     }
110
111     public void testFailUnknownSteps()
112     {
113         expectBuildException("testOnceStepsFailUnknown", "Unknown steps");
114     }
115
116     public void testFailUnknownTargets()
117     {
118         expectBuildException("testOnceTargetsFailUnknown", "Unknown target");
119     }
120
121     public void testFailStepsWithNoName()
122     {
123         configureProjectFromResource("broken_step0.xml");
124         expectBuildException("testNoNameFailOnExec", "Un-named steps");
125     }
126
127     public void testFailNestedSteps()
128     {
129         verifyCantLoadFile("broken_step1.xml", "nested 'step' elements");
130     }
131
132 // public void testFailingIff()
133
// {
134
// runTarget("testFailIff");
135
// }
136

137 // public void testFailingIffTrue()
138
// {
139
// runTarget("testFailIffTrue");
140
// }
141

142 // public void testFailingUnless()
143
// {
144
// runTarget("testFailUnless");
145
// }
146

147 // public void testFailingUnlessTrue()
148
// {
149
// runTarget("testFailUnlessTrue");
150
// }
151

152 // public void testFailingIfUnless()
153
// {
154
// runTarget("testFailIfUnless");
155
// }
156

157     public void testTargetsJustRunIt()
158     {
159         runTarget("testOnceTargetsRunIt");
160         verifyTargetsRanInOrder("f",1,2,0);
161     }
162
163     public void testTargetsRunItAndDependencies()
164     {
165         runTarget("testOnceTargetsRunItDependencies");
166         int iF3= verifyTargetsRanInOrder("f",2,3,0);
167         verifyTargetsRanInOrder("f",2,4,iF3);
168     }
169
170     public void testTargetsInheritAllByDefault()
171     {
172         runTarget("testOnceTargetsInheritAllByDefault");
173         int ilastInheritedMatch= verifyTargetsInheritedParent(1,1,0);
174         ilastInheritedMatch= verifyTargetsInheritedParent(2,4,ilastInheritedMatch);
175     }
176
177     public void testTargetsInheritNone()
178     {
179         runTarget("testOnceTargetsInheritNone");
180         int iF1= verifyTargetsRanInOrder("f",1,1,0);
181         verifyTargetsRanInOrder("f",2,4,iF1);
182     }
183
184     public void testTargetsHaltIfErrorByDefault()
185     {
186         verifyHaltedBeforeF2Run("testOnceTargetsHaltIfErrorByDefault","((T2))");
187     }
188
189     public void testTargetsTryEach()
190     {
191         runTarget("testOnceTargetsTryEach");
192         assertPropertyEquals("something.barfed","true");
193     }
194
195     public void testTargetsHaltOverridesTryEach()
196     {
197         verifyHaltedBeforeF2Run("testOnceTargetsHaltOverridesTryEach","((T2))");
198     }
199
200     public void testStepsFindLauncher()
201     {
202         runTarget("testOnceStepsFindLauncher");
203     }
204
205     public void testStepsJustRunIt()
206     {
207         runTarget("testOnceStepsRunIt");
208         verifyTargetsRanInOrder("s",1,2,0);
209     }
210
211     public void testStepsRunItIff()
212     {
213         String JavaDoc log = runTarget("testOnceStepsRunItIff");
214         int last = verifyTargetsRanInOrder("s",1,1,0);
215         verifyTargetsRanInOrder("s",1,2,last);
216         verifyOccurances(log,"[((S2))]",1);
217     }
218
219     public void testStepsRunUnless()
220     {
221         String JavaDoc log = runTarget("testOnceStepsRunItUnless");
222         assertPropertyEquals("from.s1",null);
223         verifyTargetsRanInOrder("s",1,1,0);
224         verifyOccurances(log,"((S1))",1);
225         verifyOccurances(log,"mama",0);
226     }
227
228     public void testStepsInheritParamsOverAll()
229     {
230         String JavaDoc log = runTarget("testOnceStepInheritParams");
231         verifyTargetsRanInOrder("s",1,2,0);
232         verifyOccurances(log,"400",2);
233         verifyOccurances(log,"200",0);
234         verifyOccurances(log,"300",0);
235     }
236
237     public void testStepsHaltIfErrorByDefault()
238     {
239         verifyHaltedBeforeF2Run("testOnceStepsHaltIfErrorByDefault","((S2))");
240     }
241
242     public void testStepsTryEach()
243     {
244         runTarget("testOnceStepsTryEach");
245         assertPropertyEquals("something.barfed","true");
246     }
247
248     public void testStepsHaltOverridesTryEach()
249     {
250         verifyHaltedBeforeF2Run("testOnceStepsHaltOverridesTryEach","((S2))");
251     }
252
253     public void testStepsCanCallRealTargets()
254     {
255         String JavaDoc log = runTarget("testOnceNestedAntCallsInSteps");
256         verifyTargetsRanInOrder("f",2,4,0);
257         verifyOccurances(log,AT+"999",3);
258     }
259
260     /** @since JWare/AntX 0.2 **/
261     public void testCopyPropertyTask_AntX02()
262     {
263         runTargetDumpFullLog("testCopyProperty");
264     }
265
266     /** @since JWare/AntX 0.3 **/
267     public void testCopyReferenceToChildProject_AntX03()
268     {
269         runTarget("testCopyReferenceToChildProject_AntX03");
270     }
271
272     /** @since JWare/AntX 0.4 **/
273     public void testNestedPropertySets_AntX04()
274     {
275         runTarget("testNestedPropertySets_AntX04");
276     }
277     
278     /** @since JWare/AntX 0.5 **/
279     public void testCannotCombineMacrosWithOthers_AntX05()
280     {
281         runTarget("testCannotCombineMacrosWithOthers_AntX05");
282     }
283     
284     /** @since JWare/AntX 0.5 **/
285     public void testCallLocalMacros_AntX05()
286     {
287         runTarget("testCallLocalMacros_AntX05");
288     }
289     
290     public void testCallLocalConfiguredMacros_AntX05()
291     {
292         runTarget("testCallLocalConfiguredMacros_AntX05");
293     }
294     
295     public void testCallLocalOverlayedMacros_AntX05()
296     {
297         runTarget("testCallLocalOverlayedMacros_AntX05");
298     }
299 }
300
301 /* end-of-OnceTaskTest.java */
302
Popular Tags