KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * $Id: InlineForEachTaskTest.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.InlineForEachTask
37  * InlineForEachTask}.
38  *
39  * @since JWare/AntX 0.1
40  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
41  * @version 0.5
42  * @.safety single
43  * @.group impl,test
44  **/

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

55     public InlineForEachTaskTest(String JavaDoc methodName)
56     {
57         super("InlineForEachTask::",methodName);
58     }
59     
60
61     /**
62      * Creates a test suite with a single test.
63      **/

64     public static TestSuite suiteOfOne(String JavaDoc testName)
65     {
66         TestSuite s = new TestSuite();
67         s.setName("Suite-of-One:"+testName);
68         s.addTest(new InlineForEachTaskTest(testName));
69         return s;
70     }
71
72
73     /**
74      * Create full test suite for InlineForEachTask.
75      **/

76     public static TestSuite suite()
77     {
78         return new TestSuite(InlineForEachTaskTest.class);
79         //return suiteOfOne("testBodyAsLocalMacroDef_AntX05");
80
}
81
82
83     /**
84      * Create baseline test suite for InlineForEachTask (same as full).
85      **/

86     public static TestSuite baseline()
87     {
88         return suite();
89     }
90
91
92     /**
93      * Make this test (standalone) self-running.
94      **/

95     public static void main(String JavaDoc[] argv)
96     {
97         HTCUtils.quickCheck(suite());
98     }
99
100
101 // ---------------------------------------------------------------------------------------------------------
102
// ---------------------------------------- [ Misc Setup Methods ] -----------------------------------------
103
// ---------------------------------------------------------------------------------------------------------
104

105     protected String JavaDoc getDefaultConfigureXMLFileName()
106     {
107         return "iforeach.xml";
108     }
109
110
111     final int verifyTargetsRanInLoop(String JavaDoc[] cursors, int ilastmatch)
112     {
113         String JavaDoc log= getLog();
114         String JavaDoc match;
115         int imatch;
116         for (int i=0;i<cursors.length;i++) {
117             match = "(at:"+cursors[i]+")";
118             imatch = log.indexOf(match,ilastmatch);
119             assertTrue("Expecting Log to contain \""+match+"\" from ["+ilastmatch+
120                        "] but Log was \"" + log + "\"",
121                        imatch>=0);
122             ilastmatch = imatch+match.length();
123         }
124         return ilastmatch;
125     }
126
127 // ---------------------------------------------------------------------------------------------------------
128
// ------------------------------------------- [ The Test Cases ] ------------------------------------------
129
// ---------------------------------------------------------------------------------------------------------
130

131     public void testPassEmptyTaskset()
132     {
133         runTargetNoOutput("testPassEmptyTaskset");
134     }
135
136     public void testFailBrokenLoopDefinitions()
137     {
138         runTarget("testBrokenLoops");
139     }
140
141     public void testInLoopControl()
142     {
143         runTarget("testInLoopControl");
144         int from=0;
145         from= verifyTargetsRanInLoop(new String JavaDoc[]{"0"},from);
146         from= verifyTargetsRanInLoop(new String JavaDoc[]{"0","1","2"},from);
147         from= verifyTargetsRanInLoop(new String JavaDoc[]{"0","2","4"},from);
148         from= verifyTargetsRanInLoop(new String JavaDoc[]{"-1","0"},from);
149     }
150
151     public void testNestedLoops()
152     {
153         runTarget("testNestedLoops");
154     }
155
156     public void testNestedLoopsInSteps()
157     {
158         runTarget("testNestedLoopsInSteps");
159     }
160     
161     public void testBodyAsLocalMacroDef_AntX05()
162     {
163         runTarget("testBodyAsLocalMacroDef_AntX05");
164     }
165     
166     public void testNestedLoopsAsLocalMacroDef_AntX05()
167     {
168         runTarget("testNestedLoopsAsLocalMacroDef_AntX05");
169     }
170     
171     public void testMixAndMatchLoopTypes_AntX05()
172     {
173         runTarget("testMixAndMatchLoopTypes_AntX05");
174     }
175     
176     public void testHardLimits_AntX05()
177     {
178         runTarget("testHardLimits_AntX05");
179     }
180     
181     public void testLocalForEachFromMacrodef_AntX05()
182     {
183         runTarget("testLocalForEachFromMacrodef_AntX05");
184     }
185 }
186
187 /* end-of-InlineForEachTaskTest.java */
188
Popular Tags