KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > monitor > TestPortalMonitorService


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.container.monitor;
6
7 import org.exoplatform.container.PortalContainer;
8 import org.exoplatform.container.SessionContainer ;
9 import org.exoplatform.container.RootContainer;
10 import org.exoplatform.container.monitor.PortalMonitor;
11 import org.exoplatform.container.monitor.jvm.*;
12 import org.exoplatform.test.BasicTestCase;
13 /**
14  * Thu, May 15, 2003 @
15  * @author: Tuan Nguyen
16  * @version: $Id: TestPortalMonitorService.java,v 1.5 2004/07/24 16:34:05 tuan08 Exp $
17  * @since: 0.0
18  * @email: tuan08@yahoo.com
19  */

20 public class TestPortalMonitorService extends BasicTestCase {
21
22   PortalContainer pcontainer_ ;
23   SessionContainer scontainer_ ;
24
25   public TestPortalMonitorService(String JavaDoc name) {
26     super(name);
27   }
28
29   public void setUp() throws Exception JavaDoc {
30     setTestNumber(1) ;
31     pcontainer_ = PortalContainer.getInstance();
32     scontainer_ = pcontainer_.createSessionContainer("session.container", "anon") ;
33   }
34
35   public void tearDown() throws Exception JavaDoc {
36   }
37   
38   public void testPortalMonitorService() {
39     scontainer_.startActionLifcycle() ;
40     PortalMonitor pmonitor =
41       (PortalMonitor)pcontainer_.getComponentInstanceOfType(PortalMonitor.class) ;
42     assertTrue("Found pmonitor", pmonitor != null) ;
43     pmonitor.error("error", new Exception JavaDoc()) ;
44     assertTrue("session has error", scontainer_.getMonitor().getErrorCount() == 1);
45     scontainer_.endActionLifcycle() ;
46     pmonitor.error("error", new Exception JavaDoc()) ;
47   }
48   
49   public void testOSEnvironment() {
50     System.out.println(RootContainer.getInstance().getOSEnvironment()) ;
51   }
52
53   public void testRuntimInfo() {
54     JVMRuntimeInfo info =
55       (JVMRuntimeInfo)RootContainer.getInstance().getComponentInstanceOfType(JVMRuntimeInfo.class) ;
56     System.out.println(info) ;
57   }
58   
59   
60   protected String JavaDoc getDescription() {
61     return "Test portal monitor service " ;
62   }
63 }
64
Popular Tags