KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * $Id: StepCallerTestSkeleton.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) a later
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 com.idaremedia.antx.ut.HTC;
32
33 import org.apache.tools.ant.Project;
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 abstract class StepCallerTestSkeleton extends HTC
46 {
47     /**
48      * Create new StepCallerTestSkeleton testcase.
49      **/

50     protected StepCallerTestSkeleton(String JavaDoc groupId, String JavaDoc methodName)
51     {
52         super(groupId,methodName);
53     }
54
55 // ---------------------------------------------------------------------------------------------------------
56
// ---------------------------------------- [ Misc Setup Methods ] -----------------------------------------
57
// ---------------------------------------------------------------------------------------------------------
58

59     protected abstract String JavaDoc getDefaultConfigureXMLFileName();
60
61     protected void setUp() throws Exception JavaDoc
62     {
63         configureProjectFromResource(getDefaultConfigureXMLFileName());
64         Project P= getProject();
65         PS= P.getProperty("PS");
66         AT= P.getProperty("at");
67     }
68
69     final int verifyTargetsRanInOrder(final String JavaDoc PFX, final int I, final int N, int ilastmatch)
70     {
71         String JavaDoc log= getLog();
72         for (int i=I;i<=N;i++) {
73             String JavaDoc match = PS+PFX+i+AT;
74             int imatch = log.indexOf(match,ilastmatch);
75             assertTrue("Expecting Log to contain \""+match+"\" from ["+ilastmatch+
76                        "] but Log was \"" + log + "\"",
77                        imatch>=0);
78             ilastmatch = imatch;
79         }
80         return ilastmatch;
81     }
82
83
84     final int verifyTargetsInheritedParent(final int I, final int N, int ilastInheritedMatch)
85     {
86         String JavaDoc log= getLog();
87         String JavaDoc inheritedMatch = PS+"mama"+AT;
88         for (int i=I;i<=N;i++) {
89             String JavaDoc localMatch = PS+"f"+i+AT;
90             int iLocalMatch = log.indexOf(localMatch);
91             int iInheritedMatch = log.indexOf(inheritedMatch, ilastInheritedMatch);
92             assertTrue("Expecting Log to contain \""+inheritedMatch+"\" from ["+ilastInheritedMatch+
93                        "] but Log was \"" + log + "\"",
94                        iInheritedMatch>=0);
95             assertTrue("Expecting Log not to contain \""+localMatch+"\" from [0"+
96                        "] but Log was \"" + log + "\"",
97                        iLocalMatch<0);
98             ilastInheritedMatch = iInheritedMatch;
99         }
100         return ilastInheritedMatch;
101     }
102
103     final void verifyHaltedBeforeF2Run(String JavaDoc targetName, String JavaDoc T2)
104     {
105         require_(targetName!=null,"chkHalted- nonzro target");
106         expectBuildException(targetName,
107                              "HaltIfError on first broken step");
108         assertPropertyEquals("abandoned.ship","yes");
109         verifyOccurances(getLog(),T2,0);
110     }
111
112 // ---------------------------------------------------------------------------------------------------------
113
// ------------------------------------------- [ The Test Cases ] ------------------------------------------
114
// ---------------------------------------------------------------------------------------------------------
115

116     public void checkBaseline()
117     {
118         //--Ensures setUp() works and can find our xml file!
119
assertNotNil(PS,"PS");
120         assertNotNil(AT,"at");
121     }
122
123     public void testBaseline()
124     {
125         checkBaseline();
126     }
127
128     protected String JavaDoc PS,AT;
129 }
130
131 /* end-of-StepCallerTestSkeleton.java */
132
Popular Tags