KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > autodoc > v1 > testserver > junit > JUnitTestListenerUTestI


1 /*
2  * @(#)JUnitTestListenerUTestI.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.autodoc.v1.testserver.junit;
28
29 import net.sourceforge.groboutils.autodoc.v1.*;
30 import net.sourceforge.groboutils.autodoc.v1.testserver.*;
31
32 import org.easymock.EasyMock;
33 import org.easymock.MockControl;
34 import net.sourceforge.groboutils.junit.v1.iftc.*;
35 import junit.framework.Test;
36 import junit.framework.TestCase;
37 import junit.framework.TestSuite;
38 import junit.framework.TestListener;
39 import junit.framework.AssertionFailedError;
40
41
42 /**
43  * Tests the JUnitTestListener class.
44  *
45  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
46  * @since March 27, 2002
47  * @version $Date: 2003/06/10 01:08:42 $
48  */

49 public class JUnitTestListenerUTestI extends InterfaceTestCase
50 {
51     //-------------------------------------------------------------------------
52
// Standard JUnit Class-specific declarations
53

54     private static final Class JavaDoc THIS_CLASS = JUnitTestListenerUTestI.class;
55     
56     public JUnitTestListenerUTestI( String JavaDoc name, ImplFactory f )
57     {
58         super( name, JUnitTestListener.class, f );
59     }
60
61     
62     //-------------------------------------------------------------------------
63
// setup
64

65     
66     
67     /**
68      *
69      * @exception Exception thrown under any exceptional condition.
70      */

71     protected void setUp() throws Exception JavaDoc
72     {
73         super.setUp();
74         
75         // set ourself up
76
}
77     
78     
79     protected JUnitTestListener createJUnitTestListener()
80     {
81         return (JUnitTestListener)createImplObject();
82     }
83
84
85     //-------------------------------------------------------------------------
86
// Tests
87

88     
89     
90     public void testCreateTestInfo()
91     {
92         JUnitTestListener jtl = createJUnitTestListener();
93         TestInfo ti = jtl.createTestInfo( createTest() );
94         assertNotNull(
95             "Cannot return null test info objects.",
96             ti );
97     }
98     
99     
100     public void testAddError1()
101     {
102         TestListener jtl = createJUnitTestListener();
103         jtl.addError( null, null );
104     }
105     
106     
107     public void testAddError2()
108     {
109         JUnitTestListener jtl = createJUnitTestListener();
110         jtl.addError( createTest(), null );
111     }
112     
113     
114     public void testAddError3()
115     {
116         JUnitTestListener jtl = createJUnitTestListener();
117         jtl.addError( createTest(), new Throwable JavaDoc() );
118     }
119     
120     
121     public void testAddFailure1()
122     {
123         TestListener jtl = createJUnitTestListener();
124         jtl.addFailure( null, null );
125     }
126     
127     
128     public void testAddFailure2()
129     {
130         JUnitTestListener jtl = createJUnitTestListener();
131         jtl.addFailure( createTest(), null );
132     }
133     
134     
135     public void testAddFailure3()
136     {
137         JUnitTestListener jtl = createJUnitTestListener();
138         jtl.addFailure( createTest(), new AssertionFailedError() );
139     }
140     
141     
142     public void testStartTest()
143     {
144         JUnitTestListener jtl = createJUnitTestListener();
145         jtl.startTest( createTest() );
146     }
147     
148     
149     public void testEndTest1()
150     {
151         // this shows the fix to bug 751667
152

153         JUnitTestListener jtl = createJUnitTestListener();
154         
155         // this should just generate a warning.
156
jtl.endTest( createTest() );
157     }
158     
159     
160     public void testEndTest2()
161     {
162         JUnitTestListener jtl = createJUnitTestListener();
163         jtl.startTest( createTest() );
164         jtl.endTest( createTest() );
165     }
166     
167     
168     //-------------------------------------------------------------------------
169
// Helpers
170

171     
172     protected Test createTest()
173     {
174         return new TestCase("test") {};
175     }
176     
177     
178     //-------------------------------------------------------------------------
179
// Standard JUnit declarations
180

181     
182     public static InterfaceTestSuite suite()
183     {
184         InterfaceTestSuite suite = TestCorrelateUTestI.suite();
185         suite.addTestSuite( THIS_CLASS );
186         
187         return suite;
188     }
189     
190     public static void main( String JavaDoc[] args )
191     {
192         String JavaDoc[] name = { THIS_CLASS.getName() };
193         
194         // junit.textui.TestRunner.main( name );
195
// junit.swingui.TestRunner.main( name );
196

197         junit.textui.TestRunner.main( name );
198     }
199     
200     
201     /**
202      *
203      * @exception Exception thrown under any exceptional condition.
204      */

205     protected void tearDown() throws Exception JavaDoc
206     {
207         // tear ourself down
208

209         super.tearDown();
210     }
211 }
212
213
Popular Tags