1 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 20 public class TestPortalMonitorService extends BasicTestCase { 21 22 PortalContainer pcontainer_ ; 23 SessionContainer scontainer_ ; 24 25 public TestPortalMonitorService(String name) { 26 super(name); 27 } 28 29 public void setUp() throws Exception { 30 setTestNumber(1) ; 31 pcontainer_ = PortalContainer.getInstance(); 32 scontainer_ = pcontainer_.createSessionContainer("session.container", "anon") ; 33 } 34 35 public void tearDown() throws Exception { 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 ()) ; 44 assertTrue("session has error", scontainer_.getMonitor().getErrorCount() == 1); 45 scontainer_.endActionLifcycle() ; 46 pmonitor.error("error", new Exception ()) ; 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 getDescription() { 61 return "Test portal monitor service " ; 62 } 63 } 64 | Popular Tags |