KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > autodoc > v1 > log4j > Log4jLogUTest


1 /*
2  * @(#)Log4jLogUTest.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.log4j;
28
29 import net.sourceforge.groboutils.autodoc.v1.*;
30
31 import net.sourceforge.groboutils.junit.v1.iftc.*;
32 import junit.framework.Test;
33 import junit.framework.TestCase;
34 import junit.framework.TestSuite;
35
36
37 /**
38  * Tests the Log4jLog class.
39  *
40  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
41  * @version $Date: 2003/05/27 13:32:51 $
42  * @since March 28, 2002
43  */

44 public class Log4jLogUTest extends TestCase
45 {
46     //-------------------------------------------------------------------------
47
// Standard JUnit Class-specific declarations
48

49     private static final Class JavaDoc THIS_CLASS = Log4jLogUTest.class;
50     
51     public Log4jLogUTest( String JavaDoc name )
52     {
53         super( name );
54     }
55
56     
57     //-------------------------------------------------------------------------
58
// setup
59

60     /**
61      *
62      * @exception Exception thrown under any exceptional condition.
63      */

64     protected void setUp() throws Exception JavaDoc
65     {
66         super.setUp();
67         
68         // set ourself up
69
}
70
71
72     //-------------------------------------------------------------------------
73
// Tests
74

75     
76     public void testConstructor1()
77     {
78         try
79         {
80             new Log4jLog( (Class JavaDoc)null );
81             fail("did not throw IllegalArgumentException.");
82         }
83         catch (IllegalArgumentException JavaDoc e)
84         {
85             // test exception?
86
}
87     }
88     
89     
90     public void testConstructor2()
91     {
92         new Log4jLog( this.getClass() );
93     }
94     
95     
96     public void testConstructor3()
97     {
98         try
99         {
100             new Log4jLog( (org.apache.log4j.Logger)null );
101             fail("did not throw IllegalArgumentException.");
102         }
103         catch (IllegalArgumentException JavaDoc e)
104         {
105             // test exception?
106
}
107     }
108     
109     
110     public void testConstructor4()
111     {
112         new Log4jLog( org.apache.log4j.Logger.getLogger( this.getClass() ) );
113     }
114     
115     
116     public void testConcatMessage1()
117     {
118         Log4jLog log = new Log4jLog( this.getClass() );
119         Object JavaDoc sb = log.concatMessage( null );
120         assertNotNull(
121             "concatMessage must not return null.",
122             sb );
123         assertEquals(
124             "did not concat objects correctly.",
125             "null",
126             sb.toString() );
127     }
128     
129     
130     public void testConcatMessage2()
131     {
132         Log4jLog log = new Log4jLog( this.getClass() );
133         Object JavaDoc sb = log.concatMessage( new Object JavaDoc[0] );
134         assertNotNull(
135             "concatMessage must not return null.",
136             sb );
137         assertEquals(
138             "did not concat objects correctly.",
139             "",
140             sb.toString() );
141     }
142     
143     
144     public void testConcatMessage3()
145     {
146         Log4jLog log = new Log4jLog( this.getClass() );
147         Object JavaDoc sb = log.concatMessage( new Object JavaDoc[1] );
148         assertNotNull(
149             "concatMessage must not return null.",
150             sb );
151         assertEquals(
152             "did not concat objects correctly.",
153             "null",
154             sb.toString() );
155     }
156     
157     
158     public void testConcatMessage4()
159     {
160         Log4jLog log = new Log4jLog( this.getClass() );
161         Object JavaDoc sb = log.concatMessage( new Object JavaDoc[]
162             { "a", "b" } );
163         assertNotNull(
164             "concatMessage must not return null.",
165             sb );
166         assertEquals(
167             "did not concat objects correctly.",
168             "ab",
169             sb.toString() );
170     }
171     
172     
173     public void testConcatMessage5()
174     {
175         Log4jLog log = new Log4jLog( this.getClass() );
176         StringBuffer JavaDoc sb = (StringBuffer JavaDoc)log.concatMessage( new Object JavaDoc[]
177             { "a", null, "b" } );
178         assertNotNull(
179             "concatMessage must not return null.",
180             sb );
181         assertEquals(
182             "did not concat objects correctly.",
183             "anullb",
184             sb.toString() );
185     }
186     
187     
188     //-------------------------------------------------------------------------
189
// Helpers
190

191     
192     //-------------------------------------------------------------------------
193
// Standard JUnit declarations
194

195     
196     public static Test suite()
197     {
198         InterfaceTestSuite suite = AutoDocLogUTestI.suite();
199         suite.addTestSuite( THIS_CLASS );
200         suite.addFactory( new CxFactory( "A" ) {
201             public Object JavaDoc createImplObject() {
202                 return new Log4jLog( Test.class );
203             }
204         } );
205         
206         return suite;
207     }
208     
209     public static void main( String JavaDoc[] args )
210     {
211         String JavaDoc[] name = { THIS_CLASS.getName() };
212         
213         // junit.textui.TestRunner.main( name );
214
// junit.swingui.TestRunner.main( name );
215

216         junit.textui.TestRunner.main( name );
217     }
218     
219     
220     /**
221      *
222      * @exception Exception thrown under any exceptional condition.
223      */

224     protected void tearDown() throws Exception JavaDoc
225     {
226         // tear ourself down
227

228         super.tearDown();
229     }
230 }
231
232
Popular Tags