1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.logging;
17
18 import junit.framework.TestCase;
19
20 import org.apache.log4j.Logger;
21
22
23
24
25
26
27 public class Log4jLoggerTest extends TestCase {
28
29 static Log4jAppender appender = new Log4jAppender();
30
31 static {
32 Logger logger = Logger.getRootLogger();
33 logger.addAppender(appender);
34 }
35
36
37
38
39
40 public Log4jLoggerTest(String name) {
41 super(name);
42 }
43
44 public void testInitDestroy() {
45 System.out.println("testInitDestroy");
46 Log4jLogger ll = new Log4jLogger();
47 ll.init();
48 ll.destroy();
49 }
50
51 public void testLog() {
52 System.out.println("testLog");
53 Log4jLogger log = new Log4jLogger();
54 log.log(0, null, null);
55 log.log(0, "test", null);
56 assertEquals(1,appender.getLogList().size());
57 }
58
59 public void testLogException() {
60 System.out.println("testLogException");
61 Log4jLogger log = new Log4jLogger();
62 log.log(0, null, null, null);
63 log.log(0, "test", null, null);
64 assertEquals(1, appender.getLogList().size());
65 }
66
67 protected void tearDown() throws Exception {
68
69 appender.close();
70 }
71 }