KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * $Id: LocalExecutionBubbleTest.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 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 (LGPL) as published
8  * by the Free Software Foundation; either version 2.1 of the License, or (at your option)
9  * any 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 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 GNU 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 org.apache.tools.ant.Project;
32 import org.apache.tools.ant.Target;
33
34 import junit.framework.TestSuite;
35
36 import com.idaremedia.antx.apis.Requester;
37 import com.idaremedia.antx.flowcontrol.call.AnyTargetCaller;
38 import com.idaremedia.antx.flowcontrol.wrap.LocalExecutionBubble;
39 import com.idaremedia.antx.ownhelpers.ProjectPropertiesNet;
40 import com.idaremedia.antx.print.EchoItemsTask;
41 import com.idaremedia.antx.ut.HTC;
42 import com.idaremedia.antx.ut.HTCUtils;
43
44
45 /**
46  * Test suite for {@linkplain com.idaremedia.antx.flowcontrol.wrap.LocalExecutionBubble
47  * LocalExecutionBubble} and
48  * {@linkplain com.idaremedia.antx.flowcontrol.wrap.IsolatedTaskSet IsolatedTaskSet}.
49  *
50  * @since JWare/AntX 0.1
51  * @author ssmc, &copy;2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
52  * @version 0.5
53  * @.safety single
54  * @.group impl,test
55  **/

