KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > LoggingTest


1 /*
2  * LoggingTest.java
3  * JUnit based test
4  *
5  * Created on 26. November 2002, 00:20
6  */

7
8 package org.jzonic.jlo;
9
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  * @author Administrator
17  */

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

54 }
55
Popular Tags