01: /*
02: * LoggingTest.java
03: * JUnit based test
04: *
05: * Created on 26. November 2002, 00:20
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.handler.MockHandler;
14:
15: /**
16: *
17: * @author Administrator
18: */
19: public class LoggingTest extends TestCase {
20:
21: public LoggingTest(java.lang.String testName) {
22: super (testName);
23: }
24:
25: public static void main(java.lang.String[] args) {
26: junit.textui.TestRunner.run(suite());
27: }
28:
29: public static Test suite() {
30: TestSuite suite = new TestSuite(LoggingTest.class);
31: return suite;
32: }
33:
34: public void testLogging() {
35: Logger logger = LogManager.getLogger("org.jzonic.jlo");
36: logger.info("Hello");
37: LogGenerator lg = (LogGenerator) logger.getLogGenerators().get(
38: 0);
39: MockHandler handler = (MockHandler) lg.getHandler();
40: assertEquals(1, handler.getMessages().size());
41: }
42: /*
43: public void testLoggingPerformance() {
44: Logger logger = LogManager.getLogger("org.jzonic.jlo");
45: long now = System.currentTimeMillis();
46: for ( int i = 0; i < 100;i++) {
47: logger.fatal("Hallo");
48: }
49: long elapsed = (System.currentTimeMillis()-now);
50: System.out.println("Total time:" + elapsed + "ms" );
51: double div = (double)elapsed/10000.0;
52: System.out.println("Time for one:"+ div*1000.0 +"microseconds" );
53: logger.stopLogger();
54: }
55: */
56: }
|