01: /**
02: * Copyright (C) 2001-2005 France Telecom R&D
03: */package org.objectweb.speedo.runtime.jmx;
04:
05: import org.objectweb.speedo.SpeedoTestHelper;
06: import org.objectweb.speedo.api.SpeedoProperties;
07: import org.objectweb.util.monolog.api.BasicLevel;
08:
09: import java.util.Properties;
10:
11: /**
12: *
13: *
14: * @author chassase
15: */
16: public class TestJMXHttpConsole extends SpeedoTestHelper {
17:
18: private static int port;
19:
20: public TestJMXHttpConsole(String s) {
21: super (s);
22: }
23:
24: protected String getLoggerName() {
25: return LOG_NAME + "rt.jmx";
26: }
27:
28: public Properties getPMFProperties() {
29: Properties p = super .getPMFProperties();
30: String val = p.getProperty(SpeedoProperties.JMX);
31: if (val == null) {
32: val = Boolean.TRUE.toString();
33: p.setProperty(SpeedoProperties.JMX, val);
34: }
35: val = p.getProperty(SpeedoProperties.JMX_HTTP_PORT);
36: if (val == null) {
37: val = "8083";
38: p.setProperty(SpeedoProperties.JMX_HTTP_PORT, val);
39: }
40: port = Integer.parseInt(val);
41: return p;
42: }
43:
44: public void testAllMBeans() {
45: assertNotNull("Error on page of the 'connection' mbean ",
46: getMBean("connection"));
47: assertNotNull("Error on page of the 'connection' mbean ",
48: getMBean("pmf"));
49: assertNotNull("Error on page of the 'connection' mbean ",
50: getMBean("query"));
51: assertNotNull("Error on page of the 'connection' mbean ",
52: getMBean("cache"));
53: assertNotNull("Error on page of the 'connection' mbean ",
54: getMBean("tx"));
55: }
56:
57: private String getMBean(String name) {
58: try {
59: return HTTPTools.getURL("http://localhost:" + port
60: + "/mbean", "objectname=speedo:name=" + name,
61: "GET", logger);
62: } catch (Exception e) {
63: logger.log(BasicLevel.ERROR, "Error on get the mbean '"
64: + name + "': ", e);
65: fail(e.getMessage());
66: return null;
67: }
68: }
69: }
|