@Test(expected=RuntimeException.class)
public void testDoubleRegister() throws Exception {
ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>());
String type = "timer";
String id = "a";
String alias = "ControlA";
String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
try {
cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
} finally {
cs.unregister(controlId);
}
}
java类javax.management.timer.TimerMBean的实例源码
JMXControlServiceTest.java 文件源码
项目:quarks
阅读 20
收藏 0
点赞 0
评论 0
JMXControlServiceTest.java 文件源码
项目:quarks
阅读 18
收藏 0
点赞 0
评论 0
@Test(expected=RuntimeException.class)
public void testDoubleunregister() throws Exception {
ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>());
String type = "timer";
String id = "a";
String alias = "ControlA";
String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
cs.unregister(controlId);
cs.unregister(controlId);
}
JMXControlServiceTest.java 文件源码
项目:quarks
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void testControlObject() throws Exception {
ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>());
String type = "timer";
String id = "a";
String alias = "ControlA";
String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
assertNotNull(controlId);
ObjectName on = ObjectName.getInstance(controlId);
assertEquals(DOMAIN, on.getDomain());
assertEquals(type, ObjectName.unquote(on.getKeyProperty("type")));
assertEquals(id, ObjectName.unquote(on.getKeyProperty("id")));
assertEquals(alias, ObjectName.unquote(on.getKeyProperty("alias")));
assertEquals(TimerMBean.class.getName(), ObjectName.unquote(on.getKeyProperty("interface")));
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
assertTrue(mbs.isRegistered(on));
cs.unregister(controlId);
assertFalse(mbs.isRegistered(on));
}
JMXControlServiceTest.java 文件源码
项目:quarks
阅读 19
收藏 0
点赞 0
评论 0
@Test
public void testAdditionalKeys() throws Exception {
Hashtable<String,String> addKeys = new Hashtable<>();
addKeys.put("job", "jobid");
addKeys.put("device", ObjectName.quote("pi"));
ControlService cs = new JMXControlService(DOMAIN, addKeys);
String type = "timer";
String id = "a";
String alias = "ControlA";
String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
assertNotNull(controlId);
ObjectName on = ObjectName.getInstance(controlId);
assertEquals(DOMAIN, on.getDomain());
assertEquals(type, ObjectName.unquote(on.getKeyProperty("type")));
assertEquals(id, ObjectName.unquote(on.getKeyProperty("id")));
assertEquals(alias, ObjectName.unquote(on.getKeyProperty("alias")));
assertEquals(TimerMBean.class.getName(), ObjectName.unquote(on.getKeyProperty("interface")));
assertEquals("jobid", on.getKeyProperty("job"));
assertEquals("pi", ObjectName.unquote(on.getKeyProperty("device")));
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
assertTrue(mbs.isRegistered(on));
cs.unregister(controlId);
assertFalse(mbs.isRegistered(on));
}