KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > grlea > log > test > TestOfConfiguration


1 package org.grlea.log.test;
2
3 // $Id: TestOfConfiguration.java,v 1.3 2006/07/13 12:44:56 grlea Exp $
4
// Copyright (c) 2004-2006 Graham Lea. All rights reserved.
5

6 // Licensed under the Apache License, Version 2.0 (the "License");
7
// you may not use this file except in compliance with the License.
8
// You may obtain a copy of the License at
9
//
10
// http://www.apache.org/licenses/LICENSE-2.0
11
//
12
// Unless required by applicable law or agreed to in writing, software
13
// distributed under the License is distributed on an "AS IS" BASIS,
14
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
// See the License for the specific language governing permissions and
16
// limitations under the License.
17

18
19 import junit.framework.TestSuite;
20
21 /**
22  * <p>Tests that logging for instance loggers works and is configurable.</p>
23  *
24  * @author Graham Lea
25  * @version $Revision: 1.3 $
26  */

27 public class
28 TestOfConfiguration
29 extends AbstractLoggingTest
30 {
31    public
32    TestOfConfiguration(String JavaDoc name)
33    {
34       // Standard TestCase constructor. You shouldn't edit this.
35
super(name);
36    }
37
38    public void
39    testFatal()
40    throws Exception JavaDoc
41    {
42       properties.setProperty(SimpleLoggingClass.class.getName(), "Fatal");
43       new SimpleLoggingClass(log).doSomeLogging();
44
45       String JavaDoc[] expectedOutputLineParts =
46       {
47          " |main|SimpleLoggingClass|Test of Fatal",
48       };
49
50       checkOutput(expectedOutputLineParts);
51    }
52
53    public void
54    testError()
55    throws Exception JavaDoc
56    {
57       properties.setProperty(SimpleLoggingClass.class.getName(), "Error");
58       new SimpleLoggingClass(log).doSomeLogging();
59
60       String JavaDoc[] expectedOutputLineParts =
61       {
62          " |main|SimpleLoggingClass|Test of Fatal",
63          " |main|SimpleLoggingClass|Test of Error",
64       };
65
66       checkOutput(expectedOutputLineParts);
67    }
68
69    public void
70    testWarn()
71    throws Exception JavaDoc
72    {
73       properties.setProperty(SimpleLoggingClass.class.getName(), "Warn");
74       new SimpleLoggingClass(log).doSomeLogging();
75
76       String JavaDoc[] expectedOutputLineParts =
77       {
78          " |main|SimpleLoggingClass|Test of Fatal",
79          " |main|SimpleLoggingClass|Test of Error",
80          " |main|SimpleLoggingClass|Test of Warn",
81       };
82
83       checkOutput(expectedOutputLineParts);
84    }
85
86    public void
87    testInfo()
88    throws Exception JavaDoc
89    {
90       properties.setProperty(SimpleLoggingClass.class.getName(), "Info");
91       new SimpleLoggingClass(log).doSomeLogging();
92
93       String JavaDoc[] expectedOutputLineParts =
94       {
95          " |main|SimpleLoggingClass|Test of Fatal",
96          " |main|SimpleLoggingClass|Test of Error",
97          " |main|SimpleLoggingClass|Test of Warn",
98          " |main|SimpleLoggingClass|Test of Info",
99       };
100
101       checkOutput(expectedOutputLineParts);
102    }
103
104    public void
105    testDebug()
106    throws Exception JavaDoc
107    {
108       properties.setProperty(SimpleLoggingClass.class.getName(), "Debug");
109       new SimpleLoggingClass(log).doSomeLogging();
110
111       String JavaDoc[] expectedOutputLineParts =
112       {
113          " |main|SimpleLoggingClass|Test of Fatal",
114          " |main|SimpleLoggingClass|Test of Error",
115          " |main|SimpleLoggingClass|Test of Warn",
116          " |main|SimpleLoggingClass|Test of Info",
117          " |main|SimpleLoggingClass|Test of Debug",
118       };
119
120       checkOutput(expectedOutputLineParts);
121    }
122
123    public void
124    testVerbose()
125    throws Exception JavaDoc
126    {
127       properties.setProperty(SimpleLoggingClass.class.getName(), "Verbose");
128       new SimpleLoggingClass(log).doSomeLogging();
129
130       String JavaDoc[] expectedOutputLineParts =
131       {
132          " |main|SimpleLoggingClass|Test of Fatal",
133          " |main|SimpleLoggingClass|Test of Error",
134          " |main|SimpleLoggingClass|Test of Warn",
135          " |main|SimpleLoggingClass|Test of Info",
136          " |main|SimpleLoggingClass|Test of Debug",
137          " |main|SimpleLoggingClass|Test of Verbose",
138       };
139
140       checkOutput(expectedOutputLineParts);
141    }
142
143    public void
144    testLudicrous()
145    throws Exception JavaDoc
146    {
147       properties.setProperty(SimpleLoggingClass.class.getName(), "Ludicrous");
148       new SimpleLoggingClass(log).doSomeLogging();
149
150       String JavaDoc[] expectedOutputLineParts =
151       {
152          " |main|SimpleLoggingClass|Test of Fatal",
153          " |main|SimpleLoggingClass|Test of Error",
154          " |main|SimpleLoggingClass|Test of Warn",
155          " |main|SimpleLoggingClass|Test of Info",
156          " |main|SimpleLoggingClass|Test of Debug",
157          " |main|SimpleLoggingClass|Test of Verbose",
158          " |main|SimpleLoggingClass|Test of Ludicrous",
159       };
160
161       checkOutput(expectedOutputLineParts);
162    }
163
164    public void
165    testTracing()
166    throws Exception JavaDoc
167    {
168       properties.setProperty(SimpleLoggingClass.class.getName(), "Fatal");
169       properties.setProperty(SimpleLoggingClass.class.getName() + "#trace", "true");
170       new SimpleLoggingClass(log).doSomeLogging();
171
172       String JavaDoc[] expectedOutputLineParts =
173       {
174          " |main|SimpleLoggingClass|Test of Fatal",
175          ">>>|main|SimpleLoggingClass|doSomeLogging()",
176          "<<<|main|SimpleLoggingClass|doSomeLogging()",
177       };
178
179       checkOutput(expectedOutputLineParts);
180    }
181
182    /**
183     * Returns a test suite that will automatically run all test methods in this
184     * class beginning with "test".
185     */

186    public static TestSuite
187    suite()
188    {
189       return new TestSuite(TestOfConfiguration.class);
190    }
191 }
Popular Tags