KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > TestSimple


1 /**
2  * Copyright (C) 2004 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package org.objectweb.util.monolog;
19
20 import junit.framework.TestCase;
21 import org.objectweb.util.monolog.api.MonologFactory;
22 import org.objectweb.util.monolog.api.Logger;
23 import org.objectweb.util.monolog.api.BasicLevel;
24
25 /**
26  *
27  * @author S.Chassande-Barrioz
28  */

29 public class TestSimple extends TestCase {
30
31     static MonologFactory mf = null;
32
33     public TestSimple(String JavaDoc s) {
34         super(s);
35     }
36
37     protected void setUp() throws Exception JavaDoc {
38         if (mf == null) {
39             synchronized(TestSimple.class) {
40                 if (mf == null) {
41                     mf = Monolog.getMonologFactory("monolog.properties");
42                 }
43             }
44         }
45     }
46
47     public void test1() {
48         logAllLevel(mf.getLogger("org.objectweb.util.monolog.test.fatal"));
49         logAllLevel(mf.getLogger("org.objectweb.util.monolog.test.error"));
50         logAllLevel(mf.getLogger("org.objectweb.util.monolog.test.warn"));
51         logAllLevel(mf.getLogger("org.objectweb.util.monolog.test.info"));
52         logAllLevel(mf.getLogger("org.objectweb.util.monolog.test.debug"));
53     }
54
55     private void logAllLevel(Logger logger) {
56         logger.log(BasicLevel.FATAL, "-----------------"
57             + "\n\tlogger.name: " + logger.getName()
58             + "\n\tlogger.class: " + logger.getClass().getName()
59             + "\n\tlevel=" + logger.getCurrentLevel().getName());
60         logger.log(BasicLevel.FATAL, "message FATAL ...");
61         logger.log(BasicLevel.ERROR, "message ERROR ...");
62         logger.log(BasicLevel.WARN, "message WARN ...");
63         logger.log(BasicLevel.INFO, "message INFO ...");
64         logger.log(BasicLevel.DEBUG, "message DEBUG ...");
65     }
66
67 }
68
Popular Tags