KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > uicapture > v1 > javamaker > JavaMakerUTest


1 /*
2  * @(#)JavaMakerUTest.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.uicapture.v1.javamaker;
28
29 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
30 import net.sourceforge.groboutils.junit.v1.iftc.*;
31 import junit.framework.Test;
32 import junit.framework.TestCase;
33 import junit.framework.TestSuite;
34
35 import java.io.*;
36 import net.sourceforge.groboutils.uicapture.v1.*;
37
38
39
40 /**
41  * Tests the JavaMaker class.
42  *
43  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
44  * @version $Date: 2003/05/29 13:05:56 $
45  * @since Oct 3, 2002
46  */

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

52     private static final Class JavaDoc THIS_CLASS = JavaMakerUTest.class;
53     private static final AutoDoc DOC = new AutoDoc( THIS_CLASS );
54     
55     public JavaMakerUTest( String JavaDoc name )
56     {
57         super( name );
58     }
59
60     
61     
62     
63
64     //-------------------------------------------------------------------------
65
// Tests
66

67     public void testInstantiation1()
68             throws IOException
69     {
70         try
71         {
72             new JavaMaker( (File)null, null, null );
73         }
74         catch (IllegalArgumentException JavaDoc e)
75         {
76             // test exception?
77
}
78     }
79     
80     
81     public void testInstantiation2()
82     {
83         try
84         {
85             new JavaMaker( (Writer)null, null, null );
86         }
87         catch (IllegalArgumentException JavaDoc e)
88         {
89             // test exception?
90
}
91     }
92     
93     
94     public void testInstantiation3()
95     {
96         JavaMaker jm = new JavaMaker( new StringWriter(), "a", "b" );
97     }
98     
99     
100     public void testInstantiation4()
101             throws IOException
102     {
103         File f = File.createTempFile( "JavaMakerUTest", ".tmp" );
104         JavaMaker jm = new JavaMaker( f, "a", "b" );
105     }
106     
107     
108     
109     
110     public void testStartEnd1()
111     {
112         DOC.getIT().testsIssue( 618295 );
113         StringWriter sw = new StringWriter();
114         JavaMaker jm = new JavaMaker( sw, "a", "b" );
115         
116         jm.start();
117         jm.end();
118         
119         assertTrue(
120             "Did not create Java package header correctly.",
121             sw.toString().indexOf( "package a;" ) >= 0 );
122         assertTrue(
123             "Did not create Java class definition header correctly.",
124             sw.toString().indexOf( "public class b" ) >= 0 );
125     }
126     
127     
128     
129     
130     //-------------------------------------------------------------------------
131
// Standard JUnit declarations
132

133     
134     public static Test suite()
135     {
136         InterfaceTestSuite suite = IScriptMakerUTestI.suite();
137         
138         // all tests are covered by the interface tests, so don't need this
139
// line. But will add it for insurance in case tests are needed later.
140
suite.addTestSuite( THIS_CLASS );
141         
142         suite.addFactory( new CxFactory( "A" ) {
143             public Object JavaDoc createImplObject() {
144                 return new JavaMaker( new StringWriter(),
145                     "my.package", "MyClass" );
146             }
147         } );
148         
149         return suite;
150     }
151     
152     public static void main( String JavaDoc[] args )
153     {
154         String JavaDoc[] name = { THIS_CLASS.getName() };
155         
156         // junit.textui.TestRunner.main( name );
157
// junit.swingui.TestRunner.main( name );
158

159         junit.textui.TestRunner.main( name );
160     }
161     
162     /**
163      *
164      * @exception Exception thrown under any exceptional condition.
165      */

166     protected void setUp() throws Exception JavaDoc
167     {
168         super.setUp();
169         
170         // set ourself up
171
}
172     
173     
174     /**
175      *
176      * @exception Exception thrown under any exceptional condition.
177      */

178     protected synchronized void tearDown() throws Exception JavaDoc
179     {
180         // tear ourself down
181

182         super.tearDown();
183     }
184 }
185
186
Popular Tags