KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > feedback > tests > EmitConfigureTaskTest


1 /**
2  * $Id: EmitConfigureTaskTest.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2003 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 of the License, or (at your option) any later
9  * 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.feedback.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.feedback.EmitConfigureTask EmitConfigureTask}.
37  *
38  * @since JWare/AntX 0.1
39  * @author ssmc, &copy;2002-2003 <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 EmitConfigureTaskTest extends EmitTestSkeleton
46 {
47     /** <i>PET</i> Test Category. **/
48     public static final String JavaDoc TEST_CATEGORY="CLASS";
49
50
51     /**
52      * Create new EmitConfigureTaskTest testcase.
53      **/

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

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

72     public static TestSuite baseline()
73     {
74         return suite();//new BaselineSuite(EmitConfigureTaskTest.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 "emitconf.xml";
94     }
95
96 // ---------------------------------------------------------------------------------------------------------
97
// ------------------------------------------- [ The Test Cases ] ------------------------------------------
98
// ---------------------------------------------------------------------------------------------------------
99

100     static final String JavaDoc EMITCOUNT= "EmitCount";
101     static final String JavaDoc TIMESTAMP_MARKER= "Helloworld from task";
102     static final String JavaDoc HELLOWORLD_MARKER= "Helloworld";
103     static final String JavaDoc BYEWORLD_MARKER= "Byeworld";
104
105     public void testEmptyOK()
106     {
107         runTarget("testEmptyOK");
108     }
109
110     public void testDefaultEchoesToAnt_NOT()
111     {
112         String JavaDoc log= runTarget("testDefaultEchoesToAnt_NOT");
113         assertFalse(log.indexOf("log4j")>=0, "Log4j-message *NOT* echoed to Ant");
114     }
115
116     public void testDefaultFroms_NOT()
117     {
118         String JavaDoc log = runTarget("testDefaultFroms_NOT");
119         verifyOccurances(log,"From: ",0);
120     }
121
122     private void verifyTimestamping(String JavaDoc target)
123     {
124         String JavaDoc today = getTodayString();
125         println("TODAY = ("+today+")");
126
127         String JavaDoc log = runEchoedTarget(target,null);
128         verifyOccurances(log,TIMESTAMP_MARKER,0);
129
130         int N= getIntegerProperty(EMITCOUNT);
131         String JavaDoc log4jLog = testAppender().getLog();
132         verifyOccurances(log4jLog,TIMESTAMP_MARKER,N);
133         verifyOccurances(log4jLog,today,getIntegerProperty("TimestampCount"));
134     }
135
136     public void testDefaultTimestamping()
137     {
138         verifyTimestamping("testTimestamping");
139     }
140
141     public void testDefaultTimestampingNested()
142     {
143         verifyTimestamping("testTimestampingNested");
144     }
145
146     public void testDefaultNoiseLevel()
147     {
148         String JavaDoc log = runEchoedTarget("testNoiseLevel",null);
149         verifyOccurances(log,HELLOWORLD_MARKER,getIntegerProperty("AntLogCount"));
150         String JavaDoc log4jLog = testAppender().getLog();
151         verifyOccurances(log4jLog, HELLOWORLD_MARKER, getIntegerProperty(EMITCOUNT));
152
153         testAppender().clearLog();
154
155         log = runEchoedTarget("testNoiseLevelNested",null);
156         verifyOccurances(log,HELLOWORLD_MARKER,getIntegerProperty("AntLogCount"));
157         log4jLog = testAppender().getLog();
158         verifyOccurances(log4jLog, HELLOWORLD_MARKER, getIntegerProperty(EMITCOUNT));
159
160     }
161
162     public void testUnwindingAfterFault()
163     {
164         String JavaDoc log = runEchoedTarget("testUnwindingAfterFault",null);
165         verifyOccurances(log,BYEWORLD_MARKER,getIntegerProperty("AntLogCount"));
166         String JavaDoc log4jLog= testAppender().getLog();
167         verifyOccurances(log4jLog,BYEWORLD_MARKER,getIntegerProperty(EMITCOUNT));
168     }
169
170     public void testDefaultFrom()
171     {
172         String JavaDoc log = runEchoedTarget("testEmitterPassthru");
173         int N= getIntegerProperty(EMITCOUNT);
174         verifyOccurances(log,HELLOWORLD_MARKER,N);
175         verifyOccurances(testAppender().getLog(), HELLOWORLD_MARKER, N);
176     }
177
178     public void testBlockingInheritance()
179     {
180         String JavaDoc log = runEchoedTarget("testBlockingInheritance");
181         verifyOccurances(log,"From:",1);
182         verifyOccurances(log,HELLOWORLD_MARKER,3);
183         String JavaDoc log4jLog = testAppender().getLog();
184         verifyOccurances(log4jLog,"From:",2);//+1 to root
185
verifyOccurances(log4jLog,HELLOWORLD_MARKER,0);//+3 to root
186
}
187
188     public void testUnableToLoadBrokenConfiguration()
189     {
190         verifyCantLoadFile("broken_conf0.xml","Conflicting use of refid");
191     }
192
193     public void testCanUseFromParallelTasks()
194     {
195         runEchoedTarget("testCanUseFromParallelTasks");
196     }
197
198     public void testUsingDefaultsRef()
199     {
200         runEchoedTarget("testUsingDefaultsRef");
201         String JavaDoc log4jLog = testAppender().getLog();
202         verifyOccurances(log4jLog,HELLOWORLD_MARKER,3);//+1 to root
203
verifyOccurances(log4jLog,"ant.version",3);
204     }
205
206     public void testTimestampFormat()
207     {
208         runEchoedTarget("testTimestampFormat",null);
209         String JavaDoc log4jLog = testAppender().getLog();
210         verifyOccurances(log4jLog,"Kaabllaamm:",getIntegerProperty("TimestampCount"));
211     }
212
213     public void testIncludeProperties()
214     {
215         runEchoedTarget("testIncludedProperties");
216         int N= getIntegerProperty(EMITCOUNT);
217         String JavaDoc log4jLog = testAppender().getLog();
218         verifyOccurances(log4jLog,"p.outer=",N);
219         verifyOccurances(log4jLog,"p.outer=Outside",2);
220         verifyOccurances(log4jLog,"p.inner=",N);
221         verifyOccurances(log4jLog,"p.inner=null",N-1);
222     }
223
224     public void testCannotReferToSelf()
225     {
226         runTarget("testCannotReferToSelf");
227     }
228
229
230     public void testCannotCallbackFromNestedTask()
231     {
232         runTarget("testCannotCallbackFromNestedTask");
233     }
234
235
236     public void testRelativeGroupings_AntX04()
237     {
238         runEchoedTarget("testRelativeGroupings_AntX04","AntX.Local");
239         String JavaDoc log4jLog = testAppender().getLog();
240         verifyOccurances(log4jLog, "Hello From Outer Shell",2);
241         verifyOccurances(log4jLog, "Hola From Inner Shell",1);
242         verifyOccurances(log4jLog,HELLOWORLD_MARKER,3);
243     }
244 }
245
246 /* end-of-EmitConfigureTaskTest.java */
247
Popular Tags