KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > tests > PreferRuleTest


1 /**
2  * $Id: PreferRuleTest.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.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.tests;
30
31 import junit.framework.TestSuite;
32
33 import com.idaremedia.antx.ut.HTC;
34 import com.idaremedia.antx.ut.HTCUtils;
35
36 /**
37  * Class test for {@linkplain com.idaremedia.antx.condition.PreferTask PreferTask}.
38  * <em>Warning:These tests require a live internet connection to verify certain
39  * HTTP-based assertions.</em>
40  *
41  * @since JWare/AntX 0.1
42  * @author ssmc, &copy;2002-2003 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
43  * @version 0.5
44  * @.safety single
45  * @.group impl,test
46  **/

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

57     public PreferRuleTest(String JavaDoc methodName)
58     {
59         super("PreferTask::",methodName);
60     }
61
62
63     /**
64      * Create full test suite for PreferTask.
65      **/

66     public static TestSuite suite()
67     {
68         return new TestSuite(PreferRuleTest.class);
69     }
70
71
72     /**
73      * Create baseline test suite for PreferTask (same as full).
74      **/

75     public static TestSuite baseline()
76     {
77         return suite();
78     }
79
80
81     /**
82      * Make this test (standalone) self-running.
83      **/

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

94     protected void setUp() throws Exception JavaDoc
95     {
96         configureProjectFromResource("prefer.xml");
97     }
98
99 // ---------------------------------------------------------------------------------------------------------
100
// ------------------------------------------- [ The Test Cases ] ------------------------------------------
101
// ---------------------------------------------------------------------------------------------------------
102

103     public void checkBaseline()
104     {
105         //--Ensures setUp() works and can find our xml file!
106
}
107
108     public void testBaseline()
109     {
110         checkBaseline();
111     }
112
113     public void testFailEmptyElement()
114     {
115         expectBuildExceptionContaining("undefined","Empty Assertion","At least one condition");
116     }
117
118     public void testUsingMsgId()
119     {
120         expectLogContaining("uses.msgid","Teensy Weensy Spider");
121         assertPropertyEquals("truth.not","huh?");
122     }
123
124     public void testHttpAlive()
125     {
126         runTargetNoOutput("testHttpAlive");
127         println("########",getFullLog());
128         assertPropertyEquals("www.disable",null);
129     }
130
131     public void testSimpleTruths()
132     {
133         runTargetNoOutput("simple.truths");
134
135         assertPropertyEquals("truth.istrue",null);
136         assertPropertyEquals("truth.isfalse",null);
137         assertPropertyEquals("truth.isset",null);
138         assertPropertyEquals("truth.welcome",null);
139         assertPropertyEquals("truth.isnotset",null);
140         assertPropertyEquals("truth.varset",null);
141         assertPropertyEquals("broken.varnotset",null);
142
143         assertPropertyEquals("truth.notwhitespace",null);
144         assertPropertyEquals("truth.antfile",null);
145         assertPropertyEquals("truth.isnumeric",null);
146         assertPropertyEquals("truth.isbool",null);
147         assertPropertyEquals("truth.ishexnumeric",null);
148         assertPropertyEquals("truth.varisbool",null);
149
150         assertPropertyEquals("truth.file",null);
151         assertPropertyEquals("truth.dir",null);
152         assertPropertyEquals("truth.resource",null);
153         assertPropertyEquals("truth.isclass",null);
154
155         assertPropertyEquals("broken.allset",null);
156         assertPropertyEquals("broken.noneset",null);
157         assertPropertyEquals("broken.anyset",null);
158     }
159
160     public void testPropertyOverwriteImmediate()
161     {
162         runTarget("testPropertyOverwriteImmediate");
163         assertPropertyEquals("my.required.property","default-value");
164     }
165
166     public void testPropertyOverwriteLikeVelcro()
167     {
168         runTarget("testPropertyOverwriteLikeVelcro");
169     }
170
171     public void testVariableUpdates()
172     {
173         runTarget("testVariableUpdates");
174     }
175
176     /** @since JWare/AntX 0.3 **/
177     public void testRulesRunAllPreferences_AntX03()
178     {
179         runTargetDumpFullLog("testPreferRulesTallyAll");
180     }
181
182     public void testGoodReferrals_AntX02()
183     {
184         runTargetNoOutput("testReferrals");
185         assertPropertyEquals("broken.referral0",null);
186     }
187
188     public void testCircularReferrals_AntX02()
189     {
190         String JavaDoc log= runExpecting("testCircularReferrals","CircularReferral");
191         assertTrue(log.indexOf("rule chain contains a circular dependency")>-1,"Circular problem found");
192     }
193
194     public void testIncompatibleReferrals_AntX02()
195     {
196         String JavaDoc log= runExpecting("testIncompatibleReferrals","IncompatibleReferral");
197         assertTrue(log.indexOf("must be compatible with effect")>-1,"Incompatibility found");
198     }
199
200     public void testMatches_AntX02()
201     {
202         runTarget("testMatches");
203     }
204
205     /** @since JWare/AntX 0.3 **/
206     public void testFalsePrefers_AntX03()
207     {
208         runTarget("testFalsePrefers_AntX03");
209         assertPropertyEquals("neg.istrue","huh?");
210         assertPropertyEquals("neg.isfalse","huh?");
211         assertPropertyEquals("neg.isset","huh?");
212         assertPropertyEquals("neg.isnotset","huh?");
213         assertPropertyEquals("neg.varset","huh?");
214         assertPropertyEquals("neg.varnotset","huh?");
215         assertPropertyEquals("neg.allset","huh?");
216         assertPropertyEquals("neg.noneset","huh?");
217     }
218
219     /** @since JWare/AntX 0.3 **/
220     public void testFalseMessageNoiseLevels_AntX03()
221     {
222         runTarget("testFalseMessageNoiseLevels_AntX03");
223     }
224
225     /** @since JWare/AntX 0.3 **/
226     public void testRulesAndCallerUpdateProperties_AntX03()
227     {
228         runTarget("testRulesAndCallerUpdateProperties_AntX03");
229     }
230 }
231
232
233 /* end-of-PreferRuleTest.java */
234
Popular Tags