KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > junit > v1 > AssertConstructorUTest


1 /*
2  * @(#)AssertConstructorUTest.java
3  *
4  * Copyright (C) 2002-2003 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

26
27 package net.sourceforge.groboutils.junit.v1;
28
29 import org.easymock.EasyMock;
30 import org.easymock.MockControl;
31 import junit.framework.Test;
32 import junit.framework.TestCase;
33 import junit.framework.TestSuite;
34 import junit.framework.AssertionFailedError;
35
36
37 /**
38  * Tests the AssertConstructor class.
39  *
40  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
41  * @since March 1, 2002
42  * @version $Date: 2003/02/10 22:52:22 $
43  */

44 public class AssertConstructorUTest extends TestCase
45 {
46     //-------------------------------------------------------------------------
47
// Standard JUnit Class-specific declarations
48

49     private static final Class JavaDoc THIS_CLASS = AssertConstructorUTest.class;
50     
51     public AssertConstructorUTest( String JavaDoc name )
52     {
53         super( name );
54     }
55
56     
57
58
59     //-------------------------------------------------------------------------
60
// Tests
61

62     public void testAssertHasDefaultConstructor1()
63     {
64         AssertConstructor.assertHasDefaultConstructor( Object JavaDoc.class );
65     }
66     
67     
68     public void testAssertHasDefaultConstructor2()
69     {
70         boolean failed = true;
71         try
72         {
73             AssertConstructor.assertHasDefaultConstructor( Integer JavaDoc.class );
74         }
75         catch (AssertionFailedError e)
76         {
77             failed = false;
78         }
79         if (failed)
80         {
81             fail( "Did not cause an assertion failure." );
82         }
83     }
84     
85     
86     public void testAssertHasDefaultConstructor3()
87     {
88         AssertConstructor.assertHasDefaultConstructor( new Object JavaDoc() );
89     }
90     
91     
92     public void testAssertHasDefaultConstructor4()
93     {
94         boolean failed = true;
95         try
96         {
97             AssertConstructor.assertHasDefaultConstructor( new Integer JavaDoc( 1 ) );
98         }
99         catch (AssertionFailedError e)
100         {
101             failed = false;
102         }
103         if (failed)
104         {
105             fail( "Did not cause an assertion failure." );
106         }
107     }
108     
109     public void testAssertHasDefaultConstructor1a()
110     {
111         AssertConstructor.assertHasDefaultConstructor( "A", Object JavaDoc.class );
112     }
113     
114     
115     public void testAssertHasDefaultConstructor2a()
116     {
117         boolean failed = true;
118         try
119         {
120             AssertConstructor.assertHasDefaultConstructor( ":A:",
121                 Integer JavaDoc.class );
122         }
123         catch (AssertionFailedError e)
124         {
125             assertTrue(
126                 "Did not throw an error with the message text.",
127                 e.getMessage().indexOf( ":A:" ) >= 0 );
128             failed = false;
129         }
130         if (failed)
131         {
132             fail( "Did not cause an assertion failure." );
133         }
134     }
135     
136     
137     public void testAssertHasDefaultConstructor3a()
138     {
139         AssertConstructor.assertHasDefaultConstructor( "A", new Object JavaDoc() );
140     }
141     
142     
143     public void testAssertHasDefaultConstructor4a()
144     {
145         boolean failed = true;
146         try
147         {
148             AssertConstructor.assertHasDefaultConstructor( ":A:",
149                 new Integer JavaDoc( 1 ) );
150         }
151         catch (AssertionFailedError e)
152         {
153             assertTrue(
154                 "Did not throw an error with the message text.",
155                 e.getMessage().indexOf( ":A:" ) >= 0 );
156             failed = false;
157         }
158         if (failed)
159         {
160             fail( "Did not cause an assertion failure." );
161         }
162     }
163
164     
165     
166     public void testAssertHasConstructor1()
167     {
168         AssertConstructor.assertHasConstructor( Object JavaDoc.class, new Class JavaDoc[0],
169             AssertConstructor.ANY_PROTECTION );
170     }
171     
172     
173     public void testAssertHasConstructor2()
174     {
175         boolean failed = true;
176         try
177         {
178             AssertConstructor.assertHasConstructor( Object JavaDoc.class,
179                 new Class JavaDoc[0], AssertConstructor.PRIVATE );
180         }
181         catch (AssertionFailedError e)
182         {
183             failed = false;
184         }
185         if (failed)
186         {
187             fail( "Did not cause an assertion failure." );
188         }
189     }
190
191
192     public void testAssertHasConstructor3()
193     {
194         AssertConstructor.assertHasConstructor( Integer JavaDoc.class,
195             new Class JavaDoc[] { Integer.TYPE },
196             AssertConstructor.PUBLIC );
197     }
198     
199     
200     
201     
202     //-------------------------------------------------------------------------
203
// Standard JUnit declarations
204

205     
206     public static Test suite()
207     {
208         TestSuite suite = new TestSuite( THIS_CLASS );
209         
210         return suite;
211     }
212     
213     public static void main( String JavaDoc[] args )
214     {
215         String JavaDoc[] name = { THIS_CLASS.getName() };
216         
217         // junit.textui.TestRunner.main( name );
218
// junit.swingui.TestRunner.main( name );
219

220         junit.textui.TestRunner.main( name );
221     }
222     
223     
224     /**
225      *
226      * @exception Exception thrown under any exceptional condition.
227      */

228     protected void setUp() throws Exception JavaDoc
229     {
230         super.setUp();
231         
232         // set ourself up
233
}
234     
235     
236     /**
237      *
238      * @exception Exception thrown under any exceptional condition.
239      */

240     protected void tearDown() throws Exception JavaDoc
241     {
242         // tear ourself down
243

244         
245         super.tearDown();
246     }
247 }
248
249
Popular Tags