KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > mktemp > tests > MkTempTest


1 /**
2  * $Id: MkTempTest.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.mktemp.tests;
30
31 import java.io.File JavaDoc;
32
33 import junit.framework.TestSuite;
34
35 import com.idaremedia.antx.ut.HTC;
36 import com.idaremedia.antx.ut.HTCUtils;
37
38 import com.idaremedia.antx.mktemp.TempLocator;
39 import com.idaremedia.antx.mktemp.MkTempDirectory;
40 import com.idaremedia.antx.mktemp.MkTempFile;
41
42 /**
43  * Class tests for {@linkplain com.idaremedia.antx.mktemp.TempLocator TempLocator}.
44  *
45  * @since JWare/AntX 0.1
46  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
47  * @version 0.5
48  * @.safety single
49  * @.group impl,test
50  **/

51
52 public final class MkTempTest extends HTC
53 {
54     /** <i>PET</i> Test Category. **/
55     public static final String JavaDoc TEST_CATEGORY="CLASS";
56
57
58     /**
59      * Create new MkTempTest testcase.
60      **/

61     public MkTempTest(String JavaDoc methodName)
62     {
63         super("MkTemp::",methodName);
64     }
65
66
67     /**
68      * Create full test suite for TempLocator.
69      **/

70     public static TestSuite suite()
71     {
72         return new TestSuite(MkTempTest.class);
73     }
74
75
76     /**
77      * Create baseline test suite for TempLocator (same as full).
78      **/

79     public static TestSuite baseline()
80     {
81         return suite();//new BaselineSuite(MkTempTest.class);
82
}
83
84
85     /**
86      * Make this test (standalone) self-running.
87      **/

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

98     protected void setUp() throws Exception JavaDoc
99     {
100         configureProjectFromResource("mktemp.xml");
101     }
102
103
104 // ---------------------------------------------------------------------------------------------------------
105
// ------------------------------------------- [ The Test Cases ] ------------------------------------------
106
// ---------------------------------------------------------------------------------------------------------
107

108     public void checkBaseline()
109     {
110         //--Ensures setUp() works and can find our xml file!
111
}
112
113     public void testBaseline()
114     {
115         checkBaseline();
116         File JavaDoc tmpdir = TempLocator.getSystemTempDir();
117         assertNotNil(tmpdir);
118         assertFalse(tmpdir.getName().indexOf("_will_die")>=0,"Invalid TMPDIR");
119     }
120
121     public void testEmptyTmpDirElement()
122     {
123         expectLog("testEmptyTmpDirElement","");
124     }
125
126     public void testJustSetTempDir()
127     {
128         runTarget("testJustSetTempDir");
129     }
130
131     public void testJustSetTempDirUrl_AntX05()
132     {
133         runTarget("testJustSetTempDirUrl_AntX05");
134     }
135
136     public void testCreatingOwnTempDirRoot()
137     {
138         runTarget("testOwnTempDirRoot");
139     }
140
141     public void testMkTempDirBasic()
142     {
143         runTarget("testMkTempDirBasic");
144     }
145
146     public void testMkTempFileBasic()
147     {
148         runTarget("testMkTempFileBasic");
149     }
150
151     public void testMkTempPrototypes()
152     {
153         runTarget("testMkTempPrototypes");
154     }
155
156     public void testFilteringPrototypes()
157     {
158         runTarget("testFilteringPrototypeFiles");
159     }
160
161     /** @since JWare/AntX 0.3 **/
162     public void testMkTempFileByLine_AntX03()
163     {
164         runTarget("testMkTempFileByLine_AntX03");
165     }
166
167     /** @since JWare/AntX 0.4 **/
168     public void testMkTempPropertiesFile_AntX04()
169     {
170         runTarget("testMkTempPropertiesFile_AntX04");
171     }
172
173     public void testMkTempFileDefaults()
174     {
175         MkTempFile out = new MkTempFile();
176         out.setProject(getProject());
177         assertNotNil(out.getEffectivePrefix(true));
178         assertNotNil(out.getEffectiveSuffix(true));
179         assertNotNil(out.getInDir());
180         assertTrue(out.isAutoDelete());
181         out.setPrefix("q");
182         assertEqual(out.getPrefix(),"q");
183         assertNotEqual(out.getEffectivePrefix(true),"q");
184         assertTrue(out.getEffectivePrefix(true).length()>=0,"Prefix is at least 3chars");
185         out.setPrefix("");
186         assertEqual(out.getEffectivePrefix(true),"___");
187
188         out = null;
189         out = new MkTempFile();
190         assertEqual(out.getEffectivePrefix(true),"qat");//different from empty pfx
191
assertEqual(out.getEffectiveSuffix(true),".tmp");
192     }
193
194     public void testMkTempDirectoryDefaults()
195     {
196         MkTempDirectory out = new MkTempDirectory();
197         out.setProject(getProject());
198         assertNotNil(out.getEffectivePrefix(false));
199         assertNotNil(out.getEffectiveSuffix(false));
200         assertNotNil(out.getInDir());
201         assertFalse(out.isAutoDelete());
202         assertEqual(out.getEffectivePrefix(false),"qat");//different from empty pfx
203
assertEqual(out.getEffectiveSuffix(false),"");
204     }
205
206     public void testBadInDirCaught()
207     {
208         runExpecting("testBadInDirCaught","In-Dir must exist");
209     }
210 }
211
212 /* end-of-MkTempTest.java */
213
Popular Tags