JolokiaMBeanServerUtil { public static ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { return getJolokiaMBeanServer().registerMBean(object, name); } private  JolokiaMBeanServerUtil(); static MBeanServer getJolokiaMBeanServer(); static ObjectInstance registerMBean(Object object, ObjectName name); static void unregisterMBean(ObjectName name); static final String JOLOKIA_MBEAN_SERVER_ATTRIBUTE; }
@Test public void registerMBean() throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException, InstanceNotFoundException { MBeanServer jolokiaServer = JolokiaMBeanServerUtil.getJolokiaMBeanServer(); Dummy test = new Dummy(); ObjectName name = new ObjectName("jolokia.test:name=test"); JolokiaMBeanServerUtil.registerMBean(test, name); assertTrue(jolokiaServer.isRegistered(name)); JolokiaMBeanServerUtil.unregisterMBean(name); Assert.assertFalse(jolokiaServer.isRegistered(name)); }