KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > autodoc > v1 > defimpl > AutoDocITSetUTest


1 /*
2  * @(#)AutoDocITSetUTest.java
3  *
4  * Copyright (C) 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.defimpl;
28
29 import net.sourceforge.groboutils.autodoc.v1.spi.AutoDocLogFactory;
30 import net.sourceforge.groboutils.autodoc.v1.*;
31 import net.sourceforge.groboutils.autodoc.v1.spi.*;
32
33 import org.easymock.EasyMock;
34 import org.easymock.MockControl;
35 import net.sourceforge.groboutils.junit.v1.iftc.*;
36 import junit.framework.Test;
37 import junit.framework.TestCase;
38 import junit.framework.TestSuite;
39
40 import java.util.*;
41
42
43 /**
44  * Tests the DefaultAutoDocFactory class.
45  *
46  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
47  * @version $Date: 2003/05/30 00:06:04 $
48  * @since March 27, 2002
49  */

50 public class AutoDocITSetUTest extends TestCase
51 {
52     //-------------------------------------------------------------------------
53
// Standard JUnit Class-specific declarations
54

55     private static final Class JavaDoc THIS_CLASS = AutoDocITSetUTest.class;
56     
57     public AutoDocITSetUTest( String JavaDoc name )
58     {
59         super( name );
60     }
61
62     
63     //-------------------------------------------------------------------------
64
// setup
65

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

70     protected void setUp() throws Exception JavaDoc
71     {
72         super.setUp();
73         
74         // set ourself up
75
}
76
77
78     //-------------------------------------------------------------------------
79
// Tests
80

81     
82     private static class MyAutoDocIT implements AutoDocIT
83     {
84         public Vector methodNames = new Vector();
85         public Vector longIssueID = new Vector();
86         public Vector strIssueID = new Vector();
87         
88         public void testsIssue( String JavaDoc methodName, long issueID )
89         {
90             this.methodNames.addElement( methodName );
91             this.longIssueID.addElement( new Long JavaDoc( issueID ) );
92         }
93     
94     
95         public void testsIssue( String JavaDoc methodName, String JavaDoc issueID )
96         {
97             this.methodNames.addElement( methodName );
98             this.strIssueID.addElement( issueID );
99         }
100         
101         
102         public void testsIssue( long issueID )
103         {
104             this.longIssueID.addElement( new Long JavaDoc( issueID ) );
105         }
106         
107         
108         public void testsIssue( String JavaDoc issueID )
109         {
110             this.strIssueID.addElement( issueID );
111         }
112     }
113     
114     
115     public void testTestsIssue1()
116     {
117         MyAutoDocIT mad = new MyAutoDocIT();
118         AutoDocITSet set = new AutoDocITSet();
119         set.addIT( mad );
120         
121         set.testsIssue( "name", 1L );
122         
123         assertEquals(
124             "Did not add only 1 method name.",
125             mad.methodNames.size(),
126             1 );
127         assertEquals(
128             "Did not add only 1 long id.",
129             mad.longIssueID.size(),
130             1 );
131         assertEquals(
132             "Added a string id.",
133             mad.strIssueID.size(),
134             0 );
135     }
136     
137     
138     public void testTestsIssue2()
139     {
140         MyAutoDocIT mad = new MyAutoDocIT();
141         AutoDocITSet set = new AutoDocITSet();
142         set.addIT( mad );
143         
144         set.testsIssue( "name", "1" );
145         
146         assertEquals(
147             "Did not add only 1 method name.",
148             mad.methodNames.size(),
149             1 );
150         assertEquals(
151             "Did not add only 1 string id.",
152             mad.strIssueID.size(),
153             1 );
154         assertEquals(
155             "Added a long id.",
156             mad.longIssueID.size(),
157             0 );
158     }
159     
160     
161     public void testTestsIssue3()
162     {
163         MyAutoDocIT mad = new MyAutoDocIT();
164         AutoDocITSet set = new AutoDocITSet();
165         set.addIT( mad );
166         
167         set.testsIssue( 1L );
168         
169         assertEquals(
170             "Added a method name.",
171             mad.methodNames.size(),
172             0 );
173         assertEquals(
174             "Did not add only 1 long id.",
175             mad.longIssueID.size(),
176             1 );
177         assertEquals(
178             "Added a string id.",
179             mad.strIssueID.size(),
180             0 );
181     }
182     
183     
184     public void testTestsIssue4()
185     {
186         MyAutoDocIT mad = new MyAutoDocIT();
187         AutoDocITSet set = new AutoDocITSet();
188         set.addIT( mad );
189         
190         set.testsIssue( "l" );
191         
192         assertEquals(
193             "Added a method name.",
194             mad.methodNames.size(),
195             0 );
196         assertEquals(
197             "Did not add only 1 string id.",
198             mad.strIssueID.size(),
199             1 );
200         assertEquals(
201             "Added a long id.",
202             mad.longIssueID.size(),
203             0 );
204     }
205     
206     
207     //-------------------------------------------------------------------------
208
// Standard JUnit declarations
209

210     
211     public static Test suite()
212     {
213         TestSuite suite = new TestSuite( THIS_CLASS );
214         InterfaceTestSuite its = AutoDocITUTestI.suite();
215         its.addInterfaceTestSuite( IAutoDocSetUTestI.suite() );
216         its.addFactory( new CxFactory( "A" ) {
217             public Object JavaDoc createImplObject() {
218                 return new AutoDocITSet();
219             }
220         } );
221         suite.addTest( its );
222         
223         return suite;
224     }
225     
226     public static void main( String JavaDoc[] args )
227     {
228         String JavaDoc[] name = { THIS_CLASS.getName() };
229         
230         // junit.textui.TestRunner.main( name );
231
// junit.swingui.TestRunner.main( name );
232

233         junit.textui.TestRunner.main( name );
234     }
235     
236     
237     /**
238      *
239      * @exception Exception thrown under any exceptional condition.
240      */

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

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