KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > runtime > jmx > TestJMXHttpConsole


1 /**
2  * Copyright (C) 2001-2005 France Telecom R&D
3  */

4 package org.objectweb.speedo.runtime.jmx;
5
6 import org.objectweb.speedo.SpeedoTestHelper;
7 import org.objectweb.speedo.api.SpeedoProperties;
8 import org.objectweb.util.monolog.api.BasicLevel;
9
10 import java.util.Properties JavaDoc;
11
12 /**
13  *
14  *
15  * @author chassase
16  */

17 public class TestJMXHttpConsole extends SpeedoTestHelper {
18
19     private static int port;
20     
21     public TestJMXHttpConsole(String JavaDoc s) {
22         super(s);
23     }
24
25     protected String JavaDoc getLoggerName() {
26         return LOG_NAME + "rt.jmx";
27     }
28
29     
30     
31     public Properties getPMFProperties() {
32         Properties p = super.getPMFProperties();
33         String JavaDoc val = p.getProperty(SpeedoProperties.JMX);
34         if (val == null) {
35             val = Boolean.TRUE.toString();
36             p.setProperty(SpeedoProperties.JMX, val);
37         }
38         val = p.getProperty(SpeedoProperties.JMX_HTTP_PORT);
39         if (val == null) {
40             val = "8083";
41             p.setProperty(SpeedoProperties.JMX_HTTP_PORT, val);
42         }
43         port = Integer.parseInt(val);
44         return p;
45     }
46     public void testAllMBeans() {
47         assertNotNull("Error on page of the 'connection' mbean ", getMBean("connection"));
48         assertNotNull("Error on page of the 'connection' mbean ", getMBean("pmf"));
49         assertNotNull("Error on page of the 'connection' mbean ", getMBean("query"));
50         assertNotNull("Error on page of the 'connection' mbean ", getMBean("cache"));
51         assertNotNull("Error on page of the 'connection' mbean ", getMBean("tx"));
52     }
53     private String JavaDoc getMBean(String JavaDoc name) {
54         try {
55             return HTTPTools.getURL("http://localhost:" + port + "/mbean",
56                     "objectname=speedo:name=" + name, "GET", logger);
57         } catch (Exception JavaDoc e) {
58             logger.log(BasicLevel.ERROR, "Error on get the mbean '" + name +"': ", e);
59             fail(e.getMessage());
60             return null;
61         }
62     }
63 }
64
Popular Tags