KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)JUnitTestInfoJDK13UTest.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
39
40 /**
41  * Tests the JUnitTestInfo class.
42  *
43  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
44  * @since March 27, 2002
45  * @version $Date: 2003/02/10 22:52:18 $
46  */

47 public class JUnitTestInfoJDK13UTest extends TestCase
48 {
49     //-------------------------------------------------------------------------
50
// Standard JUnit Class-specific declarations
51

52     private static final Class JavaDoc THIS_CLASS = JUnitTestInfoJDK13UTest.class;
53     
54     public JUnitTestInfoJDK13UTest( String JavaDoc name )
55     {
56         super( name );
57     }
58
59     
60     //-------------------------------------------------------------------------
61
// setup
62

63     private MockControl logControl;
64     private AutoDocLog mockLog;
65
66     private MockControl itControl;
67     private AutoDocIT mockIT;
68
69     private MockControl tpControl;
70     private AutoDocTP mockTP;
71     
72     
73     /**
74      *
75      * @exception Exception thrown under any exceptional condition.
76      */

77     protected void setUp() throws Exception JavaDoc
78     {
79         super.setUp();
80         
81         // set ourself up
82
this.logControl = EasyMock.controlFor( AutoDocLog.class );
83         this.mockLog = (AutoDocLog)this.logControl.getMock();
84         
85         this.itControl = EasyMock.controlFor( AutoDocIT.class );
86         this.mockIT = (AutoDocIT)this.itControl.getMock();
87         
88         this.tpControl = EasyMock.controlFor( AutoDocTP.class );
89         this.mockTP = (AutoDocTP)this.tpControl.getMock();
90     }
91
92
93     //-------------------------------------------------------------------------
94
// Tests
95

96     
97     public void testConstructor1()
98     {
99         try
100         {
101             new JUnitTestInfo( null );
102             fail("Did not throw IllegalArgumentException.");
103         }
104         catch (IllegalArgumentException JavaDoc e)
105         {
106             // test exception
107
}
108     }
109     
110     
111     public void testConstructor2()
112     {
113         JUnitTestInfo ti = new JUnitTestInfo( this );
114         assertEquals(
115             "Did not set suite name correctly.",
116             getClass().getName(),
117             ti.getSuite() );
118         assertEquals(
119             "Did not set method name correctly.",
120             getName(),
121             ti.getMethod() );
122     }
123     
124     
125     public void testConstructor3()
126     {
127         String JavaDoc name = "myName";
128         TestSuite ts = new TestSuite();
129         ts.setName( name );
130         JUnitTestInfo ti = new JUnitTestInfo( ts );
131         assertEquals(
132             "Did not set suite name correctly.",
133             name,
134             ti.getSuite() );
135         assertEquals(
136             "Did not set method name correctly.",
137             "run",
138             ti.getMethod() );
139     }
140     
141     
142     
143     //-------------------------------------------------------------------------
144
// Helpers
145

146     
147     
148     //-------------------------------------------------------------------------
149
// Standard JUnit declarations
150

151     
152     public static Test suite()
153     {
154         InterfaceTestSuite suite = TestInfoUTestI.suite();
155         suite.addTestSuite( THIS_CLASS );
156         suite.addFactory( new CxFactory( "A" ) {
157             public Object JavaDoc createImplObject() {
158                 return new JUnitTestInfo( new Object JavaDoc() );
159             }
160         } );
161         
162         return suite;
163     }
164     
165     public static void main( String JavaDoc[] args )
166     {
167         String JavaDoc[] name = { THIS_CLASS.getName() };
168         
169         // junit.textui.TestRunner.main( name );
170
// junit.swingui.TestRunner.main( name );
171

172         junit.textui.TestRunner.main( name );
173     }
174     
175     
176     /**
177      *
178      * @exception Exception thrown under any exceptional condition.
179      */

180     protected void tearDown() throws Exception JavaDoc
181     {
182         // tear ourself down
183

184         super.tearDown();
185     }
186 }
187
188
Popular Tags