KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > log > impl > TestLogService


1 package org.exoplatform.services.log.impl;
2
3
4 import org.apache.commons.logging.Log;
5 import org.exoplatform.container.PortalContainer;
6 import org.exoplatform.services.log.LogService;
7 import org.exoplatform.services.log.LogUtil;
8 import org.exoplatform.test.BasicTestCase;
9
10 /**
11  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
12  * Please look at license.txt in info directory for more license detail.
13  **/

14
15 /**
16  * Created by the Exo Development team.
17  * Author : Mestrallet Benjamin
18  * benjmestrallet@users.sourceforge.net
19  * Date: 14 nov. 2003
20  * Time: 22:31:20
21  */

22 public class TestLogService extends BasicTestCase {
23
24   LogService service_ ;
25
26   public TestLogService(String JavaDoc name) {
27     super(name);
28   }
29
30     protected String JavaDoc getDescription() {
31         return "Log service test";
32     }
33
34     public void setUp() throws Exception JavaDoc {
35     setTestNumber(1) ;
36     System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
37     PortalContainer manager = PortalContainer.getInstance();
38     service_ = (LogService) manager.getComponentInstanceOfType(LogService.class) ;
39   }
40
41   public void tearDown() throws Exception JavaDoc {
42   }
43
44     public void testLogService() throws Exception JavaDoc {
45     Log log = service_.getLog("org.exoplatform.services.log");
46     Log sublog = service_.getLog("org.exoplatform.services.log.sublog");
47         assertEquals(LogService.INFO, service_.getLogLevel("org.exoplatform.services.log"));
48         assertEquals(LogService.INFO, service_.getLogLevel("org.exoplatform.services.log.sublog"));
49         log.debug("debug: test category 'org.exoplatform.services.log'");
50     log.info("info: test category 'org.exoplatform.services.log'");
51     log.warn("warn: test category 'org.exoplatform.services.log'");
52     log.error("error: test category 'org.exoplatform.services.log'");
53     service_.setLogLevel("org.exoplatform.services.log", LogService.ERROR, true) ;
54     assertEquals(LogService.ERROR, service_.getLogLevel("org.exoplatform.services.log"));
55         assertEquals(LogService.ERROR, service_.getLogLevel("org.exoplatform.services.log.sublog"));
56         
57         LogUtil.debug("This is a test debug") ;
58         LogUtil.info("This is a test inof") ;
59         LogUtil.warn("This is a test warn") ;
60         LogUtil.error("This is a test error") ;
61
62     }
63 }
Popular Tags