56
57 public final class LocalExecutionBubbleTest extends HTC
58 {
59     /**
60      * Initializes new LocalExecutionBubble test case.
61      **/

62     public LocalExecutionBubbleTest(String JavaDoc methodName)
63     {
64         super("LocalExecutionBubble::",methodName);
65     }
66
67
68
69     /**
70      * Create full test suite for bubble test.
71      **/

72     public static TestSuite suite()
73     {
74         return new TestSuite(LocalExecutionBubbleTest.class);
75     }
76
77
78     /**
79      * Create baseline test suite (same as full).
80      **/

81     public static TestSuite baseline()
82     {
83         return suite();
84     }
85
86
87     /**
88      * Make this test (standalone) self-running.
89      **/

90     public static void main(String JavaDoc[] argv)
91     {
92         HTCUtils.quickCheck(suite());
93     }
94
95
96 // ---------------------------------------------------------------------------------------------------------
97
// ---------------------------------------- [ Misc Setup Methods ] -----------------------------------------
98
// ---------------------------------------------------------------------------------------------------------
99

100     protected void setUp() throws Exception JavaDoc
101     {
102         configureProjectFromResource("localcall.xml");
103     }
104
105
106
107     private void aboutToExecute(Project P)
108     {
109         P.setProperty("root.property","root.property");
110         P.setUserProperty("root.user.property","root.user.property");
111
112         assertNil(P.getReference("root.ref"));
113         assertNil(P.getProperty("local.property"));
114         assertNil(P.getProperty("local.user.property"));
115     }
116
117
118
119     private void finishExecute(Project P, boolean dumpLog)
120     {
121         if (dumpLog) {
122             println("FUUUUULLLL LOG:",getFullLog());
123         }
124         assertNil(P.getReference("root.ref"), "root.ref(out)");
125         assertNil(P.getProperty("local.property"), "local.property(out)");
126         assertNil(P.getProperty("local.user.property"), "local.user.property(out)");
127     }
128
129
130
131     private EchoItemsTask newPrintTask(Project P)
132     {
133         Target target = (Target)P.getTargets().get("echoTarget");
134         assertNotNil(target,"echoTarget");
135         EchoItemsTask task = new EchoItemsTask();
136         task.setOwningTarget(target);
137         task.setProject(P);
138         task.init();
139         task.setProperties("all");
140         task.setReferences("all");
141         return task;
142     }
143
144
145     private AnyTargetCaller newCallTask(Project P)
146     {
147         Target target = (Target)P.getTargets().get("callTarget");
148         assertNotNil(target,"callTarget");
149         AnyTargetCaller task = new AnyTargetCaller(P, "callTarget");
150         task.setOwningTarget((Target)P.getTargets().get(P.getDefaultTarget()));
151         task.init();
152         return task;
153     }
154
155 // ---------------------------------------------------------------------------------------------------------
156
// ------------------------------------------- [ The Test Cases ] ------------------------------------------
157
// ---------------------------------------------------------------------------------------------------------
158

159     public void checkBaseline()
160     {
161         //--Ensures setUp() works and can find our xml file!
162
Project P = getProject();
163         assertNotNil(P.getReference(ProjectPropertiesNet.ANT_HELPER_REFID),"ant.ProjectHelper");
164         Target target = (Target)P.getTargets().get(P.getDefaultTarget());
165         assertNotNil(target,"Default Target");
166     }
167
168
169     public void testBaseline()
170     {
171         checkBaseline();
172     }
173
174
175     /**
176      * Verify that a basic bubble will capture/restore properties and
177      * references (as best can).
178      **/

179     public void testBubbleWrap_AntX04()
180     {
181         Project P = getProject();
182
183         aboutToExecute(P);
184
185         EchoItemsTask task = newPrintTask(P);
186         Requester taskLink = new Requester.ForComponent(task);
187         LocalExecutionBubble bubble = new LocalExecutionBubble();
188         bubble.setCarefulObjectChecks(true);
189
190         bubble.enter(taskLink);
191           P.setProperty("local.property","local.property");
192           P.setUserProperty("local.user.property","local.user.property");
193           P.setProperty("root.property","local.property");
194           P.setUserProperty("root.user.property","local.user.property");
195           P.addReference("root.ref.0",new Long JavaDoc(1000));
196           task.execute();
197         bubble.leave(taskLink);
198
199         task.execute();
200         finishExecute(P,true);
201     }
202
203
204
205     /**
206      * Verify that bubble work for task sets that include tasks that
207      * will create sub or child projects.
208      **/

209     public void testBubbleWrapWithChildProject_AntX04()
210     {
211         Project P = getProject();
212
213         aboutToExecute(P);
214
215         AnyTargetCaller task = newCallTask(P);
216         Requester taskLink = new Requester.ForComponent(task);
217         LocalExecutionBubble bubble = new LocalExecutionBubble();
218         bubble.setCarefulObjectChecks(true);
219
220         bubble.enter(taskLink);
221             P.setProperty("local.property","local.property");
222             P.setUserProperty("local.user.property","local.user.property");
223             P.setProperty("root.property","local.property");
224             P.setUserProperty("root.user.property","local.user.property");
225             P.addReference("root.ref.0",new Long JavaDoc(1000));
226             task.execute();
227         bubble.leave(taskLink);
228         finishExecute(P,false);
229
230         newPrintTask(P).execute();
231         println("FUUUUULLLL LOG:",getFullLog());
232     }
233
234
235
236     public void testCallLocal_AntX04()
237     {
238         runTarget("testCallLocalTargets_AntX04");
239     }
240
241     public void testCallLocalParameterizedTargets_AntX04()
242     {
243         runTarget("testCallLocalParameterizedTargets_AntX04");
244     }
245
246     public void testCallLocalSteps_AntX04()
247     {
248         runTarget("testCallLocalSteps_AntX04");
249     }
250
251     public void testCallLocalParameterizedSteps_AntX04()
252     {
253         runTarget("testCallLocalParameterizedSteps_AntX04");
254     }
255
256     public void testCallLocalOverlayUndone_AntX04()
257     {
258         runTarget("testCallLocalOverlayUndone_AntX04");
259     }
260
261     public void testCallLocalOverlayUndoneSteps_AntX04()
262     {
263         runTarget("testCallLocalOverlayUndoneSteps_AntX04");
264     }
265
266
267     public void testIsolatedSimple_AntX04()
268     {
269         runTarget("testIsolatedSimple_AntX04");
270     }
271
272     public void testIsolatedWarnings_AntX04()
273     {
274         runTarget("testIsolatedWarnings_AntX04");
275     }
276
277     public void testNestedIsolatedBlocks_AntX04()
278     {
279         runTarget("testNestedIsolatedBlocks_AntX04");
280     }
281
282     public void testResetFixture_AntX04()
283     {
284         runTarget("testResetFixture_AntX04");
285     }
286
287     public void testWorksWithOverlay_AntX04()
288     {
289         runTarget("testWorksWithOverlay_AntX04");
290     }
291     
292     public void testLocalsPushPopped_AntX05()
293     {
294         runTarget("testLocalsPushPopped_AntX05");
295     }
296
297     public void testIsolateLocalVars_AntX05()
298     {
299         runTarget("testIsolateLocalVars_AntX05");
300     }
301     
302     public void testIsolateLocalProperties_AntX05()
303     {
304         runTarget("testIsolateLocalProperties_AntX05");
305     }
306
307     public void testBlockAllowsAllUnlessNamed_AntX05()
308     {
309         runTarget("testBlockAllowsAllUnlessNamed_AntX05");
310     }
311     
312     public void testPassthruLocalProperties_AntX05()
313     {
314         runTarget("testPassthruLocalProperties_AntX05");
315     }
316     
317     public void testConditionalFixture_AntX05()
318     {
319         runTarget("testConditionalFixture_AntX05");
320     }
321 }
322
323
324 /* end-of-LocalExecutionBubbleTest.java */
325
Popular Tags