01: /*
02: * LogConfigurationTest.java
03: * JUnit based test
04: *
05: * Created on 25. November 2002, 22:42
06: */
07:
08: package org.jzonic.jlo;
09:
10: import junit.framework.Test;
11: import junit.framework.TestCase;
12: import junit.framework.TestSuite;
13: import org.jzonic.jlo.formatter.Formatter;
14: import org.jzonic.jlo.formatter.SimpleFormatter;
15: import org.jzonic.jlo.handler.Handler;
16: import org.jzonic.jlo.handler.MockHandler;
17:
18: /**
19: *
20: * @author Administrator
21: */
22: public class LogConfigurationTest extends TestCase {
23:
24: private LogConfiguration lc;
25:
26: public LogConfigurationTest(java.lang.String testName) {
27: super (testName);
28: }
29:
30: public static void main(java.lang.String[] args) {
31: junit.textui.TestRunner.run(suite());
32: }
33:
34: public static Test suite() {
35: TestSuite suite = new TestSuite(LogConfigurationTest.class);
36: return suite;
37: }
38:
39: public void setUp() throws Exception {
40: lc = new LogConfiguration("Test");
41: }
42:
43: public void testAddLogger() {
44: Handler fileHandler = new MockHandler("Test");
45: Formatter simpleFormatter = new SimpleFormatter("Test");
46: LogGenerator lg = new LogGenerator("TestGenerator",
47: fileHandler, simpleFormatter);
48: Logger logger = new Logger("org.jzonic.jlo", Target
49: .parse("ALL"), "Default");
50: logger.addLogGenerator(lg);
51: lc.addLogger(logger);
52: assertEquals(1, lc.getLoggerCount());
53: assertNotNull(lc.getLogger("org.jzonic.jlo"));
54: }
55:
56: public void testAddLogGenerator() {
57: Handler fileHandler = new MockHandler("Test");
58: Formatter simpleFormatter = new SimpleFormatter("Test");
59: LogGenerator lg = new LogGenerator("TestGenerator",
60: fileHandler, simpleFormatter);
61: lc.addLogGenerator(lg);
62: assertEquals(1, lc.getLogGeneratorCount());
63: }
64:
65: }
|