ProvisioningServiceMBeanHandler extends AbstractCompendiumHandler { @Override protected StandardMBean constructInjectMBean(Object targetService) { ProvisioningService psMBean = new ProvisioningService( (org.osgi.service.provisioning.ProvisioningService) targetService); StandardMBean mbean = null; try { mbean = new StandardMBean(psMBean, ProvisioningServiceMBean.class); } catch (NotCompliantMBeanException e) { Logger logger = agentContext.getLogger(); logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + ProvisioningServiceMBean.class.getName(), e); } return mbean; } ProvisioningServiceMBeanHandler(JMXAgentContext agentContext);   }
@Test public void testConstructInjectMBean() { BundleContext bundleContext = mock(BundleContext.class); Logger agentLogger = mock(Logger.class); JMXAgentContext agentContext = new JMXAgentContext(bundleContext, null, agentLogger); ProvisioningService provService = mock(ProvisioningService.class); ProvisioningServiceMBeanHandler handler = new ProvisioningServiceMBeanHandler(agentContext); StandardMBean mbean = handler.constructInjectMBean(provService); assertNotNull(mbean); }