KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > autodoc > v1 > testserver > AbstractWriterServerUTestI


1 /*
2  * @(#)AbstractWriterServerUTestI.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;
28
29 import net.sourceforge.groboutils.autodoc.v1.*;
30
31 import java.io.Writer JavaDoc;
32 import java.io.StringWriter JavaDoc;
33 import java.io.IOException JavaDoc;
34
35 import org.easymock.EasyMock;
36 import org.easymock.MockControl;
37 import net.sourceforge.groboutils.junit.v1.iftc.*;
38 import junit.framework.Test;
39 import junit.framework.TestCase;
40 import junit.framework.TestSuite;
41 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
42
43
44 /**
45  * Tests the AbstractWriterServer abstract class.
46  *
47  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
48  * @since April 8, 2002
49  * @version $Date: 2003/02/10 22:52:17 $
50  */

51 public class AbstractWriterServerUTestI extends InterfaceTestCase
52 {
53     //-------------------------------------------------------------------------
54
// Standard JUnit Class-specific declarations
55

56     private static final Class JavaDoc THIS_CLASS = AbstractWriterServerUTestI.class;
57     
58     public AbstractWriterServerUTestI( String JavaDoc name, ImplFactory f )
59     {
60         super( name, AbstractWriterServer.class, f );
61     }
62
63     
64     //-------------------------------------------------------------------------
65
// setup
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     public AbstractWriterServer createAbstractWriterServer()
80     {
81         return (AbstractWriterServer)createImplObject();
82     }
83
84
85     //-------------------------------------------------------------------------
86
// Tests
87

88     
89     public void testWriteTestData1() throws Exception JavaDoc
90     {
91         AbstractWriterServer aws = createAbstractWriterServer();
92         StringWriter JavaDoc sw = new StringWriter JavaDoc();
93         
94         // should fail gracefully
95
aws.writeTestData( null, sw );
96     }
97     
98     
99     public void testWriteTestData2() throws Exception JavaDoc
100     {
101         AbstractWriterServer aws = createAbstractWriterServer();
102         StringWriter JavaDoc sw = new StringWriter JavaDoc();
103         TestData td = new TestData() {
104             public TestInfo getTestInfo() {
105                 return null;
106             }
107         };
108         
109         // should fail gracefully
110
aws.writeTestData( td, sw );
111     }
112     
113     
114     public void testWriteTestData3() throws Exception JavaDoc
115     {
116         AbstractWriterServer aws = createAbstractWriterServer();
117         StringWriter JavaDoc sw = new StringWriter JavaDoc();
118         final TestInfo ti = new DefaultTestInfo( "a", "b" );
119         TestData td = new TestData() {
120             public TestInfo getTestInfo() {
121                 return ti;
122             }
123         };
124         
125         // should work w/o error
126
aws.writeTestData( td, sw );
127     }
128     
129     
130     public void testWriteTestData4() throws Exception JavaDoc
131     {
132         AbstractWriterServer aws = createAbstractWriterServer();
133         StringWriter JavaDoc sw = new StringWriter JavaDoc();
134         final TestInfo ti = new DefaultTestInfo();
135         TestData td = new TestData() {
136             public TestInfo getTestInfo() {
137                 return ti;
138             }
139         };
140         
141         // should fail gracefully, if it does fail.
142
aws.writeTestData( td, sw );
143     }
144     
145     
146     protected void _innerOpenOutput( AbstractWriterServer aws, TestData td )
147     {
148         try
149         {
150             Writer JavaDoc w = aws.openOutput( td );
151             assertNotNull(
152                 "If no exception was thrown, then openOutput must never "+
153                 "return null.",
154                 w );
155             aws.closeOutput( w );
156         }
157         catch (IOException JavaDoc ioe)
158         {
159             // this exception is fine.
160
}
161     }
162     
163     
164     public void testOpenOutput1()
165     {
166         AbstractWriterServer aws = createAbstractWriterServer();
167         
168         try
169         {
170             _innerOpenOutput( aws, null );
171         }
172         catch (NullPointerException JavaDoc e)
173         {
174             // this is ok
175
}
176         catch (IllegalArgumentException JavaDoc e)
177         {
178             // this is ok
179
}
180     }
181     
182     
183     public void testOpenOutput2()
184     {
185         AbstractWriterServer aws = createAbstractWriterServer();
186         StringWriter JavaDoc sw = new StringWriter JavaDoc();
187         TestData td = new TestData() {
188             public TestInfo getTestInfo() {
189                 return null;
190             }
191         };
192         
193         
194         try
195         {
196             _innerOpenOutput( aws, td );
197         }
198         catch (NullPointerException JavaDoc e)
199         {
200             // this is ok
201
}
202         catch (IllegalArgumentException JavaDoc e)
203         {
204             // this is ok
205
}
206     }
207     
208     
209     public void testOpenOutput3()
210     {
211         AbstractWriterServer aws = createAbstractWriterServer();
212         StringWriter JavaDoc sw = new StringWriter JavaDoc();
213         final TestInfo ti = new DefaultTestInfo();
214         TestData td = new TestData() {
215             public TestInfo getTestInfo() {
216                 return ti;
217             }
218         };
219         
220         _innerOpenOutput( aws, td );
221     }
222     
223     
224     public void testOpenOutput4()
225     {
226         AbstractWriterServer aws = createAbstractWriterServer();
227         StringWriter JavaDoc sw = new StringWriter JavaDoc();
228         final TestInfo ti = new DefaultTestInfo( "a", "b" );
229         TestData td = new TestData() {
230             public TestInfo getTestInfo() {
231                 return ti;
232             }
233         };
234         
235         _innerOpenOutput( aws, td );
236     }
237     
238     
239     
240     //-------------------------------------------------------------------------
241
// Helpers
242

243     
244     
245     //-------------------------------------------------------------------------
246
// Standard JUnit declarations
247

248     
249     public static InterfaceTestSuite suite()
250     {
251         InterfaceTestSuite suite = new InterfaceTestSuite( THIS_CLASS );
252         suite.addInterfaceTestSuite( ServerUTestI.suite() );
253         
254         return suite;
255     }
256     
257     public static void main( String JavaDoc[] args )
258     {
259         String JavaDoc[] name = { THIS_CLASS.getName() };
260         
261         // junit.textui.TestRunner.main( name );
262
// junit.swingui.TestRunner.main( name );
263

264         junit.textui.TestRunner.main( name );
265     }
266     
267     
268     /**
269      *
270      * @exception Exception thrown under any exceptional condition.
271      */

272     protected void tearDown() throws Exception JavaDoc
273     {
274         // tear ourself down
275

276         super.tearDown();
277     }
278 }
279
280
Popular Tags